[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH rhel6-branch] Use correct NM dbus interfaces (#594716)



---
 isys/isys.py |    9 +++++----
 network.py   |   15 ++++++++-------
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/isys/isys.py b/isys/isys.py
index b10e95a..7ab5988 100755
--- a/isys/isys.py
+++ b/isys/isys.py
@@ -48,6 +48,7 @@ NM_MANAGER_IFACE = "org.freedesktop.NetworkManager"
 NM_ACTIVE_CONNECTION_IFACE = "org.freedesktop.NetworkManager.Connection.Active"
 NM_CONNECTION_IFACE = "org.freedesktop.NetworkManagerSettings.Connection"
 NM_DEVICE_IFACE = "org.freedesktop.NetworkManager.Device"
+NM_IP4CONFIG_IFACE = "org.freedesktop.NetworkManager.IP4Config"
 
 NM_STATE_UNKNOWN = 0
 NM_STATE_ASLEEP = 1
@@ -389,7 +390,7 @@ def getDeviceProperties(dev=None):
         device = bus.get_object(NM_SERVICE, path)
         device_props_iface = dbus.Interface(device, DBUS_PROPS_IFACE)
 
-        device_interface = str(device_props_iface.Get(NM_MANAGER_IFACE, "Interface"))
+        device_interface = str(device_props_iface.Get(NM_DEVICE_IFACE, "Interface"))
 
         if dev is None:
             all[device_interface] = device_props_iface
@@ -447,7 +448,7 @@ def getMacAddress(dev):
 
     device_macaddr = None
     try:
-        device_macaddr = device_props_iface.Get(NM_MANAGER_IFACE, "HwAddress").upper()
+        device_macaddr = device_props_iface.Get(NM_DEVICE_IFACE, "HwAddress").upper()
     except dbus.exceptions.DBusException as e:
         if e.get_dbus_name() != 'org.freedesktop.DBus.Error.InvalidArgs':
             raise
@@ -495,7 +496,7 @@ def isWireless(dev):
     if device_props_iface is None:
         return None
 
-    device_type = int(device_props_iface.Get(NM_MANAGER_IFACE, "DeviceType"))
+    device_type = int(device_props_iface.Get(NM_DEVICE_IFACE, "DeviceType"))
 
     # from include/NetworkManager.h in the NM source code
     #    0 == NM_DEVICE_TYPE_UNKNOWN
@@ -518,7 +519,7 @@ def getIPAddress(dev):
         return None
 
     # XXX: add support for IPv6 addresses when NM can do that
-    device_ip4addr = device_props_iface.Get(NM_MANAGER_IFACE, "Ip4Address")
+    device_ip4addr = device_props_iface.Get(NM_DEVICE_IFACE, "Ip4Address")
 
     try:
         tmp = struct.pack('I', device_ip4addr)
diff --git a/network.py b/network.py
index 6da3816..8b0d109 100644
--- a/network.py
+++ b/network.py
@@ -89,18 +89,18 @@ def getDefaultHostname(anaconda):
     for connection in active_connections:
         active_connection = bus.get_object(isys.NM_SERVICE, connection)
         active_connection_props_iface = dbus.Interface(active_connection, isys.DBUS_PROPS_IFACE)
-        devices = active_connection_props_iface.Get(isys.NM_MANAGER_IFACE, 'Devices')
+        devices = active_connection_props_iface.Get(isys.NM_ACTIVE_CONNECTION_IFACE, 'Devices')
 
         for device_path in devices:
             device = bus.get_object(isys.NM_SERVICE, device_path)
             device_props_iface = dbus.Interface(device, isys.DBUS_PROPS_IFACE)
 
-            ip4_config_path = device_props_iface.Get(isys.NM_MANAGER_IFACE, 'Ip4Config')
+            ip4_config_path = device_props_iface.Get(isys.NM_DEVICE_IFACE, 'Ip4Config')
             ip4_config_obj = bus.get_object(isys.NM_SERVICE, ip4_config_path)
             ip4_config_props = dbus.Interface(ip4_config_obj, isys.DBUS_PROPS_IFACE)
 
             # addresses (3-element list:  ipaddr, netmask, gateway)
-            addrs = ip4_config_props.Get(isys.NM_MANAGER_IFACE, "Addresses")[0]
+            addrs = ip4_config_props.Get(isys.NM_IP4CONFIG_IFACE, "Addresses")[0]
             try:
                 tmp = struct.pack('I', addrs[0])
                 ipaddr = socket.inet_ntop(socket.AF_INET, tmp)
@@ -179,13 +179,13 @@ def getActiveNetDevs():
     for connection in active_connections:
         active_connection = bus.get_object(isys.NM_SERVICE, connection)
         active_connection_props_iface = dbus.Interface(active_connection, isys.DBUS_PROPS_IFACE)
-        devices = active_connection_props_iface.Get(isys.NM_MANAGER_IFACE, 'Devices')
+        devices = active_connection_props_iface.Get(isys.NM_ACTIVE_CONNECTION_IFACE, 'Devices')
 
         for device_path in devices:
             device = bus.get_object(isys.NM_SERVICE, device_path)
             device_props_iface = dbus.Interface(device, isys.DBUS_PROPS_IFACE)
 
-            interface_name = device_props_iface.Get(isys.NM_MANAGER_IFACE, 'Interface')
+            interface_name = device_props_iface.Get(isys.NM_DEVICE_IFACE, 'Interface')
             active_devs.add(interface_name)
 
     ret = list(active_devs)
@@ -314,6 +314,7 @@ class Network:
 
         self.hostname = socket.gethostname()
         self.overrideDHCPhostname = False
+
         self.update()
 
     def update(self):
@@ -692,14 +693,14 @@ class Network:
         for device_path in device_paths:
             device = bus.get_object(isys.NM_SERVICE, device_path)
             device_props_iface = dbus.Interface(device, isys.DBUS_PROPS_IFACE)
-            iface = str(device_props_iface.Get(isys.NM_MANAGER_IFACE, "Interface"))
+            iface = str(device_props_iface.Get(isys.NM_DEVICE_IFACE, "Interface"))
             if iface in devices:
                 waited_devs_props[iface] = device_props_iface
 
         i = 0
         while True:
             for dev, device_props_iface in waited_devs_props.items():
-                state = device_props_iface.Get(isys.NM_MANAGER_IFACE, "State")
+                state = device_props_iface.Get(isys.NM_DEVICE_IFACE, "State")
                 if state == isys.NM_DEVICE_STATE_ACTIVATED:
                     waited_devs_props.pop(dev)
             if len(waited_devs_props) == 0:
-- 
1.6.0.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]