Commit 4b79d061 authored by Gabriel Monnerat's avatar Gabriel Monnerat

BUGFIX. Fix function used to find Slave Instance related with Software...

BUGFIX. Fix function used to find Slave Instance related with Software Instance that will be destroyed. When the state of Slave Instance was stopped, this object was ignored. Now, all states are considered to destroy
parent 0d706619
##############################################################################
###############################################################################
#
# Copyright (c) 2002-2011 Nexedi SA and Contributors. All Rights Reserved.
#
......@@ -86,7 +86,6 @@ def SoftwareInstance_requestDestroySlaveInstanceRelated(self):
computer_partition_relative_url = self.getAggregateRelatedValue(
"Sale Packing List Line").getAggregate(portal_type="Computer Partition")
portal_preferences = portal.portal_preferences
simulation_state = ["started", "confirmed"]
service_uid_list = [
portal.restrictedTraverse(portal_preferences.getPreferredInstanceHostingResource()).getUid(),
portal.restrictedTraverse(portal_preferences.getPreferredInstanceSetupResource()).getUid(),
......@@ -95,10 +94,13 @@ def SoftwareInstance_requestDestroySlaveInstanceRelated(self):
result_list = self.portal_catalog(portal_type="Sale Packing List Line",
aggregate_portal_type="Slave Instance",
computer_partition_relative_url=computer_partition_relative_url,
simulation_state=simulation_state,
default_resource_uid=service_uid_list)
slave_instance_list = [line.getAggregateValue(portal_type="Slave Instance") for line in result_list]
uid_list = []
for slave_instance in slave_instance_list:
slave_instance_uid = slave_instance.getUid()
if slave_instance_uid in uid_list:
continue
cleanup_packing_list = self.portal_catalog(
portal_type='Sale Packing List Line',
aggregate_relative_url=slave_instance.getRelativeUrl(),
......@@ -106,6 +108,7 @@ def SoftwareInstance_requestDestroySlaveInstanceRelated(self):
limit=1,
)
if len(cleanup_packing_list) == 0:
uid_list.append(slave_instance_uid)
slave_instance.requestDestroyComputerPartition()
finally:
# Restore the original user.
......
......@@ -790,6 +790,73 @@ class TestVifibSlapWebServiceSlaveInstance(TestVifibSlapWebServiceMixin):
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_SlaveInstance_destroy_slave_with_SlaveInstance_stopped(self):
"""
Check that request destroy from Software Instance when exists one Slave
Instance stopped, both instances will be destroyed correctly
Scenario:
1. request master instance
2. request Slave Instance
3. stop Slave Instance
4. request destroy the master instance
Both instances must be destroyed
"""
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + """
Tic
SlapLoginCurrentComputer
SoftwareInstanceAvailable
Tic
CheckEmptySlaveInstanceListFromOneComputerPartition
SlapLoginCurrentSoftwareInstance
SelectEmptyRequestedParameterDict
SetRandomRequestedReference
RequestSlaveInstanceFromComputerPartition
SlapLogout
LoginDefaultUser
ConfirmOrderedSaleOrderActiveSense
Tic
Logout
SlapLoginCurrentSoftwareInstance
RequestSlaveInstanceFromComputerPartition
SlapLogout
SlapLoginCurrentComputer
SoftwareInstanceAvailable
Tic
LoginDefaultUser
StartSoftwareInstanceFromCurrentComputerPartition
Logout
Tic
SoftwareInstanceStarted
Tic
SlapLogout
LoginDefaultUser
SelectSlaveInstanceFromOneComputerPartition
SlapLoginCurrentSoftwareInstance
RequestSoftwareInstanceStop
Tic
SlaveInstanceStopped
Tic
CheckComputerPartitionInstanceHostingSalePackingListStarted
CheckComputerPartitionInstanceHostingSalePackingListDelivered
SetDeliveryLineAmountEqualTwo
CheckComputerPartitionInstanceSetupSalePackingListStopped
RequestDestroySoftwareInstanceFromCurrentComputerPartition
Tic
CheckComputerPartitionInstanceCleanupSalePackingListConfirmed
Logout
SlapLoginCurrentComputer
SoftwareInstanceDestroyed
Tic
LoginDefaultUser
CheckComputerPartitionIsFree
CheckComputerPartitionInstanceCleanupSalePackingListDelivered
CheckComputerPartitionInstanceSetupSalePackingListDelivered
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_Security_after_destroy_SoftwareInstance_with_different_user(self):
"""
Check that destroying one Software Instance it will not destroy Slave
......
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