Commit 948544a9 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: Drop unrequired script

  It is easier to write better tales expressions
parent 5c29de81
current = context.REQUEST.get('here')
if current.getPortalType() == 'Software Release':
software_release = current
compute_node = context
else:
compute_node = current
software_release = context
return compute_node.ComputeNode_getSoftwareReleaseUsage(software_release.getUrlString())
<?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_getSoftwareReleaseUsageOnComputeNode</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
return context.getPortalObject().portal_catalog.countResults( portal = context.getPortalObject()
if context.getParentValue().isMemberOf('allocation_scope/open'):
# This is faster but all values are free_for_request == 0 if the computer is closed
return context.getPortalObject().portal_catalog.countResults(
portal_type='Compute Partition', portal_type='Compute Partition',
parent_uid=context.getUid(), parent_uid=context.getUid(),
free_for_request=0, free_for_request=0,
software_release_url=software_release_url software_release_url=software_release_url)[0][0]
)[0][0] else:
computer_uid_list = [i.uid for i in portal.portal_catalog(
portal_type='Compute Partition',
parent_uid=context.getUid()
)]
if not computer_uid_list:
return 0
return portal.portal_catalog.countResults(
portal_type='Software Instance',
default_aggregate_uid=computer_uid_list,
url_string=software_release_url)[0][0]
...@@ -60,6 +60,10 @@ ...@@ -60,6 +60,10 @@
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value> </value>
</item> </item>
<item>
<key> <string>display_width</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>field_id</string> </key> <key> <string>field_id</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
...@@ -72,6 +76,10 @@ ...@@ -72,6 +76,10 @@
<key> <string>target</string> </key> <key> <string>target</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary> </dictionary>
</value> </value>
</item> </item>
...@@ -101,7 +109,7 @@ ...@@ -101,7 +109,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>listbox_installation_state</string> </value> <value> <string>listbox_usage</string> </value>
</item> </item>
</dictionary> </dictionary>
</value> </value>
...@@ -117,7 +125,7 @@ ...@@ -117,7 +125,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>cell/Base_getSoftwareReleaseUsageOnComputeNode</string> </value> <value> <string>python: cell.getAggregateValue(portal_type="Compute Node").ComputeNode_getSoftwareReleaseUsage(cell.getUrlString())</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
compute_node_list = []
for si in context.portal_catalog(url_string=context.getUrlString(),
portal_type='Software Installation',
validation_state='validated'):
compute_node = si.getAggregateValue()
if si.getSlapState() == 'start_requested' and \
not compute_node.ComputeNode_getSoftwareReleaseUsage(context.getUrlString()) \
and compute_node.getValidationState() == 'validated':
compute_node_list.append(compute_node)
return compute_node_list
<?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>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareRelease_getUsableComputeNodeWithoutSInstanceList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -61,6 +61,14 @@ ...@@ -61,6 +61,14 @@
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value> </value>
</item> </item>
<item>
<key> <string>display_width</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>field_id</string> </key> <key> <string>field_id</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
...@@ -73,6 +81,10 @@ ...@@ -73,6 +81,10 @@
<key> <string>target</string> </key> <key> <string>target</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary> </dictionary>
</value> </value>
</item> </item>
...@@ -122,7 +134,7 @@ ...@@ -122,7 +134,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>python: cell.Base_getSoftwareReleaseUsageOnComputeNode()</string> </value> <value> <string>python: cell.ComputeNode_getSoftwareReleaseUsage(context.getUrlString())</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -71,8 +71,6 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template): ...@@ -71,8 +71,6 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_cloud/AlarmTool_checkComputeNodeMigrationConsistency', 'slapos_cloud/AlarmTool_checkComputeNodeMigrationConsistency',
'slapos_cloud/AlarmTool_checkInstanceTreeMigrationConsistency', 'slapos_cloud/AlarmTool_checkInstanceTreeMigrationConsistency',
'slapos_cloud/AlarmTool_checkPredecessorToSuccessorMigrationConsistency', 'slapos_cloud/AlarmTool_checkPredecessorToSuccessorMigrationConsistency',
'slapos_cloud/Base_getSoftwareReleaseStateOnComputeNode',
'slapos_cloud/Base_getSoftwareReleaseUsageOnComputeNode',
'slapos_cloud/ComputeNode_afterClone', 'slapos_cloud/ComputeNode_afterClone',
'slapos_cloud/ComputeNode_applyComputerModel', 'slapos_cloud/ComputeNode_applyComputerModel',
'slapos_cloud/ComputeNode_getBusyComputePartitionList', 'slapos_cloud/ComputeNode_getBusyComputePartitionList',
...@@ -110,6 +108,7 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template): ...@@ -110,6 +108,7 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_cloud/Project_init', 'slapos_cloud/Project_init',
'slapos_cloud/Resource_zGetTrackingList', 'slapos_cloud/Resource_zGetTrackingList',
'slapos_cloud/SoftwareInstallation_requestDestruction', 'slapos_cloud/SoftwareInstallation_requestDestruction',
'slapos_cloud/SoftwareInstallation_getInstallationState',
'slapos_cloud/SoftwareInstance_afterClone', 'slapos_cloud/SoftwareInstance_afterClone',
'slapos_cloud/SoftwareInstance_checkPredecessorToSuccessorMigrationConsistency', 'slapos_cloud/SoftwareInstance_checkPredecessorToSuccessorMigrationConsistency',
'slapos_cloud/SoftwareInstance_getComputeNodeUrl', 'slapos_cloud/SoftwareInstance_getComputeNodeUrl',
...@@ -118,10 +117,8 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template): ...@@ -118,10 +117,8 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_cloud/SoftwareInstance_getPartitionUrl', 'slapos_cloud/SoftwareInstance_getPartitionUrl',
'slapos_cloud/SoftwareInstance_init', 'slapos_cloud/SoftwareInstance_init',
'slapos_cloud/SoftwareInstance_renameAndRequestStopAction', 'slapos_cloud/SoftwareInstance_renameAndRequestStopAction',
'slapos_cloud/SoftwareRelease_getCurrentInstallationStateAsHtml',
'slapos_cloud/SoftwareRelease_getRelatedNetworkList', 'slapos_cloud/SoftwareRelease_getRelatedNetworkList',
'slapos_cloud/SoftwareRelease_getUsableComputeNodeList', 'slapos_cloud/SoftwareRelease_getUsableComputeNodeList',
'slapos_cloud/SoftwareRelease_getUsableComputeNodeWithoutSInstanceList',
'slapos_cloud/SoftwareInstance_viewRenameAndRequestDestroyAction', 'slapos_cloud/SoftwareInstance_viewRenameAndRequestDestroyAction',
'slapos_cloud/Base_getSupportRequestInProgress', 'slapos_cloud/Base_getSupportRequestInProgress',
'slapos_cloud/SoftwareInstance_checkDuplicationOnInstanceTreeConsistency', 'slapos_cloud/SoftwareInstance_checkDuplicationOnInstanceTreeConsistency',
......
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