You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by sa...@apache.org on 2013/06/25 16:54:32 UTC

[4/4] git commit: updated refs/heads/master-6-17-stable to 348f0ab

CLOUDSTACK-1767 VMWare DVS - cannot use untagged portgroups

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


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

Branch: refs/heads/master-6-17-stable
Commit: 348f0ab029b8515e40004deccd1045bc0983d41d
Parents: a7637cb
Author: Sateesh Chodapuneedi <sa...@apache.org>
Authored: Tue Jun 25 19:43:20 2013 +0530
Committer: Sateesh Chodapuneedi <sa...@apache.org>
Committed: Tue Jun 25 19:51:29 2013 +0530

----------------------------------------------------------------------
 .../vmware/manager/VmwareManagerImpl.java       |  9 ++--
 .../vmware/resource/VmwareResource.java         |  6 ++-
 .../com/cloud/network/VmwareTrafficLabel.java   |  5 ++-
 .../vmware/mo/HypervisorHostHelper.java         | 47 +++++++-------------
 4 files changed, 32 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/348f0ab0/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
index 1ded389..7455fc7 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
@@ -333,12 +333,15 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
         // prepare at least one network on the vswitch to enable OVF importing
         String vSwitchName = privateTrafficLabel;
         String vlanId = null;
+        String vlanToken;
         String[] tokens = privateTrafficLabel.split(",");
