DaanHoogland commented on a change in pull request #5216:
URL: https://github.com/apache/cloudstack/pull/5216#discussion_r693532725
##########
File path: test/integration/smoke/test_vm_life_cycle.py
##########
@@ -1991,3 +1990,135 @@ def test_01_vapps_vm_cycle(self):
cmd = destroyVirtualMachine.destroyVirtualMachineCmd()
cmd.id = vm.id
self.apiclient.destroyVirtualMachine(cmd)
+
+class TestCloneVM(cloudstackTestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ testClient = super(TestCloneVM, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
+ cls.hypervisor = testClient.getHypervisorInfo()
+
+ # Get Zone, Domain and templates
+ domain = get_domain(cls.apiclient)
+ cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+ cls.services['mode'] = cls.zone.networktype
+
+ # if local storage is enabled, alter the offerings to use localstorage
+ # this step is needed for devcloud
+ if cls.zone.localstorageenabled == True:
+ cls.services["service_offerings"]["tiny"]["storagetype"] = 'local'
+ cls.services["service_offerings"]["small"]["storagetype"] = 'local'
+ cls.services["service_offerings"]["medium"]["storagetype"] =
'local'
+
+ template = get_suitable_test_template(
+ cls.apiclient,
+ cls.zone.id,
+ cls.services["ostype"],
+ cls.hypervisor
+ )
+ if template == FAILED:
+ assert False, "get_suitable_test_template() failed to return
template with description %s" % cls.services["ostype"]
+
+ # Set Zones and disk offerings
+ cls.services["small"]["zoneid"] = cls.zone.id
+ cls.services["small"]["template"] = template.id
+
+ cls.services["iso1"]["zoneid"] = cls.zone.id
+
+ # Create VMs, NAT Rules etc
+ cls.account = Account.create(
+ cls.apiclient,
+ cls.services["account"],
+ domainid=domain.id
+ )
+
+ cls.small_offering = ServiceOffering.create(
+ cls.apiclient,
+ cls.services["service_offerings"]["small"]
+ )
+
+ cls.medium_offering = ServiceOffering.create(
+ cls.apiclient,
+ cls.services["service_offerings"]["medium"]
+ )
+ # create small and large virtual machines
+ cls.small_virtual_machine = VirtualMachine.create(
+ cls.apiclient,
+ cls.services["small"],
+ accountid=cls.account.name,
+ domainid=cls.account.domainid,
+ serviceofferingid=cls.small_offering.id,
+ mode=cls.services["mode"]
+ )
+ cls.medium_virtual_machine = VirtualMachine.create(
+ cls.apiclient,
+ cls.services["small"],
+ accountid=cls.account.name,
+ domainid=cls.account.domainid,
+ serviceofferingid=cls.medium_offering.id,
+ mode=cls.services["mode"]
+ )
+ cls.virtual_machine = VirtualMachine.create(
+ cls.apiclient,
+ cls.services["small"],
+ accountid=cls.account.name,
+ domainid=cls.account.domainid,
+ serviceofferingid=cls.small_offering.id,
+ mode=cls.services["mode"]
+ )
+ cls._cleanup = [
+ cls.small_offering,
+ cls.medium_offering,
+ cls.account
+ ]
+
+ @classmethod
+ def tearDownClass(cls):
+ super(TestCloneVM, cls).tearDownClass()
+
+ def setUp(self):
+ self.apiclient = self.testClient.getApiClient()
+ self.dbclient = self.testClient.getDbConnection()
+ self.cleanup = []
+
+ def tearDown(self):
+ try:
+ # Clean up, terminate the created ISOs
+ cleanup_resources(self.apiclient, self.cleanup)
+ except Exception as e:
+ raise Exception("Warning: Exception during cleanup : %s" % e)
+ return
+
+ @attr(tags = ["clone","devcloud", "advanced", "smoke", "basic", "sg"],
required_hardware="false")
+ def test_clone_vm_and_volumes(self):
+ small_disk_offering = DiskOffering.list(self.apiclient,
name='Small')[0];
+ config = Configurations.list(self.apiclient,
+ name="kvm.snapshot.enabled"
+ )
+ if len(config) == 0 or config[0].value != "true":
+ self.skipTest("Please enable kvm.snapshot.enable global config")
+ if self.hypervisor.lower() in ["kvm", "simulator"]:
+ small_virtual_machine = VirtualMachine.create(
+ self.apiclient,
+ self.services["small"],
+ accountid=self.account.name,
+ domainid=self.account.domainid,
+ serviceofferingid=self.small_offering.id,)
+ vol1 = Volume.create(
+ self.apiclient,
+ self.services,
+ account=self.account.name,
+ diskofferingid=small_disk_offering.id,
+ domainid=self.account.domainid,
+ zoneid=self.zone.id
+ )
+ small_virtual_machine.attach_volume(self.apiclient, vol1)
+ self.debug("Clone VM - ID: %s" % small_virtual_machine.id)
+ try:
+ clone_response = small_virtual_machine.clone(self.apiclient,
small_virtual_machine)
Review comment:
this is not what I mean, unless the clone_response *is* the resulting
VM, I didn't check.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]