Fixed vm-templates not being removed from primary storage with storag… (#4389)

* Fixed vm-templates not being removed from primary storage with storage garbage collection

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

Co-authored-by: sureshanaparti <12028987+sureshanaparti@users.noreply.github.com>

* Var name

Co-authored-by: sureshanaparti <12028987+sureshanaparti@users.noreply.github.com>
This commit is contained in:
Spaceman1984 2020-10-12 12:24:12 +02:00 committed by GitHub
parent d3be14d4c8
commit 1bbb29d034
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 1 deletions

View File

@ -6785,6 +6785,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
if (s_logger.isInfoEnabled()) {
s_logger.info("Destroy template volume " + vol.getPath());
}
vmMo.markAsVirtualMachine(hyperHost.getHyperHostOwnerResourcePool(), hyperHost.getMor());
vmMo.destroy();
} else {
if (s_logger.isInfoEnabled()) {

View File

@ -541,7 +541,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
// the same template may be deployed with multiple copies at per-datastore per-host basis,
// save the original template name from CloudStack DB as the UUID to associate them.
vmMo.setCustomFieldValue(CustomFieldConstants.CLOUD_UUID, templateName);
if (vAppConfig == null) {
if (vAppConfig == null || (vAppConfig.getProperty().size() == 0)) {
vmMo.markAsTemplate();
}
} else {

View File

@ -406,6 +406,10 @@ public class VirtualMachineMO extends BaseMO {
_context.getService().markAsTemplate(_mor);
}
public void markAsVirtualMachine(ManagedObjectReference resourcePool, ManagedObjectReference host) throws Exception {
_context.getService().markAsVirtualMachine(_mor, resourcePool, host);
}
public boolean isTemplate() throws Exception {
VirtualMachineConfigInfo configInfo = getConfigInfo();
return configInfo.isTemplate();