dbusmock.templates.networkmanager

NetworkManager mock template

This creates the expected methods and properties of the main org.freedesktop.NetworkManager object, but no devices. You can specify any property such as ‘NetworkingEnabled’, or ‘WirelessEnabled’ etc. in “parameters”.

Attributes

__author__

__copyright__

BUS_NAME

MAIN_OBJ

MANAGER_IFACE

MANAGER_OBJ

SETTINGS_OBJ

SETTINGS_IFACE

DEVICE_IFACE

WIRELESS_DEVICE_IFACE

ACCESS_POINT_IFACE

CSETTINGS_IFACE

ACTIVE_CONNECTION_IFACE

SYSTEM_BUS

IS_OBJECT_MANAGER

Classes

NMState

Global state

NMConnectivityState

Connectvity state

NMActiveConnectionState

Active connection state

InfrastructureMode

Infrastructure mode

DeviceState

Device states

NM80211ApSecurityFlags

Security flags

NM80211ApFlags

Device flags

Functions

activate_connection(self, conn, dev, ap)

deactivate_connection(self, active_conn_path)

add_and_activate_connection(self, conn_conf, dev, ap)

get_device_by_ip_iface(_self, iface)

set_networking_enabled(self, networking_enabled)

load(mock, parameters)

SetProperty(_self, path, iface, name, value)

SetGlobalConnectionState(self, state)

SetConnectivity(self, connectivity)

SetNetworkingEnabled(self, networking_enabled)

SetDeviceActive(_self, device_path, active_connection_path)

SetDeviceDisconnected(_self, device_path)

AddEthernetDevice(self, device_name, iface_name, state)

Add an ethernet device.

AddWiFiDevice(self, device_name, iface_name, state)

Add a WiFi Device.

AddAccessPoint(self, dev_path, ap_name, ssid, ...)

Add an access point to an existing WiFi device.

AddWiFiConnection(self, dev_path, connection_name, ...)

Add an available connection to an existing WiFi device and access point.

AddActiveConnection(self, devices, connection_device, ...)

Add an active connection to an existing WiFi device.

RemoveAccessPoint(self, dev_path, ap_path)

Remove the specified access point.

RemoveWifiConnection(self, dev_path, connection_path)

Remove the specified WiFi connection.

RemoveActiveConnection(self, dev_path, ...)

Remove the specified ActiveConnection.

SettingsAddConnection(self, connection_settings)

Add a connection.

SettingsGetConnectionByUuid(self, conn_uuid)

ConnectionUpdate(self, settings)

Update settings on a connection.

ConnectionGetSettings(self)

ConnectionGetSecrets(self, setting)

ConnectionDelete(self)

Deletes a connection.

Module Contents

dbusmock.templates.networkmanager.__author__ = 'Iftikhar Ahmad'[source]
Show Value
"""
(c) 2012 Canonical Ltd.
(c) 2017 - 2022 Martin Pitt <martin@piware.de>
"""
dbusmock.templates.networkmanager.BUS_NAME = 'org.freedesktop.NetworkManager'[source]
dbusmock.templates.networkmanager.MAIN_OBJ = '/org/freedesktop'[source]
dbusmock.templates.networkmanager.MANAGER_IFACE = 'org.freedesktop.NetworkManager'[source]
dbusmock.templates.networkmanager.MANAGER_OBJ = '/org/freedesktop/NetworkManager'[source]
dbusmock.templates.networkmanager.SETTINGS_OBJ = '/org/freedesktop/NetworkManager/Settings'[source]
dbusmock.templates.networkmanager.SETTINGS_IFACE = 'org.freedesktop.NetworkManager.Settings'[source]
dbusmock.templates.networkmanager.DEVICE_IFACE = 'org.freedesktop.NetworkManager.Device'[source]
dbusmock.templates.networkmanager.WIRELESS_DEVICE_IFACE = 'org.freedesktop.NetworkManager.Device.Wireless'[source]
dbusmock.templates.networkmanager.ACCESS_POINT_IFACE = 'org.freedesktop.NetworkManager.AccessPoint'[source]
dbusmock.templates.networkmanager.CSETTINGS_IFACE = 'org.freedesktop.NetworkManager.Settings.Connection'[source]
dbusmock.templates.networkmanager.ACTIVE_CONNECTION_IFACE = 'org.freedesktop.NetworkManager.Connection.Active'[source]
dbusmock.templates.networkmanager.SYSTEM_BUS = True[source]
dbusmock.templates.networkmanager.IS_OBJECT_MANAGER = True[source]
class dbusmock.templates.networkmanager.NMState[source]

Global state

As per https://developer.gnome.org/NetworkManager/unstable/nm-dbus-types.html#NMState

