Commit 7a1ec4c5 authored by Romain Courteaud's avatar Romain Courteaud

Simplify status view.

Do not show the expected state but only the "known" instance status, based on
SlapTool connection logs.
parent e42ba089
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>_body</string> </key>
<value> <string>title = context.getTitle()\n
result = context.getSlapStateTitle()\n
found = False\n
for instance in context.getPredecessorValueList():\n
if (instance.getTitle() == title) and (instance.getSlapState() != \'destroy_requested\'):\n
found = True\n
break\n
\n
if found:\n
result = instance.SoftwareInstance_getStatus()\n
\n
return result\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>HostingSubscription_getStatus</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -105,7 +105,7 @@
<string>my_url_string</string>
<string>my_source_reference</string>
<string>last_event_listbox</string>
<string>my_translated_slap_state_title</string>
<string>your_status</string>
<string>your_instance_xml</string>
<string>my_update_button</string>
<string>my_start_button</string>
......
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>my_translated_slap_state_title</string> </value>
<value> <string>your_status</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -118,7 +118,9 @@
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -257,4 +259,17 @@
</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: here.HostingSubscription_getStatus()</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -51,28 +51,34 @@
<item>
<key> <string>_body</string> </key>
<value> <string>"""Dirty script to return Software Instance state"""\n
if context.getPortalType() == "Hosting Subscription":\n
return context.getSlapStateTitle()\n
else:\n
state = context.getSlapState()\n
has_partition = context.getAggregate(portal_type="Computer Partition")\n
if state in ["start_requested", "stop_requested"]:\n
if not has_partition:\n
return \'Looking for a free partition\'\n
import json\n
state = context.getSlapState()\n
has_partition = context.getAggregate(portal_type="Computer Partition")\n
result = \'Unable to calculate the status...\'\n
if has_partition:\n
try:\n
memcached_dict = context.getPortalObject().portal_memcached.getMemcachedDict(\n
key_prefix=\'slap_tool\',\n
plugin_path=\'portal_memcached/default_memcached_plugin\')\n
try:\n
d = memcached_dict[context.getReference()]\n
except KeyError:\n
result = "#error no data found for %s" % context.getReference()\n
else:\n
if state == "start_requested":\n
return \'Start requested\' \n
elif state == "stop_requested":\n
return \'Stop requested\'\n
d = json.loads(d)\n
result = d[\'text\']\n
\n
except Exception:\n
raise\n
result = \'There is system issue, please try again later.\'\n
\n
else:\n
if state in ["start_requested", "stop_requested"]:\n
result = \'Looking for a free partition\'\n
elif state in ["destroy_requested"]:\n
if has_partition:\n
return \'Destruction requested\'\n
else:\n
return \'Destroyed\'\n
result = \'Destroyed\'\n
\n
else:\n
return \'Unable to calculate the status...\'\n
return result\n
</string> </value>
</item>
<item>
......
......@@ -112,7 +112,6 @@
<key> <string>right width100 alignr</string> </key>
<value>
<list>
<string>your_system_message</string>
<string>your_monitoring_status</string>
</list>
</value>
......
40
\ No newline at end of file
41
\ No newline at end of file
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