mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
server,test: fix resourceid for VOLUME.DETROY in restore VM (#9032)
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
parent
f0df8d7831
commit
33659fdf06
@ -7909,7 +7909,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||||||
|
|
||||||
// Detach, destroy and create the usage event for the old root volume.
|
// Detach, destroy and create the usage event for the old root volume.
|
||||||
_volsDao.detachVolume(root.getId());
|
_volsDao.detachVolume(root.getId());
|
||||||
_volumeService.destroyVolume(root.getId(), caller, Volume.State.Allocated.equals(root.getState()) || expunge, false);
|
destroyVolumeInContext(vm, Volume.State.Allocated.equals(root.getState()) || expunge, root);
|
||||||
|
|
||||||
// For VMware hypervisor since the old root volume is replaced by the new root volume, force expunge old root volume if it has been created in storage
|
// For VMware hypervisor since the old root volume is replaced by the new root volume, force expunge old root volume if it has been created in storage
|
||||||
if (vm.getHypervisorType() == HypervisorType.VMware) {
|
if (vm.getHypervisorType() == HypervisorType.VMware) {
|
||||||
|
|||||||
@ -116,6 +116,7 @@ class TestEventsResource(cloudstackTestCase):
|
|||||||
self.services["domain"],
|
self.services["domain"],
|
||||||
parentdomainid=self.domain.id
|
parentdomainid=self.domain.id
|
||||||
)
|
)
|
||||||
|
self.cleanup.append(domain1)
|
||||||
self.services["domainid"] = domain1.id
|
self.services["domainid"] = domain1.id
|
||||||
|
|
||||||
account = Account.create(
|
account = Account.create(
|
||||||
@ -123,6 +124,7 @@ class TestEventsResource(cloudstackTestCase):
|
|||||||
self.services["account"],
|
self.services["account"],
|
||||||
domainid=domain1.id
|
domainid=domain1.id
|
||||||
)
|
)
|
||||||
|
self.cleanup.append(account)
|
||||||
|
|
||||||
account_network = Network.create(
|
account_network = Network.create(
|
||||||
self.apiclient,
|
self.apiclient,
|
||||||
@ -130,6 +132,7 @@ class TestEventsResource(cloudstackTestCase):
|
|||||||
account.name,
|
account.name,
|
||||||
account.domainid
|
account.domainid
|
||||||
)
|
)
|
||||||
|
self.cleanup.append(account_network)
|
||||||
virtual_machine = VirtualMachine.create(
|
virtual_machine = VirtualMachine.create(
|
||||||
self.apiclient,
|
self.apiclient,
|
||||||
self.services,
|
self.services,
|
||||||
@ -138,6 +141,7 @@ class TestEventsResource(cloudstackTestCase):
|
|||||||
networkids=account_network.id,
|
networkids=account_network.id,
|
||||||
serviceofferingid=self.service_offering.id
|
serviceofferingid=self.service_offering.id
|
||||||
)
|
)
|
||||||
|
self.cleanup.append(virtual_machine)
|
||||||
volume = Volume.create(
|
volume = Volume.create(
|
||||||
self.apiclient,
|
self.apiclient,
|
||||||
self.services,
|
self.services,
|
||||||
@ -146,6 +150,7 @@ class TestEventsResource(cloudstackTestCase):
|
|||||||
domainid=account.domainid,
|
domainid=account.domainid,
|
||||||
diskofferingid=self.disk_offering.id
|
diskofferingid=self.disk_offering.id
|
||||||
)
|
)
|
||||||
|
self.cleanup.append(volume)
|
||||||
virtual_machine.attach_volume(
|
virtual_machine.attach_volume(
|
||||||
self.apiclient,
|
self.apiclient,
|
||||||
volume
|
volume
|
||||||
@ -157,15 +162,20 @@ class TestEventsResource(cloudstackTestCase):
|
|||||||
time.sleep(self.services["sleep"])
|
time.sleep(self.services["sleep"])
|
||||||
virtual_machine.detach_volume(self.apiclient, volume)
|
virtual_machine.detach_volume(self.apiclient, volume)
|
||||||
volume.delete(self.apiclient)
|
volume.delete(self.apiclient)
|
||||||
|
self.cleanup.remove(volume)
|
||||||
ts = str(time.time())
|
ts = str(time.time())
|
||||||
virtual_machine.update(self.apiclient, displayname=ts)
|
virtual_machine.update(self.apiclient, displayname=ts)
|
||||||
virtual_machine.delete(self.apiclient)
|
virtual_machine.delete(self.apiclient)
|
||||||
|
self.cleanup.remove(virtual_machine)
|
||||||
account_network.update(self.apiclient, name=account_network.name + ts)
|
account_network.update(self.apiclient, name=account_network.name + ts)
|
||||||
account_network.delete(self.apiclient)
|
account_network.delete(self.apiclient)
|
||||||
|
self.cleanup.remove(account_network)
|
||||||
account.update(self.apiclient, newname=account.name + ts)
|
account.update(self.apiclient, newname=account.name + ts)
|
||||||
account.disable(self.apiclient)
|
account.disable(self.apiclient)
|
||||||
account.delete(self.apiclient)
|
account.delete(self.apiclient)
|
||||||
|
self.cleanup.remove(account)
|
||||||
domain1.delete(self.apiclient)
|
domain1.delete(self.apiclient)
|
||||||
|
self.cleanup.remove(domain1)
|
||||||
|
|
||||||
cmd = listEvents.listEventsCmd()
|
cmd = listEvents.listEventsCmd()
|
||||||
cmd.startdate = start_time
|
cmd.startdate = start_time
|
||||||
@ -185,8 +195,9 @@ class TestEventsResource(cloudstackTestCase):
|
|||||||
for event in events:
|
for event in events:
|
||||||
if event.type.startswith("VM.") or (event.type.startswith("NETWORK.") and not event.type.startswith("NETWORK.ELEMENT")) or event.type.startswith("VOLUME.") or event.type.startswith("ACCOUNT.") or event.type.startswith("DOMAIN.") or event.type.startswith("TEMPLATE."):
|
if event.type.startswith("VM.") or (event.type.startswith("NETWORK.") and not event.type.startswith("NETWORK.ELEMENT")) or event.type.startswith("VOLUME.") or event.type.startswith("ACCOUNT.") or event.type.startswith("DOMAIN.") or event.type.startswith("TEMPLATE."):
|
||||||
if event.resourceid is None or event.resourcetype is None:
|
if event.resourceid is None or event.resourcetype is None:
|
||||||
self.debug("Failed event:: %s" % json.dumps(event, indent=2))
|
event_json = json.dumps(event.__dict__, indent=2)
|
||||||
self.fail("resourceid or resourcetype for the event not found!")
|
self.debug("Failed event:: %s" % event_json)
|
||||||
|
self.fail("resourceid or resourcetype not found for the event: %s" % event_json)
|
||||||
else:
|
else:
|
||||||
self.debug("Event %s at %s:: Resource Type: %s, Resource ID: %s" % (event.type, event.created, event.resourcetype, event.resourceid))
|
self.debug("Event %s at %s:: Resource Type: %s, Resource ID: %s" % (event.type, event.created, event.resourcetype, event.resourceid))
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user