mirror of https://github.com/apache/cloudstack.git
CS-15586: Public Vlan for an account fails in case of multiple Physical networks
Changes: - Since Now a zone can have multiple physical networks, we need to find the physical network Id from the networkOffering's tag and zoneId and trafficType when we create a guest network
This commit is contained in:
parent
9dfe6eaf53
commit
c581d8b820
|
|
@ -220,8 +220,6 @@ public interface NetworkManager extends NetworkService {
|
|||
|
||||
List<Long> listNetworkOfferingsForUpgrade(long networkId);
|
||||
|
||||
PhysicalNetwork translateZoneIdToPhysicalNetwork(long zoneId);
|
||||
|
||||
boolean isSecurityGroupSupportedInNetwork(Network network);
|
||||
|
||||
boolean isProviderSupportServiceInNetwork(long networkId, Service service, Provider provider);
|
||||
|
|
|
|||
|
|
@ -4254,9 +4254,16 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
throw new CloudRuntimeException("Unable to find network offering with availability=" +
|
||||
Availability.Required + " to automatically create the network as part of createVlanIpRange");
|
||||
}
|
||||
PhysicalNetwork physicalNetwork = translateZoneIdToPhysicalNetwork(zoneId);
|
||||
|
||||
if (requiredOfferings.get(0).getState() == NetworkOffering.State.Enabled) {
|
||||
|
||||
long physicalNetworkId = findPhysicalNetworkId(zoneId, requiredOfferings.get(0).getTags(), requiredOfferings.get(0).getTrafficType());
|
||||
// Validate physical network
|
||||
PhysicalNetwork physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId);
|
||||
if (physicalNetwork == null) {
|
||||
throw new InvalidParameterValueException("Unable to find physical network with id: "+physicalNetworkId + " and tag: " +requiredOfferings.get(0).getTags());
|
||||
}
|
||||
|
||||
s_logger.debug("Creating network for account " + owner + " from the network offering id=" +
|
||||
requiredOfferings.get(0).getId() + " as a part of createVlanIpRange process");
|
||||
guestNetwork = createGuestNetwork(requiredOfferings.get(0).getId(), owner.getAccountName() + "-network"
|
||||
|
|
@ -5946,24 +5953,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhysicalNetwork translateZoneIdToPhysicalNetwork(long zoneId) {
|
||||
List<PhysicalNetworkVO> pNtwks = _physicalNetworkDao.listByZone(zoneId);
|
||||
if (pNtwks.isEmpty()) {
|
||||
List<IdentityProxy> idList = new ArrayList<IdentityProxy>();
|
||||
idList.add(new IdentityProxy("data_center", zoneId, "zoneId"));
|
||||
throw new InvalidParameterValueException("Unable to find physical network in zone with specified id", idList);
|
||||
}
|
||||
|
||||
if (pNtwks.size() > 1) {
|
||||
List<IdentityProxy> idList = new ArrayList<IdentityProxy>();
|
||||
idList.add(new IdentityProxy("data_center", zoneId, "zoneId"));
|
||||
throw new InvalidParameterValueException("More than one physical networks exist in zone with specified id", idList);
|
||||
}
|
||||
|
||||
return pNtwks.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> listNetworkOfferingsForUpgrade(long networkId) {
|
||||
List<Long> offeringsToReturn = new ArrayList<Long>();
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ import com.cloud.network.dao.IPAddressDao;
|
|||
import com.cloud.network.dao.LoadBalancerVMMapDao;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkServiceMapDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkDao;
|
||||
import com.cloud.network.element.UserDataServiceProvider;
|
||||
import com.cloud.network.lb.LoadBalancingRulesManager;
|
||||
import com.cloud.network.rules.FirewallManager;
|
||||
|
|
@ -345,6 +346,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
VolumeHostDao _volumeHostDao;
|
||||
@Inject
|
||||
ResourceTagDao _resourceTagDao;
|
||||
@Inject
|
||||
PhysicalNetworkDao _physicalNetworkDao;
|
||||
|
||||
protected ScheduledExecutorService _executor = null;
|
||||
protected int _expungeInterval;
|
||||
|
|
@ -2187,12 +2190,17 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
throw new InvalidParameterValueException("Unable to find network offering with availability=" + Availability.Required + " to automatically create the network as a part of vm creation", null);
|
||||
}
|
||||
|
||||
PhysicalNetwork physicalNetwork = _networkMgr.translateZoneIdToPhysicalNetwork(zone.getId());
|
||||
if (requiredOfferings.get(0).getState() == NetworkOffering.State.Enabled) {
|
||||
// get Virtual networks
|
||||
List<NetworkVO> virtualNetworks = _networkMgr.listNetworksForAccount(owner.getId(), zone.getId(), Network.GuestType.Isolated);
|
||||
|
||||
if (virtualNetworks.isEmpty()) {
|
||||
long physicalNetworkId = _networkMgr.findPhysicalNetworkId(zone.getId(), requiredOfferings.get(0).getTags(), requiredOfferings.get(0).getTrafficType());
|
||||
// Validate physical network
|
||||
PhysicalNetwork physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId);
|
||||
if (physicalNetwork == null) {
|
||||
throw new InvalidParameterValueException("Unable to find physical network with id: "+physicalNetworkId + " and tag: " +requiredOfferings.get(0).getTags());
|
||||
}
|
||||
s_logger.debug("Creating network for account " + owner + " from the network offering id=" +
|
||||
requiredOfferings.get(0).getId() + " as a part of deployVM process");
|
||||
Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(),
|
||||
|
|
@ -3558,12 +3566,18 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
+ Availability.Required + " to automatically create the network as a part of vm creation", null);
|
||||
}
|
||||
|
||||
PhysicalNetwork physicalNetwork = _networkMgr.translateZoneIdToPhysicalNetwork(zone.getId());
|
||||
if (requiredOfferings.get(0).getState() == NetworkOffering.State.Enabled) {
|
||||
// get Virtual networks
|
||||
List<NetworkVO> virtualNetworks = _networkMgr.listNetworksForAccount(newAccount.getId(), zone.getId(), Network.GuestType.Isolated);
|
||||
|
||||
if (virtualNetworks.isEmpty()) {
|
||||
long physicalNetworkId = _networkMgr.findPhysicalNetworkId(zone.getId(), requiredOfferings.get(0).getTags(), requiredOfferings.get(0).getTrafficType());
|
||||
// Validate physical network
|
||||
PhysicalNetwork physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId);
|
||||
if (physicalNetwork == null) {
|
||||
throw new InvalidParameterValueException("Unable to find physical network with id: "+physicalNetworkId + " and tag: " +requiredOfferings.get(0).getTags());
|
||||
}
|
||||
|
||||
s_logger.debug("Creating network for account " + newAccount + " from the network offering id=" +
|
||||
requiredOfferings.get(0).getId() + " as a part of deployVM process");
|
||||
Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue