Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -7909,7 +7909,7 @@ public Pair<UserVmVO, Volume> doInTransaction(final TransactionStatus status) th

// Detach, destroy and create the usage event for the old root volume.
_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
if (vm.getHypervisorType() == HypervisorType.VMware) {
Expand Down
15 changes: 13 additions & 2 deletions test/integration/smoke/test_events_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,23 @@ def test_01_events_resource(self):
self.services["domain"],
parentdomainid=self.domain.id
)
self.cleanup.append(domain1)
self.services["domainid"] = domain1.id

account = Account.create(
self.apiclient,
self.services["account"],
domainid=domain1.id
)
self.cleanup.append(account)

account_network = Network.create(
self.apiclient,
self.services["network"],
account.name,
account.domainid
)
self.cleanup.append(account_network)
virtual_machine = VirtualMachine.create(
self.apiclient,
self.services,
Expand All @@ -138,6 +141,7 @@ def test_01_events_resource(self):
networkids=account_network.id,
serviceofferingid=self.service_offering.id
)
self.cleanup.append(virtual_machine)
volume = Volume.create(
self.apiclient,
self.services,
Expand All @@ -146,6 +150,7 @@ def test_01_events_resource(self):
domainid=account.domainid,
diskofferingid=self.disk_offering.id
)
self.cleanup.append(volume)
virtual_machine.attach_volume(
self.apiclient,
volume
Expand All @@ -157,15 +162,20 @@ def test_01_events_resource(self):
time.sleep(self.services["sleep"])
virtual_machine.detach_volume(self.apiclient, volume)
volume.delete(self.apiclient)
self.cleanup.remove(volume)
ts = str(time.time())
virtual_machine.update(self.apiclient, displayname=ts)
virtual_machine.delete(self.apiclient)
self.cleanup.remove(virtual_machine)
account_network.update(self.apiclient, name=account_network.name + ts)
account_network.delete(self.apiclient)
self.cleanup.remove(account_network)
account.update(self.apiclient, newname=account.name + ts)
account.disable(self.apiclient)
account.delete(self.apiclient)
self.cleanup.remove(account)
domain1.delete(self.apiclient)
self.cleanup.remove(domain1)

cmd = listEvents.listEventsCmd()
cmd.startdate = start_time
Expand All @@ -185,8 +195,9 @@ def test_01_events_resource(self):
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.resourceid is None or event.resourcetype is None:
self.debug("Failed event:: %s" % json.dumps(event, indent=2))
self.fail("resourceid or resourcetype for the event not found!")
event_json = json.dumps(event.__dict__, indent=2)
self.debug("Failed event:: %s" % event_json)
self.fail("resourceid or resourcetype not found for the event: %s" % event_json)
else:
self.debug("Event %s at %s:: Resource Type: %s, Resource ID: %s" % (event.type, event.created, event.resourcetype, event.resourceid))

Expand Down