Summary: Allow for same vlan num on different physical NICs

Detail: A previous bug in the database schema did not allow the same vlan num
to exist on separate physical networks, even though this is possible and should
be allowed. To fix this, the code was changed to also disallow the same vlan
num on different physical networks, to avoid hitting the database constraint.
The database constraint has now been changed to allow only one of a vlan num
per physical nic per data center, so different physical nics can reuse vlan
numbers. This fix adjusts the code to match by removing the old fix.

BUG-ID: CLOUDSTACK-686
Signed-off-by: Marcus Sorensen <marcus@betterservers.com> 1358881555 -0700
This commit is contained in:
Marcus Sorensen 2013-01-22 12:05:55 -07:00
parent 22e70f2c8e
commit 2e14cf5b57
1 changed files with 0 additions and 24 deletions

View File

@ -1814,9 +1814,6 @@ public class NetworkServiceImpl implements NetworkService, Manager {
throw new InvalidParameterValueException("Please specify valid integers for the vlan range.");
}
//check for vnet conflicts with other physical network(s) in the zone
checkGuestVnetsConflicts(zoneId, vnetStart, vnetEnd, null);
if ((vnetStart > vnetEnd) || (vnetStart < 0) || (vnetEnd > 4096)) {
s_logger.warn("Invalid vnet range: start range:" + vnetStart + " end range:" + vnetEnd);
throw new InvalidParameterValueException("Vnet range should be between 0-4096 and start range should be lesser than or equal to end range");
@ -1995,9 +1992,6 @@ public class NetworkServiceImpl implements NetworkService, Manager {
throw new InvalidParameterValueException("Vnet range has to be" + rangeMessage + " and start range should be lesser than or equal to stop range");
}
//check if new vnet conflicts with vnet ranges of other physical networks
checkGuestVnetsConflicts(network.getDataCenterId(), newStartVnet, newEndVnet, network.getId());
if (physicalNetworkHasAllocatedVnets(network.getDataCenterId(), network.getId())) {
String[] existingRange = network.getVnet().split("-");
int existingStartVnet = Integer.parseInt(existingRange[0]);
@ -2042,24 +2036,6 @@ public class NetworkServiceImpl implements NetworkService, Manager {
return network;
}
protected void checkGuestVnetsConflicts(long zoneId, int newStartVnet, int newEndVnet, Long pNtwkIdToSkip) {
List<? extends PhysicalNetwork> pNtwks = _physicalNetworkDao.listByZone(zoneId);
for (PhysicalNetwork pNtwk : pNtwks) {
// skip my own network and networks that don't have vnet range set
if ((pNtwk.getVnet() == null || pNtwk.getVnet().isEmpty()) || (pNtwkIdToSkip != null && pNtwkIdToSkip == pNtwk.getId())) {
continue;
}
String[] existingRange = pNtwk.getVnet().split("-");
int startVnet = Integer.parseInt(existingRange[0]);
int endVnet = Integer.parseInt(existingRange[1]);
if ((newStartVnet >= startVnet && newStartVnet <= endVnet)
|| (newEndVnet <= endVnet && newEndVnet >= startVnet)) {
throw new InvalidParameterValueException("Vnet range for physical network conflicts with another " +
"physical network's vnet in the zone");
}
}
}
private boolean physicalNetworkHasAllocatedVnets(long zoneId, long physicalNetworkId) {
return !_dcDao.listAllocatedVnets(physicalNetworkId).isEmpty();
}