Vinzenz Feenstra has uploaded a new change for review.

Change subject: Filter out duplicated network adapters on Windows
......................................................................

Filter out duplicated network adapters on Windows

Change-Id: I19d4b91ea4fb6fcec6699ab6892ba1d6240919f6
Bug-Url: https://bugzilla.redhat.com/1113089
Signed-off-by: Vinzenz Feenstra <[email protected]>
(cherry picked from commit f531f482a2b2fa03ba7ec61449f5c3539a607a03)
---
M ovirt-guest-agent/GuestAgentWin32.py
1 file changed, 18 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-guest-agent 
refs/changes/24/30224/1

diff --git a/ovirt-guest-agent/GuestAgentWin32.py 
b/ovirt-guest-agent/GuestAgentWin32.py
index 910c910..8689a90 100644
--- a/ovirt-guest-agent/GuestAgentWin32.py
+++ b/ovirt-guest-agent/GuestAgentWin32.py
@@ -54,6 +54,23 @@
     return win32ts.WTSGetActiveConsoleSessionId()
 
 
+def merge_duplicate_interfaces(interfaces):
+    temp = {}
+    for interface in interfaces:
+        hw = interface['hw']
+        if hw in temp:
+            temp[hw]['inet'] += interface['inet']
+            temp[hw]['inet6'] += interface['inet6']
+        else:
+            temp[hw] = interface
+    result = []
+    for intf in temp.itervalues():
+        intf['inet'] = list(set(intf['inet']))
+        intf['inet6'] = list(set(intf['inet6']))
+        result.append(intf)
+    return result
+
+
 def GetNetworkInterfaces():
     interfaces = list()
     try:
@@ -80,7 +97,7 @@
                     'hw': adapter.MacAddress.lower().replace('-', ':')})
     except:
         logging.exception("Error retrieving network interfaces.")
-    return interfaces
+    return merge_duplicate_interfaces(interfaces)
 
 
 class PERFORMANCE_INFORMATION(Structure):


-- 
To view, visit http://gerrit.ovirt.org/30224
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I19d4b91ea4fb6fcec6699ab6892ba1d6240919f6
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-guest-agent
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Vinzenz Feenstra <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to