chore(backups,xo-server): use extractOpaqueRef from @xen-orchestra/xapi
Instead of custom implementations.
This commit is contained in:
parent
b74ebd050a
commit
ef35021a44
@ -1,17 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
const { extractOpaqueRef } = require('@xen-orchestra/xapi')
|
||||
|
||||
const { Task } = require('../../Task')
|
||||
const assert = require('node:assert/strict')
|
||||
const { HealthCheckVmBackup } = require('../../HealthCheckVmBackup')
|
||||
|
||||
function extractOpaqueRef(str) {
|
||||
const OPAQUE_REF_RE = /OpaqueRef:[0-9a-z-]+/
|
||||
const matches = OPAQUE_REF_RE.exec(str)
|
||||
if (!matches) {
|
||||
throw new Error('no opaque ref found')
|
||||
}
|
||||
return matches[0]
|
||||
}
|
||||
exports.MixinXapiWriter = (BaseClass = Object) =>
|
||||
class MixinXapiWriter extends BaseClass {
|
||||
constructor({ sr, ...rest }) {
|
||||
|
@ -24,7 +24,7 @@ import { limitConcurrency } from 'limit-concurrency-decorator'
|
||||
import { parseDuration } from '@vates/parse-duration'
|
||||
import { PassThrough } from 'stream'
|
||||
import { forbiddenOperation, operationFailed } from 'xo-common/api-errors.js'
|
||||
import { parseDateTime, Xapi as XapiBase } from '@xen-orchestra/xapi'
|
||||
import { extractOpaqueRef, parseDateTime, Xapi as XapiBase } from '@xen-orchestra/xapi'
|
||||
import { Ref } from 'xen-api'
|
||||
import { synchronized } from 'decorator-synchronized'
|
||||
|
||||
@ -34,7 +34,7 @@ import { debounceWithKey } from '../_pDebounceWithKey.mjs'
|
||||
|
||||
import mixins from './mixins/index.mjs'
|
||||
import OTHER_CONFIG_TEMPLATE from './other-config-template.mjs'
|
||||
import { asInteger, extractOpaqueRef, canSrHaveNewVdiOfSize, isVmHvm, isVmRunning, prepareXapiParam } from './utils.mjs'
|
||||
import { asInteger, canSrHaveNewVdiOfSize, isVmHvm, isVmRunning, prepareXapiParam } from './utils.mjs'
|
||||
|
||||
const log = createLogger('xo:xapi')
|
||||
|
||||
|
@ -9,14 +9,14 @@ import { createLogger } from '@xen-orchestra/log'
|
||||
import { decorateWith } from '@vates/decorate-with'
|
||||
import { defer as deferrable } from 'golike-defer'
|
||||
import { incorrectState } from 'xo-common/api-errors.js'
|
||||
import { parseDateTime } from '@xen-orchestra/xapi'
|
||||
import { extractOpaqueRef, parseDateTime } from '@xen-orchestra/xapi'
|
||||
import { timeout } from 'promise-toolbox'
|
||||
|
||||
import ensureArray from '../../_ensureArray.mjs'
|
||||
import { debounceWithKey } from '../../_pDebounceWithKey.mjs'
|
||||
import { forEach, mapFilter, parseXml } from '../../utils.mjs'
|
||||
|
||||
import { extractOpaqueRef, isHostRunning, useUpdateSystem } from '../utils.mjs'
|
||||
import { isHostRunning, useUpdateSystem } from '../utils.mjs'
|
||||
|
||||
// TOC -------------------------------------------------------------------------
|
||||
|
||||
|
@ -46,17 +46,6 @@ export const prepareXapiParam = param => {
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
const OPAQUE_REF_RE = /OpaqueRef:[0-9a-z-]+/
|
||||
export const extractOpaqueRef = str => {
|
||||
const matches = OPAQUE_REF_RE.exec(str)
|
||||
if (!matches) {
|
||||
throw new Error('no opaque ref found')
|
||||
}
|
||||
return matches[0]
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
export const isHostRunning = host => {
|
||||
const { $metrics } = host
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user