mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
[Vmware] Add missing condition to cleanup nics if there are commands to send (#5449)
* [Vmware] Add missing condition to cleanup nics if there are commands to send
This commit is contained in:
parent
939ef4ec4b
commit
8228ecee43
@ -636,19 +636,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
|
||||
// send hypervisor-dependent commands before removing
|
||||
final List<Command> finalizeExpungeCommands = hvGuru.finalizeExpunge(vm);
|
||||
if (finalizeExpungeCommands != null && finalizeExpungeCommands.size() > 0) {
|
||||
if (CollectionUtils.isNotEmpty(finalizeExpungeCommands) || CollectionUtils.isNotEmpty(nicExpungeCommands)) {
|
||||
if (hostId != null) {
|
||||
final Commands cmds = new Commands(Command.OnError.Stop);
|
||||
for (final Command command : finalizeExpungeCommands) {
|
||||
command.setBypassHostMaintenance(expungeCommandCanBypassHostMaintenance(vm));
|
||||
cmds.addCommand(command);
|
||||
}
|
||||
if (nicExpungeCommands != null) {
|
||||
for (final Command command : nicExpungeCommands) {
|
||||
command.setBypassHostMaintenance(expungeCommandCanBypassHostMaintenance(vm));
|
||||
cmds.addCommand(command);
|
||||
}
|
||||
}
|
||||
addAllExpungeCommandsFromList(finalizeExpungeCommands, cmds, vm);
|
||||
addAllExpungeCommandsFromList(nicExpungeCommands, cmds, vm);
|
||||
_agentMgr.send(hostId, cmds);
|
||||
if (!cmds.isSuccessful()) {
|
||||
for (final Answer answer : cmds.getAnswers()) {
|
||||
@ -667,6 +659,19 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
|
||||
}
|
||||
|
||||
private void addAllExpungeCommandsFromList(List<Command> cmdList, Commands cmds, VMInstanceVO vm) {
|
||||
if (CollectionUtils.isEmpty(cmdList)) {
|
||||
return;
|
||||
}
|
||||
for (final Command command : cmdList) {
|
||||
command.setBypassHostMaintenance(expungeCommandCanBypassHostMaintenance(vm));
|
||||
if (s_logger.isTraceEnabled()) {
|
||||
s_logger.trace(String.format("Adding expunge command [%s] for VM [%s]", command.toString(), vm.toString()));
|
||||
}
|
||||
cmds.addCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
private List<Map<String, String>> getTargets(Long hostId, long vmId) {
|
||||
List<Map<String, String>> targets = new ArrayList<>();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user