mirror of https://github.com/apache/cloudstack.git
Merge 6632809e88 into b7d4df0a11
This commit is contained in:
commit
e24cfcf2f2
|
|
@ -91,6 +91,7 @@ public class VirtualMachineTO {
|
|||
private String metadataManufacturer;
|
||||
private String metadataProductName;
|
||||
private VirtualMachineMetadataTO metadata;
|
||||
private boolean excludeMetadata;
|
||||
|
||||
public VirtualMachineTO(long id, String instanceName, VirtualMachine.Type type, int cpus, Integer speed, long minRam, long maxRam, BootloaderType bootloader,
|
||||
String os, boolean enableHA, boolean limitCpuUse, String vncPassword) {
|
||||
|
|
@ -509,6 +510,10 @@ public class VirtualMachineTO {
|
|||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
public boolean isExcludeMetadata() { return excludeMetadata; }
|
||||
|
||||
public void setExcludeMetadata(boolean excludeMetadata) { this.excludeMetadata = excludeMetadata;}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("VM {id: \"%s\", name: \"%s\", uuid: \"%s\", type: \"%s\"}", id, name, uuid, type);
|
||||
|
|
|
|||
|
|
@ -71,6 +71,14 @@ public interface UnmanagedVMsManager extends VmImportService, UnmanageVMService,
|
|||
true,
|
||||
ConfigKey.Scope.Global,
|
||||
null);
|
||||
ConfigKey<Boolean> VmUnmanageLibvirtMetadataCleanup = new ConfigKey<>(Boolean.class,
|
||||
"vm.unmanage.libvirt.metadata.cleanup",
|
||||
"Advanced",
|
||||
"true",
|
||||
"Specifies whether metadata should be cleaned up when a VM is unmanaged, applicable to the KVM hypervisor.",
|
||||
true,
|
||||
ConfigKey.Scope.Global,
|
||||
null);
|
||||
|
||||
static boolean isSupported(Hypervisor.HypervisorType hypervisorType) {
|
||||
return hypervisorType == VMware || hypervisorType == KVM;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ public class UnmanageInstanceCommand extends Command {
|
|||
boolean executeInSequence = false;
|
||||
VirtualMachineTO vm;
|
||||
boolean isConfigDriveAttached;
|
||||
boolean isLibvirtMetadataCleanUpEnabled;
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
|
|
@ -58,4 +59,10 @@ public class UnmanageInstanceCommand extends Command {
|
|||
public void setConfigDriveAttached(boolean configDriveAttached) {
|
||||
isConfigDriveAttached = configDriveAttached;
|
||||
}
|
||||
|
||||
public boolean isLibvirtMetadataCleanupEnabled() {return isLibvirtMetadataCleanUpEnabled;}
|
||||
|
||||
public void setLibvirtMetadataCleanup(boolean libvirtMetadataCleanUp) {
|
||||
isLibvirtMetadataCleanUpEnabled = libvirtMetadataCleanUp;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2147,6 +2147,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
unmanageInstanceCommand = new UnmanageInstanceCommand(vmName);
|
||||
unmanageInstanceCommand.setConfigDriveAttached(vmInstanceDetailsDao.findDetail(vm.getId(), VmDetailConstants.CONFIG_DRIVE_LOCATION) != null);
|
||||
}
|
||||
boolean isEnabled = UnmanagedVMsManager.VmUnmanageLibvirtMetadataCleanup.value();
|
||||
unmanageInstanceCommand.setLibvirtMetadataCleanup(isEnabled);
|
||||
|
||||
logger.debug("Selected host ID: {} to persist domain XML for Instance: {}.", agentHostId, vmName);
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -3160,7 +3160,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
vm.addComp(createDevicesDef(vmTO, guest, vcpus, isUefiEnabled));
|
||||
|
||||
MetadataDef metaDef;
|
||||
if ((metaDef = createMetadataDef(vmTO)) != null) {
|
||||
boolean excludeMetadata = vmTO.isExcludeMetadata();
|
||||
if (!excludeMetadata && (metaDef = createMetadataDef(vmTO)) != null) {
|
||||
vm.addComp(metaDef);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,9 @@ public final class LibvirtUnmanageInstanceCommandWrapper extends CommandWrapper<
|
|||
public Answer execute(final UnmanageInstanceCommand command, final LibvirtComputingResource libvirtComputingResource) {
|
||||
String instanceName = command.getInstanceName();
|
||||
VirtualMachineTO vmSpec = command.getVm();
|
||||
if (command.isLibvirtMetadataCleanupEnabled()) {
|
||||
vmSpec.setExcludeMetadata(true);
|
||||
}
|
||||
final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtUtilitiesHelper();
|
||||
logger.debug("Attempting to unmanage KVM instance: {}", instanceName);
|
||||
Domain dom = null;
|
||||
|
|
|
|||
|
|
@ -3177,7 +3177,8 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager {
|
|||
ThreadsOnMSToImportVMwareVMFiles,
|
||||
ThreadsOnKVMHostToImportVMwareVMFiles,
|
||||
ConvertVmwareInstanceToKvmExtraParamsAllowed,
|
||||
ConvertVmwareInstanceToKvmExtraParamsAllowedList
|
||||
ConvertVmwareInstanceToKvmExtraParamsAllowedList,
|
||||
VmUnmanageLibvirtMetadataCleanup
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue