chore(xo-server): remove object properties decorator syntax
This syntax is not supported by Prettier.
This commit is contained in:
parent
774d66512e
commit
901f7b3fe2
@ -7,7 +7,7 @@ import some from 'lodash/some.js'
|
||||
import unzip from 'unzipper'
|
||||
import { asyncEach } from '@vates/async-each'
|
||||
import { createLogger } from '@xen-orchestra/log'
|
||||
import { decorateWith } from '@vates/decorate-with'
|
||||
import { decorateObject } from '@vates/decorate-with'
|
||||
import { defer as deferrable } from 'golike-defer'
|
||||
import { incorrectState } from 'xo-common/api-errors.js'
|
||||
import { extractOpaqueRef, parseDateTime } from '@xen-orchestra/xapi'
|
||||
@ -58,12 +58,9 @@ const listMissingPatches = debounceWithKey(_listMissingPatches, LISTING_DEBOUNCE
|
||||
|
||||
// =============================================================================
|
||||
|
||||
export default {
|
||||
const methods = {
|
||||
// raw { uuid: patch } map translated from updates.ops.xenserver.com/xenserver/updates.xml
|
||||
// FIXME: should be static
|
||||
@decorateWith(debounceWithKey, 24 * 60 * 60 * 1000, function () {
|
||||
return this
|
||||
})
|
||||
async _getXenUpdates() {
|
||||
const response = await this.xo.httpRequest('https://updates.ops.xenserver.com/xenserver/updates.xml')
|
||||
|
||||
@ -404,7 +401,7 @@ export default {
|
||||
return vdi
|
||||
},
|
||||
|
||||
_poolWideInstall: deferrable(async function ($defer, patches, xsCredentials) {
|
||||
async function_poolWideInstall($defer, patches, xsCredentials) {
|
||||
// New XS patching system: https://support.citrix.com/article/CTX473972/upcoming-changes-in-xencenter
|
||||
if (xsCredentials?.username === undefined || xsCredentials?.apikey === undefined) {
|
||||
throw new Error('XenServer credentials not found. See https://xen-orchestra.com/docs/updater.html#xenserver-updates')
|
||||
@ -435,14 +432,14 @@ export default {
|
||||
const updateRef = await this.call('pool_update.introduce', vdi.$ref)
|
||||
|
||||
// Checks for license restrictions (and other conditions?)
|
||||
await Promise.all(filter(this.objects.all, { $type: 'host' }).map(host =>
|
||||
this.call('pool_update.precheck', updateRef, host.$ref)
|
||||
))
|
||||
await Promise.all(
|
||||
filter(this.objects.all, { $type: 'host' }).map(host => this.call('pool_update.precheck', updateRef, host.$ref))
|
||||
)
|
||||
|
||||
log.debug(`installing patch ${p.uuid}`)
|
||||
await this.call('pool_update.pool_apply', updateRef)
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
async _hostInstall(patches, host) {
|
||||
throw new Error('single host install not implemented')
|
||||
@ -492,7 +489,6 @@ export default {
|
||||
throw new Error('non pool-wide install not implemented')
|
||||
},
|
||||
|
||||
@decorateWith(deferrable)
|
||||
async rollingPoolUpdate($defer, { xsCredentials } = {}) {
|
||||
const isXcp = _isXcp(this.pool.$master)
|
||||
|
||||
@ -655,3 +651,17 @@ export default {
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default decorateObject(methods, {
|
||||
_getXenUpdates: [
|
||||
debounceWithKey,
|
||||
24 * 60 * 60 * 1000,
|
||||
function () {
|
||||
return this
|
||||
},
|
||||
],
|
||||
|
||||
_poolWideInstall: deferrable,
|
||||
|
||||
rollingPoolUpdate: deferrable,
|
||||
})
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { decorateObject } from '@vates/decorate-with'
|
||||
import { cancelable } from 'promise-toolbox'
|
||||
|
||||
const PATH_DB_DUMP = '/pool/xmldbdump'
|
||||
|
||||
export default {
|
||||
@cancelable
|
||||
const methods = {
|
||||
exportPoolMetadata($cancelToken) {
|
||||
return this.getResource($cancelToken, PATH_DB_DUMP, {
|
||||
task: this.task_create('Export pool metadata'),
|
||||
@ -13,7 +13,6 @@ export default {
|
||||
// Restore the XAPI database from an XML backup
|
||||
//
|
||||
// See https://github.com/xapi-project/xen-api/blob/405b02e72f1ccc4f4b456fd52db30876faddcdd8/ocaml/xapi/pool_db_backup.ml#L170-L205
|
||||
@cancelable
|
||||
importPoolMetadata($cancelToken, stream, force = false) {
|
||||
return this.putResource($cancelToken, stream, PATH_DB_DUMP, {
|
||||
query: {
|
||||
@ -23,3 +22,8 @@ export default {
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
export default decorateObject(methods, {
|
||||
exportPoolMetadata: cancelable,
|
||||
importPoolMetadata: cancelable,
|
||||
})
|
||||
|
@ -1,10 +1,10 @@
|
||||
import filter from 'lodash/filter.js'
|
||||
import forEach from 'lodash/forEach.js'
|
||||
import groupBy from 'lodash/groupBy.js'
|
||||
import { decorateWith } from '@vates/decorate-with'
|
||||
import { decorateObject } from '@vates/decorate-with'
|
||||
import { defer } from 'golike-defer'
|
||||
|
||||
export default {
|
||||
const methods = {
|
||||
_connectAllSrPbds(sr) {
|
||||
return Promise.all(sr.$PBDs.map(pbd => this._plugPbd(pbd)))
|
||||
},
|
||||
@ -102,7 +102,6 @@ export default {
|
||||
},
|
||||
|
||||
// This function helps to reattach a forgotten NFS/iSCSI/HBA SR
|
||||
@decorateWith(defer)
|
||||
async reattachSr($defer, { uuid, nameLabel, nameDescription, type, deviceConfig }) {
|
||||
const srRef = await this.call('SR.introduce', uuid, nameLabel, nameDescription, type, 'user', true, {})
|
||||
$defer.onFailure(() => this.forgetSr(srRef))
|
||||
@ -125,3 +124,7 @@ export default {
|
||||
return sr.uuid
|
||||
},
|
||||
}
|
||||
|
||||
export default decorateObject(methods, {
|
||||
reattachSr: defer,
|
||||
})
|
||||
|
@ -7,7 +7,7 @@ import lte from 'lodash/lte.js'
|
||||
import mapToArray from 'lodash/map.js'
|
||||
import mapValues from 'lodash/mapValues.js'
|
||||
import noop from 'lodash/noop.js'
|
||||
import { decorateWith } from '@vates/decorate-with'
|
||||
import { decorateObject } from '@vates/decorate-with'
|
||||
import { defer as deferrable } from 'golike-defer'
|
||||
import { ignoreErrors, pCatch } from 'promise-toolbox'
|
||||
import { Ref } from 'xen-api'
|
||||
@ -23,9 +23,8 @@ const XEN_VIDEORAM_VALUES = [1, 2, 4, 8, 16]
|
||||
// handle MEMORY_CONSTRAINT_VIOLATION and derivatives like MEMORY_CONSTRAINT_VIOLATION_MAXPIN
|
||||
const isMemoryConstraintError = e => e.code.startsWith('MEMORY_CONSTRAINT_VIOLATION')
|
||||
|
||||
export default {
|
||||
const methods = {
|
||||
// TODO: clean up on error.
|
||||
@decorateWith(deferrable)
|
||||
async createVm(
|
||||
$defer,
|
||||
templateId,
|
||||
@ -468,3 +467,7 @@ export default {
|
||||
return this.callAsync(`VM.${hard ? 'hard' : 'clean'}_shutdown`, this.getObject(vmId).$ref).then(noop)
|
||||
},
|
||||
}
|
||||
|
||||
export default decorateObject(methods, {
|
||||
createVm: deferrable,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user