You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by nv...@apache.org on 2021/08/30 23:22:25 UTC
[cloudstack] branch 4.15 updated: Added Worker VM tags for few
cloned VMs, created while performing some volume operations. (#5377)
This is an automated email from the ASF dual-hosted git repository.
nvazquez pushed a commit to branch 4.15
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.15 by this push:
new 46ca853 Added Worker VM tags for few cloned VMs, created while performing some volume operations. (#5377)
46ca853 is described below
commit 46ca853e5569d55ce497bb0a275b5ac559ada5ec
Author: sureshanaparti <12...@users.noreply.github.com>
AuthorDate: Tue Aug 31 04:52:06 2021 +0530
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.
---
.../cloud/storage/resource/VmwareStorageProcessor.java | 16 ++--------------
.../cloud/hypervisor/vmware/mo/HypervisorHostHelper.java | 4 +---
.../com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java | 6 ++++++
3 files changed, 9 insertions(+), 17 deletions(-)
diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageProcessor.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageProcessor.java
index 5c7be69..0f22152 100644
--- a/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageProcessor.java
+++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageProcessor.java
@@ -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);
diff --git a/vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java b/vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
index e35c37d..aafd112 100644
--- a/vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
+++ b/vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
@@ -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;
}
diff --git a/vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java b/vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
index 0fdaa7d..0a1ad39 100644
--- a/vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
+++ b/vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
@@ -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);
+ }
}