Pearl1594 commented on a change in pull request #5985:
URL: https://github.com/apache/cloudstack/pull/5985#discussion_r807837440
##########
File path:
plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java
##########
@@ -1622,6 +1589,83 @@ private ExecutionResult
prepareNetworkElementCommand(IpAssocCommand cmd) {
return new ExecutionResult(true, null);
}
+ private ExecutionResult cleanupNetworkElementCommand(IpAssocCommand cmd) {
+ VmwareContext context = getServiceContext();
+ try {
+ VmwareHypervisorHost hyperHost = getHyperHost(context);
+ IpAddressTO[] ips = cmd.getIpAddresses();
+ String routerName =
cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
+
+ VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(routerName);
+ // command may sometimes be redirected to a wrong host, we relax
+ // the check and will try to find it within datacenter
+ if (vmMo == null) {
+ if (hyperHost instanceof HostMO) {
+ final DatacenterMO dcMo = new DatacenterMO(context,
hyperHost.getHyperHostDatacenter());
+ vmMo = dcMo.findVm(routerName);
+ }
+ }
+
+ if (vmMo == null) {
+ String msg = String.format("Router %s no longer exists to
execute IPAssoc command ", routerName);
+ s_logger.error(msg);
+ throw new Exception(msg);
+ }
+ final String lastIp =
cmd.getAccessDetail(NetworkElementCommand.NETWORK_PUB_LAST_IP);
+ if (ips.length == 1 && !ips[0].isAdd()) {
Review comment:
@weizhouapache we only unplug the nic if it is there is only 1 IP on the
NIC / last IP right? In that case is it required to loop through all the IPs?
sorry, I probably am missing something..
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]