chore(xo-server): use VM.domain_type when available (#3664)

And fallback to our previous detection when unavailable.

Starting from this commit, `virtualizationMode` will no longer contain `'pvhvm'`, this must be computed UI side by using both `virtualizationMode` and `xenTools` properties.
This commit is contained in:
Julien Fontanet
2018-11-08 14:37:47 +01:00
committed by Pierre Donias
parent b75e746586
commit 00e1601f85
2 changed files with 21 additions and 8 deletions

View File

@@ -10,7 +10,12 @@ import {
mapToArray,
parseXml,
} from './utils'
import { isHostRunning, isVmHvm, isVmRunning, parseDateTime } from './xapi'
import {
getVmDomainType,
isHostRunning,
isVmRunning,
parseDateTime,
} from './xapi'
import { useUpdateSystem } from './xapi/utils'
// ===================================================================
@@ -225,7 +230,8 @@ const TRANSFORMS = {
other_config: otherConfig,
} = obj
const isHvm = isVmHvm(obj)
const domainType = getVmDomainType(obj)
const isHvm = domainType === 'hvm'
const isRunning = isVmRunning(obj)
const xenTools = (() => {
if (!isRunning || !metrics) {
@@ -343,11 +349,7 @@ const TRANSFORMS = {
startTime: metrics && toTimestamp(metrics.start_time),
tags: obj.tags,
VIFs: link(obj, 'VIFs'),
virtualizationMode: isHvm
? guestMetrics !== undefined && guestMetrics.PV_drivers_detected
? 'pvhvm'
: 'hvm'
: 'pv',
virtualizationMode: domainType,
// <=> Are the Xen Server tools installed?
//

View File

@@ -143,7 +143,18 @@ export const isHostRunning = host => {
// -------------------------------------------------------------------
export const isVmHvm = vm => Boolean(vm.HVM_boot_policy)
export const getVmDomainType = vm => {
const dt = vm.domain_type
if (
dt !== undefined && // XS < 7.5
dt !== 'unspecified' // detection failed
) {
return dt
}
return vm.HVM_boot_policy === '' ? 'pv' : 'hvm'
}
export const isVmHvm = vm => getVmDomainType(vm) === 'hvm'
const VM_RUNNING_POWER_STATES = {
Running: true,