clean up massive onliner

This commit is contained in:
forest 2021-02-17 21:57:09 -06:00
parent fa0ddad5f5
commit 88905b944d

View File

@ -67,20 +67,33 @@ def index():
vm["state"] = "unknown"
mappedVms = []
for vm in vms:
ip_display = x['ipv4']
if not ip_display:
if vm["state"] == "running":
ip_display = "..booting.."
else:
ip_display = "unknown"
vms = list(map(
lambda x: dict(
ip_display_class = "ok"
if not x['ipv4']:
if vm["state"] == "running":
ip_display_class = "waiting-pulse"
else:
ip_display_class = "yellow"
mappedVms.append(dict(
id=x['id'],
size=x['size'],
state=x['state'],
ipv4=(x['ipv4'] if x['ipv4'] else ("..booting.." if vm["state"] == "running" else "unknown")),
ipv4_status=("ok" if x['ipv4'] else ("waiting-pulse" if vm["state"] == "running" else "yellow")),
ipv4=ip_display,
ipv4_status=ip_display_class,
os=x['os'],
created=x['created'].strftime("%b %d %Y")
), vms
))
return render_template("capsuls.html", vms=vms, has_vms=len(vms) > 0, created=created)
return render_template("capsuls.html", vms=mappedVms, has_vms=len(vms) > 0, created=created)
@bp.route("/<string:id>", methods=("GET", "POST"))
@account_required