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',
] ]
......
...@@ -35,6 +35,9 @@ from Products.ERP5Type.tests.backportUnittest import skip ...@@ -35,6 +35,9 @@ from Products.ERP5Type.tests.backportUnittest import skip
from VifibMixin import testVifibMixin from VifibMixin import testVifibMixin
from random import random from random import random
from slapos import slap from slapos import slap
import urllib
import urlparse
import httplib
from xml_marshaller import xml_marshaller from xml_marshaller import xml_marshaller
import transaction import transaction
import unittest import unittest
...@@ -204,6 +207,15 @@ class TestVifibSlapWebService(testVifibMixin): ...@@ -204,6 +207,15 @@ class TestVifibSlapWebService(testVifibMixin):
and q.getSimulationState() == state] and q.getSimulationState() == state]
self.assertEqual(1, len(delivery_line_list)) self.assertEqual(1, len(delivery_line_list))
def _checkComputerPartitionNoSalePackingList(self, resource, sequence):
computer_partition = self.portal.portal_catalog.getResultValue(
uid=sequence['computer_partition_uid'])
delivery_line_list = [q for q in computer_partition
.getAggregateRelatedValueList(
portal_type=self.sale_packing_list_line_portal_type)
if q.getResource() == resource]
self.assertEqual(0, len(delivery_line_list))
def stepCheckComputerPartitionInstanceCleanupSalePackingListDoesNotExists(self, def stepCheckComputerPartitionInstanceCleanupSalePackingListDoesNotExists(self,
sequence, **kw): sequence, **kw):
self._checkComputerPartitionSalePackingListDoesNotExists( self._checkComputerPartitionSalePackingListDoesNotExists(
...@@ -288,6 +300,12 @@ class TestVifibSlapWebService(testVifibMixin): ...@@ -288,6 +300,12 @@ class TestVifibSlapWebService(testVifibMixin):
self.portal.portal_preferences.getPreferredInstanceHostingResource(), self.portal.portal_preferences.getPreferredInstanceHostingResource(),
sequence) sequence)
def stepCheckComputerPartitionNoInstanceHostingSalePackingList(self,
sequence, **kw):
self._checkComputerPartitionNoSalePackingList(
self.portal.portal_preferences.getPreferredInstanceHostingResource(),
sequence)
def stepCheckComputerPartitionAccoutingResourceSalePackingListCancelled(self, def stepCheckComputerPartitionAccoutingResourceSalePackingListCancelled(self,
sequence, **kw): sequence, **kw):
self._checkComputerPartitionSalePackingListState('cancelled', self._checkComputerPartitionSalePackingListState('cancelled',
...@@ -1381,13 +1399,33 @@ class TestVifibSlapWebService(testVifibMixin): ...@@ -1381,13 +1399,33 @@ class TestVifibSlapWebService(testVifibMixin):
partition_reference=sequence.get('requested_reference', partition_reference=sequence.get('requested_reference',
'requested_reference'), 'requested_reference'),
partition_parameter_kw=sequence.get('requested_parameter_dict', {}), partition_parameter_kw=sequence.get('requested_parameter_dict', {}),
filter_kw=sequence.get('requested_filter_dict', {})) filter_kw=sequence.get('requested_filter_dict', {}),
state=sequence.get('instance_state'))
sequence.edit( sequence.edit(
requested_slap_computer_partition=requested_slap_computer_partition, requested_slap_computer_partition=requested_slap_computer_partition,
requested_computer_partition_reference=\ requested_computer_partition_reference=\
requested_slap_computer_partition.getId()) requested_slap_computer_partition.getId())
def stepDirectRequestComputerPartitionNotReadyResponseWithoutState(self,
sequence, **kw):
request_dict = { 'computer_id': sequence['computer_reference'] ,
'computer_partition_id': sequence['computer_partition_reference'],
'software_release': sequence['software_release_uri'],
'software_type': sequence.get('requested_reference', 'requested_reference'),
'partition_reference': sequence.get('requested_reference', 'requested_reference'),
'shared_xml': xml_marshaller.dumps(False),
'partition_parameter_xml': xml_marshaller.dumps({}),
'filter_xml': xml_marshaller.dumps({}),
#'state': Note: State is omitted
}
scheme, netloc, path, query, fragment = urlparse.urlsplit(self.server_url)
connection = httplib.HTTPConnection(host=netloc)
connection.request("POST", path + '/requestComputerPartition', urllib.urlencode(request_dict), {'Content-type': "application/x-www-form-urlencoded"})
response = connection.getresponse()
self.assertEqual(httplib.REQUEST_TIMEOUT, response.status)
def stepRequestComputerPartitionNotReadyResponse(self, sequence, **kw): def stepRequestComputerPartitionNotReadyResponse(self, sequence, **kw):
self.slap = slap.slap() self.slap = slap.slap()
self.slap.initializeConnection(self.server_url) self.slap.initializeConnection(self.server_url)
...@@ -1400,7 +1438,8 @@ class TestVifibSlapWebService(testVifibMixin): ...@@ -1400,7 +1438,8 @@ class TestVifibSlapWebService(testVifibMixin):
partition_reference=sequence.get('requested_reference', partition_reference=sequence.get('requested_reference',
'requested_reference'), 'requested_reference'),
partition_parameter_kw=sequence.get('requested_parameter_dict', {}), partition_parameter_kw=sequence.get('requested_parameter_dict', {}),
filter_kw=sequence.get('requested_filter_dict', {})) filter_kw=sequence.get('requested_filter_dict', {}),
state=sequence.get('instance_state'))
def stepRequestComputerPartitionNotFoundResponse(self, sequence, **kw): def stepRequestComputerPartitionNotFoundResponse(self, sequence, **kw):
self.slap = slap.slap() self.slap = slap.slap()
...@@ -1414,7 +1453,8 @@ class TestVifibSlapWebService(testVifibMixin): ...@@ -1414,7 +1453,8 @@ class TestVifibSlapWebService(testVifibMixin):
partition_reference=sequence.get('requested_reference', partition_reference=sequence.get('requested_reference',
'requested_reference'), 'requested_reference'),
partition_parameter_kw=sequence.get('requested_parameter_dict', {}), partition_parameter_kw=sequence.get('requested_parameter_dict', {}),
filter_kw=sequence.get('requested_filter_dict', {})) filter_kw=sequence.get('requested_filter_dict', {}),
state=sequence.get('instance_state'))
def stepSetSoftwareInstanceChildrenA(self, sequence, **kw): def stepSetSoftwareInstanceChildrenA(self, sequence, **kw):
software_instance_uid = sequence['root_software_instance_uid'] software_instance_uid = sequence['root_software_instance_uid']
...@@ -1620,7 +1660,8 @@ class TestVifibSlapWebService(testVifibMixin): ...@@ -1620,7 +1660,8 @@ class TestVifibSlapWebService(testVifibMixin):
shared=False, shared=False,
filter_kw={}, filter_kw={},
instance_xml=self.minimal_correct_xml, instance_xml=self.minimal_correct_xml,
sla_xml=self.minimal_correct_xml) sla_xml=self.minimal_correct_xml,
state=None)
finally: finally:
Base.serialize = Base.serialize_call Base.serialize = Base.serialize_call
...@@ -3621,9 +3662,15 @@ class TestVifibSlapWebService(testVifibMixin): ...@@ -3621,9 +3662,15 @@ class TestVifibSlapWebService(testVifibMixin):
def stepSetCurrentSoftwareInstanceRequested(self, sequence): def stepSetCurrentSoftwareInstanceRequested(self, sequence):
sequence.edit( sequence.edit(
requester_software_instance_uid=sequence['software_instance_uid'],
software_instance_uid=sequence['requested_software_instance_uid'], software_instance_uid=sequence['requested_software_instance_uid'],
) )
def stepSetCurrentSoftwareInstanceRequester(self, sequence):
sequence.edit(
software_instance_uid=sequence['requester_software_instance_uid']
)
def test_ComputerPartition_request_instantiate(self): def test_ComputerPartition_request_instantiate(self):
""" """
Check that after computer partition is requested it is possible to Check that after computer partition is requested it is possible to
...@@ -3688,6 +3735,185 @@ class TestVifibSlapWebService(testVifibMixin): ...@@ -3688,6 +3735,185 @@ class TestVifibSlapWebService(testVifibMixin):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
def stepSetInstanceStateStopped(self, sequence=None, **kw):
sequence['instance_state'] = 'stopped'
def test_ComputerPartition_request_instantiate_state_stopped(self):
"""
Check that after computer partition is requested it is possible to
instantiate it and it is stopped correctly, as requested initally.
"""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + '\
SetInstanceStateStopped \
SlapLoginCurrentSoftwareInstance \
RequestComputerPartitionNotReadyResponse \
Tic \
SlapLogout \
\
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckSoftwareInstanceAndRelatedComputerPartition \
CheckRequestedSoftwareInstanceAndRelatedComputerPartition \
Logout \
\
SlapLoginCurrentSoftwareInstance \
CheckRequestedComputerPartitionCleanParameterList \
Logout \
\
LoginDefaultUser \
SetCurrentSoftwareInstanceRequested \
SetSelectedComputerPartition \
SelectCurrentlyUsedSalePackingListUid \
Logout \
\
SlapLoginCurrentComputer \
SoftwareInstanceBuilding \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckComputerPartitionInstanceSetupSalePackingListStarted \
Logout \
\
SlapLoginCurrentComputer \
SoftwareInstanceAvailable \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckComputerPartitionInstanceSetupSalePackingListStopped \
Logout \
\
SlapLoginCurrentComputer \
SoftwareInstanceStopped \
Tic \
SlapLogout \
\
LoginDefaultUser \
stepCheckComputerPartitionNoInstanceHostingSalePackingList \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_request_instantiate_stop_later(self):
"""
Check that after computer partition is requested it is possible to
instantiate it and it is started correctly, and later it is stopped
correctly as requested.
"""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + '\
SlapLoginCurrentSoftwareInstance \
RequestComputerPartitionNotReadyResponse \
Tic \
SlapLogout \
\
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckSoftwareInstanceAndRelatedComputerPartition \
CheckRequestedSoftwareInstanceAndRelatedComputerPartition \
Logout \
\
SlapLoginCurrentSoftwareInstance \
CheckRequestedComputerPartitionCleanParameterList \
Logout \
\
LoginDefaultUser \
SetCurrentSoftwareInstanceRequested \
SetSelectedComputerPartition \
SelectCurrentlyUsedSalePackingListUid \
Logout \
\
SlapLoginCurrentComputer \
SoftwareInstanceBuilding \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckComputerPartitionInstanceSetupSalePackingListStarted \
Logout \
\
SlapLoginCurrentComputer \
SoftwareInstanceAvailable \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckComputerPartitionInstanceSetupSalePackingListStopped \
CheckComputerPartitionInstanceHostingSalePackingListConfirmed \
Logout \
\
SlapLoginCurrentComputer \
SoftwareInstanceStarted \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckComputerPartitionInstanceHostingSalePackingListStarted \
Logout \
\
SetInstanceStateStopped \
\
LoginDefaultUser \
SetCurrentSoftwareInstanceRequester \
SetSelectedComputerPartition \
SelectCurrentlyUsedSalePackingListUid \
Logout \
\
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
Tic \
SlapLogout \
\
LoginDefaultUser \
SetCurrentSoftwareInstanceRequested \
SetSelectedComputerPartition \
SelectCurrentlyUsedSalePackingListUid \
CheckComputerPartitionInstanceHostingSalePackingListStopped \
Logout \
\
SlapLoginCurrentComputer \
SoftwareInstanceStopped \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckComputerPartitionInstanceHostingSalePackingListDelivered \
Logout \
\
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_request_state_is_optional(self):
"""Checks that state is optional parameter on Slap Tool
This ensures backward compatibility with old libraries."""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = \
self.prepare_install_requested_computer_partition_sequence_string + '\
SlapLoginCurrentSoftwareInstance \
DirectRequestComputerPartitionNotReadyResponseWithoutState \
Tic \
SlapLogout \
\
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
# XXX: This test fails because test_vifib_customer security is cached # XXX: This test fails because test_vifib_customer security is cached
# and this user is not in SOFTINST-x group. We do not want to clear # and this user is not in SOFTINST-x group. We do not want to clear
# cache in tests. # cache in tests.
......
...@@ -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