chore(xo-web): reformat some files

This commit is contained in:
Julien Fontanet 2018-11-28 17:40:56 +01:00
parent f06a937c9c
commit 2e327be49d
6 changed files with 213 additions and 200 deletions

View File

@ -13,11 +13,11 @@ import { forEach, map, mapFilter, parseSize } from '../utils'
// ===================================================================
export function getHaValues () {
export function getHaValues() {
return ['best-effort', 'restart', '']
}
function checkPermissionOnSrs (vm, permission = 'operate') {
function checkPermissionOnSrs(vm, permission = 'operate') {
const permissions = []
forEach(vm.$VBDs, vbdId => {
const vbd = this.getObject(vbdId, 'VBD')
@ -44,7 +44,7 @@ const extract = (obj, prop) => {
}
// TODO: Implement ACLs
export async function create (params) {
export async function create(params) {
const { user } = this
const resourceSet = extract(params, 'resourceSet')
const template = extract(params, 'template')
@ -325,7 +325,7 @@ create.resolve = {
// -------------------------------------------------------------------
async function delete_ ({
async function delete_({
delete_disks, // eslint-disable-line camelcase
force,
forceDeleteDefaultTemplate,
@ -403,7 +403,7 @@ export { delete_ as delete }
// -------------------------------------------------------------------
export async function ejectCd ({ vm }) {
export async function ejectCd({ vm }) {
await this.getXapi(vm).ejectCdFromVm(vm._xapiId)
}
@ -417,7 +417,7 @@ ejectCd.resolve = {
// -------------------------------------------------------------------
export async function insertCd ({ vm, vdi, force = true }) {
export async function insertCd({ vm, vdi, force = true }) {
await this.getXapi(vm).insertCdIntoVm(vdi._xapiId, vm._xapiId, { force })
}
@ -436,7 +436,7 @@ insertCd.resolve = {
// -------------------------------------------------------------------
export async function migrate ({
export async function migrate({
vm,
host,
sr,
@ -512,7 +512,7 @@ migrate.resolve = {
// -------------------------------------------------------------------
export async function set (params) {
export async function set(params) {
const VM = extract(params, 'VM')
const xapi = this.getXapi(VM)
const vmId = VM._xapiId
@ -620,7 +620,7 @@ set.resolve = {
// -------------------------------------------------------------------
export async function restart ({ vm, force = false }) {
export async function restart({ vm, force = false }) {
const xapi = this.getXapi(vm)
if (force) {
@ -641,7 +641,7 @@ restart.resolve = {
// -------------------------------------------------------------------
export const clone = defer(async function (
export const clone = defer(async function(
$defer,
{ vm, name, full_copy: fullCopy }
) {
@ -683,7 +683,7 @@ clone.resolve = {
// -------------------------------------------------------------------
// TODO: implement resource sets
export async function copy ({ compress, name: nameLabel, sr, vm }) {
export async function copy({ compress, name: nameLabel, sr, vm }) {
if (vm.$pool === sr.$pool) {
if (vm.power_state === 'Running') {
await checkPermissionOnSrs.call(this, vm)
@ -724,7 +724,7 @@ copy.resolve = {
// -------------------------------------------------------------------
export async function convertToTemplate ({ vm }) {
export async function convertToTemplate({ vm }) {
// Convert to a template requires pool admin permission.
await this.checkPermissions(this.user.id, [[vm.$pool, 'administrate']])
@ -745,7 +745,7 @@ export { convertToTemplate as convert }
// -------------------------------------------------------------------
// TODO: implement resource sets
export const snapshot = defer(async function (
export const snapshot = defer(async function(
$defer,
{ vm, name = `${vm.name_label}_${new Date().toISOString()}` }
) {
@ -773,7 +773,7 @@ snapshot.resolve = {
// -------------------------------------------------------------------
export function rollingDeltaBackup ({
export function rollingDeltaBackup({
vm,
remote,
tag,
@ -805,7 +805,7 @@ rollingDeltaBackup.permission = 'admin'
// -------------------------------------------------------------------
export function importDeltaBackup ({ sr, remote, filePath, mapVdisSrs }) {
export function importDeltaBackup({ sr, remote, filePath, mapVdisSrs }) {
const mapVdisSrsXapi = {}
forEach(mapVdisSrs, (srId, vdiId) => {
@ -836,7 +836,7 @@ importDeltaBackup.permission = 'admin'
// -------------------------------------------------------------------
export function deltaCopy ({ force, vm, retention, sr }) {
export function deltaCopy({ force, vm, retention, sr }) {
return this.deltaCopyVm(vm, sr, force, retention)
}
@ -854,7 +854,7 @@ deltaCopy.resolve = {
// -------------------------------------------------------------------
export async function rollingSnapshot ({ vm, tag, depth, retention = depth }) {
export async function rollingSnapshot({ vm, tag, depth, retention = depth }) {
await checkPermissionOnSrs.call(this, vm)
return this.rollingSnapshotVm(vm, tag, retention)
}
@ -876,7 +876,7 @@ rollingSnapshot.description =
// -------------------------------------------------------------------
export function backup ({ vm, remoteId, file, compress }) {
export function backup({ vm, remoteId, file, compress }) {
return this.backupVm({ vm, remoteId, file, compress })
}
@ -897,7 +897,7 @@ backup.description = 'Exports a VM to the file system'
// -------------------------------------------------------------------
export function importBackup ({ remote, file, sr }) {
export function importBackup({ remote, file, sr }) {
return this.importVmBackup(remote, file, sr)
}
@ -918,7 +918,7 @@ importBackup.permission = 'admin'
// -------------------------------------------------------------------
export function rollingBackup ({
export function rollingBackup({
vm,
remoteId,
tag,
@ -956,7 +956,7 @@ rollingBackup.description =
// -------------------------------------------------------------------
export function rollingDrCopy ({
export function rollingDrCopy({
vm,
pool,
sr,
@ -1010,7 +1010,7 @@ rollingDrCopy.description =
// -------------------------------------------------------------------
export function start ({ vm, force, host }) {
export function start({ vm, force, host }) {
return this.getXapi(vm).startVm(vm._xapiId, host?._xapiId, force)
}
@ -1031,7 +1031,7 @@ start.resolve = {
// - if !force → clean shutdown
// - if force is true → hard shutdown
// - if force is integer → clean shutdown and after force seconds, hard shutdown.
export async function stop ({ vm, force }) {
export async function stop({ vm, force }) {
const xapi = this.getXapi(vm)
// Hard shutdown
@ -1066,7 +1066,7 @@ stop.resolve = {
// -------------------------------------------------------------------
export async function suspend ({ vm }) {
export async function suspend({ vm }) {
await this.getXapi(vm).call('VM.suspend', vm._xapiRef)
}
@ -1080,7 +1080,7 @@ suspend.resolve = {
// -------------------------------------------------------------------
export function resume ({ vm }) {
export function resume({ vm }) {
return this.getXapi(vm).resumeVm(vm._xapiId)
}
@ -1094,7 +1094,7 @@ resume.resolve = {
// -------------------------------------------------------------------
export function revert ({ snapshot, snapshotBefore }) {
export function revert({ snapshot, snapshotBefore }) {
return this.getXapi(snapshot).revertVm(snapshot._xapiId, snapshotBefore)
}
@ -1109,7 +1109,7 @@ revert.resolve = {
// -------------------------------------------------------------------
async function handleExport (req, res, { xapi, id, compress }) {
async function handleExport(req, res, { xapi, id, compress }) {
const stream = await xapi.exportVm(id, {
compress: compress != null ? compress : true,
})
@ -1126,7 +1126,7 @@ async function handleExport (req, res, { xapi, id, compress }) {
}
// TODO: integrate in xapi.js
async function export_ ({ vm, compress }) {
async function export_({ vm, compress }) {
if (vm.power_state === 'Running') {
await checkPermissionOnSrs.call(this, vm)
}
@ -1157,7 +1157,7 @@ export { export_ as export }
// -------------------------------------------------------------------
async function handleVmImport (req, res, { data, srId, type, xapi }) {
async function handleVmImport(req, res, { data, srId, type, xapi }) {
// Timeout seems to be broken in Node 4.
// See https://github.com/nodejs/node/issues/3319
req.setTimeout(43200000) // 12 hours
@ -1172,7 +1172,7 @@ async function handleVmImport (req, res, { data, srId, type, xapi }) {
}
// TODO: "sr_id" can be passed in URL to target a specific SR
async function import_ ({ data, sr, type }) {
async function import_({ data, sr, type }) {
if (data && type === 'xva') {
throw invalidParameters('unsupported field data for the file type xva')
}
@ -1231,7 +1231,7 @@ export { import_ as import }
// FIXME: if position is used, all other disks after this position
// should be shifted.
export async function attachDisk ({ vm, vdi, position, mode, bootable }) {
export async function attachDisk({ vm, vdi, position, mode, bootable }) {
await this.getXapi(vm).createVbd({
bootable,
mode,
@ -1260,7 +1260,7 @@ attachDisk.resolve = {
// -------------------------------------------------------------------
// TODO: implement resource sets
export async function createInterface ({
export async function createInterface({
vm,
network,
position,
@ -1329,7 +1329,7 @@ createInterface.resolve = {
// -------------------------------------------------------------------
export async function attachPci ({ vm, pciId }) {
export async function attachPci({ vm, pciId }) {
const xapi = this.getXapi(vm)
await xapi.call('VM.add_to_other_config', vm._xapiRef, 'pci', pciId)
@ -1346,7 +1346,7 @@ attachPci.resolve = {
// -------------------------------------------------------------------
export async function detachPci ({ vm }) {
export async function detachPci({ vm }) {
const xapi = this.getXapi(vm)
await xapi.call('VM.remove_from_other_config', vm._xapiRef, 'pci')
@ -1361,7 +1361,7 @@ detachPci.resolve = {
}
// -------------------------------------------------------------------
export function stats ({ vm, granularity }) {
export function stats({ vm, granularity }) {
return this.getXapiVmStats(vm._xapiId, granularity)
}
@ -1381,7 +1381,7 @@ stats.resolve = {
// -------------------------------------------------------------------
export async function setBootOrder ({ vm, order }) {
export async function setBootOrder({ vm, order }) {
const xapi = this.getXapi(vm)
order = { order }
@ -1404,7 +1404,7 @@ setBootOrder.resolve = {
// -------------------------------------------------------------------
export function recoveryStart ({ vm }) {
export function recoveryStart({ vm }) {
return this.getXapi(vm).startVmOnCd(vm._xapiId)
}
@ -1418,7 +1418,7 @@ recoveryStart.resolve = {
// -------------------------------------------------------------------
export function getCloudInitConfig ({ template }) {
export function getCloudInitConfig({ template }) {
return this.getXapi(template).getCloudInitConfig(template._xapiId)
}
@ -1432,7 +1432,7 @@ getCloudInitConfig.resolve = {
// -------------------------------------------------------------------
export async function createCloudInitConfigDrive ({ vm, sr, config, coreos }) {
export async function createCloudInitConfigDrive({ vm, sr, config, coreos }) {
const xapi = this.getXapi(vm)
if (coreos) {
// CoreOS is a special CloudConfig drive created by XS plugin
@ -1459,7 +1459,7 @@ createCloudInitConfigDrive.resolve = {
// -------------------------------------------------------------------
export async function createVgpu ({ vm, gpuGroup, vgpuType }) {
export async function createVgpu({ vm, gpuGroup, vgpuType }) {
// TODO: properly handle device. Can a VM have 2 vGPUS?
await this.getXapi(vm).createVgpu(
vm._xapiId,
@ -1482,7 +1482,7 @@ createVgpu.resolve = {
// -------------------------------------------------------------------
export async function deleteVgpu ({ vgpu }) {
export async function deleteVgpu({ vgpu }) {
await this.getXapi(vgpu).deleteVgpu(vgpu._xapiId)
}

View File

@ -93,7 +93,7 @@ export const IPV6_CONFIG_MODES = ['None', 'DHCP', 'Static', 'Autoconf']
@mixin(mapToArray(mixins))
export default class Xapi extends XapiBase {
constructor (...args) {
constructor(...args) {
super(...args)
// Patch getObject to resolve _xapiId property.
@ -132,7 +132,7 @@ export default class Xapi extends XapiBase {
this.objects.on('update', onAddOrUpdate)
}
call (...args) {
call(...args) {
const fn = super.call
const loop = () =>
@ -146,13 +146,13 @@ export default class Xapi extends XapiBase {
return loop()
}
createTask (name = 'untitled task', description) {
createTask(name = 'untitled task', description) {
return super.createTask(`[XO] ${name}`, description)
}
// =================================================================
_registerGenericWatcher (fn) {
_registerGenericWatcher(fn) {
const watchers = this._genericWatchers
const id = String(Math.random())
@ -169,7 +169,7 @@ export default class Xapi extends XapiBase {
// function.
//
// TODO: implements a timeout.
_waitObject (predicate) {
_waitObject(predicate) {
if (isFunction(predicate)) {
const { promise, resolve } = defer()
@ -201,7 +201,7 @@ export default class Xapi extends XapiBase {
// Wait for an object to be in a given state.
//
// Faster than _waitObject() with a function.
_waitObjectState (idOrUuidOrRef, predicate) {
_waitObjectState(idOrUuidOrRef, predicate) {
const object = this.getObject(idOrUuidOrRef, null)
if (object && predicate(object)) {
return object
@ -216,7 +216,7 @@ export default class Xapi extends XapiBase {
}
// Returns the objects if already presents or waits for it.
async _getOrWaitObject (idOrUuidOrRef) {
async _getOrWaitObject(idOrUuidOrRef) {
return (
this.getObject(idOrUuidOrRef, null) || this._waitObject(idOrUuidOrRef)
)
@ -224,7 +224,7 @@ export default class Xapi extends XapiBase {
// =================================================================
_setObjectProperty (object, name, value) {
_setObjectProperty(object, name, value) {
return this.call(
`${getNamespaceForType(object.$type)}.set_${camelToSnakeCase(name)}`,
object.$ref,
@ -232,7 +232,7 @@ export default class Xapi extends XapiBase {
)
}
_setObjectProperties (object, props) {
_setObjectProperties(object, props) {
const { $ref: ref, $type: type } = object
const namespace = getNamespaceForType(type)
@ -252,7 +252,7 @@ export default class Xapi extends XapiBase {
)::ignoreErrors()
}
async _updateObjectMapProperty (object, prop, values) {
async _updateObjectMapProperty(object, prop, values) {
const { $ref: ref, $type: type } = object
prop = camelToSnakeCase(prop)
@ -277,14 +277,14 @@ export default class Xapi extends XapiBase {
)
}
async setHostProperties (id, { nameLabel, nameDescription }) {
async setHostProperties(id, { nameLabel, nameDescription }) {
await this._setObjectProperties(this.getObject(id), {
nameLabel,
nameDescription,
})
}
async setPoolProperties ({ autoPoweron, nameLabel, nameDescription }) {
async setPoolProperties({ autoPoweron, nameLabel, nameDescription }) {
const { pool } = this
await Promise.all([
@ -299,14 +299,14 @@ export default class Xapi extends XapiBase {
])
}
async setSrProperties (id, { nameLabel, nameDescription }) {
async setSrProperties(id, { nameLabel, nameDescription }) {
await this._setObjectProperties(this.getObject(id), {
nameLabel,
nameDescription,
})
}
async setNetworkProperties (
async setNetworkProperties(
id,
{ nameLabel, nameDescription, defaultIsLocked }
) {
@ -323,14 +323,14 @@ export default class Xapi extends XapiBase {
// =================================================================
async addTag (id, tag) {
async addTag(id, tag) {
const { $ref: ref, $type: type } = this.getObject(id)
const namespace = getNamespaceForType(type)
await this.call(`${namespace}.add_tags`, ref, tag)
}
async removeTag (id, tag) {
async removeTag(id, tag) {
const { $ref: ref, $type: type } = this.getObject(id)
const namespace = getNamespaceForType(type)
@ -339,7 +339,7 @@ export default class Xapi extends XapiBase {
// =================================================================
async setDefaultSr (srId) {
async setDefaultSr(srId) {
this._setObjectProperties(this.pool, {
default_SR: this.getObject(srId).$ref,
})
@ -347,13 +347,13 @@ export default class Xapi extends XapiBase {
// =================================================================
async setPoolMaster (hostId) {
async setPoolMaster(hostId) {
await this.call('pool.designate_new_master', this.getObject(hostId).$ref)
}
// =================================================================
async joinPool (masterAddress, masterUsername, masterPassword, force = false) {
async joinPool(masterAddress, masterUsername, masterPassword, force = false) {
await this.call(
force ? 'pool.join_force' : 'pool.join',
masterAddress,
@ -364,7 +364,7 @@ export default class Xapi extends XapiBase {
// =================================================================
async emergencyShutdownHost (hostId) {
async emergencyShutdownHost(hostId) {
const host = this.getObject(hostId)
const vms = host.$resident_VMs
log.debug(`Emergency shutdown: ${host.name_label}`)
@ -385,7 +385,7 @@ export default class Xapi extends XapiBase {
//
// If `force` is false and the evacuation failed, the host is re-
// enabled and the error is thrown.
async _clearHost ({ $ref: ref }, force) {
async _clearHost({ $ref: ref }, force) {
await this.call('host.disable', ref)
try {
@ -399,38 +399,38 @@ export default class Xapi extends XapiBase {
}
}
async disableHost (hostId) {
async disableHost(hostId) {
await this.call('host.disable', this.getObject(hostId).$ref)
}
async forgetHost (hostId) {
async forgetHost(hostId) {
await this.call('host.destroy', this.getObject(hostId).$ref)
}
async ejectHostFromPool (hostId) {
async ejectHostFromPool(hostId) {
await this.call('pool.eject', this.getObject(hostId).$ref)
}
async enableHost (hostId) {
async enableHost(hostId) {
await this.call('host.enable', this.getObject(hostId).$ref)
}
async powerOnHost (hostId) {
async powerOnHost(hostId) {
await this.call('host.power_on', this.getObject(hostId).$ref)
}
async rebootHost (hostId, force = false) {
async rebootHost(hostId, force = false) {
const host = this.getObject(hostId)
await this._clearHost(host, force)
await this.call('host.reboot', host.$ref)
}
async restartHostAgent (hostId) {
async restartHostAgent(hostId) {
await this.call('host.restart_agent', this.getObject(hostId).$ref)
}
async setRemoteSyslogHost (hostId, syslogDestination) {
async setRemoteSyslogHost(hostId, syslogDestination) {
const host = this.getObject(hostId)
await this.call('host.set_logging', host.$ref, {
syslog_destination: syslogDestination,
@ -438,7 +438,7 @@ export default class Xapi extends XapiBase {
await this.call('host.syslog_reconfigure', host.$ref)
}
async shutdownHost (hostId, force = false) {
async shutdownHost(hostId, force = false) {
const host = this.getObject(hostId)
await this._clearHost(host, force)
@ -449,7 +449,7 @@ export default class Xapi extends XapiBase {
// Clone a VM: make a fast copy by fast copying each of its VDIs
// (using snapshots where possible) on the same SRs.
_cloneVm (vm, nameLabel = vm.name_label) {
_cloneVm(vm, nameLabel = vm.name_label) {
log.debug(
`Cloning VM ${vm.name_label}${
nameLabel !== vm.name_label ? ` as ${nameLabel}` : ''
@ -463,7 +463,7 @@ export default class Xapi extends XapiBase {
//
// If a SR is specified, it will contains the copies of the VDIs,
// otherwise they will use the SRs they are on.
async _copyVm (vm, nameLabel = vm.name_label, sr = undefined) {
async _copyVm(vm, nameLabel = vm.name_label, sr = undefined) {
let snapshot
if (isVmRunning(vm)) {
snapshot = await this._snapshotVm(vm)
@ -489,7 +489,7 @@ export default class Xapi extends XapiBase {
}
}
async cloneVm (vmId, { nameLabel = undefined, fast = true } = {}) {
async cloneVm(vmId, { nameLabel = undefined, fast = true } = {}) {
const vm = this.getObject(vmId)
const cloneRef = await (fast
@ -499,13 +499,13 @@ export default class Xapi extends XapiBase {
return /* await */ this._getOrWaitObject(cloneRef)
}
async copyVm (vmId, srId, { nameLabel = undefined } = {}) {
async copyVm(vmId, srId, { nameLabel = undefined } = {}) {
return /* await */ this._getOrWaitObject(
await this._copyVm(this.getObject(vmId), nameLabel, this.getObject(srId))
)
}
async remoteCopyVm (
async remoteCopyVm(
vmId,
targetXapi,
targetSrId,
@ -545,7 +545,7 @@ export default class Xapi extends XapiBase {
}
// Low level create VM.
_createVmRecord ({
_createVmRecord({
actions_after_crash,
actions_after_reboot,
actions_after_shutdown,
@ -645,7 +645,7 @@ export default class Xapi extends XapiBase {
)
}
async _deleteVm (
async _deleteVm(
vm,
deleteDisks = true,
force = false,
@ -730,7 +730,7 @@ export default class Xapi extends XapiBase {
])
}
async deleteVm (vmId, deleteDisks, force, forceDeleteDefaultTemplate) {
async deleteVm(vmId, deleteDisks, force, forceDeleteDefaultTemplate) {
return /* await */ this._deleteVm(
this.getObject(vmId),
deleteDisks,
@ -739,7 +739,7 @@ export default class Xapi extends XapiBase {
)
}
getVmConsole (vmId) {
getVmConsole(vmId) {
const vm = this.getObject(vmId)
const console = find(vm.$consoles, { protocol: 'rfb' })
@ -753,7 +753,7 @@ export default class Xapi extends XapiBase {
// Returns a stream to the exported VM.
@concurrency(2, stream => stream.then(stream => fromEvent(stream, 'end')))
@cancelable
async exportVm ($cancelToken, vmId, { compress = true } = {}) {
async exportVm($cancelToken, vmId, { compress = true } = {}) {
const vm = this.getObject(vmId)
const useSnapshot = isVmRunning(vm)
const exportedVm = useSnapshot
@ -782,7 +782,7 @@ export default class Xapi extends XapiBase {
return promise
}
_assertHealthyVdiChain (vdi, cache) {
_assertHealthyVdiChain(vdi, cache) {
if (vdi == null) {
return
}
@ -814,7 +814,7 @@ export default class Xapi extends XapiBase {
)
}
_assertHealthyVdiChains (vm) {
_assertHealthyVdiChains(vm) {
const cache = { __proto__: null }
forEach(vm.$VBDs, ({ $VDI }) => {
this._assertHealthyVdiChain($VDI, cache)
@ -825,7 +825,7 @@ export default class Xapi extends XapiBase {
// object.
@cancelable
@deferrable
async exportDeltaVm (
async exportDeltaVm(
$defer,
$cancelToken,
vmId: string,
@ -956,7 +956,7 @@ export default class Xapi extends XapiBase {
}
@deferrable
async importDeltaVm (
async importDeltaVm(
$defer,
delta: DeltaVmExport,
{
@ -1155,7 +1155,7 @@ export default class Xapi extends XapiBase {
return { transferSize, vm }
}
async _migrateVmWithStorageMotion (
async _migrateVmWithStorageMotion(
vm,
hostXapi,
host,
@ -1221,7 +1221,7 @@ export default class Xapi extends XapiBase {
}
@synchronized
_callInstallationPlugin (hostRef, vdi) {
_callInstallationPlugin(hostRef, vdi) {
return this.call(
'host.call_plugin',
hostRef,
@ -1237,7 +1237,7 @@ export default class Xapi extends XapiBase {
}
@deferrable
async installSupplementalPack ($defer, stream, { hostId }) {
async installSupplementalPack($defer, stream, { hostId }) {
if (!stream.length) {
throw new Error('stream must have a length')
}
@ -1254,7 +1254,7 @@ export default class Xapi extends XapiBase {
}
@deferrable
async installSupplementalPackOnAllHosts ($defer, stream) {
async installSupplementalPackOnAllHosts($defer, stream) {
if (!stream.length) {
throw new Error('stream must have a length')
}
@ -1316,7 +1316,7 @@ export default class Xapi extends XapiBase {
}
@cancelable
async _importVm ($cancelToken, stream, sr, onVmCreation = undefined) {
async _importVm($cancelToken, stream, sr, onVmCreation = undefined) {
const taskRef = await this.createTask('VM import')
const query = {}
@ -1350,7 +1350,7 @@ export default class Xapi extends XapiBase {
}
@deferrable
async _importOvaVm (
async _importOvaVm(
$defer,
stream,
{ descriptionLabel, disks, memory, nameLabel, networks, nCpus, tables },
@ -1446,7 +1446,7 @@ export default class Xapi extends XapiBase {
}
// TODO: an XVA can contain multiple VMs
async importVm (stream, { data, srId, type = 'xva' } = {}) {
async importVm(stream, { data, srId, type = 'xva' } = {}) {
const sr = srId && this.getObject(srId)
if (type === 'xva') {
@ -1460,7 +1460,7 @@ export default class Xapi extends XapiBase {
throw new Error(`unsupported type: '${type}'`)
}
async migrateVm (
async migrateVm(
vmId,
hostXapi,
hostId,
@ -1503,7 +1503,7 @@ export default class Xapi extends XapiBase {
@concurrency(2)
@cancelable
async _snapshotVm ($cancelToken, vm, nameLabel = vm.name_label) {
async _snapshotVm($cancelToken, vm, nameLabel = vm.name_label) {
log.debug(
`Snapshotting VM ${vm.name_label}${
nameLabel !== vm.name_label ? ` as ${nameLabel}` : ''
@ -1555,17 +1555,17 @@ export default class Xapi extends XapiBase {
return snapshot
}
async snapshotVm (vmId, nameLabel = undefined) {
async snapshotVm(vmId, nameLabel = undefined) {
return /* await */ this._snapshotVm(this.getObject(vmId), nameLabel)
}
async setVcpuWeight (vmId, weight) {
async setVcpuWeight(vmId, weight) {
weight = weight || null // Take all falsy values as a removal (0 included)
const vm = this.getObject(vmId)
await this._updateObjectMapProperty(vm, 'VCPUs_params', { weight })
}
async _startVm (vm, host, force) {
async _startVm(vm, host, force) {
log.debug(`Starting VM ${vm.name_label}`)
if (force) {
@ -1584,7 +1584,7 @@ export default class Xapi extends XapiBase {
: this.call('VM.start_on', vm.$ref, host.$ref, false, false)
}
async startVm (vmId, hostId, force) {
async startVm(vmId, hostId, force) {
try {
await this._startVm(
this.getObject(vmId),
@ -1602,7 +1602,7 @@ export default class Xapi extends XapiBase {
}
}
async startVmOnCd (vmId) {
async startVmOnCd(vmId) {
const vm = this.getObject(vmId)
if (isVmHvm(vm)) {
@ -1675,7 +1675,7 @@ export default class Xapi extends XapiBase {
}
// vm_operations: http://xapi-project.github.io/xen-api/classes/vm.html
async addForbiddenOperationToVm (vmId, operation, reason) {
async addForbiddenOperationToVm(vmId, operation, reason) {
await this.call(
'VM.add_to_blocked_operations',
this.getObject(vmId).$ref,
@ -1684,7 +1684,7 @@ export default class Xapi extends XapiBase {
)
}
async removeForbiddenOperationFromVm (vmId, operation) {
async removeForbiddenOperationFromVm(vmId, operation) {
await this.call(
'VM.remove_from_blocked_operations',
this.getObject(vmId).$ref,
@ -1694,7 +1694,7 @@ export default class Xapi extends XapiBase {
// =================================================================
async createVbd ({
async createVbd({
bootable = false,
other_config = {},
qos_algorithm_params = {},
@ -1756,13 +1756,13 @@ export default class Xapi extends XapiBase {
}
}
_cloneVdi (vdi) {
_cloneVdi(vdi) {
log.debug(`Cloning VDI ${vdi.name_label}`)
return this.call('VDI.clone', vdi.$ref)
}
async createVdi ({
async createVdi({
name_description,
name_label,
other_config = {},
@ -1798,7 +1798,7 @@ export default class Xapi extends XapiBase {
)
}
async moveVdi (vdiId, srId) {
async moveVdi(vdiId, srId) {
const vdi = this.getObject(vdiId)
const sr = this.getObject(srId)
@ -1838,13 +1838,13 @@ export default class Xapi extends XapiBase {
}
// TODO: check whether the VDI is attached.
async _deleteVdi (vdi) {
async _deleteVdi(vdi) {
log.debug(`Deleting VDI ${vdi.name_label}`)
await this.call('VDI.destroy', vdi.$ref)
}
_resizeVdi (vdi, size) {
_resizeVdi(vdi, size) {
log.debug(
`Resizing VDI ${vdi.name_label} from ${vdi.virtual_size} to ${size}`
)
@ -1852,7 +1852,7 @@ export default class Xapi extends XapiBase {
return this.call('VDI.resize', vdi.$ref, size)
}
_getVmCdDrive (vm) {
_getVmCdDrive(vm) {
for (const vbd of vm.$VBDs) {
if (vbd.type === 'CD') {
return vbd
@ -1860,14 +1860,14 @@ export default class Xapi extends XapiBase {
}
}
async _ejectCdFromVm (vm) {
async _ejectCdFromVm(vm) {
const cdDrive = this._getVmCdDrive(vm)
if (cdDrive) {
await this.call('VBD.eject', cdDrive.$ref)
}
}
async _insertCdIntoVm (cd, vm, { bootable = false, force = false } = {}) {
async _insertCdIntoVm(cd, vm, { bootable = false, force = false } = {}) {
const cdDrive = await this._getVmCdDrive(vm)
if (cdDrive) {
try {
@ -1896,11 +1896,11 @@ export default class Xapi extends XapiBase {
}
}
async connectVbd (vbdId) {
async connectVbd(vbdId) {
await this.call('VBD.plug', vbdId)
}
async _disconnectVbd (vbd) {
async _disconnectVbd(vbd) {
// TODO: check if VBD is attached before
try {
await this.call('VBD.unplug_force', vbd.$ref)
@ -1912,21 +1912,21 @@ export default class Xapi extends XapiBase {
}
}
async disconnectVbd (vbdId) {
async disconnectVbd(vbdId) {
await this._disconnectVbd(this.getObject(vbdId))
}
async _deleteVbd (vbd) {
async _deleteVbd(vbd) {
await this._disconnectVbd(vbd)::ignoreErrors()
await this.call('VBD.destroy', vbd.$ref)
}
deleteVbd (vbdId) {
deleteVbd(vbdId) {
return this._deleteVbd(this.getObject(vbdId))
}
// TODO: remove when no longer used.
async destroyVbdsFromVm (vmId) {
async destroyVbdsFromVm(vmId) {
await Promise.all(
mapToArray(this.getObject(vmId).$VBDs, async vbd => {
await this.disconnectVbd(vbd.$ref)::ignoreErrors()
@ -1935,25 +1935,25 @@ export default class Xapi extends XapiBase {
)
}
async deleteVdi (vdiId) {
async deleteVdi(vdiId) {
await this._deleteVdi(this.getObject(vdiId))
}
async resizeVdi (vdiId, size) {
async resizeVdi(vdiId, size) {
await this._resizeVdi(this.getObject(vdiId), size)
}
async ejectCdFromVm (vmId) {
async ejectCdFromVm(vmId) {
await this._ejectCdFromVm(this.getObject(vmId))
}
async insertCdIntoVm (cdId, vmId, opts = undefined) {
async insertCdIntoVm(cdId, vmId, opts = undefined) {
await this._insertCdIntoVm(this.getObject(cdId), this.getObject(vmId), opts)
}
// -----------------------------------------------------------------
async snapshotVdi (vdiId, nameLabel) {
async snapshotVdi(vdiId, nameLabel) {
const vdi = this.getObject(vdiId)
const snap = await this._getOrWaitObject(
@ -1969,7 +1969,7 @@ export default class Xapi extends XapiBase {
@concurrency(12, stream => stream.then(stream => fromEvent(stream, 'end')))
@cancelable
_exportVdi ($cancelToken, vdi, base, format = VDI_FORMAT_VHD) {
_exportVdi($cancelToken, vdi, base, format = VDI_FORMAT_VHD) {
const query = {
format,
vdi: vdi.$ref,
@ -1998,13 +1998,13 @@ export default class Xapi extends XapiBase {
}
@cancelable
exportVdiContent ($cancelToken, vdi, { format } = {}) {
exportVdiContent($cancelToken, vdi, { format } = {}) {
return this._exportVdi($cancelToken, this.getObject(vdi), undefined, format)
}
// -----------------------------------------------------------------
async _importVdiContent (vdi, body, format = VDI_FORMAT_VHD) {
async _importVdiContent(vdi, body, format = VDI_FORMAT_VHD) {
if (__DEV__ && body.length == null) {
throw new Error(
'Trying to import a VDI without a length field. Please report this error to Xen Orchestra.'
@ -2030,13 +2030,13 @@ export default class Xapi extends XapiBase {
})
}
importVdiContent (vdiId, body, { format } = {}) {
importVdiContent(vdiId, body, { format } = {}) {
return this._importVdiContent(this.getObject(vdiId), body, format)
}
// =================================================================
async _createVif (
async _createVif(
vm,
network,
{
@ -2086,7 +2086,7 @@ export default class Xapi extends XapiBase {
return vifRef
}
async createVif (vmId, networkId, opts = undefined) {
async createVif(vmId, networkId, opts = undefined) {
return /* await */ this._getOrWaitObject(
await this._createVif(
this.getObject(vmId),
@ -2096,7 +2096,7 @@ export default class Xapi extends XapiBase {
)
}
@deferrable
async createNetwork (
async createNetwork(
$defer,
{ name, description = 'Created with Xen Orchestra', pifId, mtu, vlan }
) {
@ -2121,7 +2121,7 @@ export default class Xapi extends XapiBase {
return this._getOrWaitObject(networkRef)
}
async editPif (pifId, { vlan }) {
async editPif(pifId, { vlan }) {
const pif = this.getObject(pifId)
const physPif = find(
this.objects.all,
@ -2168,7 +2168,7 @@ export default class Xapi extends XapiBase {
}
@deferrable
async createBondedNetwork ($defer, { bondMode, mac = '', pifIds, ...params }) {
async createBondedNetwork($defer, { bondMode, mac = '', pifIds, ...params }) {
const network = await this.createNetwork(params)
$defer.onFailure(() => this.deleteNetwork(network))
// TODO: test and confirm:
@ -2185,7 +2185,7 @@ export default class Xapi extends XapiBase {
return network
}
async deleteNetwork (networkId) {
async deleteNetwork(networkId) {
const network = this.getObject(networkId)
const pifs = network.$PIFs
@ -2207,7 +2207,7 @@ export default class Xapi extends XapiBase {
// =================================================================
async _doDockerAction (vmId, action, containerId) {
async _doDockerAction(vmId, action, containerId) {
const vm = this.getObject(vmId)
const host = vm.$resident_on || this.pool.$master
@ -2223,35 +2223,35 @@ export default class Xapi extends XapiBase {
)
}
async registerDockerContainer (vmId) {
async registerDockerContainer(vmId) {
await this._doDockerAction(vmId, 'register')
}
async deregisterDockerContainer (vmId) {
async deregisterDockerContainer(vmId) {
await this._doDockerAction(vmId, 'deregister')
}
async startDockerContainer (vmId, containerId) {
async startDockerContainer(vmId, containerId) {
await this._doDockerAction(vmId, 'start', containerId)
}
async stopDockerContainer (vmId, containerId) {
async stopDockerContainer(vmId, containerId) {
await this._doDockerAction(vmId, 'stop', containerId)
}
async restartDockerContainer (vmId, containerId) {
async restartDockerContainer(vmId, containerId) {
await this._doDockerAction(vmId, 'restart', containerId)
}
async pauseDockerContainer (vmId, containerId) {
async pauseDockerContainer(vmId, containerId) {
await this._doDockerAction(vmId, 'pause', containerId)
}
async unpauseDockerContainer (vmId, containerId) {
async unpauseDockerContainer(vmId, containerId) {
await this._doDockerAction(vmId, 'unpause', containerId)
}
async getCloudInitConfig (templateId) {
async getCloudInitConfig(templateId) {
const template = this.getObject(templateId)
const host = this.pool.$master
@ -2268,7 +2268,7 @@ export default class Xapi extends XapiBase {
}
// Specific CoreOS Config Drive
async createCoreOsCloudInitConfigDrive (vmId, srId, config) {
async createCoreOsCloudInitConfigDrive(vmId, srId, config) {
const vm = this.getObject(vmId)
const host = this.pool.$master
const sr = this.getObject(srId)
@ -2289,7 +2289,7 @@ export default class Xapi extends XapiBase {
// Generic Config Drive
@deferrable
async createCloudInitConfigDrive ($defer, vmId, srId, config) {
async createCloudInitConfigDrive($defer, vmId, srId, config) {
const vm = this.getObject(vmId)
const sr = this.getObject(srId)
@ -2325,7 +2325,7 @@ export default class Xapi extends XapiBase {
}
@deferrable
async createTemporaryVdiOnSr (
async createTemporaryVdiOnSr(
$defer,
stream,
sr,
@ -2346,7 +2346,7 @@ export default class Xapi extends XapiBase {
}
// Create VDI on an adequate local SR
async createTemporaryVdiOnHost (stream, hostId, name_label, name_description) {
async createTemporaryVdiOnHost(stream, hostId, name_label, name_description) {
const pbd = find(this.getObject(hostId).$PBDs, pbd =>
canSrHaveNewVdiOfSize(pbd.$SR, stream.length)
)
@ -2363,7 +2363,7 @@ export default class Xapi extends XapiBase {
)
}
findAvailableSharedSr (minSize) {
findAvailableSharedSr(minSize) {
return find(
this.objects.all,
obj =>
@ -2371,7 +2371,7 @@ export default class Xapi extends XapiBase {
)
}
async _assertConsistentHostServerTime (hostRef) {
async _assertConsistentHostServerTime(hostRef) {
const delta =
parseDateTime(await this.call('host.get_servertime', hostRef)).getTime() -
Date.now()

View File

@ -14,7 +14,7 @@ const XEN_VIDEORAM_VALUES = [1, 2, 4, 8, 16]
export default {
// TODO: clean up on error.
@deferrable
async createVm (
async createVm(
$defer,
templateId,
{
@ -234,7 +234,7 @@ export default {
_editVm: makeEditObject({
affinityHost: {
get: 'affinity',
set (value, vm) {
set(value, vm) {
return this._setObjectProperty(
vm,
'affinity',
@ -244,7 +244,7 @@ export default {
},
autoPoweron: {
set (value, vm) {
set(value, vm) {
return Promise.all([
this._updateObjectMapProperty(vm, 'other_config', {
autoPoweron: value ? 'true' : null,
@ -258,7 +258,7 @@ export default {
},
virtualizationMode: {
set (virtualizationMode, vm) {
set(virtualizationMode, vm) {
if (virtualizationMode !== 'pv' && virtualizationMode !== 'hvm') {
throw new Error(`The virtualization mode must be 'pv' or 'hvm'`)
}
@ -274,7 +274,7 @@ export default {
},
coresPerSocket: {
set (coresPerSocket, vm) {
set(coresPerSocket, vm) {
return this._updateObjectMapProperty(vm, 'platform', {
'cores-per-socket': coresPerSocket,
})
@ -296,7 +296,7 @@ export default {
get: vm => +vm.VCPUs_at_startup,
set: [
'VCPUs_at_startup',
function (value, vm) {
function(value, vm) {
return isVmRunning(vm) && this._set('VCPUs_number_live', value)
},
],
@ -304,7 +304,7 @@ export default {
cpuCap: {
get: vm => vm.VCPUs_params.cap && +vm.VCPUs_params.cap,
set (cap, vm) {
set(cap, vm) {
return this._updateObjectMapProperty(vm, 'VCPUs_params', { cap })
},
},
@ -320,13 +320,13 @@ export default {
cpuWeight: {
get: vm => vm.VCPUs_params.weight && +vm.VCPUs_params.weight,
set (weight, vm) {
set(weight, vm) {
return this._updateObjectMapProperty(vm, 'VCPUs_params', { weight })
},
},
highAvailability: {
set (ha, vm) {
set(ha, vm) {
return this.call('VM.set_ha_restart_priority', vm.$ref, ha)
},
},
@ -346,7 +346,7 @@ export default {
limitName: 'memory',
get: vm => +vm.memory_dynamic_max,
preprocess: parseSize,
set (dynamicMax, vm) {
set(dynamicMax, vm) {
const { $ref } = vm
const dynamicMin = Math.min(vm.memory_dynamic_min, dynamicMax)
@ -400,7 +400,7 @@ export default {
hasVendorDevice: true,
expNestedHvm: {
set (expNestedHvm, vm) {
set(expNestedHvm, vm) {
return this._updateObjectMapProperty(vm, 'platform', {
'exp-nested-hvm': expNestedHvm ? 'true' : null,
})
@ -408,7 +408,7 @@ export default {
},
nicType: {
set (nicType, vm) {
set(nicType, vm) {
return this._updateObjectMapProperty(vm, 'platform', {
nic_type: nicType,
})
@ -416,7 +416,7 @@ export default {
},
vga: {
set (vga, vm) {
set(vga, vm) {
if (!includes(XEN_VGA_VALUES, vga)) {
throw new Error(
`The different values that the VGA can take are: ${XEN_VGA_VALUES}`
@ -427,7 +427,7 @@ export default {
},
videoram: {
set (videoram, vm) {
set(videoram, vm) {
if (!includes(XEN_VIDEORAM_VALUES, videoram)) {
throw new Error(
`The different values that the video RAM can take are: ${XEN_VIDEORAM_VALUES}`
@ -438,11 +438,11 @@ export default {
},
}),
async editVm (id, props, checkLimits) {
async editVm(id, props, checkLimits) {
return /* await */ this._editVm(this.getObject(id), props, checkLimits)
},
async revertVm (snapshotId, snapshotBefore = true) {
async revertVm(snapshotId, snapshotBefore = true) {
const snapshot = this.getObject(snapshotId)
if (snapshotBefore) {
await this._snapshotVm(snapshot.$snapshot_of)
@ -458,12 +458,12 @@ export default {
}
},
async resumeVm (vmId) {
async resumeVm(vmId) {
// the force parameter is always true
return this.call('VM.resume', this.getObject(vmId).$ref, false, true)
},
shutdownVm (vmId, { hard = false } = {}) {
shutdownVm(vmId, { hard = false } = {}) {
return this.call(
`VM.${hard ? 'hard' : 'clean'}_shutdown`,
this.getObject(vmId).$ref

View File

@ -305,7 +305,7 @@ class NoObjectsWithoutServers extends Component {
noResourceSets: PropTypes.bool.isRequired,
}
render () {
render() {
const {
areObjectsFetched,
isAdmin,
@ -469,18 +469,18 @@ export default class Home extends Component {
selectedItems: {},
}
get page () {
get page() {
return this.state.page
}
set page (activePage) {
set page(activePage) {
this.setState({ activePage })
}
componentWillMount () {
componentWillMount() {
this._initFilterAndSortBy(this.props)
}
componentWillReceiveProps (props) {
componentWillReceiveProps(props) {
if (this._getFilter() !== this._getFilter(props)) {
this._initFilterAndSortBy(props)
}
@ -489,7 +489,7 @@ export default class Home extends Component {
}
}
componentDidUpdate () {
componentDidUpdate() {
const { selectedItems } = this.state
// Unselect items that are no longer visible
@ -512,11 +512,11 @@ export default class Home extends Component {
identity,
])
_getType () {
_getType() {
return this.props.type
}
_setType (type) {
_setType(type) {
const { pathname, query } = this.props.location
this.context.router.push({
pathname,
@ -526,7 +526,7 @@ export default class Home extends Component {
// Filter and sort -----------------------------------------------------------
_getDefaultFilter (props = this.props) {
_getDefaultFilter(props = this.props) {
const { type } = props
const preferences = get(() => props.user.preferences)
const defaultFilterName = get(() => preferences.defaultHomeFilters[type])
@ -540,7 +540,7 @@ export default class Home extends Component {
)
}
_getDefaultSort (props = this.props) {
_getDefaultSort(props = this.props) {
const { sortOptions } = OPTIONS[props.type]
const defaultSort = find(sortOptions, 'default')
const urlSort = find(sortOptions, { sortBy: props.location.query.sortBy })
@ -559,7 +559,7 @@ export default class Home extends Component {
}
}
_setSort (event) {
_setSort(event) {
const { sortBy, sortOrder } = event.currentTarget.dataset
const { pathname, query } = this.props.location
@ -571,7 +571,7 @@ export default class Home extends Component {
}
_setSort = this._setSort.bind(this)
_initFilterAndSortBy (props) {
_initFilterAndSortBy(props) {
const filter = this._getFilter(props)
// If filter is null, set a default filter.
@ -616,7 +616,7 @@ export default class Home extends Component {
// Optionally can take the props to be able to use it in
// componentWillReceiveProps().
_getFilter (props = this.props) {
_getFilter(props = this.props) {
return props.location.query.s
}
@ -636,7 +636,7 @@ export default class Home extends Component {
// Optionally can take the props to be able to use it in
// componentWillReceiveProps().
_setFilter (filter, props = this.props, replace) {
_setFilter(filter, props = this.props, replace) {
if (!isString(filter)) {
filter = filter.toString()
}
@ -752,7 +752,7 @@ export default class Home extends Component {
_addCustomFilter = () => {
return addCustomFilter(this._getType(), this._getFilter())
}
_getCustomFilters () {
_getCustomFilters() {
const { preferences } = this.props.user || {}
if (!preferences) {
@ -772,7 +772,10 @@ export default class Home extends Component {
size(visibleItems) > 0 &&
size(filter(selectedItems)) === size(visibleItems)
)
_getIsSomeSelected = createSelector(() => this.state.selectedItems, some)
_getIsSomeSelected = createSelector(
() => this.state.selectedItems,
some
)
_toggleMaster = () => {
const selectedItems = {}
if (!this._getIsAllSelected()) {
@ -829,7 +832,7 @@ export default class Home extends Component {
// Header --------------------------------------------------------------------
_renderHeader () {
_renderHeader() {
const customFilters = this._getCustomFilters()
const filteredItems = this._getFilteredItems()
const nItems = this._getNumberOfItems()
@ -1119,7 +1122,7 @@ export default class Home extends Component {
// ---------------------------------------------------------------------------
render () {
render() {
const { isAdmin, isPoolAdmin, noResourceSets } = this.props
const nItems = this._getNumberOfItems()

View File

@ -76,7 +76,7 @@ const ACTIONS = [
},
]
const getType = function (param) {
const getType = function(param) {
if (!param) {
return
}
@ -101,7 +101,7 @@ const reduceObject = (value, propertyName = 'id') =>
/**
* Adapts all data "arrayed" by UI-multiple-selectors to job's cross-product trick
*/
const dataToParamVectorItems = function (params, data) {
const dataToParamVectorItems = function(params, data) {
const items = []
forEach(params, (param, name) => {
if (Array.isArray(data[name]) && param.items) {
@ -139,7 +139,7 @@ const dataToParamVectorItems = function (params, data) {
})
@injectIntl
export default class Jobs extends Component {
constructor (props) {
constructor(props) {
super(props)
this.state = {
@ -158,7 +158,7 @@ export default class Jobs extends Component {
})
}
componentWillMount () {
componentWillMount() {
this.componentWillUnmount = subscribeJobs(jobs => {
const j = {}
for (const id in jobs) {
@ -436,7 +436,7 @@ export default class Jobs extends Component {
},
]
render () {
render() {
const { props, state } = this
const { action, actions, job, jobs } = state
const { formatMessage } = this.props.intl

View File

@ -62,13 +62,20 @@ const shareVmProxy = vm => shareVm(vm, vm.resourceSet)
const getVbds = createGetObjectsOfType('VBD').pick((_, { vm }) => vm.$VBDs)
const getVdis = createGetObjectsOfType('VDI').pick(
createSelector(getVbds, vbds => map(vbds, 'VDI'))
createSelector(
getVbds,
vbds => map(vbds, 'VDI')
)
)
const getSrs = createGetObjectsOfType('SR').pick(
createSelector(getVdis, vdis => uniq(map(vdis, '$SR')))
createSelector(
getVdis,
vdis => uniq(map(vdis, '$SR'))
)
)
const getSrsContainers = createSelector(getSrs, srs =>
uniq(map(srs, '$container'))
const getSrsContainers = createSelector(
getSrs,
srs => uniq(map(srs, '$container'))
)
const getAffinityHostPredicate = createSelector(
@ -89,7 +96,7 @@ class AffinityHost extends Component {
_editAffinityHost = host =>
editVm(this.props.vm, { affinityHost: host.id || null })
render () {
render() {
const { affinityHost, affinityHostPredicate } = this.props
return (
@ -123,7 +130,7 @@ class ResourceSetItem extends Component {
assign(find(resourceSets, { id }), { type: 'resourceSet' })
)
render () {
render() {
return this.props.resourceSets === undefined
? null
: renderXoItem(this._getResourceSet())
@ -131,7 +138,7 @@ class ResourceSetItem extends Component {
}
class NewVgpu extends Component {
get value () {
get value() {
return this.state
}
@ -140,7 +147,7 @@ class NewVgpu extends Component {
poolId => vgpuType => poolId === vgpuType.$pool
)
render () {
render() {
return (
<Container>
<Row>
@ -167,7 +174,7 @@ class Vgpus extends Component {
createVgpu(this.props.vm, { vgpuType, gpuGroup: vgpuType.gpuGroup })
)
render () {
render() {
const { vgpus, vm } = this.props
return (
@ -225,7 +232,7 @@ class CoresPerSocket extends Component {
_onChange = event =>
editVm(this.props.vm, { coresPerSocket: getEventValue(event) || null })
render () {
render() {
const { container, vm } = this.props
const selectedCoresPerSocket = vm.coresPerSocket
const options = this._getCoresPerSocketPossibilities()
@ -295,7 +302,10 @@ const NIC_TYPE_OPTIONS = [
@connectStore(() => {
const getVgpus = createGetObjectsOfType('vgpu').pick((_, { vm }) => vm.$VGPUs)
const getGpuGroup = createGetObjectsOfType('gpuGroup').pick(
createSelector(getVgpus, vgpus => map(vgpus, 'gpuGroup'))
createSelector(
getVgpus,
vgpus => map(vgpus, 'gpuGroup')
)
)
return {
@ -305,14 +315,14 @@ const NIC_TYPE_OPTIONS = [
}
})
export default class TabAdvanced extends Component {
componentDidMount () {
componentDidMount() {
getVmsHaValues().then(vmsHaValues => this.setState({ vmsHaValues }))
}
_onNicTypeChange = value =>
editVm(this.props.vm, { nicType: value === '' ? null : value })
render () {
render() {
const { container, isAdmin, vgpus, vm } = this.props
return (
<Container>