cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prachida...@apache.org
Subject git commit: [ASFCS40]CS-15586: Public Vlan for an account fails in case of multiple Physical networks
Date Fri, 24 Aug 2012 01:18:45 GMT
Updated Branches:
  refs/heads/master aec6b4af4 -> a08ae8e42


[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


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/a08ae8e4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/a08ae8e4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/a08ae8e4

Branch: refs/heads/master
Commit: a08ae8e42c020d6bb9e37f194efe11e707b76dbb
Parents: aec6b4a
Author: Prachi Damle <prachi@cloud.com>
Authored: Thu Aug 23 18:17:03 2012 -0700
Committer: Prachi Damle <prachi@cloud.com>
Committed: Thu Aug 23 18:18:12 2012 -0700

----------------------------------------------------------------------
 server/src/com/cloud/network/NetworkManager.java   |    2 -
 .../src/com/cloud/network/NetworkManagerImpl.java  |   24 +++++----------
 server/src/com/cloud/vm/UserVmManagerImpl.java     |   18 ++++++++--
 3 files changed, 22 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a08ae8e4/server/src/com/cloud/network/NetworkManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkManager.java b/server/src/com/cloud/network/NetworkManager.java
index 74e9d88..592ae85 100755
--- a/server/src/com/cloud/network/NetworkManager.java
+++ b/server/src/com/cloud/network/NetworkManager.java
@@ -225,8 +225,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);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a08ae8e4/server/src/com/cloud/network/NetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java
index 873c982..817075e 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -4180,9 +4180,15 @@ 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"
@@ -5877,20 +5883,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
     public List<Long> listNetworkOfferingsForUpgrade(long networkId) {
         List<Long> offeringsToReturn = new ArrayList<Long>();
         NetworkOffering originalOffering = _configMgr.getNetworkOffering(getNetwork(networkId).getNetworkOfferingId());

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a08ae8e4/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index 3af50a1..7c9501f 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -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");
             }
 
-            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()) {
-                    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(),

                             owner.getAccountName() + "-network", owner.getAccountName() +
"-network", 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="
                     + 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)
{
                         // 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(),



Mime
View raw message