mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bugfix #3 apply ip dessociation before unplugging a nic so ip is marked as add:false in ips.json
This commit is contained in:
parent
6491a69d63
commit
f5ab87c153
@ -29,6 +29,8 @@ import org.apache.log4j.Logger;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.NetworkUsageCommand;
|
||||
import com.cloud.agent.manager.Commands;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
@ -53,6 +55,9 @@ import com.cloud.vm.NicVO;
|
||||
import com.cloud.vm.VirtualMachineManager;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
|
||||
import org.apache.cloudstack.network.topology.NetworkTopology;
|
||||
import org.apache.cloudstack.network.topology.NetworkTopologyContext;
|
||||
|
||||
public class NicPlugInOutRules extends RuleApplier {
|
||||
|
||||
private static final Logger s_logger = Logger.getLogger(NicPlugInOutRules.class);
|
||||
@ -77,6 +82,28 @@ public class NicPlugInOutRules extends RuleApplier {
|
||||
|
||||
NetworkModel networkModel = visitor.getVirtualNetworkApplianceFactory().getNetworkModel();
|
||||
VirtualMachineManager itMgr = visitor.getVirtualNetworkApplianceFactory().getItMgr();
|
||||
NicDao nicDao = visitor.getVirtualNetworkApplianceFactory().getNicDao();
|
||||
|
||||
// de-associate IPs before unplugging nics
|
||||
if (!nicsToUnplug.isEmpty()) {
|
||||
NetworkTopologyContext networkTopologyContext = visitor.getVirtualNetworkApplianceFactory().getNetworkTopologyContext();
|
||||
final DataCenterDao dcDao = visitor.getVirtualNetworkApplianceFactory().getDcDao();
|
||||
final DataCenterVO dcVO = dcDao.findById(router.getDataCenterId());
|
||||
final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(dcVO);
|
||||
|
||||
final String typeString = "vpc ip association before unplugging nics";
|
||||
final boolean isPodLevelException = false;
|
||||
final boolean failWhenDisconnect = false;
|
||||
final Long podId = null;
|
||||
final VpcIpAssociationRules ipAssociationRules = new VpcIpAssociationRules(_network, _ipAddresses);
|
||||
final boolean result = networkTopology.applyRules(_network, router, typeString, isPodLevelException, podId, failWhenDisconnect,
|
||||
new RuleApplierWrapper<RuleApplier>(ipAssociationRules));
|
||||
if (!result) {
|
||||
s_logger.warn("Failed to de-associate IPs before unplugging nics");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 1) Unplug the nics
|
||||
for (Entry<String, PublicIpAddress> entry : nicsToUnplug.entrySet()) {
|
||||
Network publicNtwk = null;
|
||||
|
||||
@ -43,6 +43,8 @@ import com.cloud.vm.dao.NicDao;
|
||||
import com.cloud.vm.dao.NicIpAliasDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
|
||||
import org.apache.cloudstack.network.topology.NetworkTopologyContext;
|
||||
|
||||
public class VirtualNetworkApplianceFactory {
|
||||
|
||||
@Inject
|
||||
@ -91,6 +93,9 @@ public class VirtualNetworkApplianceFactory {
|
||||
@Inject
|
||||
private NicProfileHelper _nicProfileHelper;
|
||||
|
||||
@Inject
|
||||
private NetworkTopologyContext _networkTopologyContext;
|
||||
|
||||
public NetworkModel getNetworkModel() {
|
||||
return _networkModel;
|
||||
}
|
||||
@ -174,4 +179,8 @@ public class VirtualNetworkApplianceFactory {
|
||||
public NicProfileHelper getNicProfileHelper() {
|
||||
return _nicProfileHelper;
|
||||
}
|
||||
}
|
||||
|
||||
public NetworkTopologyContext getNetworkTopologyContext() {
|
||||
return _networkTopologyContext;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user