mirror of https://github.com/apache/cloudstack.git
Merge branch '4.15' into main
This commit is contained in:
commit
3ddcf85876
|
|
@ -2638,7 +2638,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
try {
|
||||
s_logger.debug("Mapping spec disks information to cloned VM disks for VM " + vmInternalCSName);
|
||||
if (vmMo != null && ArrayUtils.isNotEmpty(specDisks)) {
|
||||
List<VirtualDisk> vmDisks = vmMo.getVirtualDisks();
|
||||
List<VirtualDisk> vmDisks = vmMo.getVirtualDisksOrderedByKey();
|
||||
|
||||
List<VirtualDisk> rootDisks = new ArrayList<>();
|
||||
List<DiskTO> sortedRootDisksFromSpec = Arrays.asList(sortVolumesByDeviceId(specDisks))
|
||||
.stream()
|
||||
|
|
|
|||
|
|
@ -1252,20 +1252,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
|||
vmMo.createFullCloneWithSpecificDisk(templateUniqueName, dcMo.getVmFolder(), morPool, VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first()), volumeDeviceInfo);
|
||||
clonedVm = dcMo.findVm(templateUniqueName);
|
||||
|
||||
/* FR41 THIS IS OLD way of creating template using snapshot
|
||||
if (!vmMo.createSnapshot(templateUniqueName, "Temporary snapshot for template creation", false, false)) {
|
||||
String msg = "Unable to take snapshot for creating template from volume. volume path: " + volumePath;
|
||||
s_logger.error(msg);
|
||||
throw new Exception(msg);
|
||||
}
|
||||
|
||||
String hardwareVersion = String.valueOf(vmMo.getVirtualHardwareVersion());
|
||||
|
||||
// 4 MB is the minimum requirement for VM memory in VMware
|
||||
Pair<VirtualMachineMO, String[]> cloneResult =
|
||||
vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(), VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first()), hardwareVersion);
|
||||
clonedVm = cloneResult.first();
|
||||
* */
|
||||
clonedVm.tagAsWorkerVM();
|
||||
clonedVm.exportVm(secondaryMountPoint + "/" + installPath, templateUniqueName, false, false);
|
||||
|
||||
// Get VMDK filename
|
||||
|
|
@ -1858,6 +1845,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
|||
s_logger.error(msg);
|
||||
throw new Exception(msg);
|
||||
}
|
||||
clonedVm.tagAsWorkerVM();
|
||||
vmMo = clonedVm;
|
||||
}
|
||||
vmMo.exportVm(exportPath, exportName, false, false);
|
||||
|
|
|
|||
|
|
@ -1727,9 +1727,7 @@ public class HypervisorHostHelper {
|
|||
}
|
||||
|
||||
if (workingVM != null) {
|
||||
workingVM.setCustomFieldValue(CustomFieldConstants.CLOUD_WORKER, "true");
|
||||
String workerTag = String.format("%d-%s", System.currentTimeMillis(), hyperHost.getContext().getStockObject("noderuninfo"));
|
||||
workingVM.setCustomFieldValue(CustomFieldConstants.CLOUD_WORKER_TAG, workerTag);
|
||||
workingVM.tagAsWorkerVM();
|
||||
}
|
||||
return workingVM;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2825,6 +2825,20 @@ public class VirtualMachineMO extends BaseMO {
|
|||
return virtualDisks;
|
||||
}
|
||||
|
||||
public List<VirtualDisk> getVirtualDisksOrderedByKey() throws Exception {
|
||||
List<VirtualDisk> virtualDisks = getVirtualDisks();
|
||||
Collections.sort(virtualDisks, new Comparator<VirtualDisk>() {
|
||||
@Override
|
||||
public int compare(VirtualDisk disk1, VirtualDisk disk2) {
|
||||
Integer disk1Key = disk1.getKey();
|
||||
Integer disk2Key = disk2.getKey();
|
||||
return disk1Key.compareTo(disk2Key);
|
||||
}
|
||||
});
|
||||
|
||||
return virtualDisks;
|
||||
}
|
||||
|
||||
public List<String> detachAllDisksExcept(String vmdkBaseName, String deviceBusName) throws Exception {
|
||||
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
||||
|
||||
|
|
@ -3593,4 +3607,10 @@ public class VirtualMachineMO extends BaseMO {
|
|||
VirtualMachineTicket ticket = _context.getService().acquireTicket(_mor, "webmks");
|
||||
return ticket.getTicket();
|
||||
}
|
||||
|
||||
public void tagAsWorkerVM() throws Exception {
|
||||
setCustomFieldValue(CustomFieldConstants.CLOUD_WORKER, "true");
|
||||
String workerTag = String.format("%d-%s", System.currentTimeMillis(), getContext().getStockObject("noderuninfo"));
|
||||
setCustomFieldValue(CustomFieldConstants.CLOUD_WORKER_TAG, workerTag);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue