cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prachida...@apache.org
Subject [27/50] [abbrv] git commit: refs/heads/affinity_groups - Re-basing with latest master.
Date Thu, 14 Mar 2013 22:35:17 GMT
Re-basing with latest master.

CLOUDSTACK-657 VMware vNetwork Distributed Virtual Switch support in CloudStack

This is 2nd patch for feature 'Support for VMware dvSwitch in CloudStack'.

This patch introduces 2 new global configuration parameters
"vmware.use.dvswitch" - Enable dvswitch functionality.
"vmware.ports.per.dvportgroup" - Default number of ports per Vmware dvPortGroup.

This patch introduces 4 optional parameters to AddCluster API
guestvswitchtype - Type of vSwitch to use for guest traffic
guestvswitchname - Name of vSwitch to use for guest traffic
publicvswitchtype - Type of vSwitch to use for public traffic
publicvswitchname - Name of vSwitch to use for public traffic

Signed-off-by: Sateesh Chodapuneedi <sateesh@apache.org>


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

Branch: refs/heads/affinity_groups
Commit: 56f0da1e5ea963c1d614891cea51241dc4b5db50
Parents: f3f3b9c
Author: sateesh <sateesh.chodapuneedi@citrix.com>
Authored: Tue Feb 26 14:33:28 2013 +0530
Committer: Prachi Damle <prachi@cloud.com>
Committed: Thu Mar 14 15:13:04 2013 -0700

----------------------------------------------------------------------
 .../org/apache/cloudstack/api/ApiConstants.java    |    5 +-
 .../api/command/admin/cluster/AddClusterCmd.java   |   28 +++++
 server/src/com/cloud/configuration/Config.java     |    7 +-
 .../src/com/cloud/upgrade/dao/Upgrade410to420.java |   88 +++++++++++++-
 4 files changed, 116 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/56f0da1e/api/src/org/apache/cloudstack/api/ApiConstants.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java
index 2a09de8..a26b468 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -360,7 +360,10 @@ public class ApiConstants {
     public static final String CUSTOM_DISK_OFF_MAX_SIZE = "customdiskofferingmaxsize";
     public static final String DEFAULT_ZONE_ID = "defaultzoneid";
     public static final String GUID = "guid";
-
+    public static final String VSWITCH_TYPE_GUEST_TRAFFIC = "guestvswitchtype";
+    public static final String VSWITCH_TYPE_PUBLIC_TRAFFIC = "publicvswitchtype";
+    public static final String VSWITCH_NAME_GUEST_TRAFFIC = "guestvswitchname";
+    public static final String VSWITCH_NAME_PUBLIC_TRAFFIC = "publicvswitchname";
     public static final String EXTERNAL_SWITCH_MGMT_DEVICE_ID = "vsmdeviceid";
     public static final String EXTERNAL_SWITCH_MGMT_DEVICE_NAME = "vsmdevicename";
     public static final String EXTERNAL_SWITCH_MGMT_DEVICE_STATE = "vsmdevicestate";

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/56f0da1e/api/src/org/apache/cloudstack/api/command/admin/cluster/AddClusterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/cluster/AddClusterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/cluster/AddClusterCmd.java
index 7b1cd06..d55ccd7 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/cluster/AddClusterCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/cluster/AddClusterCmd.java
@@ -91,6 +91,34 @@ public class AddClusterCmd extends BaseCmd {
     @Parameter(name = ApiConstants.MEMORY_OVERCOMMIT_RATIO, type = CommandType.STRING, required
= false ,description = "value of the default ram overcommit ratio, defaults to 1")
     private String  memoryovercommitratio;
 
+    @Parameter(name = ApiConstants.VSWITCH_TYPE_GUEST_TRAFFIC, type = CommandType.STRING,
required = false, description = "Type of virtual switch used for guest traffic in the cluster.
Allowed values are, vmwaresvs (for VMware standard vSwitch) and vmwaredvs (for VMware distributed
vSwitch)")
+    private String vSwitchTypeGuestTraffic;
+
+    @Parameter(name = ApiConstants.VSWITCH_TYPE_PUBLIC_TRAFFIC, type = CommandType.STRING,
required = false, description = "Type of virtual switch used for public traffic in the cluster.
Allowed values are, vmwaresvs (for VMware standard vSwitch) and vmwaredvs (for VMware distributed
vSwitch)")
+    private String vSwitchTypePublicTraffic;
+
+    @Parameter(name = ApiConstants.VSWITCH_TYPE_GUEST_TRAFFIC, type = CommandType.STRING,
required = false, description = "Name of virtual switch used for guest traffic in the cluster.
This would override zone wide traffic label setting.")
+    private String vSwitchNameGuestTraffic;
+
+    @Parameter(name = ApiConstants.VSWITCH_TYPE_PUBLIC_TRAFFIC, type = CommandType.STRING,
required = false, description = "Name of virtual switch used for public traffic in the cluster.
 This would override zone wide traffic label setting.")
+    private String vSwitchNamePublicTraffic;
+
+    public String getVSwitchTypeGuestTraffic() {
+        return vSwitchTypeGuestTraffic;
+    }
+
+    public String getVSwitchTypePublicTraffic() {
+        return vSwitchTypePublicTraffic;
+    }
+
+    public String getVSwitchNameGuestTraffic() {
+        return vSwitchNameGuestTraffic;
+    }
+
+    public String getVSwitchNamePublicTraffic() {
+        return vSwitchNamePublicTraffic;
+    }
+
     public String getVSMIpaddress() {
         return vsmipaddress;
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/56f0da1e/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java
index b6d49bc..8a75a96 100755
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -252,11 +252,10 @@ public enum Config {
     XenGuestNetwork("Hidden", ManagementServer.class, String.class, "xen.guest.network.device",
null, "Specify for guest network name label", null),
     XenMaxNics("Advanced", AgentManager.class, Integer.class, "xen.nics.max", "7", "Maximum
allowed nics for Vms created on Xen", null),
     // VMware
-    VmwarePrivateNetworkVSwitch("Hidden", ManagementServer.class, String.class, "vmware.private.vswitch",
null, "Specify the vSwitch on host for private network", null),
-    VmwarePublicNetworkVSwitch("Hidden", ManagementServer.class, String.class, "vmware.public.vswitch",
null, "Specify the vSwitch on host for public network", null),
-    VmwareGuestNetworkVSwitch("Hidden", ManagementServer.class, String.class, "vmware.guest.vswitch",
null, "Specify the vSwitch on host for guest network", null),
     VmwareUseNexusVSwitch("Network", ManagementServer.class, Boolean.class, "vmware.use.nexus.vswitch",
"false", "Enable/Disable Cisco Nexus 1000v vSwitch in VMware environment", null),
-                            VmwareCreateFullClone("Advanced", ManagementServer.class, Boolean.class,
"vmware.create.full.clone", "false", "If set to true, creates guest VMs as full clones on
ESX", null),
+    VmwareUseDVSwitch("Network", ManagementServer.class, Boolean.class, "vmware.use.dvswitch",
"false", "Enable/Disable Nexus/Vmware dvSwitch in VMware environment", null),
+    VmwarePortsPerDVPortGroup("Network", ManagementServer.class, Integer.class, "vmware.ports.per.dvportgroup",
"256", "Default number of ports per Vmware dvPortGroup in VMware environment", null),
+    VmwareCreateFullClone("Advanced", ManagementServer.class, Boolean.class, "vmware.create.full.clone",
"false", "If set to true, creates guest VMs as full clones on ESX", null),
     VmwareServiceConsole("Advanced", ManagementServer.class, String.class, "vmware.service.console",
"Service Console", "Specify the service console network name(for ESX hosts)", null),
     VmwareManagementPortGroup("Advanced", ManagementServer.class, String.class, "vmware.management.portgroup",
"Management Network", "Specify the management network name(for ESXi hosts)", null),
     VmwareAdditionalVncPortRangeStart("Advanced", ManagementServer.class, Integer.class,
"vmware.additional.vnc.portrange.start", "50000", "Start port number of additional VNC port
range", null),

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/56f0da1e/server/src/com/cloud/upgrade/dao/Upgrade410to420.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/upgrade/dao/Upgrade410to420.java b/server/src/com/cloud/upgrade/dao/Upgrade410to420.java
index 9000e15..db562b1 100644
--- a/server/src/com/cloud/upgrade/dao/Upgrade410to420.java
+++ b/server/src/com/cloud/upgrade/dao/Upgrade410to420.java
@@ -59,10 +59,11 @@ public class Upgrade410to420 implements DbUpgrade {
 
 	@Override
 	public void performDataMigration(Connection conn) {
-	    PreparedStatement sql = null;
-	    try {
-	        sql = conn.prepareStatement("update vm_template set image_data_store_id = 1 where
type = 'SYSTEM' or type = 'BUILTIN'");
-	        sql.executeUpdate();
+        upgradeVmwareLabels(conn);
+        PreparedStatement sql = null;
+        try {
+            sql = conn.prepareStatement("update vm_template set image_data_store_id = 1 where
type = 'SYSTEM' or type = 'BUILTIN'");
+            sql.executeUpdate();
         } catch (SQLException e) {
             throw new CloudRuntimeException("Failed to upgrade vm template data store uuid:
" + e.toString());
         } finally {
@@ -73,7 +74,7 @@ public class Upgrade410to420 implements DbUpgrade {
                 }
             }
         }
-	}
+    }
 
 	@Override
 	public File[] getCleanupScripts() {
@@ -83,5 +84,78 @@ public class Upgrade410to420 implements DbUpgrade {
         }
 
         return new File[] { new File(script) };
-	    }
-    }
\ No newline at end of file
+    }
+
+    private String getNewLabel(ResultSet rs, String oldParamValue) {
+        int separatorIndex;
+        String oldGuestLabel;
+        String newGuestLabel = oldParamValue;
+        try {
+            // No need to iterate because the global param setting applies to all physical
networks irrespective of traffic type
+            if (rs.next()) {
+                oldGuestLabel = rs.getString("vmware_network_label");
+                // guestLabel is in format [[<VSWITCHNAME>],VLANID]
+                separatorIndex = oldGuestLabel.indexOf(",");
+                if(separatorIndex > -1) {
+                    newGuestLabel += oldGuestLabel.substring(separatorIndex);
+                }
+            }
+        } catch (SQLException e) {
+            s_logger.error(new CloudRuntimeException("Failed to read vmware_network_label
: " + e));
+        } finally {
+            try {
+                if (rs != null) {
+                    rs.close();
+                }
+            } catch (SQLException e) {
+            }
+        }
+        return newGuestLabel;
+    }
+
+    private void upgradeVmwareLabels(Connection conn) {
+        PreparedStatement pstmt = null;
+        ResultSet rsParams = null;
+        ResultSet rsLabel = null;
+        String newLabel;
+        String trafficType = null;
+        String trafficTypeVswitchParam;
+        String trafficTypeVswitchParamValue;
+
+        try {
+            // update the existing vmware traffic labels
+            pstmt = conn.prepareStatement("select name,value from `cloud`.`configuration`
where category='Hidden' and value is not NULL and name REGEXP 'vmware\\.*\\.vswitch';");
+            rsParams = pstmt.executeQuery();
+            while (rsParams.next()) {
+                trafficTypeVswitchParam = rsParams.getString("name");
+                trafficTypeVswitchParamValue = rsParams.getString("value");
+                // When upgraded from 4.0 to 4.1 update physical network traffic label with
trafficTypeVswitchParam
+                if (trafficTypeVswitchParam.equals("vmware.private.vswitch")) {
+                    trafficType = "Management"; //TODO(sateesh): Ignore storage traffic,
as required physical network already implemented, anything else tobe done?
+                } else if (trafficTypeVswitchParam.equals("vmware.public.vswitch")) {
+                    trafficType = "Public";
+                } else if (trafficTypeVswitchParam.equals("vmware.guest.vswitch")) {
+                    trafficType = "Guest";
+                }
+                s_logger.debug("Updating vmware label for " + trafficType + " traffic. Update
SQL statement is " + pstmt);
+                pstmt = conn.prepareStatement("select physical_network_id, traffic_type,
vmware_network_label from physical_network_traffic_types where vmware_network_label is not
NULL and traffic_type='" + trafficType + "';");
+                rsLabel = pstmt.executeQuery();
+                newLabel = getNewLabel(rsLabel, trafficTypeVswitchParamValue);
+                pstmt = conn.prepareStatement("update physical_network_traffic_types set
vmware_network_label = " + newLabel + " where traffic_type = '" + trafficType + "' and vmware_network_label
is not NULL;");
+                pstmt.executeUpdate();
+            }
+        } catch (SQLException e) {
+            throw new CloudRuntimeException("Unable to set vmware traffic labels ", e);
+        } finally {
+            try {
+                if (rsParams != null) {
+                    rsParams.close();
+                }
+                if (pstmt != null) {
+                    pstmt.close();
+                }
+            } catch (SQLException e) {
+            }
+        }
+    }
+}


Mime
View raw message