Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-f committed Nov 20, 2023
1 parent e851ec3 commit 77a7196
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
- [Self Service] Fix Self users not being able to snapshot VMs when they're members of a user group (PR [#7129](https://github.com/vatesfr/xen-orchestra/pull/7129))
- [Netbox] Fix "The selected cluster is not assigned to this site" error [Forum#7887](https://xcp-ng.org/forum/topic/7887) (PR [#7124](https://github.com/vatesfr/xen-orchestra/pull/7124))
- [Backups] Fix `MESSAGE_METHOD_UNKNOWN` during full backup [Forum#7894](https://xcp-ng.org/forum/topic/7894)(PR [#7139](https://github.com/vatesfr/xen-orchestra/pull/7139))
- [Self Service] Fix error displayed after adding a VM to a resource set ([PR #7144](https://github.com/vatesfr/xen-orchestra/pull/7144))

### Released packages

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- [Backup/Restore] In case of snapshot with memory, create the suspend VDI on the correct SR instead of the default one
- [Import/ESXi] Handle `Cannot read properties of undefined (reading 'perDatastoreUsage')` error when importing VM without storage (PR [#7168](https://github.com/vatesfr/xen-orchestra/pull/7168))
- [Export/OVA] Handle export with resulting disk larger than 8.2GB (PR [#7183](https://github.com/vatesfr/xen-orchestra/pull/7183))
- [Self Service] Fix error displayed after adding a VM to a resource set ([PR #7144](https://github.com/vatesfr/xen-orchestra/pull/7144))

### Packages to release

Expand All @@ -37,6 +38,7 @@
- @xen-orchestra/backups patch
- @xen-orchestra/cr-seed-cli major
- @xen-orchestra/vmware-explorer patch
- xo-server patch
- xo-server-netbox minor
- xo-vmdk-to-vhd patch
- xo-web patch
Expand Down
12 changes: 8 additions & 4 deletions packages/xo-server/src/xo-mixins/resource-sets.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,11 @@ export default class {
await Promise.all(mapToArray(sets, set => this._save(set)))
}

/**
* Change or remove (if null) the resource set a VM belongs to
*
* The VM is also automatically shared in the new resource set.
*/
@decorateWith(deferrable)
async setVmResourceSet($defer, vmId, resourceSetId, force = false) {
const xapi = this._app.getXapi(vmId)
Expand All @@ -430,10 +435,6 @@ export default class {
}

await xapi.xo.setData(vmId, 'resourceSet', resourceSetId === undefined ? null : resourceSetId)
await xapi.barrier(xapi.getObject(vmId).$ref)
// barrier function is used to ensure completion of previous asynchronous operations
// on the vmId object, guaranteeing that all modifications are considered before
// retrieving the resourceSetId value.
$defer.onFailure(() =>
xapi.xo.setData(vmId, 'resourceSet', previousResourceSetId === undefined ? null : previousResourceSetId)
)
Expand All @@ -442,6 +443,9 @@ export default class {
await this._app.removeAclsForObject(vmId)
}
if (resourceSetId != null) {
// ensure the object VM is up-to-date
await xapi.barrier(xapi.getObject(vmId).$ref)

await this.shareVmResourceSet(vmId)
}
}
Expand Down

0 comments on commit 77a7196

Please sign in to comment.