Camel case: Xo#getXAPI() → Xo#getXapi().

This commit is contained in:
Julien Fontanet 2016-01-13 14:39:40 +01:00
parent e0e7b1406d
commit a5364b9257
17 changed files with 110 additions and 106 deletions

View File

@ -3,7 +3,7 @@ import {parseSize} from '../utils'
// ===================================================================
export async function create ({name, size, sr}) {
const vdi = await this.getXAPI(sr).createVdi(parseSize(size), {
const vdi = await this.getXapi(sr).createVdi(parseSize(size), {
name_label: name,
sr: sr._xapiId
})
@ -25,7 +25,7 @@ create.resolve = {
// -------------------------------------------------------------------
export async function resize ({ vdi, size }) {
await this.getXAPI(vdi).resizeVdi(vdi._xapiId, parseSize(size))
await this.getXapi(vdi).resizeVdi(vdi._xapiId, parseSize(size))
}
resize.description = 'resize an existing VDI'

View File

@ -1,5 +1,5 @@
export async function register ({vm}) {
await this.getXAPI(vm).registerDockerContainer(vm._xapiId)
await this.getXapi(vm).registerDockerContainer(vm._xapiId)
}
register.permission = 'admin'
@ -16,7 +16,7 @@ register.resolve = {
// -----------------------------------------------------------------------------
export async function deregister ({vm}) {
await this.getXAPI(vm).unregisterDockerContainer(vm._xapiId)
await this.getXapi(vm).unregisterDockerContainer(vm._xapiId)
}
deregister.permission = 'admin'
@ -33,23 +33,23 @@ deregister.resolve = {
// -----------------------------------------------------------------------------
export async function start ({vm, container}) {
await this.getXAPI(vm).startDockerContainer(vm._xapiId, container)
await this.getXapi(vm).startDockerContainer(vm._xapiId, container)
}
export async function stop ({vm, container}) {
await this.getXAPI(vm).stopDockerContainer(vm._xapiId, container)
await this.getXapi(vm).stopDockerContainer(vm._xapiId, container)
}
export async function restart ({vm, container}) {
await this.getXAPI(vm).restartDockerContainer(vm._xapiId, container)
await this.getXapi(vm).restartDockerContainer(vm._xapiId, container)
}
export async function pause ({vm, container}) {
await this.getXAPI(vm).pauseDockerContainer(vm._xapiId, container)
await this.getXapi(vm).pauseDockerContainer(vm._xapiId, container)
}
export async function unpause ({vm, container}) {
await this.getXAPI(vm).unpauseDockerContainer(vm._xapiId, container)
await this.getXapi(vm).unpauseDockerContainer(vm._xapiId, container)
}
for (let fn of [start, stop, restart, pause, unpause]) {

View File

@ -21,7 +21,7 @@ set = ({
name_label: nameLabel,
name_description: nameDescription
}) ->
return @getXAPI(host).setHostProperties(host._xapiId, {
return @getXapi(host).setHostProperties(host._xapiId, {
nameLabel,
nameDescription
})
@ -48,7 +48,7 @@ exports.set = set
# FIXME: set force to false per default when correctly implemented in
# UI.
restart = ({host, force = true}) ->
return @getXAPI(host).rebootHost(host._xapiId, force)
return @getXapi(host).rebootHost(host._xapiId, force)
restart.description = 'restart the host'
@ -69,7 +69,7 @@ exports.restart = restart
#---------------------------------------------------------------------
restartAgent = ({host}) ->
return @getXAPI(host).restartHostAgent(host._xapiId)
return @getXapi(host).restartHostAgent(host._xapiId)
restartAgent.description = 'restart the Xen agent on the host'
@ -87,7 +87,7 @@ exports.restart_agent = restartAgent
#---------------------------------------------------------------------
start = ({host}) ->
return @getXAPI(host).powerOnHost(host._xapiId)
return @getXapi(host).powerOnHost(host._xapiId)
start.description = 'start the host'
@ -104,7 +104,7 @@ exports.start = start
#---------------------------------------------------------------------
stop = ({host}) ->
return @getXAPI(host).shutdownHost(host._xapiId)
return @getXapi(host).shutdownHost(host._xapiId)
stop.description = 'stop the host'
@ -121,7 +121,7 @@ exports.stop = stop
#---------------------------------------------------------------------
detach = ({host}) ->
return @getXAPI(host).ejectHostFromPool(host._xapiId)
return @getXapi(host).ejectHostFromPool(host._xapiId)
detach.description = 'eject the host of a pool'
@ -138,7 +138,7 @@ exports.detach = detach
#---------------------------------------------------------------------
enable = ({host}) ->
return @getXAPI(host).enableHost(host._xapiId)
return @getXapi(host).enableHost(host._xapiId)
enable.description = 'enable to create VM on the host'
@ -155,7 +155,7 @@ exports.enable = enable
#---------------------------------------------------------------------
disable = ({host}) ->
return @getXAPI(host).disableHost(host._xapiId)
return @getXapi(host).disableHost(host._xapiId)
disable.description = 'disable to create VM on the hsot'
@ -173,7 +173,7 @@ exports.disable = disable
# TODO: to test and to fix.
createNetwork = $coroutine ({host, name, description, pif, mtu, vlan}) ->
xapi = @getXAPI host
xapi = @getXapi host
description = description ? 'Created with Xen Orchestra'
@ -212,7 +212,7 @@ exports.createNetwork = createNetwork
# Throws an error if the host is not running the latest XS version
listMissingPatches = ({host}) ->
return @getXAPI(host).listMissingPoolPatchesOnHost(host._xapiId)
return @getXapi(host).listMissingPoolPatchesOnHost(host._xapiId)
listMissingPatches.params = {
host: { type: 'string' }
@ -229,7 +229,7 @@ listMissingPatches.description = 'return an array of missing new patches in the
#---------------------------------------------------------------------
installPatch = ({host, patch: patchUuid}) ->
return @getXAPI(host).installPoolPatchOnHost(patchUuid, host._xapiId)
return @getXapi(host).installPoolPatchOnHost(patchUuid, host._xapiId)
installPatch.description = 'install a patch on an host'
@ -247,7 +247,7 @@ exports.installPatch = installPatch
#---------------------------------------------------------------------
installAllPatches = ({host}) ->
return @getXAPI(host).installAllPoolPatchesOnHost(host._xapiId)
return @getXapi(host).installAllPoolPatchesOnHost(host._xapiId)
installAllPatches.description = 'install all the missing patches on a host'
@ -264,7 +264,7 @@ exports.installAllPatches = installAllPatches
#---------------------------------------------------------------------
emergencyShutdownHost = ({host}) ->
return @getXAPI(host).emergencyShutdownHost(host._xapiId)
return @getXapi(host).emergencyShutdownHost(host._xapiId)
emergencyShutdownHost.description = 'suspend all VMs and shutdown host'

View File

@ -1,5 +1,5 @@
async function delete_ ({ message }) {
await this.getXAPI(message).call('message.destroy', message._xapiRef)
await this.getXapi(message).call('message.destroy', message._xapiRef)
}
export {delete_ as delete}

View File

@ -5,7 +5,7 @@
async function delete_ ({PBD}) {
// TODO: check if PBD is attached before
await this.getXAPI(PBD).call('PBD.destroy', PBD._xapiRef)
await this.getXapi(PBD).call('PBD.destroy', PBD._xapiRef)
}
export {delete_ as delete}
@ -22,7 +22,7 @@ delete_.resolve = {
export async function disconnect ({PBD}) {
// TODO: check if PBD is attached before
await this.getXAPI(PBD).call('PBD.unplug', PBD._xapiRef)
await this.getXapi(PBD).call('PBD.unplug', PBD._xapiRef)
}
disconnect.params = {
@ -38,7 +38,7 @@ disconnect.resolve = {
export async function connect ({PBD}) {
// TODO: check if PBD is attached before
await this.getXAPI(PBD).call('PBD.plug', PBD._xapiRef)
await this.getXapi(PBD).call('PBD.plug', PBD._xapiRef)
}
connect.params = {

View File

@ -5,7 +5,7 @@
async function delete_ ({PIF}) {
// TODO: check if PIF is attached before
await this.getXAPI(PIF).call('PIF.destroy', PIF._xapiRef)
await this.getXapi(PIF).call('PIF.destroy', PIF._xapiRef)
}
export {delete_ as delete}
@ -22,7 +22,7 @@ delete_.resolve = {
export async function disconnect ({PIF}) {
// TODO: check if PIF is attached before
await this.getXAPI(PIF).call('PIF.unplug', PIF._xapiRef)
await this.getXapi(PIF).call('PIF.unplug', PIF._xapiRef)
}
disconnect.params = {
@ -37,7 +37,7 @@ disconnect.resolve = {
export async function connect ({PIF}) {
// TODO: check if PIF is attached before
await this.getXAPI(PIF).call('PIF.plug', PIF._xapiRef)
await this.getXapi(PIF).call('PIF.plug', PIF._xapiRef)
}
connect.params = {

View File

@ -9,7 +9,7 @@ export async function set ({
name_description: nameDescription,
name_label: nameLabel
}) {
await this.getXAPI(pool).setPoolProperties({
await this.getXapi(pool).setPoolProperties({
nameDescription,
nameLabel
})
@ -36,7 +36,7 @@ set.resolve = {
// -------------------------------------------------------------------
export async function setDefaultSr ({pool, sr}) {
await this.getXAPI(pool).setDefaultSr(sr._xapiId)
await this.getXapi(pool).setDefaultSr(sr._xapiId)
}
setDefaultSr.params = {
@ -55,7 +55,7 @@ setDefaultSr.resolve = {
// -------------------------------------------------------------------
export async function installPatch ({pool, patch: patchUuid}) {
await this.getXAPI(pool).installPoolPatchOnAllHosts(patchUuid)
await this.getXapi(pool).installPoolPatchOnAllHosts(patchUuid)
}
installPatch.params = {
@ -81,7 +81,7 @@ async function handlePatchUpload (req, res, {pool}) {
return
}
await this.getXAPI(pool).uploadPoolPatch(req, contentLength)
await this.getXapi(pool).uploadPoolPatch(req, contentLength)
}
export async function uploadPatch ({pool}) {

View File

@ -13,7 +13,7 @@ export async function set ({
name_description: nameDescription,
name_label: nameLabel
}) {
await this.getXAPI(sr).setSrProperties(sr._xapiId, {
await this.getXapi(sr).setSrProperties(sr._xapiId, {
nameDescription,
nameLabel
})
@ -34,7 +34,7 @@ set.resolve = {
// -------------------------------------------------------------------
export async function scan ({SR}) {
await this.getXAPI(SR).call('SR.scan', SR._xapiRef)
await this.getXapi(SR).call('SR.scan', SR._xapiRef)
}
scan.params = {
@ -49,7 +49,7 @@ scan.resolve = {
// TODO: find a way to call this "delete" and not destroy
export async function destroy ({SR}) {
await this.getXAPI(SR).call('SR.destroy', SR._xapiRef)
await this.getXapi(SR).call('SR.destroy', SR._xapiRef)
}
destroy.params = {
@ -63,7 +63,7 @@ destroy.resolve = {
// -------------------------------------------------------------------
export async function forget ({SR}) {
await this.getXAPI(SR).call('SR.forget', SR._xapiRef)
await this.getXapi(SR).call('SR.forget', SR._xapiRef)
}
forget.params = {
@ -82,7 +82,7 @@ export async function createIso ({
nameDescription,
path
}) {
const xapi = this.getXAPI(host)
const xapi = this.getXapi(host)
// FIXME: won't work for IPv6
// Detect if NFS or local path for ISO files
@ -132,7 +132,7 @@ export async function createNfs ({
serverPath,
nfsVersion
}) {
const xapi = this.getXAPI(host)
const xapi = this.getXapi(host)
const deviceConfig = {
server,
@ -185,7 +185,7 @@ export async function createLvm ({
nameDescription,
device
}) {
const xapi = this.getXAPI(host)
const xapi = this.getXapi(host)
const deviceConfig = {
device
@ -227,7 +227,7 @@ export async function probeNfs ({
host,
server
}) {
const xapi = this.getXAPI(host)
const xapi = this.getXapi(host)
const deviceConfig = {
server
@ -290,7 +290,7 @@ export async function createIscsi ({
chapUser,
chapPassword
}) {
const xapi = this.getXAPI(host)
const xapi = this.getXapi(host)
const deviceConfig = {
target,
@ -353,7 +353,7 @@ export async function probeIscsiIqns ({
chapUser,
chapPassword
}) {
const xapi = this.getXAPI(host)
const xapi = this.getXapi(host)
const deviceConfig = {
target: targetIp
@ -430,7 +430,7 @@ export async function probeIscsiLuns ({
chapUser,
chapPassword
}) {
const xapi = this.getXAPI(host)
const xapi = this.getXapi(host)
const deviceConfig = {
target: targetIp,
@ -508,7 +508,7 @@ export async function probeIscsiExists ({
chapUser,
chapPassword
}) {
const xapi = this.getXAPI(host)
const xapi = this.getXapi(host)
const deviceConfig = {
target: targetIp,
@ -561,7 +561,7 @@ export async function probeNfsExists ({
server,
serverPath
}) {
const xapi = this.getXAPI(host)
const xapi = this.getXapi(host)
const deviceConfig = {
server,
@ -600,7 +600,7 @@ export async function reattach ({
nameDescription,
type
}) {
const xapi = this.getXAPI(host)
const xapi = this.getXapi(host)
if (type === 'iscsi') {
type = 'lvmoiscsi' // the internal XAPI name
@ -643,7 +643,7 @@ export async function reattachIso ({
nameDescription,
type
}) {
const xapi = this.getXAPI(host)
const xapi = this.getXapi(host)
if (type === 'iscsi') {
type = 'lvmoiscsi' // the internal XAPI name

View File

@ -1,5 +1,5 @@
export async function add ({tag, object}) {
await this.getXAPI(object).addTag(object._xapiId, tag)
await this.getXapi(object).addTag(object._xapiId, tag)
}
add.description = 'add a new tag to an object'
@ -16,7 +16,7 @@ add.params = {
// -------------------------------------------------------------------
export async function remove ({tag, object}) {
await this.getXAPI(object).removeTag(object._xapiId, tag)
await this.getXapi(object).removeTag(object._xapiId, tag)
}
remove.description = 'remove an existing tag from an object'

View File

@ -1,5 +1,5 @@
export async function cancel ({task}) {
await this.getXAPI(task).call('task.cancel', task._xapiRef)
await this.getXapi(task).call('task.cancel', task._xapiRef)
}
cancel.params = {
@ -13,7 +13,7 @@ cancel.resolve = {
// -------------------------------------------------------------------
export async function destroy ({task}) {
await this.getXAPI(task).call('task.destroy', task._xapiRef)
await this.getXapi(task).call('task.destroy', task._xapiRef)
}
destroy.params = {

View File

@ -5,7 +5,7 @@
#=====================================================================
delete_ = $coroutine ({vbd}) ->
xapi = @getXAPI vbd
xapi = @getXapi vbd
# TODO: check if VBD is attached before
yield xapi.call 'VBD.destroy', vbd._xapiRef
@ -25,7 +25,7 @@ exports.delete = delete_
#---------------------------------------------------------------------
disconnect = $coroutine ({vbd}) ->
xapi = @getXAPI vbd
xapi = @getXapi vbd
yield xapi.disconnectVbd(vbd._xapiRef)
return
@ -42,7 +42,7 @@ exports.disconnect = disconnect
#---------------------------------------------------------------------
connect = $coroutine ({vbd}) ->
xapi = @getXAPI vbd
xapi = @getXapi vbd
yield xapi.connectVbd(vbd._xapiRef)
return
@ -60,7 +60,7 @@ exports.connect = connect
set = $coroutine (params) ->
{vbd} = params
xapi = @getXAPI vbd
xapi = @getXapi vbd
{ _xapiRef: ref } = vbd

View File

@ -11,7 +11,7 @@ $isArray = require 'lodash.isarray'
#=====================================================================
delete_ = $coroutine ({vdi}) ->
yield @getXAPI(vdi).deleteVdi(vdi._xapiId)
yield @getXapi(vdi).deleteVdi(vdi._xapiId)
return
@ -30,7 +30,7 @@ exports.delete = delete_
# FIXME: human readable strings should be handled.
set = $coroutine (params) ->
{vdi} = params
xapi = @getXAPI vdi
xapi = @getXapi vdi
{_xapiRef: ref} = vdi
@ -77,7 +77,7 @@ exports.set = set
#---------------------------------------------------------------------
migrate = $coroutine ({vdi, sr}) ->
xapi = @getXAPI vdi
xapi = @getXapi vdi
yield xapi.moveVdi(vdi._xapiRef, sr._xapiRef)

View File

@ -1,6 +1,6 @@
// TODO: move into vm and rename to removeInterface
async function delete_ ({vif}) {
await this.getXAPI(vif).deleteVif(vif._xapiId)
await this.getXapi(vif).deleteVif(vif._xapiId)
}
export {delete_ as delete}
@ -16,7 +16,7 @@ delete_.resolve = {
// TODO: move into vm and rename to disconnectInterface
export async function disconnect ({vif}) {
// TODO: check if VIF is attached before
await this.getXAPI(vif).call('VIF.unplug_force', vif._xapiRef)
await this.getXapi(vif).call('VIF.unplug_force', vif._xapiRef)
}
disconnect.params = {
@ -31,7 +31,7 @@ disconnect.resolve = {
// TODO: move into vm and rename to connectInterface
export async function connect ({vif}) {
// TODO: check if VIF is attached before
await this.getXAPI(vif).call('VIF.plug', vif._xapiRef)
await this.getXapi(vif).call('VIF.plug', vif._xapiRef)
}
connect.params = {

View File

@ -61,7 +61,7 @@ create = $coroutine ({
VIFs
existingDisks
}) ->
vm = yield @getXAPI(template).createVm(template._xapiId, {
vm = yield @getXapi(template).createVm(template._xapiId, {
installRepository: installation && installation.repository,
nameDescription: name_description,
nameLabel: name_label,
@ -141,7 +141,7 @@ exports.create = create
#---------------------------------------------------------------------
delete_ = ({vm, delete_disks: deleteDisks}) ->
return @getXAPI(vm).deleteVm(vm._xapiId, deleteDisks)
return @getXapi(vm).deleteVm(vm._xapiId, deleteDisks)
delete_.params = {
id: { type: 'string' }
@ -160,7 +160,7 @@ exports.delete = delete_
#---------------------------------------------------------------------
ejectCd = $coroutine ({vm}) ->
yield @getXAPI(vm).ejectCdFromVm(vm._xapiId)
yield @getXapi(vm).ejectCdFromVm(vm._xapiId)
return
ejectCd.params = {
@ -175,7 +175,7 @@ exports.ejectCd = ejectCd
#---------------------------------------------------------------------
insertCd = $coroutine ({vm, vdi, force}) ->
yield @getXAPI(vm).insertCdIntoVm(vdi._xapiId, vm._xapiId, {force})
yield @getXapi(vm).insertCdIntoVm(vdi._xapiId, vm._xapiId, {force})
return
insertCd.params = {
@ -193,7 +193,7 @@ exports.insertCd = insertCd
#---------------------------------------------------------------------
migrate = $coroutine ({vm, host}) ->
yield @getXAPI(vm).migrateVm(vm._xapiId, @getXAPI(host), host._xapiId)
yield @getXapi(vm).migrateVm(vm._xapiId, @getXapi(host), host._xapiId)
return
migrate.params = {
@ -220,7 +220,7 @@ migratePool = $coroutine ({
network
migrationNetwork
}) ->
yield @getXAPI(vm).migrateVm(vm._xapiId, @getXAPI(host), host._xapiId, {
yield @getXapi(vm).migrateVm(vm._xapiId, @getXapi(host), host._xapiId, {
migrationNetworkId: migrationNetwork?._xapiId
networkId: network?._xapiId,
srId: sr?._xapiId,
@ -261,7 +261,7 @@ exports.migrate_pool = migratePool
# FIXME: human readable strings should be handled.
set = $coroutine (params) ->
{VM} = params
xapi = @getXAPI VM
xapi = @getXapi VM
{_xapiRef: ref} = VM
@ -372,7 +372,7 @@ exports.set = set
#---------------------------------------------------------------------
restart = $coroutine ({vm, force}) ->
xapi = @getXAPI(vm)
xapi = @getXapi(vm)
if force
yield xapi.call 'VM.hard_reboot', vm._xapiRef
@ -397,7 +397,7 @@ exports.restart = restart
clone = $coroutine ({vm, name, full_copy}) ->
yield checkPermissionOnSrs.call(this, vm)
return @getXAPI(vm).cloneVm(vm._xapiRef, {
return @getXapi(vm).cloneVm(vm._xapiRef, {
nameLabel: name,
fast: not full_copy
}).then((vm) -> vm.$id)
@ -427,11 +427,11 @@ copy = $coroutine ({
if vm.power_state is 'Running'
yield checkPermissionOnSrs.call(this, vm)
return @getXAPI(vm).copyVm(vm._xapiId, sr._xapiId, {
return @getXapi(vm).copyVm(vm._xapiId, sr._xapiId, {
nameLabel
}).then((vm) -> vm.$id)
return @getXAPI(vm).remoteCopyVm(vm._xapiId, @getXAPI(sr), sr._xapiId, {
return @getXapi(vm).remoteCopyVm(vm._xapiId, @getXapi(sr), sr._xapiId, {
compress,
nameLabel
}).then((vm) -> vm.$id)
@ -460,7 +460,7 @@ exports.copy = copy
# TODO: rename convertToTemplate()
convert = $coroutine ({vm}) ->
yield @getXAPI(vm).call 'VM.set_is_a_template', vm._xapiRef, true
yield @getXapi(vm).call 'VM.set_is_a_template', vm._xapiRef, true
return true
@ -478,7 +478,7 @@ exports.convert = convert
snapshot = $coroutine ({vm, name}) ->
yield checkPermissionOnSrs.call(this, vm)
snapshot = yield @getXAPI(vm).snapshotVm(vm._xapiRef, name)
snapshot = yield @getXapi(vm).snapshotVm(vm._xapiRef, name)
return snapshot.$id
snapshot.params = {
@ -656,7 +656,7 @@ exports.rollingDrCopy = rollingDrCopy
#---------------------------------------------------------------------
start = ({vm}) ->
return @getXAPI(vm).startVm(vm._xapiId)
return @getXapi(vm).startVm(vm._xapiId)
start.params = {
id: { type: 'string' }
@ -675,7 +675,7 @@ exports.start = start
# - if force is true hard shutdown
# - if force is integer clean shutdown and after force seconds, hard shutdown.
stop = $coroutine ({vm, force}) ->
xapi = @getXAPI vm
xapi = @getXapi vm
# Hard shutdown
if force
@ -708,7 +708,7 @@ exports.stop = stop
#---------------------------------------------------------------------
suspend = $coroutine ({vm}) ->
yield @getXAPI(vm).call 'VM.suspend', vm._xapiRef
yield @getXapi(vm).call 'VM.suspend', vm._xapiRef
return true
@ -728,7 +728,7 @@ resume = $coroutine ({vm, force}) ->
if not force
force = true
yield @getXAPI(vm).call 'VM.resume', vm._xapiRef, false, force
yield @getXapi(vm).call 'VM.resume', vm._xapiRef, false, force
return true
@ -747,7 +747,7 @@ exports.resume = resume
# revert a snapshot to its parent VM
revert = $coroutine ({snapshot}) ->
# Attempts a revert from this snapshot to its parent VM
yield @getXAPI(snapshot).call 'VM.revert', snapshot._xapiRef
yield @getXapi(snapshot).call 'VM.revert', snapshot._xapiRef
return true
@ -788,7 +788,7 @@ export_ = $coroutine ({vm, compress, onlyMetadata}) ->
yield checkPermissionOnSrs.call(this, vm)
data = {
xapi: @getXAPI(vm),
xapi: @getXapi(vm),
id: vm._xapiId,
compress,
onlyMetadata
@ -839,12 +839,12 @@ import_ = $coroutine ({host, sr}) ->
if not host
throw new InvalidParameters('you must provide either host or SR')
xapi = @getXAPI(host)
xapi = @getXapi(host)
sr = xapi.pool.$default_SR
if not sr
throw new InvalidParameters('there is not default SR in this pool')
else
xapi = @getXAPI(sr)
xapi = @getXapi(sr)
return {
$sendTo: yield @registerHttpRequest(handleVmImport, {
@ -869,7 +869,7 @@ exports.import = import_
# FIXME: if position is used, all other disks after this position
# should be shifted.
attachDisk = $coroutine ({vm, vdi, position, mode, bootable}) ->
yield @getXAPI(vm).attachVdiToVm(vdi._xapiId, vm._xapiId, {
yield @getXapi(vm).attachVdiToVm(vdi._xapiId, vm._xapiId, {
bootable,
position,
readOnly: mode is 'RO'
@ -898,7 +898,7 @@ exports.attachDisk = attachDisk
# FIXME: position should be optional and default to last.
createInterface = $coroutine ({vm, network, position, mtu, mac}) ->
vif = yield @getXAPI(vm).createVif(vm._xapiId, network._xapiId, {
vif = yield @getXapi(vm).createVif(vm._xapiId, network._xapiId, {
mac,
mtu,
position
@ -923,7 +923,7 @@ exports.createInterface = createInterface
#---------------------------------------------------------------------
attachPci = $coroutine ({vm, pciId}) ->
xapi = @getXAPI vm
xapi = @getXapi vm
yield xapi.call 'VM.add_to_other_config', vm._xapiRef, 'pci', pciId
@ -943,7 +943,7 @@ exports.attachPci = attachPci
#---------------------------------------------------------------------
detachPci = $coroutine ({vm}) ->
xapi = @getXAPI vm
xapi = @getXapi vm
yield xapi.call 'VM.remove_from_other_config', vm._xapiRef, 'pci'
@ -983,7 +983,7 @@ exports.stats = stats;
#---------------------------------------------------------------------
setBootOrder = $coroutine ({vm, order}) ->
xapi = @getXAPI vm
xapi = @getXapi vm
order = {order: order}
if vm.virtualizationMode == 'hvm'
@ -1008,7 +1008,7 @@ exports.setBootOrder = setBootOrder
#---------------------------------------------------------------------
recoveryStart = ({vm}) ->
return @getXAPI(vm).startVmOnCd(vm._xapiId)
return @getXapi(vm).startVmOnCd(vm._xapiId)
recoveryStart.params = {
id: { type: 'string' }
@ -1022,7 +1022,7 @@ exports.recoveryStart = recoveryStart
#---------------------------------------------------------------------
getCloudInitConfig = $coroutine ({template}) ->
return yield @getXAPI(template).getCloudInitConfig(template._xapiId)
return yield @getXapi(template).getCloudInitConfig(template._xapiId)
getCloudInitConfig.params = {
template: { type: 'string' }
@ -1036,7 +1036,7 @@ exports.getCloudInitConfig = getCloudInitConfig
#---------------------------------------------------------------------
createCloudInitConfigDrive = $coroutine ({vm, sr, config, coreos}) ->
xapi = @getXAPI vm
xapi = @getXapi vm
# CoreOS is a special CloudConfig drive created by XS plugin
if coreos
yield xapi.createCoreOsCloudInitConfigDrive(vm._xapiId, sr._xapiId, config)

View File

@ -492,7 +492,7 @@ const setUpConsoleProxy = (webServer, xo) => {
})
}
const xapi = xo.getXAPI(id, ['VM', 'VM-controller'])
const xapi = xo.getXapi(id, ['VM', 'VM-controller'])
const vmConsole = xapi.getVmConsole(id)
// FIXME: lost connection due to VM restart is not detected.

View File

@ -93,7 +93,7 @@ export default class {
const [ stream, length ] = await this._openAndwaitReadableFile(
path, 'VM to import not found in this remote')
const xapi = this._xo.getXAPI(sr)
const xapi = this._xo.getXapi(sr)
await xapi.importVm(stream, length, { srId: sr._xapiId })
}
@ -133,7 +133,7 @@ export default class {
}
async _rollingDeltaVdiBackup ({vdi, path, depth}) {
const xapi = this._xo.getXAPI(vdi)
const xapi = this._xo.getXapi(vdi)
const backupDirectory = `vdi_${vdi.uuid}`
vdi = xapi.getObject(vdi._xapiId)
@ -226,7 +226,7 @@ export default class {
}
// Restore...
const xapi = this._xo.getXAPI(vdi)
const xapi = this._xo.getXapi(vdi)
for (; j <= i; j++) {
await this._importVdiBackupContent(xapi, `${path}/${backups[j]}`, vdi._xapiId)
@ -253,7 +253,7 @@ export default class {
}
const promises = []
const xapi = this._xo.getXAPI(vm)
const xapi = this._xo.getXapi(vm)
for (const vbdId of vm.$VBDs) {
const vbd = this._xo.getObject(vbdId)
@ -343,7 +343,7 @@ export default class {
async importDeltaVmBackup ({sr, remoteId, filePath}) {
const remote = await this._xo.getRemote(remoteId)
const fullBackupPath = `${remote.path}/${filePath}`
const xapi = this._xo.getXAPI(sr)
const xapi = this._xo.getXapi(sr)
// Import vm metadata.
const vm = await this._importVmMetadata(xapi, `${fullBackupPath}.xva`)
@ -399,7 +399,7 @@ export default class {
const targetStream = createWriteStream(pathToFile, { flags: 'wx' })
const promise = eventToPromise(targetStream, 'finish')
const sourceStream = await this._xo.getXAPI(vm).exportVm(vm._xapiId, {
const sourceStream = await this._xo.getXapi(vm).exportVm(vm._xapiId, {
compress,
onlyMetadata: onlyMetadata || false
})
@ -431,7 +431,7 @@ export default class {
}
async rollingSnapshotVm (vm, tag, depth) {
const xapi = this._xo.getXAPI(vm)
const xapi = this._xo.getXapi(vm)
vm = xapi.getObject(vm._xapiId)
const reg = new RegExp('^rollingSnapshot_[^_]+_' + escapeStringRegexp(tag) + '_')
@ -452,9 +452,9 @@ export default class {
tag = 'DR_' + tag
const reg = new RegExp('^' + escapeStringRegexp(`${vm.name_label}_${tag}_`) + '[0-9]{8}T[0-9]{6}Z$')
const targetXapi = this._xo.getXAPI(sr)
const targetXapi = this._xo.getXapi(sr)
sr = targetXapi.getObject(sr._xapiId)
const sourceXapi = this._xo.getXAPI(vm)
const sourceXapi = this._xo.getXapi(vm)
vm = sourceXapi.getObject(vm._xapiId)
const vms = []

View File

@ -849,8 +849,12 @@ export default class Xo extends EventEmitter {
return xapi.disconnect()
}
getXAPI () {
throw new Error(`Use <Xo#getXapi()> (camel case) instead.`)
}
// Returns the XAPI connection associated to an object.
getXAPI (object, type) {
getXapi (object, type) {
if (isString(object)) {
object = this.getObject(object, type)
}
@ -869,21 +873,21 @@ export default class Xo extends EventEmitter {
}
getXapiVmStats (vm, granularity) {
const xapi = this.getXAPI(vm)
const xapi = this.getXapi(vm)
return this._xapiStats.getVmPoints(xapi, vm._xapiId, granularity)
}
getXapiHostStats (host, granularity) {
const xapi = this.getXAPI(host)
const xapi = this.getXapi(host)
return this._xapiStats.getHostPoints(xapi, host._xapiId, granularity)
}
async mergeXenPools (sourceId, targetId, force = false) {
const sourceXapi = this.getXAPI(sourceId)
const sourceXapi = this.getXapi(sourceId)
const {
_auth: { user, password },
_url: { hostname }
} = this.getXAPI(targetId)
} = this.getXapi(targetId)
// We don't want the events of the source XAPI to interfere with
// the events of the new XAPI.