CLOUDSTACK-2045: [Multiple IPs Per Nic] This feature is not working well

in case of networks with external devices after GC

add an exception for networks that use external networking devices and has
secondary guest IP's allocated. On network GC, when network goes through
implement phase a new vlan is allocated, based on the acquired VLAN id cidr
of the network is decided in case of external networking case. While NIC
uses reservation strategy 'Start' which ensures that new primary ip is
allocated for the NiC from the new CIDR. Secondary IP's have hardcoded
IP's in  network rules. So prevent network GC.
This commit is contained in:
Murali Reddy 2013-06-28 12:21:56 +05:30
parent 6da29c4cde
commit 0f40cfbea8
5 changed files with 37 additions and 0 deletions

View File

@ -276,4 +276,6 @@ public interface NetworkModel {
Nic getNicInNetworkIncludingRemoved(long vmId, long networkId);
boolean getExecuteInSeqNtwkElmtCmd();
boolean isNetworkReadyForGc(long networkId);
}

View File

@ -2975,6 +2975,11 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
List<Long> networkIds = _networksDao.findNetworksToGarbageCollect();
for (Long networkId : networkIds) {
if (!_networkModel.isNetworkReadyForGc(networkId)) {
continue;
}
Long time = _lastNetworkIdsToFree.remove(networkId);
if (time == null) {
if (s_logger.isDebugEnabled()) {

View File

@ -2126,4 +2126,25 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
public boolean getExecuteInSeqNtwkElmtCmd() {
return _executeInSequenceNtwkElmtCmd;
}
@Override
public boolean isNetworkReadyForGc(long networkId) {
Network network = getNetwork(networkId);
List<Long> networkIds = _networksDao.findNetworksToGarbageCollect();
List<String> secondaryIps = _nicSecondaryIpDao.listSecondaryIpAddressInNetwork(networkId);
if (!networkIds.contains(networkId)) {
return false;
}
// add an exception for networks that use external networking devices and has secondary guest IP's allocated.
// On network GC, when network goes through implement phase a new vlan is allocated, based on the acquired VLAN
// id cidr of the network is decided in case of external networking case. While NIC uses reservation strategy 'Start'
// which ensures that new primary ip is allocated for the NiC from the new CIDR. Secondary IP's have hardcoded IP's in
// network rules. So prevent network GC.
if (secondaryIps != null && !secondaryIps.isEmpty() &&
networkIsConfiguredForExternalNetworking(network.getDataCenterId(), networkId)) {
}
return true;
}
}

View File

@ -885,4 +885,9 @@ public class MockNetworkModelImpl extends ManagerBase implements NetworkModel {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isNetworkReadyForGc(long networkId) {
return true;
}
}

View File

@ -898,4 +898,8 @@ public class MockNetworkModelImpl extends ManagerBase implements NetworkModel {
return false;
}
@Override
public boolean isNetworkReadyForGc(long networkId) {
return true;
}
}