Commit 1f6a3958 authored by Łukasz Nowak's avatar Łukasz Nowak

Provide server side implementation of state parameter.

Keep backward compatibility and start automatically just after partition become
available.

Implement start_requested and stop_requested states in order to have stateful
information about software instance requested state.

Asynchronously read software instance state and take proper actions in such
case (only after .available() call for now).

Note: Done in one big commit, as changes are interrelated, and impact system
functionality.
parent e45a44a3
......@@ -62,6 +62,7 @@ shared = kwargs["shared"]\n
software_type = kwargs["software_type"]\n
instance_xml = kwargs["instance_xml"]\n
sla_xml = kwargs["sla_xml"]\n
state = kwargs["state"]\n
\n
# Get root software instance\n
predecessor_software_instance = software_instance\n
......@@ -129,6 +130,12 @@ else:\n
predecessor_software_instance.edit(\n
predecessor_uid_list=predecessor_uid_list,\n
activate_kw={\'tag\': tag},)\n
if state == \'started\':\n
request_software_instance.startRequested()\n
elif state == \'stopped\':\n
request_software_instance.stopRequested()\n
else:\n
raise ValueError(\'State %r is not supported\' % state)\n
\n
predecessor_list = software_instance.getPredecessorList() + [request_software_instance.getRelativeUrl()]\n
software_instance.edit(\n
......
......@@ -50,9 +50,13 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>packing_list_line = context.SoftwareInstance_getInstanceHostingPackingListLine(state_change)\n
packing_list = packing_list_line.getParentValue()\n
packing_list.stop()\n
<value> <string>try:\n
packing_list_line = context.SoftwareInstance_getInstanceHostingPackingListLine(state_change)\n
except ValueError:\n
pass\n
else:\n
packing_list = packing_list_line.getParentValue()\n
packing_list.stop()\n
</string> </value>
</item>
<item>
......
......@@ -34,8 +34,10 @@
<string>request_stop_computer_partition_action</string>
<string>start_computer_partition</string>
<string>start_computer_partition_installation</string>
<string>start_requested</string>
<string>stop_computer_partition</string>
<string>stop_computer_partition_installation</string>
<string>stop_requested</string>
<string>update_slave_partition_list</string>
</tuple>
</value>
......
<?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>start_requested</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>transitions</string> </key>
<value>
<tuple>
<string>destroy_computer_partition</string>
<string>report_computer_partition_error</string>
<string>request_computer_partition</string>
<string>request_destroy_computer_partition</string>
<string>request_destroy_computer_partition_action</string>
<string>request_software_instance</string>
<string>request_start_computer_partition</string>
<string>request_start_computer_partition_action</string>
<string>request_stop_computer_partition</string>
<string>request_stop_computer_partition_action</string>
<string>start_computer_partition</string>
<string>start_computer_partition_installation</string>
<string>start_requested</string>
<string>stop_computer_partition</string>
<string>stop_computer_partition_installation</string>
<string>stop_requested</string>
<string>update_slave_partition_list</string>
</tuple>
</value>
</item>
<item>
<key> <string>type_list</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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></string> </value>
</item>
<item>
<key> <string>transitions</string> </key>
<value>
<tuple>
<string>destroy_computer_partition</string>
<string>report_computer_partition_error</string>
<string>request_computer_partition</string>
<string>request_destroy_computer_partition</string>
<string>request_destroy_computer_partition_action</string>
<string>request_software_instance</string>
<string>request_start_computer_partition</string>
<string>request_start_computer_partition_action</string>
<string>request_stop_computer_partition</string>
<string>request_stop_computer_partition_action</string>
<string>start_computer_partition</string>
<string>start_computer_partition_installation</string>
<string>start_requested</string>
<string>stop_computer_partition</string>
<string>stop_computer_partition_installation</string>
<string>stop_requested</string>
<string>update_slave_partition_list</string>
</tuple>
</value>
</item>
<item>
<key> <string>type_list</string> </key>
<value>
<tuple/>
</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_icon</string> </key>
<value> <string></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>start_requested</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
<value> <string>start_requested</string> </value>
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></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_icon</string> </key>
<value> <string></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>stop_requested</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
<value> <string>stop_requested</string> </value>
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
243
\ No newline at end of file
244
\ No newline at end of file
......@@ -28,7 +28,7 @@
<key> <string>after_script_name</string> </key>
<value>
<list>
<string>SalePackingList_requestStartSoftwareInstance</string>
<string>SalePackingList_requestStoredSoftwareInstanceState</string>
</list>
</value>
</item>
......
......@@ -59,7 +59,10 @@ sale_packing_list_line = sale_packing_list_line_list[0]\n
resource = sale_packing_list_line.getResource()\n
if resource == preference_tool.getPreferredInstanceSetupResource():\n
software_instance = sale_packing_list_line.getAggregateValue(portal_type=\'Software Instance\')\n
if software_instance.getSlapState() == \'start_requested\':\n
software_instance.requestStartComputerPartition()\n
elif software_instance.getSlapState() == \'stop_requested\':\n
software_instance.requestStopComputerPartition()\n
</string> </value>
</item>
<item>
......@@ -68,7 +71,7 @@ if resource == preference_tool.getPreferredInstanceSetupResource():\n
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SalePackingList_requestStartSoftwareInstance</string> </value>
<value> <string>SalePackingList_requestStoredSoftwareInstanceState</string> </value>
</item>
</dictionary>
</pickle>
......
378
\ No newline at end of file
379
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment