feat(xo-server/metadata-backups): list proxy backups (#5517)

This commit is contained in:
badrAZ
2021-01-23 12:42:55 +01:00
committed by GitHub
parent 874e889b36
commit 26f5ef5e31
2 changed files with 49 additions and 9 deletions

View File

@@ -13,8 +13,8 @@
- [Health] Show duplicated MAC addresses with their VIFs, VMs and networks [#5448](https://github.com/vatesfr/xen-orchestra/issues/5448) (PR [#5468](https://github.com/vatesfr/xen-orchestra/pull/5468))
- [Host/stats] Show interfaces' names in graph "Network throughput" instead of PIFs' indices (PR [#5483](https://github.com/vatesfr/xen-orchestra/pull/5483))
- [Pool/advanced] Ability to define default migration network [#3788](https://github.com/vatesfr/xen-orchestra/issues/3788#issuecomment-743207834) (PR [#5465](https://github.com/vatesfr/xen-orchestra/pull/5465))
- [Proxy] Ability to run metadata backups (PR [#5499](https://github.com/vatesfr/xen-orchestra/pull/5499))
- [Metadata backups] Ability to link a backup to a proxy (PR [#4206](https://github.com/vatesfr/xen-orchestra/pull/4206))
- [Proxy] Support metadata backups (PRs [#5499](https://github.com/vatesfr/xen-orchestra/pull/5499) [#5517](https://github.com/vatesfr/xen-orchestra/pull/5517))
### Bug fixes

View File

@@ -654,7 +654,28 @@ export default class metadataBackup {
// scheduleName,
// timestamp
// }]
async _listXoMetadataBackups(remoteId, handler) {
async _listXoMetadataBackups(remoteId) {
const app = this._app
const { proxy, url, options } = await app.getRemoteWithCredentials(remoteId)
if (proxy !== undefined) {
const { [remoteId]: backups } = await app.callProxyMethod(proxy, 'backup.listXoMetadataBackups', {
remotes: {
[remoteId]: {
url,
options,
},
},
})
// inject the remote id on the backup which is needed for restoreMetadataBackup()
backups.forEach(backup => {
backup.id = `${remoteId}${backup.id}`
})
return backups
}
const handler = await this._app.getRemoteHandler(remoteId)
const safeReaddir = createSafeReaddir(handler, 'listXoMetadataBackups')
const backups = []
@@ -687,7 +708,30 @@ export default class metadataBackup {
// poolMaster,
// }]
// }
async _listPoolMetadataBackups(remoteId, handler) {
async _listPoolMetadataBackups(remoteId) {
const app = this._app
const { proxy, url, options } = await app.getRemoteWithCredentials(remoteId)
if (proxy !== undefined) {
const { [remoteId]: backupsByPool } = await app.callProxyMethod(proxy, 'backup.listPoolMetadataBackups', {
remotes: {
[remoteId]: {
url,
options,
},
},
})
// inject the remote id on the backup which is needed for restoreMetadataBackup()
Object.values(backupsByPool).forEach(backups =>
backups.forEach(backup => {
backup.id = `${remoteId}${backup.id}`
})
)
return backupsByPool
}
const handler = await this._app.getRemoteHandler(remoteId)
const safeReaddir = createSafeReaddir(handler, 'listXoMetadataBackups')
const backupsByPool = {}
@@ -731,18 +775,14 @@ export default class metadataBackup {
// }
// }
async listMetadataBackups(remoteIds: string[]) {
const app = this._app
const xo = {}
const pool = {}
await Promise.all(
remoteIds.map(async remoteId => {
try {
const handler = await app.getRemoteHandler(remoteId)
const [xoList, poolList] = await Promise.all([
this._listXoMetadataBackups(remoteId, handler),
this._listPoolMetadataBackups(remoteId, handler),
this._listXoMetadataBackups(remoteId),
this._listPoolMetadataBackups(remoteId),
])
if (xoList.length !== 0) {
xo[remoteId] = xoList