Repository: cloudstack
Updated Branches:
  refs/heads/master 0642a6982 -> 35803805c


CLOUDSTACK-9491: incorrect parsing of device list to find ethernet index of 
plugged NIC

  In VmwareResource, findRouterEthDeviceIndex() method find ethernet interface 
index given
  the mac address. This method is used, once a nic is plugged to determine 
ethernet interface.
  "/proc/sys/net/ipv4/conf" from the VR and looped through the devices to find 
the right
  ethernet interface. However current logic read it once, and loops through the 
device list.
  Its observerd device may not show up '/proc/sys/net/ipv4/conf' immediatly 
once NIC is plugged
  in the VM from vCenter.Fix ensured, while waiting for 15 sec in the loop, 
read the latest
  content from /proc/sys/net/ipv4/conf, so that right device list is processed.


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

Branch: refs/heads/master
Commit: b449351a9f464cfeec90660ccc4ab8f7e547a27c
Parents: fcee71f
Author: Murali Reddy <[email protected]>
Authored: Fri Oct 28 17:50:36 2016 +0530
Committer: Murali Reddy <[email protected]>
Committed: Fri Oct 28 17:50:36 2016 +0530

----------------------------------------------------------------------
 .../hypervisor/vmware/resource/VmwareResource.java    | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b449351a/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 238ba3e..abd5f3b 100644
--- 
a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ 
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -831,18 +831,19 @@ public class VmwareResource implements 
StoragePoolResource, ServerResource, Vmwa
         VmwareManager mgr = 
getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
 
         s_logger.info("findRouterEthDeviceIndex. mac: " + mac);
-
-        // TODO : this is a temporary very inefficient solution, will refactor 
it later
-        Pair<Boolean, String> result = SshHelper.sshExecute(routerIp, 
DefaultDomRSshPort, "root", mgr.getSystemVMKeyFile(), null, "ls 
/proc/sys/net/ipv4/conf");
+        ArrayList<String> skipInterfaces = new 
ArrayList<String>(Arrays.asList("all", "default", "lo"));
 
         // when we dynamically plug in a new NIC into virtual router, it may 
take time to show up in guest OS
         // we use a waiting loop here as a workaround to synchronize 
activities in systems
         long startTick = System.currentTimeMillis();
         while (System.currentTimeMillis() - startTick < 15000) {
+
+            // TODO : this is a temporary very inefficient solution, will 
refactor it later
+            Pair<Boolean, String> result = SshHelper.sshExecute(routerIp, 
DefaultDomRSshPort, "root", mgr.getSystemVMKeyFile(), null, "ls 
/proc/sys/net/ipv4/conf");
             if (result.first()) {
                 String[] tokens = result.second().split("\\s+");
                 for (String token : tokens) {
-                    if (!("all".equalsIgnoreCase(token) || 
"default".equalsIgnoreCase(token) || "lo".equalsIgnoreCase(token))) {
+                    if (!(skipInterfaces.contains(token))) {
                         String cmd = String.format("ip address show %s | grep 
link/ether | sed -e 's/^[ \t]*//' | cut -d' ' -f2", token);
 
                         if (s_logger.isDebugEnabled())
@@ -853,8 +854,11 @@ public class VmwareResource implements 
StoragePoolResource, ServerResource, Vmwa
                         if (s_logger.isDebugEnabled())
                             s_logger.debug("result: " + result2.first() + ", 
output: " + result2.second());
 
-                        if (result2.first() && 
result2.second().trim().equalsIgnoreCase(mac.trim()))
+                        if (result2.first() && 
result2.second().trim().equalsIgnoreCase(mac.trim())) {
                             return Integer.parseInt(token.substring(3));
+                        } else {
+                            skipInterfaces.add(token);
+                        }
                     }
                 }
             }

Reply via email to