GENICLOUD-31 Remove duplicate entries from the bridged interface.
authorMarco Yuen <marcoy@gmail.com>
Sat, 9 Jul 2011 00:17:05 +0000 (20:17 -0400)
committerMarco Yuen <marcoy@gmail.com>
Sat, 9 Jul 2011 00:17:05 +0000 (20:17 -0400)
plnet.py

index 001bbee..0f692f4 100755 (executable)
--- a/plnet.py
+++ b/plnet.py
@@ -157,9 +157,8 @@ def InitInterfaces(logger, plc, data, root="", files_only=False, program="NodeMa
             elif orig_ifname:
                 ifname = orig_ifname
                 device_id -= 1
             elif orig_ifname:
                 ifname = orig_ifname
                 device_id -= 1
-            if 'PRIMARY' in details: del details['PRIMARY']
             logger.log('net:InitInterfaces: Bridge detected. Adding %s to devices_map' % ifname)
             logger.log('net:InitInterfaces: Bridge detected. Adding %s to devices_map' % ifname)
-            devices_map[ifname] = details
+            devices_map[ifname] = removeBridgedIfaceDetails(details)
             bridgeName = details['BRIDGE']
 
             logger.log('net:InitInterfaces: Adding bridge %s' % bridgeName)
             bridgeName = details['BRIDGE']
 
             logger.log('net:InitInterfaces: Adding bridge %s' % bridgeName)
@@ -422,6 +421,16 @@ def prepDetails(interface, hostname=''):
 
     return details
 
 
     return details
 
+##
+# Remove duplicate entry from the bridged interface's configuration file.
+#
+def removeBridgedIfaceDetails(details):
+    for key in [ 'PRIMARY', 'PERSISTENT_DHCLIENT', 'DHCLIENTARGS', 'DHCP_HOSTNAME',
+                 'BOOTPROTO', 'IPADDR', 'NETMASK', 'GATEWAY', 'DNS1', 'DNS2' ]:
+        if key in details:
+            del details[key]
+    return details
+
 if __name__ == "__main__":
     import optparse
     import sys
 if __name__ == "__main__":
     import optparse
     import sys