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 @@ ...@@ -105,7 +105,7 @@
<string>my_url_string</string> <string>my_url_string</string>
<string>my_source_reference</string> <string>my_source_reference</string>
<string>last_event_listbox</string> <string>last_event_listbox</string>
<string>my_translated_slap_state_title</string> <string>your_status</string>
<string>your_instance_xml</string> <string>your_instance_xml</string>
<string>my_update_button</string> <string>my_update_button</string>
<string>my_start_button</string> <string>my_start_button</string>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>my_translated_slap_state_title</string> </value> <value> <string>your_status</string> </value>
</item> </item>
<item> <item>
<key> <string>message_values</string> </key> <key> <string>message_values</string> </key>
...@@ -118,7 +118,9 @@ ...@@ -118,7 +118,9 @@
</item> </item>
<item> <item>
<key> <string>default</string> </key> <key> <string>default</string> </key>
<value> <string></string> </value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
...@@ -257,4 +259,17 @@ ...@@ -257,4 +259,17 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </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> </ZopeData>
...@@ -51,28 +51,34 @@ ...@@ -51,28 +51,34 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""Dirty script to return Software Instance state"""\n <value> <string>"""Dirty script to return Software Instance state"""\n
if context.getPortalType() == "Hosting Subscription":\n import json\n
return context.getSlapStateTitle()\n state = context.getSlapState()\n
else:\n has_partition = context.getAggregate(portal_type="Computer Partition")\n
state = context.getSlapState()\n result = \'Unable to calculate the status...\'\n
has_partition = context.getAggregate(portal_type="Computer Partition")\n if has_partition:\n
if state in ["start_requested", "stop_requested"]:\n try:\n
if not has_partition:\n memcached_dict = context.getPortalObject().portal_memcached.getMemcachedDict(\n
return \'Looking for a free partition\'\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 else:\n
if state == "start_requested":\n d = json.loads(d)\n
return \'Start requested\' \n result = d[\'text\']\n
elif state == "stop_requested":\n \n
return \'Stop requested\'\n except Exception:\n
raise\n
result = \'There is system issue, please try again later.\'\n
\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 elif state in ["destroy_requested"]:\n
if has_partition:\n result = \'Destroyed\'\n
return \'Destruction requested\'\n
else:\n
return \'Destroyed\'\n
\n \n
else:\n return result\n
return \'Unable to calculate the status...\'\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
...@@ -112,7 +112,6 @@ ...@@ -112,7 +112,6 @@
<key> <string>right width100 alignr</string> </key> <key> <string>right width100 alignr</string> </key>
<value> <value>
<list> <list>
<string>your_system_message</string>
<string>your_monitoring_status</string> <string>your_monitoring_status</string>
</list> </list>
</value> </value>
......
40 41
\ No newline at end of file \ 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