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
\n
if slap_state == \'free\':\n
computer = context.getParentValue()\n
return computer.Computer_getSoftwareReleaseUrlStringList([\'stopped\'])\n
return computer.Computer_getSoftwareReleaseUrlStringList()\n
\n
elif slap_state == \'busy\':\n
\n
......
......@@ -54,7 +54,7 @@
portal = context.getPortalObject()\n
portal_type = "Software Release"\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
return context.portal_catalog(\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 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery\n
computer = context\n
portal = context.getPortalObject()\n
if len(state_list) == 1:\n
state_string = "= \'%s\'" % state_list[0]\n
else:\n
state_string = "IN %s" % (tuple(state_list),)\n
catalog_query = portal.portal_catalog(\n
ComplexQuery(\n
Query(\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
<value> <string>url_string_list = []\n
for software_installation in context.getPortalObject().portal_catalog(\n
portal_type=\'Software Installation\',\n
validation_state=\'validated\',\n
default_aggregate_uid=context.getUid()\n
):\n
url_string = software_installation.getUrlString()\n
if url_string:\n
url_string_list.append(url_string)\n
return url_string_list\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_list</string> </value>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -6,6 +6,27 @@
</pickle>
<pickle>
<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>
<key> <string>_objects</string> </key>
<value>
......
......@@ -10,7 +10,8 @@
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>portal_type</string>
<string>all_columns</string>
<string>columns</string>
<string>selection_name</string>
<string>title</string>
</list>
......@@ -73,6 +74,68 @@
<key> <string>values</string> </key>
<value>
<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>
<key> <string>field_id</string> </key>
<value> <string>my_list_mode_listbox</string> </value>
......
......@@ -97,7 +97,7 @@
<list>
<string>my_title</string>
<string>my_reference</string>
<string>my_root_software_release_url</string>
<string>my_url_string</string>
</list>
</value>
</item>
......
......@@ -16,7 +16,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_root_software_release_url</string> </value>
<value> <string>my_url_string</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......
480
\ No newline at end of file
481
\ 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 @@
<type>Slave Instance</type>
<workflow>local_permission_vifib_interaction_workflow</workflow>
</chain>
<chain>
<type>Software Installation</type>
<workflow>local_permission_vifib_interaction_workflow</workflow>
</chain>
<chain>
<type>Software Instance</type>
<workflow>local_permission_vifib_interaction_workflow</workflow>
......
......@@ -2,7 +2,7 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="TransitionDefinition" module="Products.DCWorkflow.Transitions"/>
<global name="InteractionDefinition" module="Products.ERP5.Interaction"/>
</pickle>
<pickle>
<dictionary>
......@@ -10,10 +10,6 @@
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string></string> </value>
......@@ -22,9 +18,25 @@
<key> <string>actbox_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>activate_script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<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>
<key> <string>description</string> </key>
......@@ -38,15 +50,39 @@
</item>
<item>
<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>
<key> <string>new_state_id</string> </key>
<value> <string>stop_requested</string> </value>
<key> <string>once_per_transaction</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>portal_type_filter</string> </key>
<value>
<list>
<string>Software Installation</string>
</list>
</value>
</item>
<item>
<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>
<key> <string>title</string> </key>
......@@ -56,27 +92,6 @@
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</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>
</pickle>
</record>
......
469
\ No newline at end of file
470
\ No newline at end of file
......@@ -88,6 +88,8 @@ Service Module
Short Message
Site Message
Slave Instance
Software Installation
Software Installation Module
Software Instance
Software Instance Module
Software Product
......
......@@ -88,6 +88,8 @@ Service Module
Short Message
Site Message
Slave Instance
Software Installation
Software Installation Module
Software Instance
Software Instance Module
Software Product
......
......@@ -17,4 +17,5 @@ Sale Packing List | local_permission_vifib_interaction_workflow
Sale Trade Condition Module | init_vifib_interaction_workflow
Sale Trade Condition | 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
\ No newline at end of file
......@@ -52,88 +52,81 @@
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery\n
computer = state_change[\'object\']\n
portal = computer.getPortalObject()\n
# Get required arguments\n
kwargs = state_change.kwargs\n
software_release_url = state_change.kwargs["software_release_url"]\n
\n
portal = computer.getPortalObject()\n
\n
\n
# Only get one software release\n
software_release_document_result = portal.portal_catalog(\n
portal_type=\'Software Release\', # validation_state=(\'shared\', \'released\', \'published\', \'shared_alive\', \'released_alive\', \'published_alive\'),\n
url_string=software_release_url, limit=2)\n
if len(software_release_document_result) != 1:\n
raise ValueError("No software release found for %s %s" % (computer.getRelativeUrl(), software_release_url))\n
else:\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
# Required args\n
# Raise TypeError if all parameters are not provided\n
try:\n
software_release_url = kwargs[\'software_release_url\']\n
state = kwargs["state"]\n
except KeyError:\n
raise TypeError("Computer_requestSoftwareReleaseChange takes exactly 2 arguments")\n
\n
state_list = []\n
state_list.extend(portal.getPortalReservedInventoryStateList())\n
state_list.extend(portal.getPortalTransitInventoryStateList())\n
state_list.extend([\'stopped\', \'delivered\'])\n
tag = "%s_%s_inProgress" % (computer.getUid(), \n
software_release_url)\n
\n
current_delivery_line = portal.portal_catalog.getResultValue(\n
portal_type=\'Purchase Packing List Line\',\n
simulation_state=state_list,\n
default_resource_uid=[\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
if (portal.portal_activities.countMessageWithTag(tag) > 0):\n
# The software instance is already under creation but can not be fetched from catalog\n
# As it is not possible to fetch informations, it is better to raise an error\n
raise NotImplementedError(tag)\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
# change installation in progress\n
return\n
software_installation_portal_type = \'Software Installation\'\n
# Check if it already exists\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
# XXX Hardcoded values\n
person = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
if len(software_installation_list) > 1:\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
packing_list_portal_type = "Purchase Packing List"\n
module = portal.getDefaultModule(portal_type=packing_list_portal_type)\n
packing_list = module.newContent(\n
portal_type=packing_list_portal_type,\n
start_date=DateTime(),\n
destination_value=person,\n
destination_section_value=person,\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
# Change desired state\n
if (state == "available"):\n
software_installation.requestStart()\n
elif (state == "destroyed"):\n
software_installation.requestDestroy()\n
else:\n
raise ValueError("state should be available or destroyed, but is %s" % state)\n
\n
packing_list.confirm(activate_kw=activate_kw)\n
packing_list.startBuilding()\n
# Change the state at the end to allow to execute updateLocalRoles only once in the transaction\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>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change, service_uid</string> </value>
<value> <string>state_change</string> </value>
</item>
<item>
<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 @@
<string>cleanup_software_release_installation</string>
<string>create_computer_registration</string>
<string>report_computer_bang</string>
<string>report_software_release_installation_error</string>
<string>request_computer_registration</string>
<string>request_software_release_cleanup</string>
<string>request_software_release_installation</string>
<string>start_software_release_installation</string>
<string>stop_software_release_installation</string>
<string>request_software_release</string>
</tuple>
</value>
</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 @@
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string>Computer_requestSoftwareReleaseCleanup</string> </value>
<value> <string>Computer_requestSoftwareReleaseChange</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -38,7 +38,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>request_software_release_cleanup</string> </value>
<value> <string>request_software_release</string> </value>
</item>
<item>
<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
\ No newline at end of file
808
\ No newline at end of file
......@@ -22,10 +22,7 @@
<key> <string>transitions</string> </key>
<value>
<tuple>
<string>bang</string>
<string>report_computer_partition_error</string>
<string>request_instance</string>
<string>unallocate_partition</string>
<string>report_error</string>
</tuple>
</value>
</item>
......
......@@ -22,9 +22,9 @@
<key> <string>transitions</string> </key>
<value>
<tuple>
<string>bang</string>
<string>report_error</string>
<string>request_destroy</string>
<string>request_start</string>
<string>request_stop</string>
</tuple>
</value>
</item>
......
......@@ -22,14 +22,9 @@
<key> <string>transitions</string> </key>
<value>
<tuple>
<string>allocate_partition</string>
<string>bang</string>
<string>rename</string>
<string>report_computer_partition_error</string>
<string>report_error</string>
<string>request_destroy</string>
<string>request_instance</string>
<string>request_start</string>
<string>request_stop</string>
</tuple>
</value>
</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 @@
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string>Computer_requestSoftwareReleaseInstallation</string> </value>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -38,7 +38,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>request_software_release_installation</string> </value>
<value> <string>report_error</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
<value> <string>Report Error</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
<value> <string>Request Destruction</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
<value> <string>Request Start</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
......
46
\ No newline at end of file
47
\ No newline at end of file
......@@ -54,7 +54,7 @@
portal = context.getPortalObject()\n
portal_type = "Software Release"\n
\n
url_string_list = context.Computer_getSoftwareReleaseUrlStringList([\'confirmed\', \'started\', \'stopped\'])\n
url_string_list = context.Computer_getSoftwareReleaseUrlStringList()\n
if url_string_list:\n
return context.portal_catalog(\n
portal_type=portal_type,\n
......
461
\ No newline at end of file
462
\ No newline at end of file
......@@ -676,14 +676,7 @@ class SlapTool(BaseTool):
Request Software Release installation
"""
computer_document = self._getComputerDocument(computer_id)
if state == 'available':
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)
computer_document.requestSoftwareRelease(software_release_url=url, state=state)
@convertToREST
def _buildingSoftwareRelease(self, url, computer_id):
......@@ -691,8 +684,16 @@ class SlapTool(BaseTool):
Reports that Software Release is being build
"""
computer_document = self._getComputerDocument(computer_id)
computer_document.startSoftwareReleaseInstallation(
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():
if portal.portal_workflow.isTransitionPossible(delivery, 'start'):
delivery.start(comment='Software Release building report.')
@convertToREST
def _availableSoftwareRelease(self, url, computer_id):
......@@ -700,7 +701,19 @@ class SlapTool(BaseTool):
Reports that Software Release is available
"""
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
def _destroyedSoftwareRelease(self, url, computer_id):
......@@ -708,7 +721,24 @@ class SlapTool(BaseTool):
Reports that Software Release is available
"""
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
def _softwareReleaseError(self, url, computer_id, error_log):
......@@ -716,9 +746,9 @@ class SlapTool(BaseTool):
Add an error for a software Release workflow
"""
computer_document = self._getComputerDocument(computer_id)
computer_document.reportSoftwareReleaseInstallationError(
comment=error_log,
software_release_url=url)
software_installation = self._getSoftwareInstallationForComputer(url,
computer_document)
software_installation.reportError(comment=error_log)
@convertToREST
def _buildingComputerPartition(self, computer_id, computer_partition_id):
......@@ -1033,6 +1063,27 @@ class SlapTool(BaseTool):
return service_document
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,
computer_partition_id, slave_reference=None):
computer_partition_document = self._getComputerPartitionDocument(
......@@ -1115,23 +1166,19 @@ class SlapTool(BaseTool):
"""Returns list of Software Releases documentsfor computer"""
computer_document = self._getComputerDocument(computer_reference)
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 = []
for software_release_url_string in computer_document\
.Computer_getSoftwareReleaseUrlStringList(state_list):
for software_installation in portal.portal_catalog(
portal_type='Software Installation',
default_aggregate_uid=computer_document.getUid(),
validation_state='validated',
):
software_release_response = SoftwareRelease(
software_release=software_release_url_string,
software_release=software_installation.getUrlString(),
computer_guid=computer_reference)
software_release_response._requested_state = \
computer_document.Computer_getSoftwareReleaseRequestedState(
software_release_url_string)
software_release_list.append(software_release_response)
if software_installation.getSlapState() == 'request_destroy':
software_release_response._requested_state = 'destroyed'
else:
software_release_response._requested_state = 'available'
return software_release_list
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