mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-17 02:53:18 +01:00
[ASFCS40]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 Conflicts: server/src/com/cloud/network/NetworkManagerImpl.java server/src/com/cloud/vm/UserVmManagerImpl.java
This commit is contained in:
parent
aec6b4af48
commit
a08ae8e42c
@ -225,8 +225,6 @@ public interface NetworkManager extends NetworkService {
|
|||||||
|
|
||||||
List<Long> listNetworkOfferingsForUpgrade(long networkId);
|
List<Long> listNetworkOfferingsForUpgrade(long networkId);
|
||||||
|
|
||||||
PhysicalNetwork translateZoneIdToPhysicalNetwork(long zoneId);
|
|
||||||
|
|
||||||
boolean isSecurityGroupSupportedInNetwork(Network network);
|
boolean isSecurityGroupSupportedInNetwork(Network network);
|
||||||
|
|
||||||
boolean isProviderSupportServiceInNetwork(long networkId, Service service, Provider provider);
|
boolean isProviderSupportServiceInNetwork(long networkId, Service service, Provider provider);
|
||||||
|
|||||||
@ -4180,9 +4180,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
throw new CloudRuntimeException("Unable to find network offering with availability=" +
|
throw new CloudRuntimeException("Unable to find network offering with availability=" +
|
||||||
Availability.Required + " to automatically create the network as part of createVlanIpRange");
|
Availability.Required + " to automatically create the network as part of createVlanIpRange");
|
||||||
}
|
}
|
||||||
PhysicalNetwork physicalNetwork = translateZoneIdToPhysicalNetwork(zoneId);
|
|
||||||
|
|
||||||
if (requiredOfferings.get(0).getState() == NetworkOffering.State.Enabled) {
|
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=" +
|
s_logger.debug("Creating network for account " + owner + " from the network offering id=" +
|
||||||
requiredOfferings.get(0).getId() + " as a part of createVlanIpRange process");
|
requiredOfferings.get(0).getId() + " as a part of createVlanIpRange process");
|
||||||
guestNetwork = createGuestNetwork(requiredOfferings.get(0).getId(), owner.getAccountName() + "-network"
|
guestNetwork = createGuestNetwork(requiredOfferings.get(0).getId(), owner.getAccountName() + "-network"
|
||||||
@ -5876,20 +5882,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public PhysicalNetwork translateZoneIdToPhysicalNetwork(long zoneId) {
|
|
||||||
List<PhysicalNetworkVO> pNtwks = _physicalNetworkDao.listByZone(zoneId);
|
|
||||||
if (pNtwks.isEmpty()) {
|
|
||||||
throw new InvalidParameterValueException("Unable to find physical network in zone id=" + zoneId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pNtwks.size() > 1) {
|
|
||||||
throw new InvalidParameterValueException("More than one physical networks exist in zone id=" + zoneId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return pNtwks.get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Long> listNetworkOfferingsForUpgrade(long networkId) {
|
public List<Long> listNetworkOfferingsForUpgrade(long networkId) {
|
||||||
List<Long> offeringsToReturn = new ArrayList<Long>();
|
List<Long> offeringsToReturn = new ArrayList<Long>();
|
||||||
|
|||||||
@ -2206,13 +2206,18 @@ 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");
|
throw new InvalidParameterValueException("Unable to find network offering with availability=" + Availability.Required + " to automatically create the network as a part of vm creation");
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicalNetwork physicalNetwork = _networkMgr.translateZoneIdToPhysicalNetwork(zone.getId());
|
|
||||||
if (requiredOfferings.get(0).getState() == NetworkOffering.State.Enabled) {
|
if (requiredOfferings.get(0).getState() == NetworkOffering.State.Enabled) {
|
||||||
// get Virtual networks
|
// get Virtual networks
|
||||||
List<NetworkVO> virtualNetworks = _networkMgr.listNetworksForAccount(owner.getId(), zone.getId(), Network.GuestType.Isolated);
|
List<NetworkVO> virtualNetworks = _networkMgr.listNetworksForAccount(owner.getId(), zone.getId(), Network.GuestType.Isolated);
|
||||||
|
|
||||||
if (virtualNetworks.isEmpty()) {
|
if (virtualNetworks.isEmpty()) {
|
||||||
s_logger.debug("Creating network for account " + owner + " from the network offering id=" + requiredOfferings.get(0).getId() + " as a part of deployVM process");
|
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(),
|
Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(),
|
||||||
owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, null,
|
owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, null,
|
||||||
null, null, owner, null, physicalNetwork, zone.getId(), ACLType.Account, null, null);
|
null, null, owner, null, physicalNetwork, zone.getId(), ACLType.Account, null, null);
|
||||||
@ -3593,13 +3598,18 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
throw new InvalidParameterValueException("Unable to find network offering with availability="
|
throw new InvalidParameterValueException("Unable to find network offering with availability="
|
||||||
+ Availability.Required + " to automatically create the network as a part of vm creation");
|
+ Availability.Required + " to automatically create the network as a part of vm creation");
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicalNetwork physicalNetwork = _networkMgr.translateZoneIdToPhysicalNetwork(zone.getId());
|
|
||||||
if (requiredOfferings.get(0).getState() == NetworkOffering.State.Enabled) {
|
if (requiredOfferings.get(0).getState() == NetworkOffering.State.Enabled) {
|
||||||
// get Virtual networks
|
// get Virtual networks
|
||||||
List<NetworkVO> virtualNetworks = _networkMgr.listNetworksForAccount(newAccount.getId(), zone.getId(), Network.GuestType.Isolated);
|
List<NetworkVO> virtualNetworks = _networkMgr.listNetworksForAccount(newAccount.getId(), zone.getId(), Network.GuestType.Isolated);
|
||||||
|
|
||||||
if (virtualNetworks.isEmpty()) {
|
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=" +
|
s_logger.debug("Creating network for account " + newAccount + " from the network offering id=" +
|
||||||
requiredOfferings.get(0).getId() + " as a part of deployVM process");
|
requiredOfferings.get(0).getId() + " as a part of deployVM process");
|
||||||
Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(),
|
Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user