3232from marvin .lib .common import (get_zone ,
3333 get_template ,
3434 get_test_template ,
35+ get_builtin_template_info ,
3536 get_domain )
3637from nose .plugins .attrib import attr
3738from marvin .sshClient import SshClient
@@ -48,7 +49,7 @@ def setUpClass(cls):
4849 cls .apiclient = testClient .getApiClient ()
4950 cls .services = testClient .getParsedTestDataConfig ()
5051 cls .hostConfig = cls .config .__dict__ ["zones" ][0 ].__dict__ ["pods" ][0 ].__dict__ ["clusters" ][0 ].__dict__ ["hosts" ][
51- 0 ].__dict__
52+ 0 ].__dict__
5253 cls ._cleanup = []
5354 cls .unsupportedHypervisor = False
5455 cls .hypervisor = cls .testClient .getHypervisorInfo ()
@@ -115,10 +116,10 @@ def setUpClass(cls):
115116 cls ._cleanup .append (cls .big_offering )
116117
117118 Configurations .update (
118- cls .apiclient ,
119- name = "enable.dynamic.scale.vm" ,
120- value = "true"
121- )
119+ cls .apiclient ,
120+ name = "enable.dynamic.scale.vm" ,
121+ value = "true"
122+ )
122123
123124 cls .small_offering_dynamic_scaling_disabled = ServiceOffering .create (
124125 cls .apiclient ,
@@ -228,11 +229,11 @@ def test_01_scale_vm(self):
228229 if self .hypervisor .lower () != 'simulator' :
229230 hostid = self .virtual_machine .hostid
230231 host = Host .list (
231- self .apiclient ,
232- zoneid = self .zone .id ,
233- hostid = hostid ,
234- type = 'Routing'
235- )[0 ]
232+ self .apiclient ,
233+ zoneid = self .zone .id ,
234+ hostid = hostid ,
235+ type = 'Routing'
236+ )[0 ]
236237
237238 try :
238239 username = self .hostConfig ["username" ]
@@ -566,11 +567,11 @@ def test_04_scale_vm_with_user_account(self):
566567 )[0 ]
567568 hostid = list_vm_response .hostid
568569 host = Host .list (
569- self .apiclient ,
570- zoneid = self .zone .id ,
571- hostid = hostid ,
572- type = 'Routing'
573- )[0 ]
570+ self .apiclient ,
571+ zoneid = self .zone .id ,
572+ hostid = hostid ,
573+ type = 'Routing'
574+ )[0 ]
574575
575576 try :
576577 username = self .hostConfig ["username" ]
@@ -665,10 +666,46 @@ def test_05_scale_vm_dont_allow_disk_offering_change(self):
665666 # scale up the VM to serviceoffering3
666667 # Check disk offering of root volume to be diskoffering3 since setting allow.diskOffering.change.during.scale.vm is true
667668
669+ builtin_info = get_builtin_template_info (self .apiclient , self .zone .id )
670+ self .services ["template_2" ]["url" ] = builtin_info [0 ]
671+ self .services ["template_2" ]["hypervisor" ] = builtin_info [1 ]
672+ self .services ["template_2" ]["format" ] = builtin_info [2 ]
673+
674+ try :
675+ template = Template .register (self .apiclient ,
676+ self .services ["template_2" ],
677+ zoneid = self .zone .id ,
678+ account = self .account .name ,
679+ domainid = self .account .domainid ,
680+ hypervisor = self .hypervisor
681+ )
682+
683+ template .download (self .apiclient )
684+ except Exception as e :
685+ self .fail ("Failed to register template: %s" % e )
686+
687+ time .sleep (120 )
688+
689+ template = Template .update (
690+ template ,
691+ self .apiclient ,
692+ isdynamicallyscalable = 'true'
693+ )
694+
695+ templates = Template .list (self .apiclient ,
696+ templatefilter = \
697+ self .services ["template_2" ]["templatefilter" ],
698+ id = template .id ,
699+ )
700+
701+ template = templates [0 ]
702+ disk_offering = self .services ["disk_offering" ]
703+ disk_offering ["disksize" ] = 25
704+ disk_offering ["name" ] = "Disk Offering 1"
668705 self .disk_offering1 = DiskOffering .create (
669- self .apiclient ,
670- self . services [ " disk_offering" ] ,
671- )
706+ self .apiclient ,
707+ disk_offering ,
708+ )
672709 self ._cleanup .append (self .disk_offering1 )
673710 offering_data = {
674711 'displaytext' : 'ServiceOffering1WithDiskOffering1' ,
@@ -689,6 +726,7 @@ def test_05_scale_vm_dont_allow_disk_offering_change(self):
689726 self .virtual_machine_test = VirtualMachine .create (
690727 self .apiclient ,
691728 self .services ["small" ],
729+ templateid = template .id ,
692730 accountid = self .account .name ,
693731 domainid = self .account .domainid ,
694732 serviceofferingid = self .ServiceOffering1WithDiskOffering1 .id ,
@@ -707,11 +745,11 @@ def test_05_scale_vm_dont_allow_disk_offering_change(self):
707745 if self .hypervisor .lower () != 'simulator' :
708746 hostid = self .virtual_machine_test .hostid
709747 host = Host .list (
710- self .apiclient ,
711- zoneid = self .zone .id ,
712- hostid = hostid ,
713- type = 'Routing'
714- )[0 ]
748+ self .apiclient ,
749+ zoneid = self .zone .id ,
750+ hostid = hostid ,
751+ type = 'Routing'
752+ )[0 ]
715753
716754 try :
717755 username = self .hostConfig ["username" ]
@@ -728,10 +766,12 @@ def test_05_scale_vm_dont_allow_disk_offering_change(self):
728766 self .apiclient ,
729767 isdynamicallyscalable = 'true' )
730768
769+ disk_offering2 = self .services ["disk_offering" ]
770+ disk_offering2 ["name" ] = "Disk Offering 2"
731771 self .disk_offering2 = DiskOffering .create (
732- self .apiclient ,
733- self . services [ "disk_offering" ] ,
734- )
772+ self .apiclient ,
773+ disk_offering2 ,
774+ )
735775 self ._cleanup .append (self .disk_offering2 )
736776 offering_data = {
737777 'displaytext' : 'ServiceOffering2WithDiskOffering2' ,
@@ -809,6 +849,7 @@ def test_05_scale_vm_dont_allow_disk_offering_change(self):
809849 self .debug ("Simulator doesn't support changing disk offering, volume resize" )
810850 return
811851 disk_offering_data = self .services ["disk_offering" ]
852+ disk_offering_data ["name" ] = "Disk Offering 3"
812853 if self .hypervisor .lower () in ['xenserver' ]:
813854 self .debug ("For hypervisor %s, do not resize volume and just change try to change the disk offering" )
814855 volume_response = Volume .list (
@@ -818,9 +859,9 @@ def test_05_scale_vm_dont_allow_disk_offering_change(self):
818859 )[0 ]
819860 disk_offering_data ["disksize" ] = int (volume_response .size / (1024 ** 3 ))
820861 self .disk_offering3 = DiskOffering .create (
821- self .apiclient ,
822- disk_offering_data ,
823- )
862+ self .apiclient ,
863+ disk_offering_data ,
864+ )
824865 self ._cleanup .append (self .disk_offering3 )
825866 offering_data = {
826867 'displaytext' : 'ServiceOffering3WithDiskOffering3' ,
@@ -846,6 +887,8 @@ def test_05_scale_vm_dont_allow_disk_offering_change(self):
846887 value = "true"
847888 )
848889
890+ time .sleep (30 )
891+
849892 self .debug ("Scaling VM-ID: %s to service offering: %s and state %s" % (
850893 self .virtual_machine_test .id ,
851894 self .ServiceOffering3WithDiskOffering3 .id ,
@@ -891,6 +934,7 @@ def test_05_scale_vm_dont_allow_disk_offering_change(self):
891934 listall = True
892935 )[0 ]
893936
937+ self .debug ("After scaling 3: Volume disk offering %s and disk offering 3: %s" % (volume_response .diskofferingid , self .disk_offering3 .id ))
894938 self .assertEqual (
895939 volume_response .diskofferingid ,
896940 self .disk_offering3 .id ,
0 commit comments