Commit 90fb9773 authored by Romain Courteaud's avatar Romain Courteaud

Allow to change the software type of a instance.

This fix ComputerPartition.request software type modification
parent 3ca1ad85
......@@ -85,7 +85,7 @@ while (predecessor_software_instance is not None):\n
predecessor_software_instance = predecessor_software_instance.getPredecessorRelatedValue(\n
portal_type="Software Instance")\n
\n
tag = "%s_%s_%s_inProgress" % (root_software_instance.getUid(), software_type,\n
tag = "%s_%s_inProgress" % (root_software_instance.getUid(),\n
requested_partition_reference)\n
\n
# Check if it already exists\n
......@@ -94,7 +94,6 @@ request_software_instance = software_instance.portal_catalog.getResultValue(\n
# XXX: User based property is used in non manual operation\n
# XXX-2: Do we really need to use root_uid?\n
title=requested_partition_reference,\n
source_reference=software_type,\n
root_uid=root_software_instance.getUid(),\n
)\n
\n
......@@ -134,6 +133,7 @@ else:\n
# Sale Packing List interaction has to be requested automatically with an interaction workflow\n
request_software_instance.edit(\n
text_content=instance_xml,\n
source_reference=software_type,\n
sla_xml=sla_xml,\n
activate_kw={\'tag\': tag},\n
)\n
......
......@@ -6,6 +6,7 @@ import httplib
from xml_marshaller import xml_marshaller
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
from slapos import slap
class TestVifibSlapComputerPartitionRequest(TestVifibSlapWebServiceMixin):
########################################
......@@ -1011,6 +1012,78 @@ class TestVifibSlapComputerPartitionRequest(TestVifibSlapWebServiceMixin):
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
##################################################
# ComputerPartition.request - change software type
##################################################
def stepSetFirstSoftwareType(self, sequence,
**kw):
sequence.edit(requested_software_type="FirstSoftwareType")
def stepRequestComputerPartitionWithAnotherSoftwareType(self, sequence, **kw):
self.slap = slap.slap()
self.slap.initializeConnection(self.server_url)
slap_computer_partition = self.slap.registerComputerPartition(
sequence['computer_reference'],
sequence['computer_partition_reference'])
kw = dict(software_release=sequence['software_release_uri'],
software_type="SecondSoftwareType",
partition_reference=sequence.get('requested_reference',
'requested_reference'),
partition_parameter_kw=sequence.get('requested_parameter_dict', {}),
filter_kw=sequence.get('requested_filter_dict', {}),
state=sequence.get('instance_state'))
requested_slap_computer_partition = slap_computer_partition.request(**kw)
def stepCheckRequestComputerPartitionWithAnotherSoftwareType(
self, sequence, **kw):
self.slap = slap.slap()
self.slap.initializeConnection(self.server_url)
slap_computer_partition = self.slap.registerComputerPartition(
sequence['computer_reference'],
sequence['computer_partition_reference'])
kw = dict(software_release=sequence['software_release_uri'],
software_type="SecondSoftwareType",
partition_reference=sequence.get('requested_reference',
'requested_reference'),
partition_parameter_kw=sequence.get('requested_parameter_dict', {}),
filter_kw=sequence.get('requested_filter_dict', {}),
state=sequence.get('instance_state'))
requested_slap_computer_partition = slap_computer_partition.request(**kw)
self.assertEquals(sequence.get('requested_computer_partition_reference'),
requested_slap_computer_partition.getId())
self.assertEquals("SecondSoftwareType",
requested_slap_computer_partition.getInstanceParameterDict()['slap_software_type'])
self.assertEquals(1,
requested_slap_computer_partition._need_modification)
def test_ComputerPartition_request_changeSoftwareType(self):
"""
Check that requesting the same instance with a different software type
does not create a new instance
"""
self.computer_partition_amount = 3
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + '\
SelectRequestedReference \
SelectEmptyRequestedParameterDict \
\
SlapLoginCurrentSoftwareInstance \
SetFirstSoftwareType \
RequestComputerPartition \
Tic \
RequestComputerPartitionWithAnotherSoftwareType \
Tic \
CheckRequestComputerPartitionWithAnotherSoftwareType \
Tic \
SlapLogout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapComputerPartitionRequest))
......
......@@ -260,6 +260,7 @@ class TestVifibSlapOpenOrderRequest(TestVifibSlapWebServiceMixin):
PersonRequestSlapSoftwareInstanceWithAnotherSoftwareType
Tic
CheckPersonRequestSlapSoftwareInstanceWithAnotherSoftwareType
Tic
SlapLogout
"""
sequence_list.addSequenceString(sequence_string)
......
......@@ -1515,7 +1515,8 @@ class TestVifibSlapWebServiceMixin(testVifibMixin):
sequence['computer_reference'],
sequence['computer_partition_reference'])
kw = dict(software_release=sequence['software_release_uri'],
software_type=sequence.get('requested_reference', 'requested_reference'),
software_type=sequence.get('requested_software_type',
'requested_software_type'),
partition_reference=sequence.get('requested_reference',
'requested_reference'),
partition_parameter_kw=sequence.get('requested_parameter_dict', {}),
......
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