[PATCH f15-branch] Changes for NetworkManager API 0.9

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

 



Related NM bugs: #672282, #604334

New NM is not in f15 yet, will be probably with build 0.8.995
---
 loader/net.c                |    2 +-
 loader/nfsinstall.c         |    2 +-
 pyanaconda/isys/__init__.py |   15 +++++++++------
 pyanaconda/isys/iface.c     |   10 ++++++++--
 pyanaconda/isys/iface.h     |    6 ++++++
 pyanaconda/network.py       |   15 +++++++++------
 6 files changed, 34 insertions(+), 16 deletions(-)

diff --git a/loader/net.c b/loader/net.c
index 22ed892..ba183c1 100644
--- a/loader/net.c
+++ b/loader/net.c
@@ -2063,7 +2063,7 @@ int get_connection(iface_t *iface) {
         }
         state = nm_client_get_state(client);
 
-        if (state == NM_STATE_CONNECTED) {
+        if (is_connected_state(state)) {
             logMessage(INFO, "%s (%d): NetworkManager connected",
                        __func__, __LINE__);
             res_init();
diff --git a/loader/nfsinstall.c b/loader/nfsinstall.c
index ed92f78..3ba6e66 100644
--- a/loader/nfsinstall.c
+++ b/loader/nfsinstall.c
@@ -348,7 +348,7 @@ int getFileFromNfs(char * url, char * dest, struct loaderData_s * loaderData) {
         }
 
         state = nm_client_get_state(client);
-        if (state != NM_STATE_CONNECTED) {
+        if (! is_connected_state(state)) {
             logMessage(ERROR, "%s (%d): no active network devices",
                        __func__, __LINE__);
             g_object_unref(client);
diff --git a/pyanaconda/isys/__init__.py b/pyanaconda/isys/__init__.py
index 7b4debc..b896569 100755
--- a/pyanaconda/isys/__init__.py
+++ b/pyanaconda/isys/__init__.py
@@ -51,18 +51,21 @@ NM_SERVICE = "org.freedesktop.NetworkManager"
 NM_MANAGER_PATH = "/org/freedesktop/NetworkManager"
 NM_MANAGER_IFACE = "org.freedesktop.NetworkManager"
 NM_ACTIVE_CONNECTION_IFACE = "org.freedesktop.NetworkManager.Connection.Active"
-NM_CONNECTION_IFACE = "org.freedesktop.NetworkManagerSettings.Connection"
+NM_CONNECTION_IFACE = "org.freedesktop.NetworkManager.Settings.Connection"
 NM_DEVICE_IFACE = "org.freedesktop.NetworkManager.Device"
 NM_IP4CONFIG_IFACE = "org.freedesktop.NetworkManager.IP4Config"
 NM_IP6CONFIG_IFACE = "org.freedesktop.NetworkManager.IP6Config"
 NM_ACCESS_POINT_IFACE = "org.freedesktop.NetworkManager.AccessPoint"
 
 NM_STATE_UNKNOWN = 0
-NM_STATE_ASLEEP = 1
-NM_STATE_CONNECTING = 2
-NM_STATE_CONNECTED = 3
-NM_STATE_DISCONNECTED = 4
-NM_DEVICE_STATE_ACTIVATED = 8
+NM_STATE_ASLEEP = 10
+NM_STATE_DISCONNECTED = 20
+NM_STATE_DISCONNECTING = 30
+NM_STATE_CONNECTING = 40
+NM_STATE_CONNECTED_LOCAL = 50
+NM_STATE_CONNECTED_SITE = 60
+NM_STATE_CONNECTED_GLOBAL = 70
+NM_DEVICE_STATE_ACTIVATED = 100
 
 DBUS_PROPS_IFACE = "org.freedesktop.DBus.Properties"
 
diff --git a/pyanaconda/isys/iface.c b/pyanaconda/isys/iface.c
index 0a9ad6c..5479b37 100644
--- a/pyanaconda/isys/iface.c
+++ b/pyanaconda/isys/iface.c
@@ -184,7 +184,7 @@ char *iface_ip2str(char *ifname, int family) {
         return NULL;
     }
 
-    if (nm_client_get_state(client) != NM_STATE_CONNECTED) {
+    if (! is_connected_state(nm_client_get_state(client))) {
         g_object_unref(client);
         return NULL;
     }
@@ -407,6 +407,12 @@ int iface_have_in6_addr(struct in6_addr *addr6) {
     return _iface_have_valid_addr(addr6, AF_INET6, INET6_ADDRSTRLEN);
 }
 
+int is_connected_state(NMState state) {
+    return (state == NM_STATE_CONNECTED_LOCAL ||
+            state == NM_STATE_CONNECTED_SITE ||
+            state == NM_STATE_CONNECTED_GLOBAL);
+}
+
 /* Check if NM has an active connection */
 gboolean is_nm_connected(void) {
     NMState state;
@@ -421,7 +427,7 @@ gboolean is_nm_connected(void) {
     state = nm_client_get_state(client);
     g_object_unref(client);
 
-    if (state == NM_STATE_CONNECTED)
+    if (is_connected_state(state))
         return TRUE;
     else
         return FALSE;
diff --git a/pyanaconda/isys/iface.h b/pyanaconda/isys/iface.h
index b7eaa6f..c243892 100644
--- a/pyanaconda/isys/iface.h
+++ b/pyanaconda/isys/iface.h
@@ -27,6 +27,7 @@
 #include <netlink/cache.h>
 #include <netlink/socket.h>
 #include <glib.h>
+#include <NetworkManager.h>
 
 /* Enumerated types used in iface.c as well as loader's network code */
 enum { IPUNUSED = -1, IPV4, IPV6 };
@@ -167,4 +168,9 @@ int iface_set_interface_mtu(char *ifname, int mtu);
  */
 int is_wireless_device(char *ifname);
 
+/*
+ * Checks if the state means nm is connected
+ */
+int is_connected_state(NMState state);
+
 #endif /* ISYSIFACE_H */
diff --git a/pyanaconda/network.py b/pyanaconda/network.py
index 304b1c0..d1c9903 100644
--- a/pyanaconda/network.py
+++ b/pyanaconda/network.py
@@ -146,6 +146,12 @@ def sanityCheckIPString(ip_string):
     except socket.error:
         raise IPError, errstr
 
+
+def nmIsConnected(state):
+    return state in (isys.NM_STATE_CONNECTED_LOCAL,
+                     isys.NM_STATE_CONNECTED_SITE,
+                     isys.NM_STATE_CONNECTED_GLOBAL)
+
 def hasActiveNetDev():
     try:
         bus = dbus.SystemBus()
@@ -153,10 +159,7 @@ def hasActiveNetDev():
         props = dbus.Interface(nm, isys.DBUS_PROPS_IFACE)
         state = props.Get(isys.NM_SERVICE, "State")
 
-        if int(state) == isys.NM_STATE_CONNECTED:
-            return True
-        else:
-            return False
+        return nmIsConnected(state)
     except:
         return False
 
@@ -793,13 +796,13 @@ class Network:
         i = 0
         while i < CONNECTION_TIMEOUT:
             state = props.Get(isys.NM_SERVICE, "State")
-            if int(state) == isys.NM_STATE_CONNECTED:
+            if nmIsConnected(state):
                 return True
             i += 1
             time.sleep(1)
 
         state = props.Get(isys.NM_SERVICE, "State")
-        if int(state) == isys.NM_STATE_CONNECTED:
+        if nmIsConnected(state):
             return True
 
         return False
-- 
1.7.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux