From 2e14cf5b5772a6c19d3da0dfae71804200a76abe Mon Sep 17 00:00:00 2001 From: Marcus Sorensen Date: Tue, 22 Jan 2013 12:05:55 -0700 Subject: [PATCH] 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 1358881555 -0700 --- .../com/cloud/network/NetworkServiceImpl.java | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java index b05aece918e..7530e943116 100755 --- a/server/src/com/cloud/network/NetworkServiceImpl.java +++ b/server/src/com/cloud/network/NetworkServiceImpl.java @@ -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 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(); }