NM_STATE_UNKNOWN = 0[source]
NM_STATE_ASLEEP = 10[source]
NM_STATE_DISCONNECTED = 20[source]
NM_STATE_DISCONNECTING = 30[source]
NM_STATE_CONNECTING = 40[source]
NM_STATE_CONNECTED_LOCAL = 50[source]
NM_STATE_CONNECTED_SITE = 60[source]
NM_STATE_CONNECTED_GLOBAL = 70[source]
class dbusmock.templates.networkmanager.NMConnectivityState[source]

Connectvity state

As per https://developer.gnome.org/NetworkManager/unstable/nm-dbus-types.html#NMConnectivityState

NM_CONNECTIVITY_UNKNOWN = 0[source]
NM_CONNECTIVITY_NONE = 1[source]
NM_CONNECTIVITY_PORTAL = 2[source]
NM_CONNECTIVITY_LIMITED = 3[source]
NM_CONNECTIVITY_FULL = 4[source]
class dbusmock.templates.networkmanager.NMActiveConnectionState[source]

Active connection state

As per https://developer.gnome.org/NetworkManager/unstable/nm-dbus-types.html#NMActiveConnectionState

NM_ACTIVE_CONNECTION_STATE_UNKNOWN = 0[source]
NM_ACTIVE_CONNECTION_STATE_ACTIVATING = 1[source]
NM_ACTIVE_CONNECTION_STATE_ACTIVATED = 2[source]
NM_ACTIVE_CONNECTION_STATE_DEACTIVATING = 3[source]
NM_ACTIVE_CONNECTION_STATE_DEACTIVATED = 4[source]
class dbusmock.templates.networkmanager.InfrastructureMode[source]

Infrastructure mode

As per https://developer.gnome.org/NetworkManager/unstable/nm-dbus-types.html#NM80211Mode

NM_802_11_MODE_UNKNOWN = 0[source]
NM_802_11_MODE_ADHOC = 1[source]
NM_802_11_MODE_INFRA = 2[source]
NM_802_11_MODE_AP = 3[source]
NAME_MAP[source]
class dbusmock.templates.networkmanager.DeviceState[source]

Device states

As per https://developer.gnome.org/NetworkManager/unstable/nm-dbus-types.html#NMDeviceState

UNKNOWN = 0[source]
UNMANAGED = 10[source]
UNAVAILABLE = 20[source]
DISCONNECTED = 30[source]
PREPARE = 40[source]
CONFIG = 50[source]
NEED_AUTH = 60[source]
IP_CONFIG = 70[source]
IP_CHECK = 80[source]
SECONDARIES = 90[source]
ACTIVATED = 100[source]
DEACTIVATING = 110[source]
FAILED = 120[source]
class dbusmock.templates.networkmanager.NM80211ApSecurityFlags[source]

Security flags

As per https://developer.gnome.org/NetworkManager/unstable/nm-dbus-types.html#NM80211ApSecurityFlags

NM_802_11_AP_SEC_NONE = 0[source]
NM_802_11_AP_SEC_PAIR_WEP40 = 1[source]
NM_802_11_AP_SEC_PAIR_WEP104 = 2[source]
NM_802_11_AP_SEC_PAIR_TKIP = 4[source]
NM_802_11_AP_SEC_PAIR_CCMP = 8[source]
NM_802_11_AP_SEC_GROUP_WEP40 = 16[source]
NM_802_11_AP_SEC_GROUP_WEP104 = 32[source]
NM_802_11_AP_SEC_GROUP_TKIP = 64[source]
NM_802_11_AP_SEC_GROUP_CCMP = 128[source]
NM_802_11_AP_SEC_KEY_MGMT_PSK = 256[source]
NM_802_11_AP_SEC_KEY_MGMT_802_1X = 512[source]
NAME_MAP[source]
class dbusmock.templates.networkmanager.NM80211ApFlags[source]

Device flags

As per https://developer.gnome.org/NetworkManager/unstable/nm-dbus-types.html#NM80211ApFlags

