Commit 83cd6825 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: x

parent b2f8cd4e
"""Dirty script to return Software Instance state"""
import json
state = context.getSlapState()
has_partition = context.getAggregate(portal_type="Compute Partition")
result = 'Unable to calculate the status...'
if has_partition:
try:
memcached_dict = context.Base_getSlapToolMemcachedDict()
try:
d = memcached_dict[context.getReference()]
except KeyError:
result = context.getSlapStateTitle()
else:
d = json.loads(d)
result = d['text']
if result.startswith('#access '):
result = result[len('#access '):]
except Exception:
raise
# result = 'There is system issue, please try again later.'
d = context.getAccessStatus()
if d.get("no_data") == 1:
result = context.getSlapStateTitle()
else:
result = d['text']
if result.startswith('#access '):
result = result[len('#access '):]
else:
if state in ["start_requested", "stop_requested"]:
......
from DateTime import DateTime
portal = context.getPortalObject()
import json
error_style = 'background-color: red; display: block; height: 2em; width: 2em; float: left; margin: 5px;'
access_style = 'background-color: green; display: block; height: 2em; width: 2em; float: left; margin: 5px;'
......@@ -14,20 +13,17 @@ software_installation = portal.portal_catalog.getResultValue(
if not software_installation or software_installation.getSlapState() == "destroy_requested":
return '<span" style="%s" title="Information not available"></a>' % error_style
memcached_dict = context.Base_getSlapToolMemcachedDict()
try:
d = memcached_dict[software_installation.getReference()]
except KeyError:
d = software_installation.getAccessStatus()
if d.get("no_data") == 1:
return "<a href='%s' style='%s'></a>" % (software_installation.getRelativeUrl(),
error_style)
else:
d = json.loads(d)
result = d['text']
date = DateTime(d['created_at'])
limit_date = DateTime() - 0.084
if result.startswith('#error ') or (date - limit_date) < 0:
access_style = error_style
result = d['text']
date = DateTime(d['created_at'])
limit_date = DateTime() - 0.084
if result.startswith('#error ') or (date - limit_date) < 0:
access_style = error_style
return "<a href='%s' style='%s' title='%s at %s'></a>" % (
software_installation.getRelativeUrl(),
access_style, result, d['created_at'])
return "<a href='%s' style='%s' title='%s at %s'></a>" % (
software_installation.getRelativeUrl(),
access_style, result, d['created_at'])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment