incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [8/11] Phase 1 of Nicira integration
Date Fri, 13 Jul 2012 20:52:12 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/79c7da07/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java b/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java
index daa35e3..24d24f8 100644
--- a/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java
@@ -20,9 +20,12 @@ import java.util.List;
 
 import javax.ejb.Local;
 
+import org.apache.log4j.Logger;
+
 import com.cloud.configuration.Config;
 import com.cloud.configuration.dao.ConfigurationDao;
 import com.cloud.dc.DataCenter;
+import com.cloud.dc.DataCenter.NetworkType;
 import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.deploy.DeployDestination;
 import com.cloud.deploy.DeploymentPlan;
@@ -32,10 +35,13 @@ import com.cloud.event.EventVO;
 import com.cloud.exception.InsufficientAddressCapacityException;
 import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
 import com.cloud.network.Network;
+import com.cloud.network.Network.GuestType;
 import com.cloud.network.Network.State;
 import com.cloud.network.NetworkManager;
 import com.cloud.network.NetworkVO;
 import com.cloud.network.Networks.BroadcastDomainType;
+import com.cloud.network.PhysicalNetwork;
+import com.cloud.network.PhysicalNetwork.IsolationMethod;
 import com.cloud.network.PhysicalNetworkVO;
 import com.cloud.network.dao.NetworkDao;
 import com.cloud.network.dao.PhysicalNetworkDao;
@@ -58,7 +64,7 @@ import com.cloud.vm.VirtualMachineProfile;
 
 @Local(value = NetworkGuru.class)
 public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
-
+    private static final Logger s_logger = Logger.getLogger(ExternalGuestNetworkGuru.class);
     @Inject
     NetworkManager _networkMgr;
     @Inject
@@ -68,7 +74,27 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
     @Inject
     PortForwardingRulesDao _pfRulesDao;
 
-    //FIXME: why there is dependency on Ovs tunnel manager.
+    public ExternalGuestNetworkGuru() {
+        super();
+        _isolationMethods = new IsolationMethod[] { IsolationMethod.GRE, IsolationMethod.L3,
IsolationMethod.VLAN };
+    }
+
+    protected boolean canHandle(NetworkOffering offering,
+            final NetworkType networkType, final PhysicalNetwork physicalNetwork) {
+        // This guru handles only Guest Isolated network that supports Source
+        // nat service
+        if (networkType == NetworkType.Advanced
+                && isMyTrafficType(offering.getTrafficType())
+                && offering.getGuestType() == Network.GuestType.Isolated
+                && isMyIsolationMethod(physicalNetwork)) {
+            return true;
+        } else {
+            s_logger.trace("We only take care of Guest networks of type   "
+                    + GuestType.Isolated + " in zone of type "
+                    + NetworkType.Advanced);
+            return false;
+        }
+    }    
     
     @Override
     public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified,
Account owner) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/79c7da07/server/src/com/cloud/network/guru/GuestNetworkGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/guru/GuestNetworkGuru.java b/server/src/com/cloud/network/guru/GuestNetworkGuru.java
index 33cfb2d..cd5f551 100755
--- a/server/src/com/cloud/network/guru/GuestNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/GuestNetworkGuru.java
@@ -16,6 +16,7 @@
 // under the License.
 package com.cloud.network.guru;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Random;
 import java.util.Set;
@@ -46,9 +47,12 @@ import com.cloud.network.Network.State;
 import com.cloud.network.NetworkManager;
 import com.cloud.network.NetworkProfile;
 import com.cloud.network.NetworkVO;
+import com.cloud.network.PhysicalNetwork;
+import com.cloud.network.PhysicalNetwork.IsolationMethod;
 import com.cloud.network.PhysicalNetworkVO;
 import com.cloud.network.Networks.AddressFormat;
 import com.cloud.network.Networks.BroadcastDomainType;
+import com.cloud.network.Networks.IsolationType;
 import com.cloud.network.Networks.Mode;
 import com.cloud.network.Networks.TrafficType;
 import com.cloud.network.dao.IPAddressDao;
@@ -72,7 +76,7 @@ import com.cloud.vm.VirtualMachineProfile;
 import com.cloud.vm.dao.NicDao;
 
 @Local(value = NetworkGuru.class)
-public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
+public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
     private static final Logger s_logger = Logger.getLogger(GuestNetworkGuru.class);
     @Inject
     protected NetworkManager _networkMgr;
