Skip to content

Commit a0986bf

Browse files
authored
FR566 - Specifying HW version - worker VM improvements - KDDI-4.11.3.0 (#23)
https://shapeblue.atlassian.net/browse/FRO-935
1 parent 46a8454 commit a0986bf

File tree

5 files changed

+25
-20
lines changed

5 files changed

+25
-20
lines changed

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public Answer execute(VmwareHostService hostService, BackupSnapshotCommand cmd)
342342
dsMo = new DatastoreMO(hyperHost.getContext(), morDs);
343343

344344
workerVMName = hostService.getWorkerName(context, cmd, 0);
345-
vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, workerVMName);
345+
vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, workerVMName, null);
346346

347347
if (vmMo == null) {
348348
throw new Exception("Failed to find the newly create or relocated VM. vmName: " + workerVMName);
@@ -645,7 +645,7 @@ private Ternary<String, Long, Long> createTemplateFromVolume(VirtualMachineMO vm
645645
}
646646

647647
// 4 MB is the minimum requirement for VM memory in VMware
648-
vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(), VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first()));
648+
vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(), VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first()), null);
649649
clonedVm = vmMo.getRunningHost().findVmOnHyperHost(workerVmName);
650650
if (clonedVm == null) {
651651
String msg = "Unable to create dummy VM to export volume. volume path: " + volumePath;
@@ -962,7 +962,7 @@ private void exportVolumeToSecondaryStroage(VirtualMachineMO vmMo, String volume
962962
}
963963

964964
// 4 MB is the minimum requirement for VM memory in VMware
965-
vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(), VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first()));
965+
vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(), VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first()), null);
966966
clonedVm = vmMo.getRunningHost().findVmOnHyperHost(workerVmName);
967967
if (clonedVm == null) {
968968
String msg = "Unable to create dummy VM to export volume. volume path: " + volumePath;
@@ -1002,7 +1002,7 @@ private Pair<String, String> copyVolumeToSecStorage(VmwareHostService hostServic
10021002
if (vmMo == null) {
10031003
// create a dummy worker vm for attaching the volume
10041004
DatastoreMO dsMo = new DatastoreMO(hyperHost.getContext(), morDs);
1005-
workerVm = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, workerVmName);
1005+
workerVm = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, workerVmName, null);
10061006

10071007
if (workerVm == null) {
10081008
String msg = "Unable to create worker VM to execute CopyVolumeCommand";

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ private Answer execute(ResizeVolumeCommand cmd) {
710710

711711
s_logger.info("Create worker VM " + vmName);
712712

713-
vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, vmName);
713+
vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, vmName, null);
714714

715715
if (vmMo == null) {
716716
throw new Exception("Unable to create a worker VM for volume resize");

plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ private String cleanUpDatastore(Command cmd, HostDatastoreSystemMO hostDatastore
396396
if (vmName != null) {
397397
String workerVmName = hostService.getWorkerName(context, cmd, 0);
398398

399-
VirtualMachineMO vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, workerVmName);
399+
VirtualMachineMO vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, workerVmName, null);
400400

401401
if (vmMo == null) {
402402
throw new Exception("Unable to create a worker VM for volume creation");
@@ -786,7 +786,7 @@ public Answer cloneVolumeFromBaseTemplate(CopyCommand cmd) {
786786
String dummyVmName = hostService.getWorkerName(context, cmd, 0);
787787

788788
try {
789-
vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, dummyVmName);
789+
vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, dummyVmName, null);
790790
if (vmMo == null) {
791791
throw new Exception("Unable to create a dummy VM for volume creation");
792792
}
@@ -986,7 +986,7 @@ private Pair<String, String> copyVolumeToSecStorage(VmwareHostService hostServic
986986
if (vmMo == null || VmwareResource.getVmState(vmMo) == PowerState.PowerOff) {
987987
// create a dummy worker vm for attaching the volume
988988
DatastoreMO dsMo = new DatastoreMO(hyperHost.getContext(), morDs);
989-
workerVm = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, workerVmName);
989+
workerVm = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, workerVmName, null);
990990

991991
if (workerVm == null) {
992992
String msg = "Unable to create worker VM to execute CopyVolumeCommand";
@@ -1120,7 +1120,7 @@ private Ternary<String, Long, Long> createTemplateFromVolume(VirtualMachineMO vm
11201120

11211121
// 4 MB is the minimum requirement for VM memory in VMware
11221122
Pair<VirtualMachineMO, String[]> cloneResult =
1123-
vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(), VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first()));
1123+
vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(), VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first()), null);
11241124
clonedVm = cloneResult.first();
11251125

11261126
clonedVm.exportVm(secondaryMountPoint + "/" + installPath, templateUniqueName, false, false);
@@ -1518,7 +1518,7 @@ private void exportManagedStorageSnapshotToTemplate(CopyCommand cmd, String inst
15181518
ManagedObjectReference dsMor = hyperHost.findDatastoreByName(dsFile.getDatastoreName());
15191519
DatastoreMO dsMo = new DatastoreMO(context, dsMor);
15201520

1521-
VirtualMachineMO workerVM = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, workerVMName);
1521+
VirtualMachineMO workerVM = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, workerVMName, null);
15221522

15231523
if (workerVM == null) {
15241524
throw new CloudRuntimeException("Failed to find the newly created worker VM: " + workerVMName);
@@ -1683,9 +1683,11 @@ private Pair<String, String[]> exportVolumeToSecondaryStroage(VirtualMachineMO v
16831683
throw new Exception(msg);
16841684
}
16851685

1686+
String virtualHardwareVersion = String.valueOf(vmMo.getVirtualHardwareVersion());
1687+
16861688
// 4 MB is the minimum requirement for VM memory in VMware
16871689
Pair<VirtualMachineMO, String[]> cloneResult =
1688-
vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(), VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first()));
1690+
vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(), VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first()), virtualHardwareVersion);
16891691
clonedVm = cloneResult.first();
16901692
String disks[] = cloneResult.second();
16911693

@@ -1761,7 +1763,7 @@ public Answer backupSnapshot(CopyCommand cmd) {
17611763
if(vmMo == null) {
17621764
dsMo = new DatastoreMO(hyperHost.getContext(), morDs);
17631765
workerVMName = hostService.getWorkerName(context, cmd, 0);
1764-
vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, workerVMName);
1766+
vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, workerVMName, null);
17651767
if (vmMo == null) {
17661768
throw new Exception("Failed to find the newly create or relocated VM. vmName: " + workerVMName);
17671769
}
@@ -2214,7 +2216,7 @@ public Answer createVolume(CreateObjectCommand cmd) {
22142216
String dummyVmName = hostService.getWorkerName(context, cmd, 0);
22152217
try {
22162218
s_logger.info("Create worker VM " + dummyVmName);
2217-
vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, dummyVmName);
2219+
vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, dummyVmName, null);
22182220
if (vmMo == null) {
22192221
throw new Exception("Unable to create a dummy VM for volume creation");
22202222
}
@@ -2842,7 +2844,7 @@ private void createVmdk(Command cmd, DatastoreMO dsMo, String vmdkDatastorePath,
28422844

28432845
String dummyVmName = hostService.getWorkerName(context, cmd, 0);
28442846

2845-
VirtualMachineMO vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, dummyVmName);
2847+
VirtualMachineMO vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, dummyVmName, null);
28462848

28472849
if (vmMo == null) {
28482850
throw new Exception("Unable to create a dummy VM for volume creation");

vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,7 +1600,7 @@ private static VirtualDeviceConfigSpec getControllerSpec(String diskController,
16001600

16011601
return controllerSpec;
16021602
}
1603-
public static VirtualMachineMO createWorkerVM(VmwareHypervisorHost hyperHost, DatastoreMO dsMo, String vmName) throws Exception {
1603+
public static VirtualMachineMO createWorkerVM(VmwareHypervisorHost hyperHost, DatastoreMO dsMo, String vmName, String hardwareVersion) throws Exception {
16041604

16051605
// Allow worker VM to float within cluster so that we will have better chance to
16061606
// create it successfully
@@ -1611,6 +1611,9 @@ public static VirtualMachineMO createWorkerVM(VmwareHypervisorHost hyperHost, Da
16111611
VirtualMachineMO workingVM = null;
16121612
VirtualMachineConfigSpec vmConfig = new VirtualMachineConfigSpec();
16131613
vmConfig.setName(vmName);
1614+
if (hardwareVersion != null){
1615+
vmConfig.setVersion("vmx-" + hardwareVersion);
1616+
}
16141617
vmConfig.setMemoryMB((long)4);
16151618
vmConfig.setNumCPUs(1);
16161619
vmConfig.setGuestId(VirtualMachineGuestOsIdentifier.OTHER_GUEST.value());
@@ -1929,7 +1932,7 @@ public static void createOvfFile(VmwareHypervisorHost host, String diskFileName,
19291932
ManagedObjectReference morDs) throws Exception {
19301933
VmwareContext context = host.getContext();
19311934
ManagedObjectReference morOvf = context.getServiceContent().getOvfManager();
1932-
VirtualMachineMO workerVmMo = HypervisorHostHelper.createWorkerVM(host, new DatastoreMO(context, morDs), ovfName);
1935+
VirtualMachineMO workerVmMo = HypervisorHostHelper.createWorkerVM(host, new DatastoreMO(context, morDs), ovfName, null);
19331936
if (workerVmMo == null)
19341937
throw new Exception("Unable to find just-created worker VM");
19351938

vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,21 +1941,21 @@ public String[] getCurrentSnapshotDiskChainDatastorePaths(String diskDevice) thr
19411941
}
19421942

19431943
// return the disk chain (VMDK datastore paths) for cloned snapshot
1944-
public Pair<VirtualMachineMO, String[]> cloneFromCurrentSnapshot(String clonedVmName, int cpuSpeedMHz, int memoryMb, String diskDevice, ManagedObjectReference morDs)
1944+
public Pair<VirtualMachineMO, String[]> cloneFromCurrentSnapshot(String clonedVmName, int cpuSpeedMHz, int memoryMb, String diskDevice, ManagedObjectReference morDs, String cloneHardwareVersion)
19451945
throws Exception {
19461946
assert (morDs != null);
19471947
String[] disks = getCurrentSnapshotDiskChainDatastorePaths(diskDevice);
1948-
VirtualMachineMO clonedVm = cloneFromDiskChain(clonedVmName, cpuSpeedMHz, memoryMb, disks, morDs);
1948+
VirtualMachineMO clonedVm = cloneFromDiskChain(clonedVmName, cpuSpeedMHz, memoryMb, disks, morDs, cloneHardwareVersion);
19491949
return new Pair<VirtualMachineMO, String[]>(clonedVm, disks);
19501950
}
19511951

1952-
public VirtualMachineMO cloneFromDiskChain(String clonedVmName, int cpuSpeedMHz, int memoryMb, String[] disks, ManagedObjectReference morDs) throws Exception {
1952+
public VirtualMachineMO cloneFromDiskChain(String clonedVmName, int cpuSpeedMHz, int memoryMb, String[] disks, ManagedObjectReference morDs, String cloneHardwareVersion) throws Exception {
19531953
assert (disks != null);
19541954
assert (disks.length >= 1);
19551955

19561956
HostMO hostMo = getRunningHost();
19571957

1958-
VirtualMachineMO clonedVmMo = HypervisorHostHelper.createWorkerVM(hostMo, new DatastoreMO(hostMo.getContext(), morDs), clonedVmName);
1958+
VirtualMachineMO clonedVmMo = HypervisorHostHelper.createWorkerVM(hostMo, new DatastoreMO(hostMo.getContext(), morDs), clonedVmName, cloneHardwareVersion);
19591959
if (clonedVmMo == null)
19601960
throw new Exception("Unable to find just-created blank VM");
19611961

0 commit comments

Comments
 (0)