def test_13_revert_renamed_snapshot(self): '''Revert which was created with globalid than renamed with uuid''' virtual_machine = VirtualMachine.create( self.apiclient, {"name":"StorPool-%s" % uuid.uuid4() }, zoneid=self.zone.id, templateid=self.template.id, serviceofferingid=self.service_offering.id, hypervisor=self.hypervisor, hostid = self.host_on_local_1.id, rootdisksize=10 ) self.assertEqual(VirtualMachine.RUNNING, virtual_machine.state, "Running") listvol = Volume.list( self.apiclient, virtualmachineid = virtual_machine.id, type = "ROOT" ) snapshot = Snapshot.create(self.apiclient, volume_id = listvol[0].id) virtual_machine.stop(self.apiclient, forced = True) globalId = self.storpool_snapshot_globalid(snapshot) sn = sptypes.SnapshotUpdateDesc(rename = snapshot.id) rename = self.spapi.snapshotUpdate(snapshotName = globalId, json = sn) snapshot.validateState( self.apiclient, snapshotstate="backedup", ) Volume.revertToSnapshot(self.apiclient, snapshot.id) virtual_machine.start(self.apiclient) cmd = destroyVirtualMachine.destroyVirtualMachineCmd() cmd.id = virtual_machine.id cmd.expunge = True self.apiclient.destroyVirtualMachine(cmd) snapshot.delete(self.apiclient)
def test_04_iops_root_volume_reverted(self): ''' Test resize iops of ROOT StorPool's disk after revert ''' vol = Volume.list( self.apiclient, virtualmachineid= self.virtual_machine.id, type='ROOT', listall = True, ) self.helper.check_storpool_volume_iops(self.spapi, vol[0]) snapshot = Snapshot.create(self.apiclient, vol[0].id,) reverted_snapshot1 = Volume.revertToSnapshot(self.apiclient, volumeSnapshotId = snapshot.id) vol = Volume.list( self.apiclient, virtualmachineid= self.virtual_machine.id, type='ROOT', listall = True, ) self.helper.check_storpool_volume_iops(self.spapi, vol[0])
def test_05_revert_delete_volume_snapshot(self): '''Revert volume snapshot created with uuid''' # create snapshot with globalid bypassed snapshot_bypassed2 = self.helper.create_snapshot( True, self.virtual_machine2) #create snapshot with globalid on secondary snapshot_on_secondary2 = self.helper.create_snapshot( False, self.virtual_machine2) self.virtual_machine2.stop(self.apiclient, forced=True) reverted_snapshot = Volume.revertToSnapshot( self.apiclient, volumeSnapshotId=snapshot_bypassed2.id) self.virtual_machine2.start(self.apiclient) try: ssh_client = self.virtual_machine2.get_ssh_client(reconnect=True) except Exception: self.fail("SSH failed for Virtual machine: %s" % self.virtual_machine2.ipaddress) self.virtual_machine2.stop(self.apiclient, forced=True) reverted_snapshot1 = Volume.revertToSnapshot( self.apiclient, volumeSnapshotId=snapshot_on_secondary2.id) self.virtual_machine2.start(self.apiclient) try: ssh_client = self.virtual_machine2.get_ssh_client(reconnect=True) except Exception: self.fail("SSH failed for Virtual machine: %s" % self.virtual_machine2.ipaddress) self.virtual_machine2.stop(self.apiclient, forced=True) reverted_snapshot2 = Volume.revertToSnapshot( self.apiclient, volumeSnapshotId=self.snapshot_on_secondary.id) self.virtual_machine2.start(self.apiclient) try: ssh_client = self.virtual_machine2.get_ssh_client(reconnect=True) except Exception: self.fail("SSH failed for Virtual machine: %s" % self.virtual_machine2.ipaddress) self.virtual_machine2.stop(self.apiclient, forced=True) reverted_snapshot2 = Volume.revertToSnapshot( self.apiclient, volumeSnapshotId=self.snapshot_bypassed.id) self.virtual_machine2.start(self.apiclient) try: ssh_client = self.virtual_machine2.get_ssh_client(reconnect=True) except Exception: self.fail("SSH failed for Virtual machine: %s" % self.virtual_machine2.ipaddress) snapshot_bypassed2.delete(self.apiclient) snapshot_on_secondary2.delete(self.apiclient)