feat(xo-server): pass backup network address to proxy
Fixes zammad#4836
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
> Users must be able to say: “I had this issue, happy to know it's fixed”
|
||||
|
||||
- [Self service] Change identifiers used for VM templates to avoid them from being removed on XCP-ng upgrade
|
||||
- [Proxy] Always connect to XAPI via [backup network if defined](https://xen-orchestra.com/blog/xen-orchestra-5-64/#backupmigrationnetwork)
|
||||
|
||||
### Packages to release
|
||||
|
||||
@@ -30,6 +31,8 @@
|
||||
>
|
||||
> In case of conflict, the highest (lowest in previous list) `$version` wins.
|
||||
|
||||
- xen-api minor
|
||||
- @xen-orchestra/xapi
|
||||
- @vates/predicates major
|
||||
- @xen-orchestra/mixins minor
|
||||
- @xen-orchestra/backups patch
|
||||
|
||||
@@ -818,22 +818,14 @@ export class Xapi extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
async _setHostAddressInUrl(url, host) {
|
||||
const pool = this._pool
|
||||
|
||||
const poolBackupNetwork = pool.other_config['xo:backupNetwork']
|
||||
async _getHostBackupAddress(host) {
|
||||
if (host === undefined) {
|
||||
if (poolBackupNetwork === undefined) {
|
||||
const xapiUrl = this._url
|
||||
url.hostname = xapiUrl.hostname
|
||||
url.port = xapiUrl.port
|
||||
return
|
||||
}
|
||||
|
||||
host = await this.getRecord('host', pool.master)
|
||||
host = await this.getRecord('host', this._pool.master)
|
||||
}
|
||||
|
||||
let { address } = host
|
||||
|
||||
const poolBackupNetwork = this._pool.other_config['xo:backupNetwork']
|
||||
if (poolBackupNetwork !== undefined) {
|
||||
const hostPifs = new Set(host.PIFs)
|
||||
try {
|
||||
@@ -855,7 +847,26 @@ export class Xapi extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
url.hostname = address
|
||||
return address
|
||||
}
|
||||
|
||||
async getHostBackupUrl(host) {
|
||||
return Object.assign(new URL('http://localhost'), {
|
||||
...this._url,
|
||||
hostname: await this._getHostBackupAddress(host),
|
||||
})
|
||||
}
|
||||
|
||||
async _setHostAddressInUrl(url, host) {
|
||||
const poolBackupNetwork = this._pool.other_config['xo:backupNetwork']
|
||||
if (host === undefined && poolBackupNetwork === undefined) {
|
||||
const xapiUrl = this._url
|
||||
url.hostname = xapiUrl.hostname
|
||||
url.port = xapiUrl.port
|
||||
return
|
||||
}
|
||||
|
||||
url.hostname = await this._getHostBackupAddress(host)
|
||||
}
|
||||
|
||||
_setUrl(url) {
|
||||
|
||||
@@ -270,14 +270,17 @@ export default class BackupNg {
|
||||
remotes[id] = remote
|
||||
}),
|
||||
asyncMapSettled([...servers], async id => {
|
||||
const { allowUnauthorized, host, password, username } = await app.getXenServer(id)
|
||||
const { allowUnauthorized, password, username } = await app.getXenServer(id)
|
||||
|
||||
const xapi = app.getAllXapis()[id]
|
||||
|
||||
xapis[id] = {
|
||||
allowUnauthorized,
|
||||
credentials: {
|
||||
username,
|
||||
password,
|
||||
},
|
||||
url: host,
|
||||
url: await xapi.getHostBackupUrl(xapi.pool.$master),
|
||||
}
|
||||
}),
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user