Skip to content

Commit

Permalink
fix(vmware-explorer/Esxi#search): handle more than 100 entries
Browse files Browse the repository at this point in the history
  • Loading branch information
fbeauchamp authored and julien-f committed Feb 27, 2023
1 parent 24ac3ea commit f5d19fd
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 20 deletions.
52 changes: 32 additions & 20 deletions @xen-orchestra/vmware-explorer/esxi.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -124,29 +124,41 @@ export default class Esxi extends EventEmitter {
objectSet: [objectSpec],
}

result = await this.#exec('RetrievePropertiesEx', {
_this: propertyCollector,
specSet: [propertyFilterSpec],
options: { attributes: { type: 'RetrieveOptions' } },
})

let token
const objects = {}
const returnObj = Array.isArray(result.returnval.objects) ? result.returnval.objects : [result.returnval.objects]
do {
if (token !== undefined) {
result = await this.#exec('ContinueRetrievePropertiesEx', {
_this: propertyCollector,
token,
})
} else {
result = await this.#exec('RetrievePropertiesEx', {
_this: propertyCollector,
specSet: [propertyFilterSpec],
options: { attributes: { type: 'RetrieveOptions' } },
})
}

returnObj.forEach(({ obj, propSet }) => {
objects[obj.$value] = {}
propSet = Array.isArray(propSet) ? propSet : [propSet]
propSet.forEach(({ name, val }) => {
// don't care about the type for now
delete val.attributes
// a scalar value : simplify it
if (val.$value) {
objects[obj.$value][name] = val.$value
} else {
objects[obj.$value][name] = val
}
const returnObj = Array.isArray(result.returnval.objects) ? result.returnval.objects : [result.returnval.objects]
returnObj.forEach(({ obj, propSet }) => {
objects[obj.$value] = {}
propSet = Array.isArray(propSet) ? propSet : [propSet]
propSet.forEach(({ name, val }) => {
// don't care about the type for now
delete val.attributes
// a scalar value : simplify it
if (val.$value) {
objects[obj.$value][name] = val.$value
} else {
objects[obj.$value][name] = val
}
})
})
})

token = result.returnval.token
} while (token)

return objects
}

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- [xo-cli] Fix `write EPIPE` error when used with piped output is closed (e.g. like `| head`) [#6680](https://github.com/vatesfr/xen-orchestra/issues/6680)
- [VM] Show distro icon for openSUSE [Forum#6965](https://xcp-ng.org/forum/topic/6965)
- [ESXI import] Handle listing more than 100 VMs

### Packages to release

Expand All @@ -35,6 +36,7 @@
<!--packages-start-->

- @xen-orchestra/vmware-explorer patch
- @xen-orchestra/backups minor
- xo-cli minor
- xo-server-auth-oidc minor
Expand Down

0 comments on commit f5d19fd

Please sign in to comment.