incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [1/2] git commit: CLOUDSTACK-573: check if external provider enabled, only when finalize the service/provider list for the network
Date Fri, 30 Nov 2012 21:14:58 GMT
Updated Branches:
  refs/heads/master 77f80ab72 -> 7857b1f62


CLOUDSTACK-573: check if external provider enabled, only when finalize the service/provider
list for the network


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

Branch: refs/heads/master
Commit: 7857b1f62ab905790e4dd96f6b19d7d67255b56c
Parents: 1aa4ad6
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Fri Nov 30 13:03:05 2012 -0800
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Fri Nov 30 13:07:01 2012 -0800

----------------------------------------------------------------------
 .../src/com/cloud/network/NetworkManagerImpl.java  |   31 ++++++++------
 .../network/element/VpcVirtualRouterElement.java   |    2 +-
 server/src/com/cloud/vm/UserVmManagerImpl.java     |    2 +-
 3 files changed, 20 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7857b1f6/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 ec0ca79..9841f10 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -23,6 +23,7 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Comparator;
 import java.util.Date;
 import java.util.HashMap;
@@ -1672,7 +1673,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService,
Manag
                 NetworkVO vo = new NetworkVO(id, network, offering.getId(), guru.getName(),
owner.getDomainId(), owner.getId(),
                         related, name, displayText, predefined.getNetworkDomain(), offering.getGuestType(),

                         plan.getDataCenterId(), plan.getPhysicalNetworkId(), aclType, offering.getSpecifyIpRanges(),
vpcId);
-                networks.add(_networksDao.persist(vo, vo.getGuestType() == Network.GuestType.Isolated,

+                networks.add(_networksDao.persist(vo, vo.getGuestType() == Network.GuestType.Isolated,
                         finalizeServicesAndProvidersForNetwork(offering, plan.getPhysicalNetworkId())));
 
                 if (domainId != null && aclType == ACLType.Domain) {
@@ -2664,10 +2665,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService,
Manag
             }
         }
 
-        if (cidr != null && networkOfferingIsConfiguredForExternalNetworking(networkOfferingId))
{
+        Collection<String> ntwkProviders = finalizeServicesAndProvidersForNetwork(ntwkOff,
physicalNetworkId).values();
+        if (cidr != null && providersConfiguredForExternalNetworking(ntwkProviders))
{
             throw new InvalidParameterValueException("Cannot specify CIDR when using network
offering with external devices!");
         }
 
+
         // Vlan is created in 2 cases - works in Advance zone only:
         // 1) GuestType is Shared
         // 2) GuestType is Isolated, but SourceNat service is disabled
@@ -4366,17 +4369,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService,
Manag
             return false;
         }
     }
-
-    public boolean networkOfferingIsConfiguredForExternalNetworking(long networkOfferingId)
{
-        boolean netscalerInNetworkOffering = isProviderForNetworkOffering(Network.Provider.Netscaler,
networkOfferingId);
-        boolean juniperInNetworkOffering = isProviderForNetworkOffering(Network.Provider.JuniperSRX,
networkOfferingId);
-        boolean f5InNetworkOffering = isProviderForNetworkOffering(Network.Provider.F5BigIp,
networkOfferingId);
-
-        if (netscalerInNetworkOffering || juniperInNetworkOffering || f5InNetworkOffering)
{
-            return true;
-        } else {
-            return false;
+    
+    public boolean providersConfiguredForExternalNetworking(Collection<String> providers)
{
+        for(String providerStr : providers){
+            Provider provider = Network.Provider.getProvider(providerStr);
+            if(provider.isExternal()){
+                return true;
+            }
         }
+        return false;
     }
 
     @Override
@@ -4651,7 +4652,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService,
Manag
             }
 
             if (networkOfferingId != oldNetworkOfferingId) {
-                if (networkOfferingIsConfiguredForExternalNetworking(networkOfferingId) !=
networkOfferingIsConfiguredForExternalNetworking(oldNetworkOfferingId)
+                NetworkOffering oldNtwkOff = _networkOfferingDao.findByIdIncludingRemoved(oldNetworkOfferingId);
+                Collection<String> newProviders = finalizeServicesAndProvidersForNetwork(networkOffering,
network.getPhysicalNetworkId()).values();
+                Collection<String> oldProviders = finalizeServicesAndProvidersForNetwork(oldNtwkOff,
network.getPhysicalNetworkId()).values();
+                
+                if (providersConfiguredForExternalNetworking(newProviders) != providersConfiguredForExternalNetworking(oldProviders)
                         && !changeCidr) {
                     throw new InvalidParameterValueException("Updating network failed since
guest CIDR needs to be changed!");
                 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7857b1f6/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/VpcVirtualRouterElement.java b/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
index 2a2d05a..0acc47d 100644
--- a/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
+++ b/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
@@ -304,7 +304,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements
Vpc
         Map<Capability, String> networkACLCapabilities = new HashMap<Capability,
String>();
         networkACLCapabilities.put(Capability.SupportedProtocols, "tcp,udp,icmp");
         capabilities.put(Service.NetworkACL, networkACLCapabilities);
-        
+
         return capabilities;
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7857b1f6/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 1af344f..837e3f7 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -2195,7 +2195,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService,
Manager
 
                 if (!(network.getTrafficType() == TrafficType.Guest && network.getGuestType()
== Network.GuestType.Shared)) {
                     throw new InvalidParameterValueException("Can specify only Shared Guest
networks when" +
-                    		" deploy vm in Advance Security Group enabled zone", null);
+                    		" deploy vm in Advance Security Group enabled zone");
                 }
 
                 // Perform account permission check


Mime
View raw message