Commit 4686f6bc authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: use status gadget rather them something else

   Reuse status gadget so it has the same information as its displayed to the user.
parent 1402e99b
...@@ -102,13 +102,14 @@ ...@@ -102,13 +102,14 @@
<string>listbox_installation_state</string> <string>listbox_installation_state</string>
<string>listbox_usage</string> <string>listbox_usage</string>
<string>my_busy_compute_partition_list_creation_date</string> <string>my_busy_compute_partition_list_creation_date</string>
<string>listbox_installation_status</string>
<string>my_busy_compute_partition_list_instance_tree_title</string> <string>my_busy_compute_partition_list_instance_tree_title</string>
<string>my_busy_compute_partition_list_instance_title</string> <string>my_busy_compute_partition_list_instance_title</string>
<string>listbox_image</string> <string>listbox_image</string>
<string>listbox_software_release</string> <string>listbox_software_release</string>
<string>my_busy_compute_partition_list_error_reported</string>
<string>my_busy_compute_partition_list_status</string> <string>my_busy_compute_partition_list_status</string>
<string>listbox_status</string>
<string>my_busy_compute_partition_list_error_reported</string>
<string>listbox_error_reported</string>
</list> </list>
</value> </value>
</item> </item>
......
...@@ -145,9 +145,13 @@ ...@@ -145,9 +145,13 @@
<string>Usage</string> <string>Usage</string>
</tuple> </tuple>
<tuple> <tuple>
<string>installation_status</string> <string>status</string>
<string>Status</string> <string>Status</string>
</tuple> </tuple>
<tuple>
<string>error_reported</string>
<string>Reported Message</string>
</tuple>
</list> </list>
</value> </value>
</item> </item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>default</string>
<string>editable</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_error_reported</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_string_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Reported Error</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: cell.getAggregateRelatedValue(portal_type="Software Instance").SoftwareInstance_hasReportedError(include_message=True, )</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from DateTime import DateTime
portal = context.getPortalObject()
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;'
software_installation = portal.portal_catalog.getResultValue(
portal_type='Software Installation',
validation_state='validated',
url_string=context.getUrlString(),
default_aggregate_uid=compute_node_uid
)
if not software_installation or software_installation.getSlapState() == "destroy_requested":
return '<span" style="%s" title="Information not available"></a>' % error_style
d = software_installation.getAccessStatus()
if d.get("no_data") == 1:
return "<a href='%s' style='%s'></a>" % (software_installation.getRelativeUrl(),
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'])
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>compute_node_uid</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareRelease_getCurrentInstallationStateAsHtml</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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