@@ -48,7 +48,7 @@ def setUpClass(cls):
4848 cls .apiclient = testClient .getApiClient ()
4949 cls .services = testClient .getParsedTestDataConfig ()
5050 cls .hostConfig = cls .config .__dict__ ["zones" ][0 ].__dict__ ["pods" ][0 ].__dict__ ["clusters" ][0 ].__dict__ ["hosts" ][
51- 0 ].__dict__
51+ 0 ].__dict__
5252 cls ._cleanup = []
5353 cls .unsupportedHypervisor = False
5454 cls .hypervisor = cls .testClient .getHypervisorInfo ()
@@ -115,10 +115,10 @@ def setUpClass(cls):
115115 cls ._cleanup .append (cls .big_offering )
116116
117117 Configurations .update (
118- cls .apiclient ,
119- name = "enable.dynamic.scale.vm" ,
120- value = "true"
121- )
118+ cls .apiclient ,
119+ name = "enable.dynamic.scale.vm" ,
120+ value = "true"
121+ )
122122
123123 cls .small_offering_dynamic_scaling_disabled = ServiceOffering .create (
124124 cls .apiclient ,
@@ -228,11 +228,11 @@ def test_01_scale_vm(self):
228228 if self .hypervisor .lower () != 'simulator' :
229229 hostid = self .virtual_machine .hostid
230230 host = Host .list (
231- self .apiclient ,
232- zoneid = self .zone .id ,
233- hostid = hostid ,
234- type = 'Routing'
235- )[0 ]
231+ self .apiclient ,
232+ zoneid = self .zone .id ,
233+ hostid = hostid ,
234+ type = 'Routing'
235+ )[0 ]
236236
237237 try :
238238 username = self .hostConfig ["username" ]
@@ -566,11 +566,11 @@ def test_04_scale_vm_with_user_account(self):
566566 )[0 ]
567567 hostid = list_vm_response .hostid
568568 host = Host .list (
569- self .apiclient ,
570- zoneid = self .zone .id ,
571- hostid = hostid ,
572- type = 'Routing'
573- )[0 ]
569+ self .apiclient ,
570+ zoneid = self .zone .id ,
571+ hostid = hostid ,
572+ type = 'Routing'
573+ )[0 ]
574574
575575 try :
576576 username = self .hostConfig ["username" ]
@@ -664,11 +664,49 @@ def test_05_scale_vm_dont_allow_disk_offering_change(self):
664664 # update setting allow.diskOffering.change.during.scale.vm to true
665665 # scale up the VM to serviceoffering3
666666 # Check disk offering of root volume to be diskoffering3 since setting allow.diskOffering.change.during.scale.vm is true
667+ template = self .template
668+ if self .hypervisor .lower () in ['xenserver' ]:
669+ test_template = get_test_template (self .apiclient , self .zone .id , self .hypervisor )
670+ self .services ["template_2" ]["url" ] = test_template ["url" ]
671+ self .services ["template_2" ]["hypervisor" ] = test_template ["hypervisor" ]
672+ self .services ["template_2" ]["format" ] = test_template ["format" ]
673+ self .services ["template_2" ]["ostype" ] = "CentOS 5.6 (64-bit)"
674+
675+ try :
676+ template = Template .register (self .apiclient ,
677+ self .services ["template_2" ],
678+ zoneid = self .zone .id ,
679+ account = self .account .name ,
680+ domainid = self .account .domainid ,
681+ hypervisor = self .hypervisor
682+ )
683+
684+ template .download (self .apiclient )
685+ except Exception as e :
686+ self .fail ("Failed to register template: %s" % e )
687+
688+ time .sleep (120 )
689+
690+ template = Template .update (
691+ template ,
692+ self .apiclient ,
693+ isdynamicallyscalable = 'true'
694+ )
695+
696+ templates = Template .list (self .apiclient ,
697+ templatefilter = \
698+ self .services ["template_2" ]["templatefilter" ],
699+ id = template .id ,
700+ )
667701
702+ template = templates [0 ]
703+
704+ disk_offering = self .services ["disk_offering" ]
705+ disk_offering ["name" ] = "Disk Offering 1"
668706 self .disk_offering1 = DiskOffering .create (
669- self .apiclient ,
670- self . services [ " disk_offering" ] ,
671- )
707+ self .apiclient ,
708+ disk_offering ,
709+ )
672710 self ._cleanup .append (self .disk_offering1 )
673711 offering_data = {
674712 'displaytext' : 'ServiceOffering1WithDiskOffering1' ,
@@ -689,6 +727,7 @@ def test_05_scale_vm_dont_allow_disk_offering_change(self):
689727 self .virtual_machine_test = VirtualMachine .create (
690728 self .apiclient ,
691729 self .services ["small" ],
730+ templateid = template .id ,
692731 accountid = self .account .name ,
693732 domainid = self .account .domainid ,
694733 serviceofferingid = self .ServiceOffering1WithDiskOffering1 .id ,
@@ -707,11 +746,11 @@ def test_05_scale_vm_dont_allow_disk_offering_change(self):
707746 if self .hypervisor .lower () != 'simulator' :
708747 hostid = self .virtual_machine_test .hostid
709748 host = Host .list (
710- self .apiclient ,
711- zoneid = self .zone .id ,
712- hostid = hostid ,
713- type = 'Routing'
714- )[0 ]
749+ self .apiclient ,
750+ zoneid = self .zone .id ,
751+ hostid = hostid ,
752+ type = 'Routing'
753+ )[0 ]
715754
716755 try :
717756 username = self .hostConfig ["username" ]
@@ -728,10 +767,12 @@ def test_05_scale_vm_dont_allow_disk_offering_change(self):
728767 self .apiclient ,
729768 isdynamicallyscalable = 'true' )
730769
770+ disk_offering2 = self .services ["disk_offering" ]
771+ disk_offering2 ["name" ] = "Disk Offering 2"
731772 self .disk_offering2 = DiskOffering .create (
732- self .apiclient ,
733- self . services [ "disk_offering" ],
734- )
773+ self .apiclient ,
774+ disk_offering2
775+ )
735776 self ._cleanup .append (self .disk_offering2 )
736777 offering_data = {
737778 'displaytext' : 'ServiceOffering2WithDiskOffering2' ,
@@ -809,6 +850,7 @@ def test_05_scale_vm_dont_allow_disk_offering_change(self):
809850 self .debug ("Simulator doesn't support changing disk offering, volume resize" )
810851 return
811852 disk_offering_data = self .services ["disk_offering" ]
853+ disk_offering_data ["name" ] = "Disk Offering 3"
812854 if self .hypervisor .lower () in ['xenserver' ]:
813855 self .debug ("For hypervisor %s, do not resize volume and just change try to change the disk offering" )
814856 volume_response = Volume .list (
@@ -818,9 +860,9 @@ def test_05_scale_vm_dont_allow_disk_offering_change(self):
818860 )[0 ]
819861 disk_offering_data ["disksize" ] = int (volume_response .size / (1024 ** 3 ))
820862 self .disk_offering3 = DiskOffering .create (
821- self .apiclient ,
822- disk_offering_data ,
823- )
863+ self .apiclient ,
864+ disk_offering_data ,
865+ )
824866 self ._cleanup .append (self .disk_offering3 )
825867 offering_data = {
826868 'displaytext' : 'ServiceOffering3WithDiskOffering3' ,
@@ -846,6 +888,8 @@ def test_05_scale_vm_dont_allow_disk_offering_change(self):
846888 value = "true"
847889 )
848890
891+ time .sleep (30 )
892+
849893 self .debug ("Scaling VM-ID: %s to service offering: %s and state %s" % (
850894 self .virtual_machine_test .id ,
851895 self .ServiceOffering3WithDiskOffering3 .id ,
0 commit comments