Commit f74598cc authored by Gabriel Monnerat's avatar Gabriel Monnerat

merged with master

parents 22437b34 34f0974e
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
* general: Polish requirement versions. [Arnaud Fontaine] * general: Polish requirement versions. [Arnaud Fontaine]
* general: Remove libnetworkcache. [Lucas Carvalho] * general: Remove libnetworkcache. [Lucas Carvalho]
* slap: Remove not needed method from interface. [Romain Courteaud] * slap: Remove not needed method from interface. [Romain Courteaud]
* slap: state parameter is accepted and transmitted to SlapOS master [Łukasz
Nowak]
* slapformat: Implement dry run. [Vincent Pelletier] * slapformat: Implement dry run. [Vincent Pelletier]
* slapgrid: Allow to select any buildout binary used to bootstrap environment. * slapgrid: Allow to select any buildout binary used to bootstrap environment.
[Łukasz Nowak] [Łukasz Nowak]
......
...@@ -62,6 +62,7 @@ shared = kwargs["shared"]\n ...@@ -62,6 +62,7 @@ shared = kwargs["shared"]\n
software_type = kwargs["software_type"]\n software_type = kwargs["software_type"]\n
instance_xml = kwargs["instance_xml"]\n instance_xml = kwargs["instance_xml"]\n
sla_xml = kwargs["sla_xml"]\n sla_xml = kwargs["sla_xml"]\n
state = kwargs["state"]\n
\n \n
# Get root software instance\n # Get root software instance\n
predecessor_software_instance = software_instance\n predecessor_software_instance = software_instance\n
...@@ -129,8 +130,17 @@ else:\n ...@@ -129,8 +130,17 @@ else:\n
predecessor_software_instance.edit(\n predecessor_software_instance.edit(\n
predecessor_uid_list=predecessor_uid_list,\n predecessor_uid_list=predecessor_uid_list,\n
activate_kw={\'tag\': tag},)\n activate_kw={\'tag\': tag},)\n
\n if state == \'started\':\n
request_software_instance.startRequested()\n
request_software_instance.activate(after_tag=tag).requestStartComputerPartition()\n
elif state == \'stopped\':\n
request_software_instance.stopRequested() \n
request_software_instance.activate(after_tag=tag).requestStopComputerPartition()\n
else:\n
raise ValueError(\'State %r is not supported\' % state)\n
predecessor_list = software_instance.getPredecessorList() + [request_software_instance.getRelativeUrl()]\n predecessor_list = software_instance.getPredecessorList() + [request_software_instance.getRelativeUrl()]\n
\n
\n
software_instance.edit(\n software_instance.edit(\n
predecessor_list=predecessor_list,\n predecessor_list=predecessor_list,\n
activate_kw={\'tag\': tag},)\n activate_kw={\'tag\': tag},)\n
......
...@@ -56,12 +56,20 @@ software_instance = state_change[\'object\']\n ...@@ -56,12 +56,20 @@ software_instance = state_change[\'object\']\n
service_relative_url = software_instance.portal_preferences.\\\n service_relative_url = software_instance.portal_preferences.\\\n
getPreferredInstanceHostingResource()\n getPreferredInstanceHostingResource()\n
need_to_create_packing_list = False\n need_to_create_packing_list = False\n
\n
try:\n try:\n
sale_packing_list_line = context.SoftwareInstance_getInstanceHostingPackingListLine(state_change)\n instance_setup_line = context.SoftwareInstance_getInstanceSetupPackingListLine(state_change)\n
except ValueError:\n except ValueError:\n
need_to_create_packing_list = True\n pass\n
else:\n else:\n
if instance_setup_line.getSimulationState() == \'stopped\':\n
try:\n
sale_packing_list_line = context.SoftwareInstance_getInstanceHostingPackingListLine(state_change)\n
except ValueError:\n
need_to_create_packing_list = True\n
else:\n
if sale_packing_list_line.getSimulationState() == \'stopped\':\n
# previously it was still in stop in progress state, now it shall be started again\n
sale_packing_list_line.getParentValue().deliver()\n
if sale_packing_list_line.getSimulationState() == \'delivered\':\n if sale_packing_list_line.getSimulationState() == \'delivered\':\n
need_to_create_packing_list = True\n need_to_create_packing_list = True\n
\n \n
......
...@@ -50,9 +50,13 @@ ...@@ -50,9 +50,13 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>packing_list_line = context.SoftwareInstance_getInstanceHostingPackingListLine(state_change)\n <value> <string>try:\n
packing_list = packing_list_line.getParentValue()\n packing_list_line = context.SoftwareInstance_getInstanceHostingPackingListLine(state_change)\n
packing_list.stop()\n except ValueError:\n
pass\n
else:\n
packing_list = packing_list_line.getParentValue()\n
packing_list.stop()\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
...@@ -34,8 +34,10 @@ ...@@ -34,8 +34,10 @@
<string>request_stop_computer_partition_action</string> <string>request_stop_computer_partition_action</string>
<string>start_computer_partition</string> <string>start_computer_partition</string>
<string>start_computer_partition_installation</string> <string>start_computer_partition_installation</string>
<string>start_requested</string>
<string>stop_computer_partition</string> <string>stop_computer_partition</string>
<string>stop_computer_partition_installation</string> <string>stop_computer_partition_installation</string>
<string>stop_requested</string>
<string>update_slave_partition_list</string> <string>update_slave_partition_list</string>
</tuple> </tuple>
</value> </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>
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<key> <string>after_script_name</string> </key> <key> <string>after_script_name</string> </key>
<value> <value>
<list> <list>
<string>SalePackingList_requestStartSoftwareInstance</string> <string>SalePackingList_requestStoredSoftwareInstanceState</string>
</list> </list>
</value> </value>
</item> </item>
......
...@@ -59,7 +59,10 @@ sale_packing_list_line = sale_packing_list_line_list[0]\n ...@@ -59,7 +59,10 @@ sale_packing_list_line = sale_packing_list_line_list[0]\n
resource = sale_packing_list_line.getResource()\n resource = sale_packing_list_line.getResource()\n
if resource == preference_tool.getPreferredInstanceSetupResource():\n if resource == preference_tool.getPreferredInstanceSetupResource():\n
software_instance = sale_packing_list_line.getAggregateValue(portal_type=\'Software Instance\')\n software_instance = sale_packing_list_line.getAggregateValue(portal_type=\'Software Instance\')\n
if software_instance.getSlapState() == \'start_requested\':\n
software_instance.requestStartComputerPartition()\n software_instance.requestStartComputerPartition()\n
elif software_instance.getSlapState() == \'stop_requested\':\n
software_instance.requestStopComputerPartition()\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -68,7 +71,7 @@ if resource == preference_tool.getPreferredInstanceSetupResource():\n ...@@ -68,7 +71,7 @@ if resource == preference_tool.getPreferredInstanceSetupResource():\n
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>SalePackingList_requestStartSoftwareInstance</string> </value> <value> <string>SalePackingList_requestStoredSoftwareInstanceState</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -259,7 +259,7 @@ class SlapTool(BaseTool): ...@@ -259,7 +259,7 @@ class SlapTool(BaseTool):
def requestComputerPartition(self, computer_id=None, def requestComputerPartition(self, computer_id=None,
computer_partition_id=None, software_release=None, software_type=None, computer_partition_id=None, software_release=None, software_type=None,
partition_reference=None, shared_xml=None, partition_parameter_xml=None, partition_reference=None, shared_xml=None, partition_parameter_xml=None,
filter_xml=None): filter_xml=None, state=None):
""" """
Asynchronously requests creation of computer partition for assigned Asynchronously requests creation of computer partition for assigned
parameters parameters
...@@ -273,7 +273,7 @@ class SlapTool(BaseTool): ...@@ -273,7 +273,7 @@ class SlapTool(BaseTool):
""" """
return self._requestComputerPartition(computer_id, computer_partition_id, return self._requestComputerPartition(computer_id, computer_partition_id,
software_release, software_type, partition_reference, software_release, software_type, partition_reference,
shared_xml, partition_parameter_xml, filter_xml) shared_xml, partition_parameter_xml, filter_xml, state)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'useComputer') 'useComputer')
...@@ -565,7 +565,7 @@ class SlapTool(BaseTool): ...@@ -565,7 +565,7 @@ class SlapTool(BaseTool):
@convertToREST @convertToREST
def _requestComputerPartition(self, computer_id, computer_partition_id, def _requestComputerPartition(self, computer_id, computer_partition_id,
software_release, software_type, partition_reference, software_release, software_type, partition_reference,
shared_xml, partition_parameter_xml, filter_xml): shared_xml, partition_parameter_xml, filter_xml, state):
""" """
Asynchronously requests creation of computer partition for assigned Asynchronously requests creation of computer partition for assigned
parameters parameters
...@@ -578,6 +578,10 @@ class SlapTool(BaseTool): ...@@ -578,6 +578,10 @@ class SlapTool(BaseTool):
In any other case returns not important data and HTTP code is 403 Forbidden In any other case returns not important data and HTTP code is 403 Forbidden
""" """
if state:
state = xml_marshaller.xml_marshaller.loads(state)
if state is None:
state = 'started'
if shared_xml: if shared_xml:
shared = xml_marshaller.xml_marshaller.loads(shared_xml) shared = xml_marshaller.xml_marshaller.loads(shared_xml)
else: else:
...@@ -621,7 +625,8 @@ class SlapTool(BaseTool): ...@@ -621,7 +625,8 @@ class SlapTool(BaseTool):
partition_reference=partition_reference, partition_reference=partition_reference,
shared=shared, shared=shared,
instance_xml=instance_xml, instance_xml=instance_xml,
sla_xml=sla_xml) sla_xml=sla_xml,
state=state)
# Get requested software instance # Get requested software instance
requested_software_instance = software_instance_document.portal_catalog.\ requested_software_instance = software_instance_document.portal_catalog.\
...@@ -643,7 +648,8 @@ class SlapTool(BaseTool): ...@@ -643,7 +648,8 @@ class SlapTool(BaseTool):
software_title=partition_reference, software_title=partition_reference,
shared=shared, shared=shared,
instance_xml=instance_xml, instance_xml=instance_xml,
sla_xml=sla_xml) sla_xml=sla_xml,
state=state)
requested_software_instance = person.portal_catalog.\ requested_software_instance = person.portal_catalog.\
getResultValue( getResultValue(
portal_type="Software Instance", portal_type="Software Instance",
......
...@@ -33,12 +33,12 @@ from Products.ERP5Type.tests.utils import DummyMailHost ...@@ -33,12 +33,12 @@ from Products.ERP5Type.tests.utils import DummyMailHost
import os import os
REQUIRED_RULE_REFERENCE_LIST = [ REQUIRED_RULE_REFERENCE_LIST = [
'default_delivery_rule',
'default_order_rule',
'default_delivering_rule', 'default_delivering_rule',
'default_invoicing_rule', 'default_delivery_rule',
'default_invoice_transaction_rule',
'default_invoice_rule', 'default_invoice_rule',
'default_invoice_transaction_rule',
'default_invoicing_rule',
'default_order_rule',
] ]
......
...@@ -723,8 +723,9 @@ class Parser(OptionParser): ...@@ -723,8 +723,9 @@ class Parser(OptionParser):
"declaration.", "declaration.",
type=str), type=str),
Option("-n", "--dry_run", Option("-n", "--dry_run",
help="Apply no changes, only print what would happen.", help="Don't actually do anything.",
type=str), default=False,
action="store_true"),
Option("-v", "--verbose", Option("-v", "--verbose",
default=False, default=False,
action="store_true", action="store_true",
...@@ -737,10 +738,6 @@ class Parser(OptionParser): ...@@ -737,10 +738,6 @@ class Parser(OptionParser):
help="Shall slapformat alter user database [default: True]"), help="Shall slapformat alter user database [default: True]"),
Option('--alter_network', choices=['True', 'False'], Option('--alter_network', choices=['True', 'False'],
help="Shall slapformat alter network configuration [default: True]"), help="Shall slapformat alter network configuration [default: True]"),
Option("-d", "--dry-run",
default=False,
action="store_true",
help="Don't actually do anything."),
]) ])
def check_args(self): def check_args(self):
......
...@@ -236,6 +236,7 @@ def bootstrapBuildout(path, buildout=None, ...@@ -236,6 +236,7 @@ def bootstrapBuildout(path, buildout=None,
invocation_list.append(pkg_resources.resource_filename(__name__, invocation_list.append(pkg_resources.resource_filename(__name__,
'zc.buildout-bootstap.py')) 'zc.buildout-bootstap.py'))
invocation_list.extend(additional_buildout_parametr_list) invocation_list.extend(additional_buildout_parametr_list)
if buildout is not None:
invocation_list.append('bootstrap') invocation_list.append('bootstrap')
try: try:
umask = os.umask(SAFE_UMASK) umask = os.umask(SAFE_UMASK)
......
...@@ -149,7 +149,8 @@ class OpenOrder(SlapDocument): ...@@ -149,7 +149,8 @@ class OpenOrder(SlapDocument):
zope.interface.implements(interface.IOpenOrder) zope.interface.implements(interface.IOpenOrder)
def request(self, software_release, partition_reference, def request(self, software_release, partition_reference,
partition_parameter_kw=None, software_type=None, filter_kw=None): partition_parameter_kw=None, software_type=None, filter_kw=None,
state=None):
if partition_parameter_kw is None: if partition_parameter_kw is None:
partition_parameter_kw = {} partition_parameter_kw = {}
if filter_kw is None: if filter_kw is None:
...@@ -158,7 +159,8 @@ class OpenOrder(SlapDocument): ...@@ -158,7 +159,8 @@ class OpenOrder(SlapDocument):
'software_release': software_release, 'software_release': software_release,
'partition_reference': partition_reference, 'partition_reference': partition_reference,
'partition_parameter_xml': xml_marshaller.dumps(partition_parameter_kw), 'partition_parameter_xml': xml_marshaller.dumps(partition_parameter_kw),
'filter_xml': xml_marshaller.dumps(filter_kw) 'filter_xml': xml_marshaller.dumps(filter_kw),
'state': state,
} }
if software_type is not None: if software_type is not None:
request_dict['software_type'] = software_type request_dict['software_type'] = software_type
...@@ -282,7 +284,8 @@ class ComputerPartition(SlapDocument): ...@@ -282,7 +284,8 @@ class ComputerPartition(SlapDocument):
# Computer Partition data are fetch from server shall be delayed # Computer Partition data are fetch from server shall be delayed
@_syncComputerPartitionInformation @_syncComputerPartitionInformation
def request(self, software_release, software_type, partition_reference, def request(self, software_release, software_type, partition_reference,
shared=False, partition_parameter_kw=None, filter_kw=None): shared=False, partition_parameter_kw=None, filter_kw=None,
state=None):
if partition_parameter_kw is None: if partition_parameter_kw is None:
partition_parameter_kw = {} partition_parameter_kw = {}
elif not isinstance(partition_parameter_kw, dict): elif not isinstance(partition_parameter_kw, dict):
...@@ -304,6 +307,7 @@ class ComputerPartition(SlapDocument): ...@@ -304,6 +307,7 @@ class ComputerPartition(SlapDocument):
'partition_parameter_xml': xml_marshaller.dumps( 'partition_parameter_xml': xml_marshaller.dumps(
partition_parameter_kw), partition_parameter_kw),
'filter_xml': xml_marshaller.dumps(filter_kw), 'filter_xml': xml_marshaller.dumps(filter_kw),
'state': xml_marshaller.dumps(state),
} }
self._connection_helper.POST('/requestComputerPartition', request_dict) self._connection_helper.POST('/requestComputerPartition', request_dict)
xml = self._connection_helper.response.read() xml = self._connection_helper.response.read()
......
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