Commit 1402e99b authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: get Software Installation State from itself

   This is a clean up, there seems to be legacy calls from before the form was refactor. This speeds up form rendering by a lot.
parent 948544a9
compute_node = context.REQUEST.get('here')
software_release = context
return compute_node.ComputeNode_getSoftwareReleaseState(software_release.getUid())
<?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>*args, **kwargs</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getSoftwareReleaseStateOnComputeNode</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal = context.getPortalObject()
software_installation_list = portal.portal_catalog(
portal_type='Software Installation',
default_aggregate_uid=context.getUid(),
validation_state='validated',
limit=1,
url_string={'query': portal.portal_catalog.getResultValue(uid=software_release_uid).getUrlString(), 'key': 'ExactMatch'},
sort_on=(('creation_date', 'DESC'),)
)
if len(software_installation_list) == 0:
return 'Destroyed'
software_installation = software_installation_list[0].getObject()
s = software_installation.getSlapState()
if s == 'start_requested':
return 'Installation requested'
else:
return 'Destruction requested'
......@@ -60,6 +60,10 @@
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
......@@ -72,6 +76,10 @@
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
......@@ -117,7 +125,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>cell/Base_getSoftwareReleaseStateOnComputeNode</string> </value>
<value> <string>cell/SoftwareInstallation_getInstallationState</string> </value>
</item>
</dictionary>
</pickle>
......
if context.getValidationState() != "validated":
return 'Destroyed'
if context.getSlapState() == 'start_requested':
return 'Installation requested'
else:
return 'Destruction requested'
......@@ -50,11 +50,11 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>software_release_uid</string> </value>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ComputeNode_getSoftwareReleaseState</string> </value>
<value> <string>SoftwareInstallation_getInstallationState</string> </value>
</item>
</dictionary>
</pickle>
......
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