Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

clean up CloudStack metadata (zone, pod, cluster, host details) for vm (kvm) unmanage operation. #12127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pavanaravapalli wants to merge 1 commit into apache:main
base: main
Choose a base branch
Loading
from pavanaravapalli:remove-libvirt-metadata-unmanaged-kvm-vm
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,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) {
Expand Down Expand Up @@ -503,6 +504,10 @@ public void setMetadata(VirtualMachineMetadataTO metadata) {
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);
Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,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;
Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class UnmanageInstanceCommand extends Command {
boolean executeInSequence = false;
VirtualMachineTO vm;
boolean isConfigDriveAttached;
boolean isLibvirtMetadataCleanUpEnabled;

@Override
public boolean executeInSequence() {
Expand Down Expand Up @@ -58,4 +59,10 @@ public boolean isConfigDriveAttached() {
public void setConfigDriveAttached(boolean configDriveAttached) {
isConfigDriveAttached = configDriveAttached;
}

public boolean isLibvirtMetadataCleanupEnabled() {return isLibvirtMetadataCleanUpEnabled;}

public void setLibvirtMetadataCleanup(boolean libvirtMetadataCleanUp) {
isLibvirtMetadataCleanUpEnabled = libvirtMetadataCleanUp;
}
}
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2091,6 +2091,8 @@ Long persistDomainForKVM(VMInstanceVO vm, Long paramHostId) {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3014,7 +3014,8 @@ private void configureVM(VirtualMachineTO vmTO, LibvirtVMDef vm, Map<String, Str
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -3037,7 +3037,8 @@ public ConfigKey<?>[] getConfigKeys() {
ThreadsOnMSToImportVMwareVMFiles,
ThreadsOnKVMHostToImportVMwareVMFiles,
ConvertVmwareInstanceToKvmExtraParamsAllowed,
ConvertVmwareInstanceToKvmExtraParamsAllowedList
ConvertVmwareInstanceToKvmExtraParamsAllowedList,
VmUnmanageLibvirtMetadataCleanup
};
}
}
Loading

AltStyle によって変換されたページ (->オリジナル) /