weizhouapache commented on a change in pull request #5985:
URL: https://github.com/apache/cloudstack/pull/5985#discussion_r807950988
##########
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:
@Pearl1594
from what I have tested, it is good to use `if (ips.length == 1 &&
!ips[0].isAdd()) {`
I do not know if there are special case that, there are multiple ip address
in IpAssocCommand and we need to remove one of them.
--
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]