-        if(tokens.length == 2) {
+        if(tokens.length >= 2) {
             vSwitchName = tokens[0].trim();
-            vlanId = tokens[1].trim();
+            vlanToken = tokens[1].trim();
+            if (!vlanToken.isEmpty()) {
+                vlanId = vlanToken;
+            }
         }
-
         s_logger.info("Preparing network on host " + hostMo.getContext().toString() + " for " + privateTrafficLabel);
         HypervisorHostHelper.prepareNetwork(vSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/348f0ab0/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index 068192b..2a5597d 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -2938,7 +2938,11 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
             // If all 3 fields are mentioned then number of tokens would be 3.
             // If only <VSWITCH>,<VLANID> are mentioned then number of tokens would be 2.
             if(tokens.length == 2 || tokens.length == 3) {
-                return new Pair<String, String>(tokens[0], tokens[1]);
+                String vlanToken = tokens[1];
+                if (vlanToken.isEmpty()) {
+                    vlanToken = Vlan.UNTAGGED;
+                }
+                return new Pair<String, String>(tokens[0], vlanToken);
             } else {
                 return new Pair<String, String>(nicTo.getName(), Vlan.UNTAGGED);
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/348f0ab0/plugins/hypervisors/vmware/src/com/cloud/network/VmwareTrafficLabel.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/network/VmwareTrafficLabel.java b/plugins/hypervisors/vmware/src/com/cloud/network/VmwareTrafficLabel.java
index 90a4278..8d2890a 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/network/VmwareTrafficLabel.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/network/VmwareTrafficLabel.java
@@ -74,7 +74,10 @@ public class VmwareTrafficLabel implements TrafficLabel {
             _vSwitchName = tokens[VMWARE_LABEL_FIELD_INDEX_NAME].trim();
         }
         if (tokens.length > VMWARE_LABEL_FIELD_INDEX_VLANID) {
-            _vlanId = tokens[VMWARE_LABEL_FIELD_INDEX_VLANID].trim();
+            String vlanToken = tokens[VMWARE_LABEL_FIELD_INDEX_VLANID].trim();
+            if (!vlanToken.isEmpty()) {
+                _vlanId = vlanToken;
+            }
         }
         if (tokens.length > VMWARE_LABEL_FIELD_INDEX_VSWITCH_TYPE) {
             _vSwitchType = VirtualSwitchType.getType(tokens[VMWARE_LABEL_FIELD_INDEX_VSWITCH_TYPE].trim());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/348f0ab0/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
index 3739058..994fb30 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
@@ -461,7 +461,7 @@ public class HypervisorHostHelper {
             VmwareDistributedVirtualSwitchPvlanSpec pvlanSpec = null;
             //VMwareDVSPvlanConfigSpec pvlanSpec = null;
             DVSSecurityPolicy secPolicy;
-            VMwareDVSPortSetting dvsPortSetting;
+            VMwareDVSPortSetting dvsPortSetting = null;
             DVPortgroupConfigSpec dvPortGroupSpec;
             DVPortgroupConfigInfo dvPortgroupInfo;
             //DVSConfigInfo dvsInfo;
@@ -551,30 +551,21 @@ public class HypervisorHostHelper {
             }
 
             // Next, create the port group. For this, we need to create a VLAN spec.
-            if (vid == null) {
-                vlanSpec = createDVPortVlanSpec();
-            } else {
-                if (spvlanid == null) {
-                    // Create vlan spec.
-                    vlanSpec = createDVPortVlanIdSpec(vid);
-                } else {
-                    // Create a pvlan spec. The pvlan spec is different from the pvlan config spec
-                    // that we created earlier. The pvlan config spec is used to configure the switch
-                    // with a <primary vlanId, secondary vlanId> tuple. The pvlan spec is used
-                    // to configure a port group (i.e., a network) with a secondary vlan id. We don't
-                    // need to mention more than the secondary vlan id because one secondary vlan id
-                    // can be associated with only one primary vlan id. Give vCenter the secondary vlan id,
-                    // and it will find out the associated primary vlan id and do the rest of the
-                    // port group configuration.
-                    pvlanSpec = createDVPortPvlanIdSpec(spvlanid);
-            }
-            }
-
             // NOTE - VmwareDistributedVirtualSwitchPvlanSpec extends VmwareDistributedVirtualSwitchVlanSpec.
-            if (pvlanSpec != null) {
+            if (vid == null || spvlanid == null) {
+                vlanSpec = createDVPortVlanIdSpec(vid);
+                dvsPortSetting = createVmwareDVPortSettingSpec(shapingPolicy, secPolicy, vlanSpec);
+            } else if (spvlanid != null) {
+                // Create a pvlan spec. The pvlan spec is different from the pvlan config spec
+                // that we created earlier. The pvlan config spec is used to configure the switch
+                // with a <primary vlanId, secondary vlanId> tuple. The pvlan spec is used
+                // to configure a port group (i.e., a network) with a secondary vlan id. We don't
+                // need to mention more than the secondary vlan id because one secondary vlan id
+                // can be associated with only one primary vlan id. Give vCenter the secondary vlan id,
+                // and it will find out the associated primary vlan id and do the rest of the
+                // port group configuration.
+                pvlanSpec = createDVPortPvlanIdSpec(spvlanid);
                 dvsPortSetting = createVmwareDVPortSettingSpec(shapingPolicy, secPolicy, pvlanSpec);
-            } else {
-            dvsPortSetting = createVmwareDVPortSettingSpec(shapingPolicy, secPolicy, vlanSpec);
             }
 
             dvPortGroupSpec = createDvPortGroupSpec(networkName, dvsPortSetting, numPorts, autoExpandSupported);
@@ -804,17 +795,13 @@ public class HypervisorHostHelper {
         pvlanConfigSpec.setOperation(operation.toString());
         return pvlanConfigSpec;
     }
-    public static VmwareDistributedVirtualSwitchVlanIdSpec createDVPortVlanIdSpec(int vlanId) {
+
+    public static VmwareDistributedVirtualSwitchVlanIdSpec createDVPortVlanIdSpec(Integer vlanId) {
         VmwareDistributedVirtualSwitchVlanIdSpec vlanIdSpec = new VmwareDistributedVirtualSwitchVlanIdSpec();
-        vlanIdSpec.setVlanId(vlanId);
+        vlanIdSpec.setVlanId(vlanId == null ? 0 : vlanId.intValue());
         return vlanIdSpec;
     }
 
-    public static VmwareDistributedVirtualSwitchVlanSpec createDVPortVlanSpec() {
-        VmwareDistributedVirtualSwitchVlanSpec vlanSpec = new VmwareDistributedVirtualSwitchVlanSpec();
-        return vlanSpec;
-    }
-
     public static DVSSecurityPolicy createDVSSecurityPolicy() {
         DVSSecurityPolicy secPolicy = new DVSSecurityPolicy();
         BoolPolicy allow = new BoolPolicy();