mirror of https://github.com/apache/cloudstack.git
Added Worker VM tags for few cloned VMs, created while performing some volume operations. (#5377)
Worker VM tags are missed for few cloned VMs in VMware, and so these are skipped when tracking / cleaning up of Worker VMs. Adding proper Worker VM tags to these VMs would make them trackable from CloudStack.
This commit is contained in:
parent
41f6f0e568
commit
46ca853e55
|
|
@ -1242,20 +1242,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
|
||||
|
|
@ -1848,6 +1835,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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3553,4 +3553,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