@@ -93,12 +97,16 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru
{
     Random _rand = new Random(System.currentTimeMillis());
 
     private static final TrafficType[] _trafficTypes = {TrafficType.Guest};
-
+    
+    // Currently set to anything except STT for the Nicira integration.
+    protected IsolationMethod[] _isolationMethods;
+    
     String _defaultGateway;
     String _defaultCidr;
 
     protected GuestNetworkGuru() {
         super();
+        _isolationMethods = null;
     }
 
     @Override
@@ -115,21 +123,54 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru
{
     public TrafficType[] getSupportedTrafficType() {
         return _trafficTypes;
     }
+    
+    public boolean isMyIsolationMethod(PhysicalNetwork physicalNetwork) {
+        if (physicalNetwork == null) {
+            // Can't tell if there is no physical network
+            return false;
+        }
+        
+        List<String> methods = physicalNetwork.getIsolationMethods();
+        if (methods.isEmpty()) {
+            // The empty isolation method is assumed to be VLAN
+            s_logger.debug("Empty physical isolation type for physical network " + physicalNetwork.getUuid());
+            methods = new ArrayList<String>(1);
+            methods.add("VLAN");
+        }
+        
+        for (IsolationMethod m : _isolationMethods) {
+            if (methods.contains(m.toString())) {
+                return true;
+            }
+        }
+        
+        return false;
+    }
+    
+    public IsolationMethod[] getIsolationMethods() {
+        return _isolationMethods;
+    }
 
-    protected boolean canHandle(NetworkOffering offering, DataCenter dc) {
+    protected abstract boolean canHandle(NetworkOffering offering, final NetworkType networkType,
PhysicalNetwork physicalNetwork);
+/*    protected boolean canHandle(NetworkOffering offering, final NetworkType networkType,
final List<String> isolationMethods) {
         // This guru handles only Guest Isolated network that supports Source nat service
-        if (dc.getNetworkType() == NetworkType.Advanced && isMyTrafficType(offering.getTrafficType())
&& offering.getGuestType() == Network.GuestType.Isolated) {
+        if (networkType == NetworkType.Advanced 
+                && isMyTrafficType(offering.getTrafficType()) 
+                && offering.getGuestType() == Network.GuestType.Isolated
+                && isMyIsolationMethod(isolationMethods)) {
             return true;
         } else {
             s_logger.trace("We only take care of Guest networks of type   " + GuestType.Isolated
+ " in zone of type " + NetworkType.Advanced);
             return false;
         }
     }
-
+*/
     @Override
     public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified,
Account owner) {
         DataCenter dc = _dcDao.findById(plan.getDataCenterId());
-        if (!canHandle(offering, dc)) {
+        PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan.getPhysicalNetworkId());
+
+        if (!canHandle(offering, dc.getNetworkType(), physnet)) {
             return null;
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/79c7da07/server/src/com/cloud/server/StatsCollector.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/StatsCollector.java b/server/src/com/cloud/server/StatsCollector.java
index 389b728..29e4233 100755
--- a/server/src/com/cloud/server/StatsCollector.java
+++ b/server/src/com/cloud/server/StatsCollector.java
@@ -168,6 +168,7 @@ public class StatsCollector {
 		        sc.addAnd("type", SearchCriteria.Op.NEQ, Host.Type.SecondaryStorageVM.toString());
 		        sc.addAnd("type", SearchCriteria.Op.NEQ, Host.Type.ExternalFirewall.toString());
 		        sc.addAnd("type", SearchCriteria.Op.NEQ, Host.Type.ExternalLoadBalancer.toString());
+                sc.addAnd("type", SearchCriteria.Op.NEQ, Host.Type.L2Networking.toString());
 				ConcurrentHashMap<Long, HostStats> hostStats = new ConcurrentHashMap<Long, HostStats>();
 				List<HostVO> hosts = _hostDao.search(sc, null);
 				for (HostVO host : hosts)

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/79c7da07/setup/db/create-schema.sql
----------------------------------------------------------------------
diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql
index c2efb27..a15222a 100755
--- a/setup/db/create-schema.sql
+++ b/setup/db/create-schema.sql
@@ -137,6 +137,9 @@ DROP TABLE IF EXISTS `cloud`.`op_dc_storage_network_ip_address`;
 DROP TABLE IF EXISTS `cloud`.`cluster_vsm_map`;
 DROP TABLE IF EXISTS `cloud`.`virtual_supervisor_module`;
 DROP TABLE IF EXISTS `cloud`.`port_profile`;
+DROP TABLE IF EXISTS `cloud`,`external_nicira_nvp_devices`;
+DROP TABLE IF EXISTS `cloud`,`nicira_nvp_nic_map`;
+
 
 CREATE TABLE `cloud`.`version` (
   `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id',
@@ -2152,4 +2155,24 @@ CREATE TABLE `cloud`.`resource_tags` (
   ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 
+CREATE TABLE `cloud`.`external_nicira_nvp_devices` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `uuid` varchar(255) UNIQUE,
+  `physical_network_id` bigint unsigned NOT NULL COMMENT 'id of the physical network in to
which nicira nvp device is added',
+  `provider_name` varchar(255) NOT NULL COMMENT 'Service Provider name corresponding to this
nicira nvp device',
+  `device_name` varchar(255) NOT NULL COMMENT 'name of the nicira nvp device',
+  `host_id` bigint unsigned NOT NULL COMMENT 'host id coresponding to the external nicira
nvp device',
+  PRIMARY KEY (`id`),
+  CONSTRAINT `fk_external_nicira_nvp_devices__host_id` FOREIGN KEY (`host_id`) REFERENCES
`host`(`id`) ON DELETE CASCADE,
+  CONSTRAINT `fk_external_nicira_nvp_devices__physical_network_id` FOREIGN KEY (`physical_network_id`)
REFERENCES `physical_network`(`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`nicira_nvp_nic_map` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `logicalswitch` varchar(255) NOT NULL COMMENT 'nicira uuid of logical switch this port
is provisioned on',
+  `logicalswitchport` varchar(255) UNIQUE COMMENT 'nicira uuid of this logical switch port',
+  `nic` varchar(255) UNIQUE COMMENT 'cloudstack uuid of the nic connected to this logical
switch port',
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
 SET foreign_key_checks = 1;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/79c7da07/ui/scripts/ui-custom/zoneWizard.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui-custom/zoneWizard.js b/ui/scripts/ui-custom/zoneWizard.js
index 3928619..a94bf5b 100644
--- a/ui/scripts/ui-custom/zoneWizard.js
+++ b/ui/scripts/ui-custom/zoneWizard.js
@@ -596,7 +596,7 @@
 				}
 			});	
       //when OVS tunnel manager is used			
-      if(ovsTunnelManager == true) {	
+      //if(ovsTunnelManager == true) {    
 			  //Advanced zone supports 2 isolation method(VLAN, GRE), so show dropdown including the
2 options
 				if($wizard.find('.select-network-model input:radio[name=network-model]:checked').val()
== 'Advanced') { 
 					$nameField.append(
@@ -614,15 +614,20 @@
 								}).html('VLAN'),	
 								$('<option>').attr({
 									value: 'GRE'
-								}).html('GRE')	
+                                }).html('GRE'),
+                                                                $('<option>').attr({
+                                                                        value: 'STT'
+                                                                }).html('STT')
+
 							)
 						)
 					);
 				}
 				//Basic zone supports only 1 isolation method (L3), so there is no point showing dropdown.
