feat(xo-server/proxy.upgradeAppliance): support proxies with unknown VM

This commit is contained in:
Julien Fontanet
2022-11-07 00:19:13 +01:00
parent aa0b2ff93a
commit 5723598923
2 changed files with 23 additions and 1 deletions

View File

@@ -8,6 +8,7 @@
> Users must be able to say: “Nice enhancement, I'm eager to test it” > Users must be able to say: “Nice enhancement, I'm eager to test it”
- [API] `proxy.register` accepts `vmUuid` parameter which can be used when not connected to the XAPI containing the XO Proxy VM - [API] `proxy.register` accepts `vmUuid` parameter which can be used when not connected to the XAPI containing the XO Proxy VM
- [Proxy] Can now upgrade proxies in VMs not connected to XO
### Bug fixes ### Bug fixes

View File

@@ -195,7 +195,28 @@ export default class Proxy {
} }
} }
return this.updateProxyAppliance(id, { upgrade: true }) let isVmKnown = false
const { vmUuid } = await this._getProxy(id)
if (vmUuid !== undefined) {
try {
this.getObject(vmUuid, 'VM')
isVmKnown = true
} catch (error) {
if (!noSuchObject.is(error)) {
throw error
}
}
}
if (isVmKnown) {
// use the standard upgrade (via VM reboot)
await this.updateProxyAppliance(id, { upgrade: true })
} else {
// use the (limited) API upgrade instead
await this.callProxyMethod(id, 'appliance.updater.upgrade')
}
} }
async updateProxyAppliance(id, { httpProxy, upgrade = false }) { async updateProxyAppliance(id, { httpProxy, upgrade = false }) {