@stordata/vsphere-soapify
Version:
A NodeJS abstraction layer for the vSphere SOAP API
743 lines (729 loc) • 20.9 kB
JavaScript
'use strict';
const { expect } = require('chai'),
Client = require('../../client'),
ClusterComputeResource = require('./ClusterComputeResource');
describe('The ManagedEntity class', function() {
let client,
cluster;
beforeEach(function() {
client = new Client('https://url/sdk');
cluster = new ClusterComputeResource(client, 'my-entity-01', [
{
name: 'host',
val: [
{
attributes: {
type: 'HostSystem'
},
$value: 'host-67'
},
{
attributes: {
type: 'HostSystem'
},
$value: 'host-72'
}
]
},
{
name: 'resourcePool',
val: {
attributes: {
type: 'ResourcePool'
},
$val: 'respool-01'
}
}
]);
});
describe('The getAll method', function() {
it('should fetch all instances available at the given property path', function() {
this.mockSoapOperation('5.5', 'RetrieveServiceContent');
this.mockSoapOperation('5.5', 'ManagedEntity/getAllHosts/RetrievePropertiesEx');
return cluster.getAll('host')
.then(hosts => expect(hosts).to.deep.equal([
{
configStatus: 'green',
datastore: [
{
ref: 'datastore-29'
}, {
ref: 'datastore-30'
}
],
hardware: {
smcPresent: false
},
licensableResource: {
resource: {
numCpuCores: 40,
numCpuPackages: 4,
numVmsStarted: 1
}
},
name: 'aziliz.stordata.fr',
overallStatus: 'red',
parent: {
ref: 'domain-c37'
},
ref: 'host-67',
runtime: {
bootTime: new Date('2019-01-24T11:12:33.617Z'),
connectionState: 'connected',
dasHostState: {
state: 'master'
},
inMaintenanceMode: false,
powerState: 'poweredOn',
standbyMode: 'none'
},
summary: {
config: {
faultToleranceEnabled: false,
port: 443,
product: {
apiType: 'HostAgent',
apiVersion: '6.7.1',
build: '10302608',
fullName: 'VMware ESXi 6.7.0 build-10302608',
licenseProductName: 'VMware ESX Server',
licenseProductVersion: '6.0',
localeBuild: '000',
localeVersion: 'INTL',
name: 'VMware ESXi',
osType: 'vmnix-x86',
productLineId: 'embeddedEsx',
vendor: 'VMware, Inc.',
version: '6.7.0'
},
vmotionEnabled: true
},
hardware: {
cpuMhz: 2200,
cpuModel: 'Intel(R) Xeon(R) CPU E5-4640 v2 @ 2.20GHz',
memorySize: 274830041088,
model: 'PowerEdge R820',
numCpuCores: 40,
numCpuPkgs: 4,
numCpuThreads: 80,
numHBAs: 5,
numNics: 8,
uuid: '4c4c4544-0036-3910-8050-b9c04f323132',
vendor: 'Dell Inc.'
},
managementServerIp: '10.78.7.214',
maxEVCModeKey: 'intel-ivybridge',
overallStatus: 'red',
quickStats: {
distributedCpuFairness: 1826,
distributedMemoryFairness: 1288,
overallCpuUsage: 8833,
overallMemoryUsage: 51287,
uptime: 9776958
},
rebootRequired: false
}
},
{
configStatus: 'green',
datastore: [
{
ref: 'datastore-29'
}, {
ref: 'datastore-30'
}
],
hardware: {
smcPresent: false
},
licensableResource: {
resource: {
numCpuCores: 40,
numCpuPackages: 4,
numVmsStarted: 0
}
},
name: 'tumet.stordata.fr',
overallStatus: 'red',
parent: {
ref: 'domain-c37'
},
ref: 'host-72',
runtime: {
bootTime: new Date('2019-01-24T11:14:28.460Z'),
connectionState: 'connected',
dasHostState: {
state: 'connectedToMaster'
},
inMaintenanceMode: false,
powerState: 'poweredOn',
standbyMode: 'none'
},
summary: {
config: {
faultToleranceEnabled: false,
port: 443,
product: {
apiType: 'HostAgent',
apiVersion: '6.7.1',
build: '10302608',
fullName: 'VMware ESXi 6.7.0 build-10302608',
licenseProductName: 'VMware ESX Server',
licenseProductVersion: '6.0',
localeBuild: '000',
localeVersion: 'INTL',
name: 'VMware ESXi',
osType: 'vmnix-x86',
productLineId: 'embeddedEsx',
vendor: 'VMware, Inc.',
version: '6.7.0'
},
vmotionEnabled: true
},
hardware: {
cpuMhz: 2200,
cpuModel: 'Intel(R) Xeon(R) CPU E5-4640 v2 @ 2.20GHz',
memorySize: 274830041088,
model: 'PowerEdge R820',
numCpuCores: 40,
numCpuPkgs: 4,
numCpuThreads: 80,
numHBAs: 5,
numNics: 8,
uuid: '4c4c4544-0036-3910-8050-c7c04f323132',
vendor: 'Dell Inc.'
},
managementServerIp: '10.78.7.214',
maxEVCModeKey: 'intel-ivybridge',
overallStatus: 'red',
quickStats: {
distributedCpuFairness: 10000,
distributedMemoryFairness: 2470,
overallCpuUsage: 2312,
overallMemoryUsage: 33575,
uptime: 9776811
},
rebootRequired: false
}
}
]));
});
});
describe('The get method', function() {
it('should fetch a single instance available at the given property path', function() {
this.mockSoapOperation('5.5', 'RetrieveServiceContent');
this.mockSoapOperation('5.5', 'ManagedEntity/getResourcePool/RetrievePropertiesEx');
return cluster.get('resourcePool')
.then(hosts => expect(hosts).to.deep.equal({
childConfiguration: [
{
cpuAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 4000
}
},
entity: {
ref: 'vm-127'
},
memoryAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 81920
}
}
},
{
cpuAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 2000
}
},
entity: {
ref: 'vm-121'
},
memoryAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 20480
}
}
},
{
cpuAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 1000
}
},
entity: {
ref: 'vm-129'
},
memoryAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 10240
}
}
},
{
cpuAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 2000
}
},
entity: {
ref: 'vm-115'
},
memoryAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 40960
}
}
},
{
cpuAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 2000
}
},
entity: {
ref: 'vm-108'
},
memoryAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 40960
}
}
},
{
cpuAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 2000
}
},
entity: {
ref: 'vm-113'
},
memoryAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 40960
}
}
},
{
cpuAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 2000
}
},
entity: {
ref: 'vm-107'
},
memoryAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 40960
}
}
},
{
cpuAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 2000
}
},
entity: {
ref: 'vm-110'
},
memoryAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 40960
}
}
},
{
cpuAllocation: {
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 2000
}
},
entity: {
ref: 'vm-68'
},
memoryAllocation: {
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 102400
}
}
},
{
cpuAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 4000
}
},
entity: {
ref: 'vm-102'
},
memoryAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 163840
}
}
},
{
cpuAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 2000
}
},
entity: {
ref: 'vm-109'
},
memoryAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 40960
}
}
},
{
cpuAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 2000
}
},
entity: {
ref: 'vm-111'
},
memoryAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 40960
}
}
},
{
cpuAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 2000
}
},
entity: {
ref: 'vm-112'
},
memoryAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 40960
}
}
},
{
cpuAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 2000
}
},
entity: {
ref: 'vm-126'
},
memoryAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 81920
}
}
},
{
cpuAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 2000
}
},
entity: {
ref: 'vm-114'
},
memoryAllocation: {
expandableReservation: false,
limit: -1,
reservation: 0,
shares: {
level: 'normal',
shares: 40960
}
}
}
],
config: {
cpuAllocation: {
expandableReservation: true,
limit: 160732,
reservation: 160732,
shares: {
level: 'normal',
shares: 4000
}
},
entity: {
ref: 'resgroup-38'
},
memoryAllocation: {
expandableReservation: true,
limit: 501587,
reservation: 501587,
shares: {
level: 'normal',
shares: 163840
}
}
},
configStatus: 'green',
name: 'Resources',
overallStatus: 'green',
owner: {
ref: 'domain-c37'
},
parent: {
ref: 'domain-c37'
},
ref: 'resgroup-38',
resourcePool: [],
runtime: {
cpu: {
maxUsage: 160732,
overallUsage: 440,
reservationUsed: 80366,
reservationUsedForVm: 0,
unreservedForPool: 80366,
unreservedForVm: 80366
},
memory: {
maxUsage: 525945798656,
overallUsage: 80617668608,
reservationUsed: 263855276032,
reservationUsedForVm: 882900992,
unreservedForPool: 262090522624,
unreservedForVm: 262090522624
},
overallStatus: 'green'
},
summary: {
config: {
cpuAllocation: {
expandableReservation: true,
limit: 160732,
reservation: 160732,
shares: {
level: 'normal',
shares: 4000
}
},
entity: {
ref: 'resgroup-38'
},
memoryAllocation: {
expandableReservation: true,
limit: 501587,
reservation: 501587,
shares: {
level: 'normal',
shares: 163840
}
}
},
configuredMemoryMB: 82944,
name: 'Resources',
quickStats: {
balloonedMemory: 0,
compressedMemory: 0,
consumedOverheadMemory: 641,
distributedCpuEntitlement: 440,
distributedMemoryEntitlement: 28217,
guestMemoryUsage: 6973,
hostMemoryUsage: 76883,
overallCpuDemand: 440,
overallCpuUsage: 440,
overheadMemory: 842,
privateMemory: 76242,
sharedMemory: 0,
staticCpuEntitlement: 72600,
staticMemoryEntitlement: 86897,
swappedMemory: 0
},
runtime: {
cpu: {
maxUsage: 160732,
overallUsage: 440,
reservationUsed: 80366,
reservationUsedForVm: 0,
unreservedForPool: 80366,
unreservedForVm: 80366
},
memory: {
maxUsage: 525945798656,
overallUsage: 80617668608,
reservationUsed: 263855276032,
reservationUsedForVm: 882900992,
unreservedForPool: 262090522624,
unreservedForVm: 262090522624
},
overallStatus: 'green'
}
},
vm: [
{
ref: 'vm-127'
},
{
ref: 'vm-121'
},
{
ref: 'vm-129'
},
{
ref: 'vm-115'
},
{
ref: 'vm-108'
},
{
ref: 'vm-113'
},
{
ref: 'vm-107'
},
{
ref: 'vm-110'
},
{
ref: 'vm-68'
},
{
ref: 'vm-102'
},
{
ref: 'vm-109'
},
{
ref: 'vm-111'
},
{
ref: 'vm-112'
},
{
ref: 'vm-126'
},
{
ref: 'vm-114'
}
]
}));
});
});
});