45
45
* remove workaround once we get a fix for the pm scripts issue that causes the
46
46
wakealarm and alarm_IRQ entries to not be reset after resume from S4
47
* Add in post-resume check to determine of network has resumed
48
47
* Add in checks to factor in the consumer-test hibernate/suspend test cases
50
v1.2: Removed NetworkManager class and replaced with simple call to nmcli
51
v1.1: Added handling of NetworkManager 0.9 status codes.
51
52
v1.0: Added code to support Hibernate (S4) and allow choice between S3 and S4
53
54
Created mechanism in SuspendTest() class to check /proc/driver/rtc as a
279
class NetworkManagerException(Exception):
284
class NetworkManager(object):
286
NM_SERVICE = "org.freedesktop.NetworkManager"
287
NM_PATH = "/org/freedesktop/NetworkManager"
288
NM_INTERFACE = NM_SERVICE
290
NM_PATH_DEVICES = "/org/freedesktop/NetworkManager/Devices"
291
NM_INTERFACE_DEVICES = "org.freedesktop.NetworkManager.Devices"
293
NMI_SERVICE = "org.freedesktop.NetworkManagerInfo"
294
NMI_PATH = "/org/freedesktop/NetworkManagerInfo"
295
NMI_INTERFACE = NMI_SERVICE
297
HAL_SERVICE = "org.freedesktop.Hal"
298
HAL_PATH = "/org/freedesktop/Hal/Manager"
299
HAL_INTERFACE = "org.freedesktop.Hal.Manager"
300
HAL_INTERFACE_DEVICE = "org.freedesktop.Hal.Device"
302
STATE_UNKNOWN = "unknown"
303
STATE_ASLEEP = "asleep"
304
STATE_CONNECTING = "connecting"
305
STATE_CONNECTED = "connected"
306
STATE_DISCONNECTED = "disconnected"
319
raise NetworkManagerException, "Python module not found: dbus"
322
self._bus = dbus.SystemBus()
323
self.nm_object = self._bus.get_object(self.NM_SERVICE, self.NM_PATH)
324
self.nm_service = dbus.Interface(self.nm_object, self.NM_INTERFACE)
325
except dbus.exceptions.DBusException:
326
raise NetworkManagerException, "Failed to connect to dbus service"
329
state = self.nm_service.state()
330
return self._state_table[state]
333
280
def check_network():
335
nm = NetworkManager()
336
except NetworkManagerException:
339
281
start = datetime.now()
340
282
logging.debug("Waiting 60 seconds for NetworkManager to reconnect.")
342
if nm.get_state() == nm.STATE_CONNECTED:
344
# give 60 seconds to NetworkManager to get to a CONNECTED state, then give up
345
if datetime.now() - start > timedelta(seconds=60):
285
if check_output(["/usr/bin/nmcli", "-t", "-f",
286
"STATE", "nm"]).strip() == "connected":
288
# give 60 seconds to NetworkManager to get to a CONNECTED state, then give up
289
if datetime.now() - start > timedelta(seconds=60):
292
except OSError as err:
293
logging.error("Unable to verify network status: %s" % err)
350
297
usage = 'Usage: %prog [OPTIONS]'