You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by su...@apache.org on 2021/09/17 16:25:23 UTC
[cloudstack] branch main updated: [Vmware] Add missing condition to
cleanup nics if there are commands to send (#5449)
This is an automated email from the ASF dual-hosted git repository.
sureshanaparti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/main by this push:
new 8228ece [Vmware] Add missing condition to cleanup nics if there are commands to send (#5449)
8228ece is described below
commit 8228ecee43b5a16e8a811f4c289725260c5e74ef
Author: Nicolas Vazquez <ni...@gmail.com>
AuthorDate: Fri Sep 17 13:24:52 2021 -0300
[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
---
.../com/cloud/vm/VirtualMachineManagerImpl.java | 27 +++++++++++++---------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java
index 69c5cc6..d45b920 100755
--- a/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -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<>();