bug 13250: don't check physicalNetworkId for control traffic type

This commit is contained in:
Alena Prokharchyk 2012-01-24 12:49:30 -08:00
parent b4c5f07fca
commit 0e13bb58e3
2 changed files with 53 additions and 18 deletions

View File

@ -4973,7 +4973,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (pNtwkId == null) {
throw new InvalidParameterValueException("Unable to find physical network which match the tags " + tag);
}
return pNtwkId;
} else {
return pNtwks.get(0).getId();
@ -5207,6 +5206,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
@Override
public boolean isSecurityGroupSupportedInNetwork(Network network) {
if (network.getTrafficType() != TrafficType.Guest) {
s_logger.trace("Security group can be enabled for Guest networks only; and network " + network + " has a diff traffic type");
return false;
}
Long physicalNetworkId = network.getPhysicalNetworkId();
//physical network id can be null in Guest Network in Basic zone, so locate the physical network
@ -5558,6 +5562,34 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
@Override
public String getNetworkTag(HypervisorType hType, Network network) {
//no network tag for control traffic type
if (network.getTrafficType() == TrafficType.Control) {
return null;
}
Long physicalNetworkId = null;
if (network.getTrafficType() != TrafficType.Guest) {
physicalNetworkId = getNonGuestNetworkPhysicalNetworkId(network);
} else {
NetworkOffering offering = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
physicalNetworkId = findPhysicalNetworkId(network.getDataCenterId(), offering.getTags());
}
if (physicalNetworkId == null) {
assert (false) : "Can't get the physical network";
s_logger.warn("Can't get the physical network");
return null;
}
return _pNTrafficTypeDao.getNetworkTag(physicalNetworkId, network.getTrafficType(), hType);
}
protected Long getNonGuestNetworkPhysicalNetworkId(Network network) {
//no physical network for control traffic type
if (network.getTrafficType() == TrafficType.Control) {
return null;
}
Long physicalNetworkId = network.getPhysicalNetworkId();
if (physicalNetworkId == null) {
@ -5575,15 +5607,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
}
}
if (physicalNetworkId == null) {
assert (false) : "Can't get the physical network";
s_logger.warn("Can't get the physical network");
return null;
}
return _pNTrafficTypeDao.getNetworkTag(physicalNetworkId, network.getTrafficType(), hType);
}
return physicalNetworkId;
}
@Override
@ -5681,9 +5706,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
@Override
public Long getPhysicalNetworkId(Network network) {
if (network.getTrafficType() != TrafficType.Guest) {
return getNonGuestNetworkPhysicalNetworkId(network);
}
Long physicalNetworkId = network.getPhysicalNetworkId();
NetworkOffering offering = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
if (physicalNetworkId == null) {
physicalNetworkId = findPhysicalNetworkId(network.getDataCenterId(), null);
physicalNetworkId = findPhysicalNetworkId(network.getDataCenterId(), offering.getTags());
}
return physicalNetworkId;
}

View File

@ -108,7 +108,12 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
@Inject VirtualRouterProviderDao _vrProviderDao;
protected boolean canHandle(Network network, Service service) {
if (!_networkMgr.isProviderEnabledInPhysicalNetwork(_networkMgr.getPhysicalNetworkId(network), "VirtualRouter")) {
Long physicalNetworkId = _networkMgr.getPhysicalNetworkId(network);
if (physicalNetworkId == null) {
return false;
}
if (!_networkMgr.isProviderEnabledInPhysicalNetwork(physicalNetworkId, "VirtualRouter")) {
return false;
}
@ -144,7 +149,11 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
@Override
public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
if (!canHandle(network, null)) {
if (vm.getType() != VirtualMachine.Type.User) {
return false;
}
if (!canHandle(network, null)) {
return false;
}
@ -154,11 +163,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
}
if (!_networkMgr.isProviderEnabledInPhysicalNetwork(_networkMgr.getPhysicalNetworkId(network), "VirtualRouter")) {
return false;
}
if (vm.getType() != VirtualMachine.Type.User) {
return false;
}
}
@SuppressWarnings("unchecked")
VirtualMachineProfile<UserVm> uservm = (VirtualMachineProfile<UserVm>)vm;