Commit a9215903 authored by Łukasz Nowak's avatar Łukasz Nowak

Split Software Installation management.

Avoid playing directly with deliveries and reuse direct linking between
Software Installation and Computer.

Also move out error reporting from Computer to Software Installation.
parent 8431e252
...@@ -56,7 +56,7 @@ portal_preferences = portal.portal_preferences\n ...@@ -56,7 +56,7 @@ portal_preferences = portal.portal_preferences\n
\n \n
if slap_state == \'free\':\n if slap_state == \'free\':\n
computer = context.getParentValue()\n computer = context.getParentValue()\n
return computer.Computer_getSoftwareReleaseUrlStringList([\'stopped\'])\n return computer.Computer_getSoftwareReleaseUrlStringList()\n
\n \n
elif slap_state == \'busy\':\n elif slap_state == \'busy\':\n
\n \n
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
portal_type = "Software Release"\n portal_type = "Software Release"\n
\n \n
url_string_list = context.Computer_getSoftwareReleaseUrlStringList([\'confirmed\', \'started\', \'stopped\', \'delivered\'])\n url_string_list = context.Computer_getSoftwareReleaseUrlStringList()\n
if url_string_list:\n if url_string_list:\n
return context.portal_catalog(\n return context.portal_catalog(\n
portal_type=portal_type,\n portal_type=portal_type,\n
......
<?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>portal = context.getPortalObject()\n
\n
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery\n
\n
software_release_document = portal.portal_catalog.getResultValue(portal_type=\'Software Release\', url_string=software_release_url)\n
\n
software_setup_resource = portal.restrictedTraverse(portal.portal_preferences.getPreferredSoftwareSetupResource())\n
software_cleanup_resource = portal.restrictedTraverse(portal.portal_preferences.getPreferredSoftwareCleanupResource())\n
\n
current_delivery_line = portal.portal_catalog.getResultValue(\n
default_resource_uid=[\n
software_setup_resource.getUid(),\n
software_cleanup_resource.getUid(),\n
],\n
default_aggregate_uid=ComplexQuery(\n
Query(default_aggregate_uid=software_release_document.getUid()),\n
Query(default_aggregate_uid=context.getUid()),\n
operator="AND",\n
),\n
portal_type=\'Purchase Packing List Line\',\n
sort_on=((\'movement.start_date\', \'DESC\'),),\n
limit=1\n
)\n
\n
if current_delivery_line.getResource() == software_cleanup_resource.getRelativeUrl():\n
return \'destroyed\'\n
else:\n
return \'available\'\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>software_release_url</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Computer_getSoftwareReleaseRequestedState</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -50,38 +50,21 @@ ...@@ -50,38 +50,21 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery\n <value> <string>url_string_list = []\n
computer = context\n for software_installation in context.getPortalObject().portal_catalog(\n
portal = context.getPortalObject()\n portal_type=\'Software Installation\',\n
if len(state_list) == 1:\n validation_state=\'validated\',\n
state_string = "= \'%s\'" % state_list[0]\n default_aggregate_uid=context.getUid()\n
else:\n ):\n
state_string = "IN %s" % (tuple(state_list),)\n url_string = software_installation.getUrlString()\n
catalog_query = portal.portal_catalog(\n if url_string:\n
ComplexQuery(\n url_string_list.append(url_string)\n
Query(\n return url_string_list\n
aggregate_aggregate_uid=computer.getUid(),\n
table_alias_list=(\n
("catalog", "found_movement"),\n
("category", "service_resource"),\n
("category", "software_release_aggregate"),\n
("category", "computer_aggregate"),\n
),\n
),\n
Query(\n
portal_type=\'Software Release\',\n
),\n
operator="AND"),\n
where_expression="found_movement.simulation_state %s " \\\n
" AND " \\\n
"found_movement.portal_type=\'Purchase Packing List Line\'" % \\\n
(state_string,))\n
return [q.getUrlString() for q in catalog_query if q.getUrlString()]\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>state_list</string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -6,6 +6,27 @@ ...@@ -6,6 +6,27 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<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/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item> <item>
<key> <string>_objects</string> </key> <key> <string>_objects</string> </key>
<value> <value>
......
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
<key> <string>delegated_list</string> </key> <key> <string>delegated_list</string> </key>
<value> <value>
<list> <list>
<string>portal_type</string> <string>all_columns</string>
<string>columns</string>
<string>selection_name</string> <string>selection_name</string>
<string>title</string> <string>title</string>
</list> </list>
...@@ -73,6 +74,68 @@ ...@@ -73,6 +74,68 @@
<key> <string>values</string> </key> <key> <string>values</string> </key>
<value> <value>
<dictionary> <dictionary>
<item>
<key> <string>all_columns</string> </key>
<value>
<list>
<tuple>
<string>title</string>
<string>Title</string>
</tuple>
<tuple>
<string>reference</string>
<string>Reference</string>
</tuple>
<tuple>
<string>url_string</string>
<string>URL</string>
</tuple>
<tuple>
<string>translated_validation_state_title</string>
<string>State</string>
</tuple>
<tuple>
<string>translated_slap_state_title</string>
<string>Slap State</string>
</tuple>
<tuple>
<string>creation_date</string>
<string>Creation Date</string>
</tuple>
<tuple>
<string>modification_date</string>
<string>Modification Date</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>columns</string> </key>
<value>
<list>
<tuple>
<string>title</string>
<string>Title</string>
</tuple>
<tuple>
<string>reference</string>
<string>Reference</string>
</tuple>
<tuple>
<string>url_string</string>
<string>URL</string>
</tuple>
<tuple>
<string>translated_validation_state_title</string>
<string>State</string>
</tuple>
<tuple>
<string>translated_slap_state_title</string>
<string>Slap State</string>
</tuple>
</list>
</value>
</item>
<item> <item>
<key> <string>field_id</string> </key> <key> <string>field_id</string> </key>
<value> <string>my_list_mode_listbox</string> </value> <value> <string>my_list_mode_listbox</string> </value>
......
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
<list> <list>
<string>my_title</string> <string>my_title</string>
<string>my_reference</string> <string>my_reference</string>
<string>my_root_software_release_url</string> <string>my_url_string</string>
</list> </list>
</value> </value>
</item> </item>
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>my_root_software_release_url</string> </value> <value> <string>my_url_string</string> </value>
</item> </item>
<item> <item>
<key> <string>message_values</string> </key> <key> <string>message_values</string> </key>
......
480 481
\ No newline at end of file \ No newline at end of file
<type_roles>
<role id='Auditor'>
<property id='title'>Computer</property>
<multi_property id='category'>role/computer</multi_property>
<multi_property id='base_category'>role</multi_property>
</role>
<role id='Author; Auditor'>
<property id='title'>Group company</property>
<multi_property id='category'>group/company</multi_property>
<multi_property id='base_category'>group</multi_property>
</role>
<role id='Auditor; Author'>
<property id='title'>Member</property>
<multi_property id='category'>role/member</multi_property>
<multi_property id='base_category'>role</multi_property>
</role>
</type_roles>
\ No newline at end of file
<type_roles>
<role id='Assignor'>
<property id='title'>Computer</property>
<property id='base_category_script'>ERP5Type_getSecurityCategoryFromContent</property>
<multi_property id='base_category'>aggregate</multi_property>
</role>
<role id='Assignor'>
<property id='title'>Group company</property>
<multi_property id='category'>group/company</multi_property>
<multi_property id='base_category'>group</multi_property>
</role>
<role id='Assignee'>
<property id='title'>Owner become Assignee</property>
<property id='description'>XXX Needed to allow doActionFor while creating the document</property>
<property id='base_category_script'>ERP5Type_acquireSecurityFromOwner</property>
<multi_property id='base_category'>source</multi_property>
</role>
</type_roles>
\ No newline at end of file
...@@ -75,6 +75,10 @@ ...@@ -75,6 +75,10 @@
<type>Slave Instance</type> <type>Slave Instance</type>
<workflow>local_permission_vifib_interaction_workflow</workflow> <workflow>local_permission_vifib_interaction_workflow</workflow>
</chain> </chain>
<chain>
<type>Software Installation</type>
<workflow>local_permission_vifib_interaction_workflow</workflow>
</chain>
<chain> <chain>
<type>Software Instance</type> <type>Software Instance</type>
<workflow>local_permission_vifib_interaction_workflow</workflow> <workflow>local_permission_vifib_interaction_workflow</workflow>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<ZopeData> <ZopeData>
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<global name="TransitionDefinition" module="Products.DCWorkflow.Transitions"/> <global name="InteractionDefinition" module="Products.ERP5.Interaction"/>
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
...@@ -10,10 +10,6 @@ ...@@ -10,10 +10,6 @@
<key> <string>actbox_category</string> </key> <key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value> <value> <string>workflow</string> </value>
</item> </item>
<item>
<key> <string>actbox_icon</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>actbox_name</string> </key> <key> <string>actbox_name</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
...@@ -22,9 +18,25 @@ ...@@ -22,9 +18,25 @@
<key> <string>actbox_url</string> </key> <key> <string>actbox_url</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>activate_script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item> <item>
<key> <string>after_script_name</string> </key> <key> <string>after_script_name</string> </key>
<value> <string></string> </value> <value>
<list>
<string>Base_updateAllLocalRoles</string>
</list>
</value>
</item>
<item>
<key> <string>before_commit_script_name</string> </key>
<value>
<tuple/>
</value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
...@@ -38,15 +50,39 @@ ...@@ -38,15 +50,39 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>request_stop</string> </value> <value> <string>SoftwareInstallation_setAggregateList</string> </value>
</item>
<item>
<key> <string>method_id</string> </key>
<value>
<list>
<string>_setAggregate.*</string>
</list>
</value>
</item> </item>
<item> <item>
<key> <string>new_state_id</string> </key> <key> <string>once_per_transaction</string> </key>
<value> <string>stop_requested</string> </value> <value> <int>0</int> </value>
</item>
<item>
<key> <string>portal_type_filter</string> </key>
<value>
<list>
<string>Software Installation</string>
</list>
</value>
</item> </item>
<item> <item>
<key> <string>script_name</string> </key> <key> <string>script_name</string> </key>
<value> <string></string> </value> <value>
<list>
<string>Base_updateAllLocalRoles</string>
</list>
</value>
</item>
<item>
<key> <string>temporary_document_disallowed</string> </key>
<value> <int>0</int> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
...@@ -56,27 +92,6 @@ ...@@ -56,27 +92,6 @@
<key> <string>trigger_type</string> </key> <key> <string>trigger_type</string> </key>
<value> <int>2</int> </value> <value> <int>2</int> </value>
</item> </item>
<item>
<key> <string>var_exprs</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
......
469 470
\ No newline at end of file \ No newline at end of file
...@@ -88,6 +88,8 @@ Service Module ...@@ -88,6 +88,8 @@ Service Module
Short Message Short Message
Site Message Site Message
Slave Instance Slave Instance
Software Installation
Software Installation Module
Software Instance Software Instance
Software Instance Module Software Instance Module
Software Product Software Product
......
...@@ -88,6 +88,8 @@ Service Module ...@@ -88,6 +88,8 @@ Service Module
Short Message Short Message
Site Message Site Message
Slave Instance Slave Instance
Software Installation
Software Installation Module
Software Instance Software Instance
Software Instance Module Software Instance Module
Software Product Software Product
......
...@@ -17,4 +17,5 @@ Sale Packing List | local_permission_vifib_interaction_workflow ...@@ -17,4 +17,5 @@ Sale Packing List | local_permission_vifib_interaction_workflow
Sale Trade Condition Module | init_vifib_interaction_workflow Sale Trade Condition Module | init_vifib_interaction_workflow
Sale Trade Condition | local_permission_vifib_interaction_workflow Sale Trade Condition | local_permission_vifib_interaction_workflow
Slave Instance | local_permission_vifib_interaction_workflow Slave Instance | local_permission_vifib_interaction_workflow
Software Installation | local_permission_vifib_interaction_workflow
Software Instance | local_permission_vifib_interaction_workflow Software Instance | local_permission_vifib_interaction_workflow
\ No newline at end of file
...@@ -52,88 +52,81 @@ ...@@ -52,88 +52,81 @@
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery\n
computer = state_change[\'object\']\n computer = state_change[\'object\']\n
portal = computer.getPortalObject()\n
# Get required arguments\n # Get required arguments\n
kwargs = state_change.kwargs\n kwargs = state_change.kwargs\n
software_release_url = state_change.kwargs["software_release_url"]\n
\n
portal = computer.getPortalObject()\n
\n
\n \n
# Only get one software release\n # Required args\n
software_release_document_result = portal.portal_catalog(\n # Raise TypeError if all parameters are not provided\n
portal_type=\'Software Release\', # validation_state=(\'shared\', \'released\', \'published\', \'shared_alive\', \'released_alive\', \'published_alive\'),\n try:\n
url_string=software_release_url, limit=2)\n software_release_url = kwargs[\'software_release_url\']\n
if len(software_release_document_result) != 1:\n state = kwargs["state"]\n
raise ValueError("No software release found for %s %s" % (computer.getRelativeUrl(), software_release_url))\n except KeyError:\n
else:\n raise TypeError("Computer_requestSoftwareReleaseChange takes exactly 2 arguments")\n
software_release_document = software_release_document_result[0]\n
\n
tag = \'Computer_%s_software_release_%s_change\' % (computer.getUid(), software_release_document.getUid())\n
if portal.portal_activities.countMessageWithTag(tag) > 0:\n
raise NotImplementedError(\'In progress\')\n
activate_kw = {\'tag\': tag}\n
\n \n
state_list = []\n tag = "%s_%s_inProgress" % (computer.getUid(), \n
state_list.extend(portal.getPortalReservedInventoryStateList())\n software_release_url)\n
state_list.extend(portal.getPortalTransitInventoryStateList())\n
state_list.extend([\'stopped\', \'delivered\'])\n
\n \n
current_delivery_line = portal.portal_catalog.getResultValue(\n if (portal.portal_activities.countMessageWithTag(tag) > 0):\n
portal_type=\'Purchase Packing List Line\',\n # The software instance is already under creation but can not be fetched from catalog\n
simulation_state=state_list,\n # As it is not possible to fetch informations, it is better to raise an error\n
default_resource_uid=[\n raise NotImplementedError(tag)\n
portal.restrictedTraverse(portal.portal_preferences.getPreferredSoftwareCleanupResource()).getUid(),\n
portal.restrictedTraverse(portal.portal_preferences.getPreferredSoftwareSetupResource()).getUid(),\n
],\n
sort_on=((\'movement.start_date\', \'DESC\'),),\n
aggregate_relative_url=ComplexQuery(\n
Query(aggregate_relative_url=software_release_document.getRelativeUrl()),\n
Query(aggregate_relative_url=computer.getRelativeUrl()),\n
operator="AND"),\n
limit=1\n
)\n
\n \n
if current_delivery_line is not None and current_delivery_line.getResourceUid() == service_uid and current_delivery_line.getSimulationState() not in [\'stopped\', \'delivered\']:\n software_installation_portal_type = \'Software Installation\'\n
# change installation in progress\n # Check if it already exists\n
return\n software_installation_list = portal.portal_catalog(\n
portal_type=software_installation_portal_type,\n
url_string={\'query\': software_release_url, \'key\': \'ExactMatch\'},\n
validation_state="validated",\n
default_aggregate_uid=computer.getUid(),\n
limit=2,\n
)\n
\n \n
# XXX Hardcoded values\n if len(software_installation_list) > 1:\n
person = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n raise NotImplementedError("Too many Software Installation %s found %s" % (software_release_url, [x.path for x in software_installation_list]))\n
elif len(software_installation_list) == 1:\n
software_installation = software_installation_list[0].getObject()\n
if (software_installation.getSlapState() == "destroy_requested") or \\\n
(software_installation.getUrlString() != software_release_url) or \\\n
(software_installation.getValidationState() != "validated") or \\\n
(software_installation.getAggregate() != computer.getRelativeUrl()):\n
raise NotImplementedError("The system was not able to get the expected Software Installation")\n
else:\n
if (state == "destroyed"):\n
# No need to create destroyed subscription.\n
return\n
software_installation_reference = "SOFTINSTALL-%s" % context.getPortalObject().portal_ids\\\n
.generateNewId(id_group=\'slap_software_installation_reference\', id_generator=\'uid\')\n
software_installation = portal.getDefaultModule(portal_type=software_installation_portal_type).newContent(\n
portal_type=software_installation_portal_type,\n
reference=software_installation_reference,\n
url_string=software_release_url,\n
aggregate=computer.getRelativeUrl(),\n
activate_kw={\'tag\': tag},\n
)\n
\n \n
packing_list_portal_type = "Purchase Packing List"\n # Change desired state\n
module = portal.getDefaultModule(portal_type=packing_list_portal_type)\n if (state == "available"):\n
packing_list = module.newContent(\n software_installation.requestStart()\n
portal_type=packing_list_portal_type,\n elif (state == "destroyed"):\n
start_date=DateTime(),\n software_installation.requestDestroy()\n
destination_value=person,\n else:\n
destination_section_value=person,\n raise ValueError("state should be available or destroyed, but is %s" % state)\n
destination_decision_value=person,\n
source_administration_value=person,\n
# XXX Hardcoded values\n
source="organisation_module/vifib_internet",\n
source_section="organisation_module/vifib_internet",\n
price_currency="currency_module/EUR",\n
activate_kw=activate_kw\n
)\n
packing_list.newContent(\n
portal_type="Purchase Packing List Line",\n
resource_uid=service_uid,\n
aggregate_value_list=[software_release_document, computer],\n
quantity=1,\n
activate_kw=activate_kw\n
)\n
\n \n
packing_list.confirm(activate_kw=activate_kw)\n # Change the state at the end to allow to execute updateLocalRoles only once in the transaction\n
packing_list.startBuilding()\n validation_state = software_installation.getValidationState()\n
slap_state = software_installation.getSlapState()\n
if validation_state == \'draft\':\n
portal.portal_workflow.doActionFor(software_installation,\n
\'validate_action\')\n
]]></string> </value> ]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>state_change, service_uid</string> </value> <value> <string>state_change</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
<?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>computer = state_change[\'object\']\n
portal = computer.getPortalObject()\n
# Software installation service\n
service_relative_url = portal.portal_preferences.\\\n
getPreferredSoftwareCleanupResource()\n
service = portal.restrictedTraverse(service_relative_url)\n
\n
context.Computer_requestSoftwareReleaseChange(state_change, service_uid=service.getUid())\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Computer_requestSoftwareReleaseCleanup</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>computer = state_change[\'object\']\n
portal = computer.getPortalObject()\n
# Software installation service\n
service_relative_url = portal.portal_preferences.\\\n
getPreferredSoftwareSetupResource()\n
service = portal.restrictedTraverse(service_relative_url)\n
\n
context.Computer_requestSoftwareReleaseChange(state_change, service_uid=service.getUid())\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Computer_requestSoftwareReleaseInstallation</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>packing_list_line = context.Computer_getSoftwareSetupPackingListLine(state_change)\n
packing_list = packing_list_line.getParentValue()\n
if packing_list.getPortalObject().portal_workflow.isTransitionPossible(packing_list, \'start\'):\n
packing_list.start()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Computer_startSoftwareReleaseInstallation</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>packing_list_line = context.Computer_getSoftwareSetupPackingListLine(state_change)\n
packing_list = packing_list_line.getParentValue()\n
if packing_list.getPortalObject().portal_workflow.isTransitionPossible(packing_list, \'stop\'):\n
packing_list.stop()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Computer_stopSoftwareReleaseInstallation</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -26,12 +26,8 @@ ...@@ -26,12 +26,8 @@
<string>cleanup_software_release_installation</string> <string>cleanup_software_release_installation</string>
<string>create_computer_registration</string> <string>create_computer_registration</string>
<string>report_computer_bang</string> <string>report_computer_bang</string>
<string>report_software_release_installation_error</string>
<string>request_computer_registration</string> <string>request_computer_registration</string>
<string>request_software_release_cleanup</string> <string>request_software_release</string>
<string>request_software_release_installation</string>
<string>start_software_release_installation</string>
<string>stop_software_release_installation</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="TransitionDefinition" module="Products.DCWorkflow.Transitions"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>report_software_release_installation_error</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Report Software Release Installation Error</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
</item> </item>
<item> <item>
<key> <string>after_script_name</string> </key> <key> <string>after_script_name</string> </key>
<value> <string>Computer_requestSoftwareReleaseCleanup</string> </value> <value> <string>Computer_requestSoftwareReleaseChange</string> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>request_software_release_cleanup</string> </value> <value> <string>request_software_release</string> </value>
</item> </item>
<item> <item>
<key> <string>new_state_id</string> </key> <key> <string>new_state_id</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="TransitionDefinition" module="Products.DCWorkflow.Transitions"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string>Computer_startSoftwareReleaseInstallation</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>start_software_release_installation</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Start Software Release Installation</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="TransitionDefinition" module="Products.DCWorkflow.Transitions"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string>Computer_stopSoftwareReleaseInstallation</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>stop_software_release_installation</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Stop Software Release Installation</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
807 808
\ No newline at end of file \ No newline at end of file
...@@ -22,10 +22,7 @@ ...@@ -22,10 +22,7 @@
<key> <string>transitions</string> </key> <key> <string>transitions</string> </key>
<value> <value>
<tuple> <tuple>
<string>bang</string> <string>report_error</string>
<string>report_computer_partition_error</string>
<string>request_instance</string>
<string>unallocate_partition</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
<key> <string>transitions</string> </key> <key> <string>transitions</string> </key>
<value> <value>
<tuple> <tuple>
<string>bang</string> <string>report_error</string>
<string>request_destroy</string>
<string>request_start</string> <string>request_start</string>
<string>request_stop</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -22,14 +22,9 @@ ...@@ -22,14 +22,9 @@
<key> <string>transitions</string> </key> <key> <string>transitions</string> </key>
<value> <value>
<tuple> <tuple>
<string>allocate_partition</string> <string>report_error</string>
<string>bang</string>
<string>rename</string>
<string>report_computer_partition_error</string>
<string>request_destroy</string> <string>request_destroy</string>
<string>request_instance</string>
<string>request_start</string> <string>request_start</string>
<string>request_stop</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="StateDefinition" module="Products.DCWorkflow.States"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>stop_requested</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Stop Requested</string> </value>
</item>
<item>
<key> <string>transitions</string> </key>
<value>
<tuple>
<string>allocate_partition</string>
<string>bang</string>
<string>rename</string>
<string>report_computer_partition_error</string>
<string>request_destroy</string>
<string>request_instance</string>
<string>request_start</string>
<string>request_stop</string>
</tuple>
</value>
</item>
<item>
<key> <string>type_list</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
</item> </item>
<item> <item>
<key> <string>after_script_name</string> </key> <key> <string>after_script_name</string> </key>
<value> <string>Computer_requestSoftwareReleaseInstallation</string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>request_software_release_installation</string> </value> <value> <string>report_error</string> </value>
</item> </item>
<item> <item>
<key> <string>new_state_id</string> </key> <key> <string>new_state_id</string> </key>
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string></string> </value> <value> <string>Report Error</string> </value>
</item> </item>
<item> <item>
<key> <string>trigger_type</string> </key> <key> <string>trigger_type</string> </key>
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string></string> </value> <value> <string>Request Destruction</string> </value>
</item> </item>
<item> <item>
<key> <string>trigger_type</string> </key> <key> <string>trigger_type</string> </key>
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string></string> </value> <value> <string>Request Start</string> </value>
</item> </item>
<item> <item>
<key> <string>trigger_type</string> </key> <key> <string>trigger_type</string> </key>
......
46 47
\ No newline at end of file \ No newline at end of file
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
portal_type = "Software Release"\n portal_type = "Software Release"\n
\n \n
url_string_list = context.Computer_getSoftwareReleaseUrlStringList([\'confirmed\', \'started\', \'stopped\'])\n url_string_list = context.Computer_getSoftwareReleaseUrlStringList()\n
if url_string_list:\n if url_string_list:\n
return context.portal_catalog(\n return context.portal_catalog(\n
portal_type=portal_type,\n portal_type=portal_type,\n
......
461 462
\ No newline at end of file \ No newline at end of file
...@@ -676,14 +676,7 @@ class SlapTool(BaseTool): ...@@ -676,14 +676,7 @@ class SlapTool(BaseTool):
Request Software Release installation Request Software Release installation
""" """
computer_document = self._getComputerDocument(computer_id) computer_document = self._getComputerDocument(computer_id)
if state == 'available': computer_document.requestSoftwareRelease(software_release_url=url, state=state)
computer_document.requestSoftwareReleaseInstallation(
software_release_url=url)
elif state == 'destroyed':
computer_document.requestSoftwareReleaseCleanup(
software_release_url=url)
else:
raise ValueError('State %s is not supported' % state)
@convertToREST @convertToREST
def _buildingSoftwareRelease(self, url, computer_id): def _buildingSoftwareRelease(self, url, computer_id):
...@@ -691,8 +684,16 @@ class SlapTool(BaseTool): ...@@ -691,8 +684,16 @@ class SlapTool(BaseTool):
Reports that Software Release is being build Reports that Software Release is being build
""" """
computer_document = self._getComputerDocument(computer_id) computer_document = self._getComputerDocument(computer_id)
computer_document.startSoftwareReleaseInstallation( software_installation = self._getSoftwareInstallationForComputer(url,
software_release_url=url) computer_document)
delivery = software_installation.getCausalityValue(portal_type=["Purchase Packing List"])
if delivery is not None:
portal = self.getPortalObject()
line = delivery.contentValues(portal_type="Purchase Packing List Line")[0]
if line.getResource() == portal.portal_preferences.\
getPreferredSoftwareSetupResource():
if portal.portal_workflow.isTransitionPossible(delivery, 'start'):
delivery.start(comment='Software Release building report.')
@convertToREST @convertToREST
def _availableSoftwareRelease(self, url, computer_id): def _availableSoftwareRelease(self, url, computer_id):
...@@ -700,7 +701,19 @@ class SlapTool(BaseTool): ...@@ -700,7 +701,19 @@ class SlapTool(BaseTool):
Reports that Software Release is available Reports that Software Release is available
""" """
computer_document = self._getComputerDocument(computer_id) computer_document = self._getComputerDocument(computer_id)
computer_document.stopSoftwareReleaseInstallation(software_release_url=url) software_installation = self._getSoftwareInstallationForComputer(url,
computer_document)
delivery = software_installation.getCausalityValue(portal_type=["Purchase Packing List"])
if delivery is not None:
portal = self.getPortalObject()
line = delivery.contentValues(portal_type="Purchase Packing List Line")[0]
if line.getResource() == portal.portal_preferences.\
getPreferredSoftwareSetupResource():
comment = 'Software Release available report.'
if portal.portal_workflow.isTransitionPossible(delivery, 'start'):
delivery.start(comment=comment)
if portal.portal_workflow.isTransitionPossible(delivery, 'stop'):
delivery.stop(comment=comment)
@convertToREST @convertToREST
def _destroyedSoftwareRelease(self, url, computer_id): def _destroyedSoftwareRelease(self, url, computer_id):
...@@ -708,7 +721,24 @@ class SlapTool(BaseTool): ...@@ -708,7 +721,24 @@ class SlapTool(BaseTool):
Reports that Software Release is available Reports that Software Release is available
""" """
computer_document = self._getComputerDocument(computer_id) computer_document = self._getComputerDocument(computer_id)
computer_document.cleanupSoftwareReleaseInstallation(software_release_url=url) software_installation = self._getSoftwareInstallationForComputer(url,
computer_document)
delivery = software_installation.getCausalityValue(portal_type=["Purchase Packing List"])
comment = 'Software Release destroyed report.'
portal = self.getPortalObject()
if delivery is not None:
line = delivery.contentValues(portal_type="Purchase Packing List Line")[0]
if line.getResource() == portal.portal_preferences.\
getPreferredSoftwareSetupResource():
if portal.portal_workflow.isTransitionPossible(delivery, 'start'):
delivery.start(comment=comment)
if portal.portal_workflow.isTransitionPossible(delivery, 'stop'):
delivery.stop(comment=comment)
if portal.portal_workflow.isTransitionPossible(delivery, 'deliver'):
delivery.deliver(comment=comment)
if portal.portal_workflow.isTransitionPossible(software_installation,
'invalidate'):
software_installation.invalidate(comment=comment)
@convertToREST @convertToREST
def _softwareReleaseError(self, url, computer_id, error_log): def _softwareReleaseError(self, url, computer_id, error_log):
...@@ -716,9 +746,9 @@ class SlapTool(BaseTool): ...@@ -716,9 +746,9 @@ class SlapTool(BaseTool):
Add an error for a software Release workflow Add an error for a software Release workflow
""" """
computer_document = self._getComputerDocument(computer_id) computer_document = self._getComputerDocument(computer_id)
computer_document.reportSoftwareReleaseInstallationError( software_installation = self._getSoftwareInstallationForComputer(url,
comment=error_log, computer_document)
software_release_url=url) software_installation.reportError(comment=error_log)
@convertToREST @convertToREST
def _buildingComputerPartition(self, computer_id, computer_partition_id): def _buildingComputerPartition(self, computer_id, computer_partition_id):
...@@ -1033,6 +1063,27 @@ class SlapTool(BaseTool): ...@@ -1033,6 +1063,27 @@ class SlapTool(BaseTool):
return service_document return service_document
raise Unauthorized raise Unauthorized
def _getSoftwareInstallationForComputer(self, url, computer_document):
software_installation_list = self.getPortalObject().portal_catalog(
portal_type='Software Installation',
default_aggregate_uid=computer_document.getUid(),
validation_state='validated',
limit=2,
url_string={'query': url, 'key': 'ExactMatch'},
)
l = len(software_installation_list)
if l == 1:
return software_installation_list[0].getObject()
elif l == 0:
raise NotFound('No software release %r found on computer %r' % (url,
computer_document.getReference()))
else:
raise ValueError('Wrong list of software releases on %r: %s' % (
computer_document.getReference(), ', '.join([q.getRelativeUrl() for q \
in software_installation_list])
))
def _getSoftwareInstanceForComputerPartition(self, computer_id, def _getSoftwareInstanceForComputerPartition(self, computer_id,
computer_partition_id, slave_reference=None): computer_partition_id, slave_reference=None):
computer_partition_document = self._getComputerPartitionDocument( computer_partition_document = self._getComputerPartitionDocument(
...@@ -1115,23 +1166,19 @@ class SlapTool(BaseTool): ...@@ -1115,23 +1166,19 @@ class SlapTool(BaseTool):
"""Returns list of Software Releases documentsfor computer""" """Returns list of Software Releases documentsfor computer"""
computer_document = self._getComputerDocument(computer_reference) computer_document = self._getComputerDocument(computer_reference)
portal = self.getPortalObject() portal = self.getPortalObject()
state_list = []
state_list.extend(portal.getPortalReservedInventoryStateList())
state_list.extend(portal.getPortalTransitInventoryStateList())
if full:
state_list.extend(portal.getPortalCurrentInventoryStateList())
software_release_list = [] software_release_list = []
for software_release_url_string in computer_document\ for software_installation in portal.portal_catalog(
.Computer_getSoftwareReleaseUrlStringList(state_list): portal_type='Software Installation',
default_aggregate_uid=computer_document.getUid(),
validation_state='validated',
):
software_release_response = SoftwareRelease( software_release_response = SoftwareRelease(
software_release=software_release_url_string, software_release=software_installation.getUrlString(),
computer_guid=computer_reference) computer_guid=computer_reference)
software_release_response._requested_state = \ if software_installation.getSlapState() == 'request_destroy':
computer_document.Computer_getSoftwareReleaseRequestedState( software_release_response._requested_state = 'destroyed'
software_release_url_string) else:
software_release_list.append(software_release_response) software_release_response._requested_state = 'available'
return software_release_list return software_release_list
def _reportComputerUsage(self, computer, usage): def _reportComputerUsage(self, computer, usage):
......
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