NM_802_11_AP_FLAGS_NONE = 0[source]
NM_802_11_AP_FLAGS_PRIVACY = 1[source]
dbusmock.templates.networkmanager.activate_connection(self, conn, dev, ap)[source]
dbusmock.templates.networkmanager.deactivate_connection(self, active_conn_path)[source]
dbusmock.templates.networkmanager.add_and_activate_connection(self, conn_conf, dev, ap)[source]
dbusmock.templates.networkmanager.get_device_by_ip_iface(_self, iface)[source]
dbusmock.templates.networkmanager.set_networking_enabled(self, networking_enabled)[source]
dbusmock.templates.networkmanager.load(mock, parameters)[source]
dbusmock.templates.networkmanager.SetProperty(_self, path, iface, name, value)[source]
dbusmock.templates.networkmanager.SetGlobalConnectionState(self, state)[source]
dbusmock.templates.networkmanager.SetConnectivity(self, connectivity)[source]
dbusmock.templates.networkmanager.SetNetworkingEnabled(self, networking_enabled)[source]
dbusmock.templates.networkmanager.SetDeviceActive(_self, device_path, active_connection_path)[source]
dbusmock.templates.networkmanager.SetDeviceDisconnected(_self, device_path)[source]
dbusmock.templates.networkmanager.AddEthernetDevice(self, device_name, iface_name, state)[source]

Add an ethernet device.

You have to specify device_name, device interface name (e. g. eth0), and state. You can use the predefined DeviceState values (e. g. DeviceState.ACTIVATED) or supply a numeric value. For valid state values please visit https://developer.gnome.org/NetworkManager/unstable/nm-dbus-types.html#NMDeviceState

Please note that this does not set any global properties.

Returns the new object path.

dbusmock.templates.networkmanager.AddWiFiDevice(self, device_name, iface_name, state)[source]

Add a WiFi Device.

You have to specify device_name, device interface name (e. g. wlan0) and state. You can use the predefined DeviceState values (e. g. DeviceState.ACTIVATED) or supply a numeric value. For valid state values, please visit https://developer.gnome.org/NetworkManager/unstable/nm-dbus-types.html#NMDeviceState

Please note that this does not set any global properties.

Returns the new object path.

dbusmock.templates.networkmanager.AddAccessPoint(self, dev_path, ap_name, ssid, hw_address, mode, frequency, rate, strength, security)[source]

Add an access point to an existing WiFi device.

You have to specify WiFi Device path, Access Point object name, ssid, hw_address, mode, frequency, rate, strength and security. For valid access point property values, please visit https://developer.gnome.org/NetworkManager/unstable/gdbus-org.freedesktop.NetworkManager.AccessPoint.html

Please note that this does not set any global properties.

Returns the new object path.

dbusmock.templates.networkmanager.AddWiFiConnection(self, dev_path, connection_name, ssid_name, _key_mgmt)[source]

Add an available connection to an existing WiFi device and access point.

You have to specify WiFi Device path, Connection object name, SSID and key management.

The SSID must match one of the previously created access points.

Please note that this only sets minimal global properties in ipv{4,6}, no others.

Returns the new object path.

dbusmock.templates.networkmanager.AddActiveConnection(self, devices, connection_device, specific_object, name, state)[source]

Add an active connection to an existing WiFi device.

You have to a list of the involved WiFi devices, the connection path, the access point path, ActiveConnection object name and connection state.

Please note that this does not set any global properties.

Returns the new object path.

dbusmock.templates.networkmanager.RemoveAccessPoint(self, dev_path, ap_path)[source]

Remove the specified access point.

You have to specify the device to remove the access point from, and the path of the access point.

Please note that this does not set any global properties.

dbusmock.templates.networkmanager.RemoveWifiConnection(self, dev_path, connection_path)[source]

Remove the specified WiFi connection.

You have to specify the device to remove the connection from, and the path of the Connection.

Please note that this does not set any global properties.

dbusmock.templates.networkmanager.RemoveActiveConnection(self, dev_path, active_connection_path)[source]

Remove the specified ActiveConnection.

You have to specify the device to remove the connection from, and the path of the ActiveConnection.

Please note that this does not set any global properties.

dbusmock.templates.networkmanager.SettingsAddConnection(self, connection_settings)[source]

Add a connection.

connection_settings is a String String Variant Map Map. See https://developer.gnome.org/NetworkManager/0.9/spec.html #type-String_String_Variant_Map_Map

If you omit uuid, this method adds one for you.

dbusmock.templates.networkmanager.SettingsGetConnectionByUuid(self, conn_uuid)[source]
dbusmock.templates.networkmanager.ConnectionUpdate(self, settings)[source]

Update settings on a connection.

settings is a String String Variant Map Map. See https://developer.gnome.org/NetworkManager/0.9/spec.html#type-String_String_Variant_Map_Map

dbusmock.templates.networkmanager.ConnectionGetSettings(self)[source]
dbusmock.templates.networkmanager.ConnectionGetSecrets(self, setting)[source]
dbusmock.templates.networkmanager.ConnectionDelete(self)[source]

Deletes a connection.

This also
  • removes the deleted connection from any device,

  • removes any active connection(s) it might be associated with,

  • removes it from the Settings interface,

  • as well as deletes the object from the mock.

Note: If this was the only active connection, we change the global connection state.