cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajeshbatt...@apache.org
Subject [4/6] git commit: updated refs/heads/master to 866cc41
Date Thu, 30 Apr 2015 09:11:52 GMT
CLOUDSTACK-8420: [Hyper-V] Fixed number format exception when untagged vlan is used for Hyper-V
setup Change the vlan data type to string from int and handled the untagged vlan cases
this closes #201


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

Branch: refs/heads/master
Commit: 48067e5ecde8dee9b1db9566fe3b18eafc6948a7
Parents: 7949caf
Author: Anshul Gangwar <anshul.gangwar@citrix.com>
Authored: Tue Apr 7 16:39:26 2015 +0530
Committer: Rajesh Battala <rajesh.battala@citrix.com>
Committed: Thu Apr 30 14:43:22 2015 +0530

----------------------------------------------------------------------
 .../com/cloud/agent/api/GetVmConfigAnswer.java  |  6 ++--
 .../agent/api/ModifyVmNicConfigCommand.java     |  8 ++---
 .../ServerResource/HypervResource/WmiCallsV2.cs | 12 ++++++++
 .../resource/HypervDirectConnectResource.java   | 31 +++++++++++---------
 4 files changed, 36 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48067e5e/core/src/com/cloud/agent/api/GetVmConfigAnswer.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/GetVmConfigAnswer.java b/core/src/com/cloud/agent/api/GetVmConfigAnswer.java
index d7b65f7..ffbd591 100644
--- a/core/src/com/cloud/agent/api/GetVmConfigAnswer.java
+++ b/core/src/com/cloud/agent/api/GetVmConfigAnswer.java
@@ -44,13 +44,13 @@ public class GetVmConfigAnswer extends Answer {
 
     public class NicDetails {
         String macAddress;
-        int vlanid;
+        String vlanid;
         boolean state;
 
         public NicDetails() {
         }
 
-        public NicDetails(String macAddress, int vlanid, boolean state) {
+        public NicDetails(String macAddress, String vlanid, boolean state) {
             this.macAddress = macAddress;
             this.vlanid = vlanid;
             this.state = state;
@@ -60,7 +60,7 @@ public class GetVmConfigAnswer extends Answer {
             return macAddress;
         }
 
-        public int getVlanid() {
+        public String getVlanid() {
             return vlanid;
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48067e5e/core/src/com/cloud/agent/api/ModifyVmNicConfigCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/ModifyVmNicConfigCommand.java b/core/src/com/cloud/agent/api/ModifyVmNicConfigCommand.java
index c7c54b8..635097d 100644
--- a/core/src/com/cloud/agent/api/ModifyVmNicConfigCommand.java
+++ b/core/src/com/cloud/agent/api/ModifyVmNicConfigCommand.java
@@ -22,7 +22,7 @@ package com.cloud.agent.api;
 
 public class ModifyVmNicConfigCommand extends Command {
     String vmName;
-    int vlan;
+    String vlan;
     String macAddress;
     int index;
     boolean enable;
@@ -31,19 +31,19 @@ public class ModifyVmNicConfigCommand extends Command {
     protected ModifyVmNicConfigCommand() {
     }
 
-    public ModifyVmNicConfigCommand(String vmName, int vlan, String macAddress) {
+    public ModifyVmNicConfigCommand(String vmName, String vlan, String macAddress) {
         this.vmName = vmName;
         this.vlan = vlan;
         this.macAddress = macAddress;
     }
 
-    public ModifyVmNicConfigCommand(String vmName, int vlan, int position) {
+    public ModifyVmNicConfigCommand(String vmName, String vlan, int position) {
         this.vmName = vmName;
         this.vlan = vlan;
         this.index = position;
     }
 
-    public ModifyVmNicConfigCommand(String vmName, int vlan, int position, boolean enable)
{
+    public ModifyVmNicConfigCommand(String vmName, String vlan, int position, boolean enable)
{
         this.vmName = vmName;
         this.vlan = vlan;
         this.index = position;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48067e5e/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
index f9b6e34..a83b6df 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
@@ -947,6 +947,12 @@ namespace HypervResource
 
             EthernetSwitchPortVlanSettingData vlanSettings = GetVlanSettings(ethernetConnections[index]);
 
+            if (vlanid.Equals("untagged", StringComparison.CurrentCultureIgnoreCase))
+            {
+                // recevied vlan is untagged, don't parse for the vlan in the isolation uri
+                vlanid = null;
+            }
+
             if (vlanSettings == null)
             {
                 // when modifying  nic to not connected dont create vlan
@@ -1105,6 +1111,12 @@ namespace HypervResource
             EthernetPortAllocationSettingData[] vmEthernetConnections = GetEthernetConnections(vm);
             EthernetSwitchPortVlanSettingData vlanSettings = GetVlanSettings(vmEthernetConnections[pos]);
 
+            if (vlanid.Equals("untagged", StringComparison.CurrentCultureIgnoreCase))
+            {
+                // recevied vlan is untagged, don't parse for the vlan in the isolation uri
+                vlanid = null;
+            }
+
             if (vlanSettings == null)
             {
                 // when modifying  nic to not connected dont create vlan

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48067e5e/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java
b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java
index 0c9fd30..9f9fcb4 100644
--- a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java
+++ b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java
@@ -578,7 +578,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
S
             if (BroadcastDomainType.getSchemeValue(broadcastUri) != BroadcastDomainType.Vlan)
{
                 throw new InternalErrorException("Unable to assign a public IP to a VIF on
network " + nic.getBroadcastUri());
             }
-            int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri));
+            String vlanId = BroadcastDomainType.getValue(broadcastUri);
             int publicNicInfo = -1;
             publicNicInfo = getVmFreeNicIndex(vmName);
             if (publicNicInfo > 0) {
@@ -608,11 +608,11 @@ public class HypervDirectConnectResource extends ServerResourceBase
implements S
             if (BroadcastDomainType.getSchemeValue(broadcastUri) != BroadcastDomainType.Vlan)
{
                 throw new InternalErrorException("Unable to unassign a public IP to a VIF
on network " + nic.getBroadcastUri());
             }
-            int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri));
+            String vlanId = BroadcastDomainType.getValue(broadcastUri);
             int publicNicInfo = -1;
             publicNicInfo = getVmNics(vmName, vlanId);
             if (publicNicInfo > 0) {
-                modifyNicVlan(vmName, 2, publicNicInfo, false, "");
+                modifyNicVlan(vmName, "2", publicNicInfo, false, "");
             }
             return new UnPlugNicAnswer(cmd, true, "success");
         } catch (Exception e) {
@@ -696,7 +696,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
S
                 if (BroadcastDomainType.getSchemeValue(broadcastUri) != BroadcastDomainType.Vlan)
{
                     throw new InternalErrorException("Unable to assign a public IP to a VIF
on network " + ip.getBroadcastUri());
                 }
-                int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri));
+                String vlanId = BroadcastDomainType.getValue(broadcastUri);
                 int publicNicInfo = -1;
                 publicNicInfo = getVmNics(routerName, vlanId);
 
@@ -744,7 +744,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
S
 
         try {
             URI broadcastUri = nic.getBroadcastUri();
-            int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri));
+            String vlanId = BroadcastDomainType.getValue(broadcastUri);
             int ethDeviceNum = getVmNics(domrName, vlanId);
             if (ethDeviceNum > 0) {
                 nic.setDeviceId(ethDeviceNum);
@@ -770,7 +770,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
S
                 if (BroadcastDomainType.getSchemeValue(broadcastUri) != BroadcastDomainType.Vlan)
{
                     throw new InternalErrorException("Invalid Broadcast URI " + ip.getBroadcastUri());
                 }
-                int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri));
+                String vlanId = BroadcastDomainType.getValue(broadcastUri);
                 int publicNicInfo = -1;
                 publicNicInfo = getVmNics(routerName, vlanId);
                 if (publicNicInfo < 0) {
@@ -798,7 +798,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
S
 
         try {
             String broadcastUri = pubIp.getBroadcastUri();
-            int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri));
+            String vlanId = BroadcastDomainType.getValue(broadcastUri);
             int ethDeviceNum = getVmNics(routerName, vlanId);
             if (ethDeviceNum > 0) {
                 pubIp.setNicDevId(ethDeviceNum);
@@ -820,7 +820,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
S
 
         try {
             URI broadcastUri = nic.getBroadcastUri();
-            int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri));
+            String vlanId = BroadcastDomainType.getValue(broadcastUri);
             int ethDeviceNum = getVmNics(routerName, vlanId);
             if (ethDeviceNum > 0) {
                 nic.setDeviceId(ethDeviceNum);
@@ -1845,10 +1845,13 @@ public class HypervDirectConnectResource extends ServerResourceBase
implements S
         return nicposition;
     }
 
-    protected int getVmNics(String vmName, int vlanid) {
+    protected int getVmNics(String vmName, String vlanid) {
         GetVmConfigCommand vmConfig = new GetVmConfigCommand(vmName);
         URI agentUri = null;
         int nicposition = -1;
+        if(vlanid.equalsIgnoreCase("untagged")) {
+            vlanid = "-1";
+        }
         try {
             String cmdName = GetVmConfigCommand.class.getName();
             agentUri =
@@ -1866,8 +1869,8 @@ public class HypervDirectConnectResource extends ServerResourceBase
implements S
             GetVmConfigAnswer ans = ((GetVmConfigAnswer)result[0]);
             List<NicDetails> nics = ans.getNics();
             for (NicDetails nic : nics) {
-                if (nic.getVlanid() == vlanid) {
-                    nicposition = nics.indexOf(nic);
+                nicposition++;
+                if (nicposition > 1 && nic.getVlanid().equals(vlanid)) {
                     break;
                 }
             }
@@ -1875,7 +1878,7 @@ public class HypervDirectConnectResource extends ServerResourceBase
implements S
         return nicposition;
     }
 
-    protected void modifyNicVlan(String vmName, int vlanId, String macAddress) {
+    protected void modifyNicVlan(String vmName, String vlanId, String macAddress) {
         ModifyVmNicConfigCommand modifynic = new ModifyVmNicConfigCommand(vmName, vlanId,
macAddress);
         URI agentUri = null;
         try {
@@ -1895,7 +1898,7 @@ public class HypervDirectConnectResource extends ServerResourceBase
implements S
         }
     }
 
-    protected void modifyNicVlan(String vmName, int vlanId, int pos, boolean enable, String
switchLabelName) {
+    protected void modifyNicVlan(String vmName, String vlanId, int pos, boolean enable, String
switchLabelName) {
         ModifyVmNicConfigCommand modifyNic = new ModifyVmNicConfigCommand(vmName, vlanId,
pos, enable);
         modifyNic.setSwitchLableName(switchLabelName);
         URI agentUri = null;
@@ -1923,7 +1926,7 @@ public class HypervDirectConnectResource extends ServerResourceBase
implements S
         if (BroadcastDomainType.getSchemeValue(broadcastUri) != BroadcastDomainType.Vlan)
{
             throw new InternalErrorException("Unable to assign a public IP to a VIF on network
" + broadcastId);
         }
-        int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri));
+        String vlanId = BroadcastDomainType.getValue(broadcastUri);
 
         int publicNicInfo = -1;
         publicNicInfo = getVmNics(vmName, vlanId);


Mime
View raw message