Commit 4e097035 authored by Rafael Monnerat's avatar Rafael Monnerat

Computer Partition Need Modification if new Slave Instance be allocated

Force the update of Computer Partition is any Slave Instance is allocated
or stopped. This make the system automatically update configuration if
the new slave instances be created.
parent e8827c7b
...@@ -424,6 +424,8 @@ class SlapTool(BaseTool): ...@@ -424,6 +424,8 @@ class SlapTool(BaseTool):
slap_partition._need_modification = 1 slap_partition._need_modification = 1
elif movement.getSimulationState() == 'started': elif movement.getSimulationState() == 'started':
slap_partition._requested_state = 'started' slap_partition._requested_state = 'started'
slap_partition._need_modification = \
self._hasSlaveInstanceNeedModification(computer_partition_document)
elif movement.getSimulationState() == 'stopped': elif movement.getSimulationState() == 'stopped':
slap_partition._requested_state = 'stopped' slap_partition._requested_state = 'stopped'
slap_partition._need_modification = 1 slap_partition._need_modification = 1
...@@ -445,6 +447,33 @@ class SlapTool(BaseTool): ...@@ -445,6 +447,33 @@ class SlapTool(BaseTool):
movement.getResource() movement.getResource()
return slap_partition return slap_partition
def _hasSlaveInstanceNeedModification(self, computer_partition_document):
"""
Check if modification is needed for...
"""
portal = self.getPortalObject()
portal_preferences = portal.portal_preferences
service = portal.restrictedTraverse(
portal_preferences.getPreferredInstanceHostingResource())
query = ComplexQuery(Query(aggregate_portal_type="Slave Instance"),
Query(aggregate_relative_url=computer_partition_document.getRelativeUrl()),
operator="AND")
# Use getTrackingList
catalog_result = portal.portal_catalog(
portal_type='Sale Packing List Line',
# Search only for Confirmed and Stopped, the only one states that require
# buildout be re-updated.
simulation_state= ["confirmed", 'stopped'],
default_resource_uid=service.getUid(),
sort_on=(('movement.start_date', 'DESC'),),
limit=1,
query=query)
return len(catalog_result)
@convertToREST @convertToREST
def _buildingSoftwareRelease(self, url, computer_id): def _buildingSoftwareRelease(self, url, computer_id):
""" """
......
...@@ -5546,6 +5546,95 @@ class TestVifibSlapWebService(testVifibMixin): ...@@ -5546,6 +5546,95 @@ class TestVifibSlapWebService(testVifibMixin):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
def test_Computer_getComputerPartitionList_HostingResource_StartedState_with_slave(self):
"""
Check that calling Computer.getComputerPartitionList works in
started state with the hosting resource when a Slave Partition is present.
We validate checking more them one Slave Instance allocation.
"""
sequence_list = SequenceList()
sequence_string = self.prepare_started_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckEmptyComputerGetComputerPartitionCall \
SlapLogout \
\
LoginTestVifibCustomer \
PersonRequestSlaveInstance \
SlapLogout \
\
LoginDefaultUser \
ConfirmOrderedSaleOrderActiveSense \
Tic \
Logout \
\
SlapLoginCurrentComputer \
SoftwareInstanceAvailable \
Tic \
CheckSuccessComputerGetComputerPartitionCall \
SoftwareInstanceStarted \
Tic \
SlapLogout \
\
LoginDefaultUser \
SetDeliveryLineAmountEqualTwo \
CheckComputerPartitionInstanceHostingSalePackingListStarted \
Logout \
\
SlapLoginCurrentComputer \
CheckEmptyComputerGetComputerPartitionCall \
SlapLogout \
\
LoginTestVifibCustomer \
PersonRequestSlaveInstance \
SlapLogout \
\
LoginDefaultUser \
ConfirmOrderedSaleOrderActiveSense \
Tic \
Logout \
\
SlapLoginCurrentComputer \
SoftwareInstanceAvailable \
Tic \
CheckSuccessComputerGetComputerPartitionCall \
SoftwareInstanceStarted \
Tic \
SlapLogout \
\
LoginDefaultUser \
SetDeliveryLineAmountEqualThree \
CheckComputerPartitionInstanceHostingSalePackingListStarted \
Logout \
\
SlapLoginCurrentComputer \
CheckEmptyComputerGetComputerPartitionCall \
SlapLogout \
\
LoginTestVifibCustomer \
SlaveInstanceStopped \
Tic \
Logout \
\
SlapLoginCurrentComputer \
CheckSuccessComputerGetComputerPartitionCall \
SoftwareInstanceStarted \
SlapLogout \
\
LoginDefaultUser \
SetDeliveryLineAmountEqualThree \
CheckComputerPartitionInstanceHostingSalePackingListStarted \
SetDeliveryLineAmountEqualOne \
CheckComputerPartitionInstanceHostingSalePackingListDelivered \
Logout \
\
SlapLoginCurrentComputer \
CheckEmptyComputerGetComputerPartitionCall \
SlapLogout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_Computer_getComputerPartitionList_HostingResource_StoppedState(self): def test_Computer_getComputerPartitionList_HostingResource_StoppedState(self):
""" """
Check that calling Computer.getComputerPartitionList works in Check that calling Computer.getComputerPartitionList works in
...@@ -6386,6 +6475,12 @@ class TestVifibSlapWebService(testVifibMixin): ...@@ -6386,6 +6475,12 @@ class TestVifibSlapWebService(testVifibMixin):
def stepSetDeliveryLineAmountEqualTwo(self, sequence): def stepSetDeliveryLineAmountEqualTwo(self, sequence):
sequence.edit(delivery_line_amount=2) sequence.edit(delivery_line_amount=2)
def stepSetDeliveryLineAmountEqualThree(self, sequence):
sequence.edit(delivery_line_amount=3)
def stepSetDeliveryLineAmountEqualOne(self, sequence):
sequence.edit(delivery_line_amount=1)
prepare_two_purchase_packing_list = \ prepare_two_purchase_packing_list = \
prepare_software_release_purchase_packing_list + '\ prepare_software_release_purchase_packing_list + '\
LoginDefaultUser \ LoginDefaultUser \
......
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