NM.Connection¶
- Implementations:
Methods¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
|
|
|
Properties¶
None
Signals¶
Name |
Short Description |
---|---|
The |
|
The |
|
The |
Fields¶
None
Class Details¶
- class NM.Connection¶
- Bases:
- Structure:
NM.Connection
is the interface implemented byNM.RemoteConnection
on the client side, and #NMSettingsConnection on the daemon side.- add_setting(setting)¶
- Parameters:
setting (
NM.Setting
) – theNM.Setting
to add to the connection object
Adds a
NM.Setting
to the connection, replacing any previousNM.Setting
of the same name which has previously been added to theNM.Connection
. The connection takes ownership of theNM.Setting
object and does not increase the setting object’s reference count.
- clear_secrets()¶
Clears and frees any secrets that may be stored in the connection, to avoid keeping secret data in memory when not needed.
- clear_secrets_with_flags(func, *user_data)¶
- Parameters:
func (
NM.SettingClearSecretsWithFlagsFn
orNone
) – function to be called to determine whether a specific secret should be cleared or not. IfNone
, all secrets are cleared.user_data (
object
orNone
) – caller-supplied data passed to func
Clears and frees secrets determined by func.
- clear_settings()¶
Deletes all of self's settings.
- compare(b, flags)¶
- Parameters:
b (
NM.Connection
) – a secondNM.Connection
to compare with the firstflags (
NM.SettingCompareFlags
) – compare flags, e.g.NM.SettingCompareFlags.EXACT
- Returns:
- Return type:
Compares two
NM.Connection
objects for similarity, with comparison behavior modified by a set of flags. SeeNM.Setting.compare
() for a description of each flag’s behavior.
- dump()¶
Print the connection (including secrets!) to stdout. For debugging purposes ONLY, should NOT be used for serialization of the setting, or machine-parsed in any way. The output format is not guaranteed to be stable and may change at any time.
- for_each_setting_value(func, *user_data)¶
- Parameters:
func (
NM.SettingValueIterFn
) – user-supplied function called for each setting’s propertyuser_data (
object
orNone
) – user data passed to func at each invocation
Iterates over the properties of each
NM.Setting
object in theNM.Connection
, calling the supplied user function for each property.
- get_connection_type()¶
- Returns:
the type from the connection’s ‘connection’ setting
- Return type:
A shortcut to return the type from the connection’s
NM.SettingConnection
.
- get_id()¶
- Returns:
the ID from the connection’s ‘connection’ setting
- Return type:
A shortcut to return the ID from the connection’s
NM.SettingConnection
.
- get_interface_name()¶
-
Returns the interface name as stored in NMSettingConnection:interface_name. If the connection contains no
NM.SettingConnection
, it will returnNone
.For hardware devices and software devices created outside of NetworkManager, this name is used to match the device. for software devices created by NetworkManager, this is the name of the created interface.
- get_path()¶
- Returns:
the D-Bus path of the connection, previously set by a call to
NM.Connection.set_path
().- Return type:
Returns the connection’s D-Bus path.
- get_setting(setting_type)¶
- Parameters:
setting_type (
GObject.GType
) – theGObject.GType
of the setting object to return- Returns:
the
NM.Setting
, orNone
if no setting of that type was previously added to theNM.Connection
- Return type:
Gets the
NM.Setting
with the givenGObject.GType
, if one has been previously added to theNM.Connection
.
- get_setting_802_1x()¶
- Returns:
an
NM.Setting8021x
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.Setting8021x
the connection might contain.
- get_setting_adsl()¶
- Returns:
an
NM.SettingAdsl
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingAdsl
the connection might contain.
- get_setting_bluetooth()¶
- Returns:
an
NM.SettingBluetooth
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingBluetooth
the connection might contain.
- get_setting_bond()¶
- Returns:
an
NM.SettingBond
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingBond
the connection might contain.
- get_setting_bridge()¶
- Returns:
an
NM.SettingBridge
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingBridge
the connection might contain.
- get_setting_bridge_port()¶
- Returns:
an
NM.SettingBridgePort
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingBridgePort
the connection might contain.
- get_setting_by_name(name)¶
- Parameters:
name (
str
) – a setting name- Returns:
the
NM.Setting
, orNone
if no setting with that name was previously added to theNM.Connection
- Return type:
Gets the
NM.Setting
with the given name, if one has been previously added theNM.Connection
.
- get_setting_cdma()¶
- Returns:
an
NM.SettingCdma
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingCdma
the connection might contain.
- get_setting_connection()¶
- Returns:
an
NM.SettingConnection
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingConnection
the connection might contain.
- get_setting_dcb()¶
- Returns:
an
NM.SettingDcb
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingDcb
the connection might contain.
- get_setting_dummy()¶
- Returns:
an
NM.SettingDummy
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingDummy
the connection might contain.New in version 1.8.
- get_setting_generic()¶
- Returns:
an
NM.SettingGeneric
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingGeneric
the connection might contain.
- get_setting_gsm()¶
- Returns:
an
NM.SettingGsm
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingGsm
the connection might contain.
- get_setting_infiniband()¶
- Returns:
an
NM.SettingInfiniband
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingInfiniband
the connection might contain.
- get_setting_ip4_config()¶
- Returns:
an
NM.SettingIP4Config
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingIP4Config
the connection might contain.Note that it returns the value as type
NM.SettingIPConfig
, since the vast majority of IPv4-setting-related methods are on that type, notNM.SettingIP4Config
.
- get_setting_ip6_config()¶
- Returns:
an
NM.SettingIP6Config
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingIP6Config
the connection might contain.Note that it returns the value as type
NM.SettingIPConfig
, since the vast majority of IPv6-setting-related methods are on that type, notNM.SettingIP6Config
.
- get_setting_ip_tunnel()¶
- Returns:
an
NM.SettingIPTunnel
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingIPTunnel
the connection might contain.New in version 1.2.
- get_setting_macsec()¶
- Returns:
an
NM.SettingMacsec
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingMacsec
the connection might contain.New in version 1.6.
- get_setting_macvlan()¶
- Returns:
an
NM.SettingMacvlan
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingMacvlan
the connection might contain.New in version 1.2.
- get_setting_olpc_mesh()¶
- Returns:
an
NM.SettingOlpcMesh
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingOlpcMesh
the connection might contain.
- get_setting_ovs_bridge()¶
- Returns:
an
NM.SettingOvsBridge
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingOvsBridge
the connection might contain.New in version 1.14.
- get_setting_ovs_interface()¶
- Returns:
an
NM.SettingOvsInterface
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingOvsInterface
the connection might contain.New in version 1.14.
- get_setting_ovs_patch()¶
- Returns:
an
NM.SettingOvsPatch
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingOvsPatch
the connection might contain.New in version 1.14.
- get_setting_ovs_port()¶
- Returns:
an
NM.SettingOvsPort
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingOvsPort
the connection might contain.New in version 1.14.
- get_setting_ppp()¶
- Returns:
an
NM.SettingPpp
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingPpp
the connection might contain.
- get_setting_pppoe()¶
- Returns:
an
NM.SettingPppoe
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingPppoe
the connection might contain.
- get_setting_proxy()¶
- Returns:
an
NM.SettingProxy
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingProxy
the connection might contain.New in version 1.6.
- get_setting_serial()¶
- Returns:
an
NM.SettingSerial
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingSerial
the connection might contain.
- get_setting_tc_config()¶
- Returns:
an
NM.SettingTCConfig
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingTCConfig
the connection might contain.New in version 1.12.
- get_setting_team()¶
- Returns:
an
NM.SettingTeam
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingTeam
the connection might contain.
- get_setting_team_port()¶
- Returns:
an
NM.SettingTeamPort
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingTeamPort
the connection might contain.
- get_setting_tun()¶
- Returns:
an
NM.SettingTun
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingTun
the connection might contain.New in version 1.14.
- get_setting_vlan()¶
- Returns:
an
NM.SettingVlan
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingVlan
the connection might contain.
- get_setting_vpn()¶
- Returns:
an
NM.SettingVpn
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingVpn
the connection might contain.
- get_setting_vxlan()¶
- Returns:
an
NM.SettingVxlan
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingVxlan
the connection might contain.New in version 1.2.
- get_setting_wimax()¶
- Returns:
an
NM.SettingWimax
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingWimax
the connection might contain.
- get_setting_wired()¶
- Returns:
an
NM.SettingWired
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingWired
the connection might contain.
- get_setting_wireless()¶
- Returns:
an
NM.SettingWireless
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingWireless
the connection might contain.
- get_setting_wireless_security()¶
- Returns:
an
NM.SettingWirelessSecurity
if the connection contains one, otherwiseNone
- Return type:
A shortcut to return any
NM.SettingWirelessSecurity
the connection might contain.
- get_settings()¶
- Returns:
a
None
-terminated array containing every setting of self. If the connection has no settings,None
is returned.- Return type:
[
NM.Setting
] orNone
Retrieves the settings in self.
The returned array is
None
-terminated.New in version 1.10.
- get_uuid()¶
- Returns:
the UUID from the connection’s ‘connection’ setting
- Return type:
A shortcut to return the UUID from the connection’s
NM.SettingConnection
.
- get_virtual_device_description()¶
- Returns:
the name of self's device, or
None
if self is not a virtual connection type- Return type:
Returns the name that
NM.Device.disambiguate_names
() would return for the virtual device that would be created for self. Eg, “VLAN (eth1.1)”.
- is_type(type)¶
- Parameters:
type (
str
) – a setting name to check the connection’s type against (likeNM.SETTING_WIRELESS_SETTING_NAME
orNM.SETTING_WIRED_SETTING_NAME
)- Returns:
- Return type:
A convenience function to check if the given self is a particular type (ie wired, Wi-Fi, ppp, etc). Checks the
NM.SettingConnection
:type
property of the connection and matches that against type.
- is_virtual()¶
- Returns:
whether self refers to a virtual device
- Return type:
Checks if self refers to a virtual device (and thus can potentially be activated even if the device it refers to doesn’t exist).
- need_secrets()¶
- Returns:
the setting name of the
NM.Setting
object which has invalid or missing secrets- hints:
the address of a pointer to a
GLib.PtrArray
, initialized toNone
, which on return points to an allocatedGLib.PtrArray
containing the property names of secrets of theNM.Setting
which may be required; the caller owns the array and must free the array itself with g_ptr_array_free(), but not free its elements
- Return type:
Returns the name of the first setting object in the connection which would need secrets to make a successful connection. The returned hints are only intended as a guide to what secrets may be required, because in some circumstances, there is no way to conclusively determine exactly which secrets are needed.
- normalize(parameters)¶
- Parameters:
parameters ({
str
:object
} orNone
) – aGLib.HashTable
with normalization parameters to allow customization of the normalization by providing specific arguments. Unknown arguments will be ignored and the default will be used. The keys must be strings compared withGLib.str_equal
() function. The values are opaque and depend on the parameter name.- Raises:
- Returns:
True
if the connection is valid,False
if it is not- modified:
outputs whether any settings were modified.
- Return type:
Does some basic normalization and fixup of well known inconsistencies and deprecated fields. If the connection was modified in any way, the output parameter modified is set
True
.Finally the connection will be verified and
True
returns if the connection is valid. As this function only performs some specific normalization steps it cannot repair all connections. If the connection has errors that cannot be normalized, the connection will not be modified.
- remove_setting(setting_type)¶
- Parameters:
setting_type (
GObject.GType
) – theGObject.GType
of the setting object to remove
Removes the
NM.Setting
with the givenGObject.GType
from theNM.Connection
. This operation dereferences theNM.Setting
object.
- replace_settings(new_settings)¶
- Parameters:
new_settings (
GLib.Variant
) – aGLib.Variant
of type %NM_VARIANT_TYPE_CONNECTION, with the new settings- Raises:
- Returns:
True
if connection was updated,False
if new_settings could not be deserialized (in which case self will be unchanged).- Return type:
Replaces self's settings with new_settings (which must be syntactically valid, and describe a known type of connection, but does not need to result in a connection that passes
NM.Connection.verify
()).
- replace_settings_from_connection(new_connection)¶
- Parameters:
new_connection (
NM.Connection
) – aNM.Connection
to replace the settings of self with
Deep-copies the settings of new_connection and replaces the settings of self with the copied settings.
- set_path(path)¶
- Parameters:
path (
str
) – the D-Bus path of the connection as given by the settings service which provides the connection
Sets the D-Bus path of the connection. This property is not serialized, and is only for the reference of the caller. Sets the
NM.Connection
:path
property.
- to_dbus(flags)¶
- Parameters:
flags (
NM.ConnectionSerializationFlags
) – serialization flags, e.g.NM.ConnectionSerializationFlags.ALL
- Returns:
a new floating
GLib.Variant
describing the connection, its settings, and each setting’s properties.- Return type:
Converts the
NM.Connection
into aGLib.Variant
of type %NM_VARIANT_TYPE_CONNECTION describing the connection, suitable for marshalling over D-Bus or otherwise serializing.
- update_secrets(setting_name, secrets)¶
- Parameters:
setting_name (
str
) – the setting object name to which the secrets applysecrets (
GLib.Variant
) – aGLib.Variant
of secrets, of type %NM_VARIANT_TYPE_CONNECTION or %NM_VARIANT_TYPE_SETTING
- Raises:
- Returns:
True
if the secrets were successfully updated,False
if the update failed (tried to update secrets for a setting that doesn’t exist, etc)- Return type:
Update the specified setting’s secrets, given a dictionary of secrets intended for that setting (deserialized from D-Bus for example). Will also extract the given setting’s secrets hash if given a connection dictionary. If setting_name is
None
, expects a fully serializedNM.Connection
as returned byNM.Connection.to_dbus
() and will update all secrets from all settings contained in secrets.
- verify()¶
- Raises:
- Returns:
- Return type:
Validates the connection and all its settings. Each setting’s properties have allowed values, and some values are dependent on other values. For example, if a Wi-Fi connection is security enabled, the
NM.SettingWireless
setting object’s ‘security’ property must contain the setting name of theNM.SettingWirelessSecurity
object, which must also be present in the connection for the connection to be valid. As another example, theNM.SettingWired
object’s ‘mac-address’ property must be a validly formatted MAC address. The returnedGLib.Error
contains information about which setting and which property failed validation, and how it failed validation.
- verify_secrets()¶
- Raises:
- Returns:
- Return type:
Verifies the secrets in the connection.
New in version 1.2.
- do_changed() virtual¶
emitted when any change to the connection’s settings occurs
- do_secrets_cleared() virtual¶
emitted when the connection’s secrets are cleared
Signal Details¶
- NM.Connection.signals.changed(connection)¶
- Signal Name:
changed
- Flags:
- Parameters:
connection (
NM.Connection
) – The object which received the signal
The
::changed
signal is emitted when any property (including secrets) of any setting of the connection is modified, or when settings are added or removed.
- NM.Connection.signals.secrets_cleared(connection)¶
- Signal Name:
secrets-cleared
- Flags:
- Parameters:
connection (
NM.Connection
) – The object which received the signal
The
::secrets-cleared
signal is emitted when the secrets of a connection are cleared.
- NM.Connection.signals.secrets_updated(connection, setting_name)¶
- Signal Name:
secrets-updated
- Flags:
- Parameters:
connection (
NM.Connection
) – The object which received the signalsetting_name (
str
) – the setting name of theNM.Setting
for which secrets were updated
The
::secrets-updated
signal is emitted when the secrets of a setting have been changed.