-			}
-			//when OVS tunnel manager is not used, isolationmethods parameter in createPhysicalNetwork
API is ignored. So no showing dropdown.	
+//            }
+      //when OVS tunnel manager is not used, isolationmethods parameter in createPhysicalNetwork
API is ignored. So no showing dropdown.    
       //isolationmethods parameter has not been used by network gurus so far. By default(i.e.
when OVS tunnel manager is not used), networks are isolated with VLANs in Advanced zone, with
L3 in basic zone.
+      //No longer the case, as the Nicira stuff also depends on this now
 						
 			
       var $dropContainer = $('<div>').addClass('drop-container').append(

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/79c7da07/wscript_configure
----------------------------------------------------------------------
diff --git a/wscript_configure b/wscript_configure
index 0ccf40a..70fb163 100644
--- a/wscript_configure
+++ b/wscript_configure
@@ -288,7 +288,7 @@ depsclasspath = [ in_javadir(_basename(x)) for x in _glob(_join(conf.srcdir,"dep
 conf.env.DEPSCLASSPATH = pathsep.join(depsclasspath)
 
 # the MS classpath points to JARs required to run the management server
-msclasspath = [ in_javadir("%s-%s.jar"%(conf.env.PACKAGE,x)) for x in "utils api core server
server-extras core-extras vmware-base ovm dp-user-concentrated-pod dp-user-dispersing host-allocator-random
plugin-f5 plugin-netscaler plugin-ovs plugin-srx storage-allocator-random user-authenticator-ldap
user-authenticator-md5 user-authenticator-plaintext vmware xen".split() ]
+msclasspath = [ in_javadir("%s-%s.jar"%(conf.env.PACKAGE,x)) for x in "utils api core server
server-extras core-extras vmware-base ovm dp-user-concentrated-pod dp-user-dispersing host-allocator-random
plugin-f5 plugin-netscaler plugin-ovs plugin-srx storage-allocator-random user-authenticator-ldap
user-authenticator-md5 user-authenticator-plaintext vmware xen plugin-nicira-nvp".split()
]
 conf.env.MSCLASSPATH = pathsep.join(msclasspath)
 
 # the agent and simulator classpaths point to JARs required to run these two applications


Mime
View raw message