From cff698960679733436b0d90dd2d458a260b51483 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 7 Feb 2019 19:51:31 +0100 Subject: [PATCH 1/2] module: use introspection variables instead of plain strings for setting names --- library/network_connections.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/library/network_connections.py b/library/network_connections.py index 1ce8a7d..200b356 100644 --- a/library/network_connections.py +++ b/library/network_connections.py @@ -749,11 +749,15 @@ class NMUtil: ) if connection["type"] == "ethernet": - s_con.set_property(NM.SETTING_CONNECTION_TYPE, "802-3-ethernet") + s_con.set_property( + NM.SETTING_CONNECTION_TYPE, NM.SETTING_WIRED_SETTING_NAME + ) s_wired = self.connection_ensure_setting(con, NM.SettingWired) s_wired.set_property(NM.SETTING_WIRED_MAC_ADDRESS, connection["mac"]) elif connection["type"] == "infiniband": - s_con.set_property(NM.SETTING_CONNECTION_TYPE, "infiniband") + s_con.set_property( + NM.SETTING_CONNECTION_TYPE, NM.SETTING_INFINIBAND_SETTING_NAME + ) s_infiniband = self.connection_ensure_setting(con, NM.SettingInfiniband) s_infiniband.set_property( NM.SETTING_INFINIBAND_MAC_ADDRESS, connection["mac"] @@ -774,17 +778,19 @@ class NMUtil: ), ) elif connection["type"] == "bridge": - s_con.set_property(NM.SETTING_CONNECTION_TYPE, "bridge") + s_con.set_property( + NM.SETTING_CONNECTION_TYPE, NM.SETTING_BRIDGE_SETTING_NAME + ) s_bridge = self.connection_ensure_setting(con, NM.SettingBridge) s_bridge.set_property(NM.SETTING_BRIDGE_STP, False) elif connection["type"] == "bond": - s_con.set_property(NM.SETTING_CONNECTION_TYPE, "bond") + s_con.set_property(NM.SETTING_CONNECTION_TYPE, NM.SETTING_BOND_SETTING_NAME) s_bond = self.connection_ensure_setting(con, NM.SettingBond) s_bond.add_option("mode", connection["bond"]["mode"]) if connection["bond"]["miimon"] is not None: s_bond.add_option("miimon", str(connection["bond"]["miimon"])) elif connection["type"] == "team": - s_con.set_property(NM.SETTING_CONNECTION_TYPE, "team") + s_con.set_property(NM.SETTING_CONNECTION_TYPE, NM.SETTING_TEAM_SETTING_NAME) elif connection["type"] == "vlan": s_vlan = self.connection_ensure_setting(con, NM.SettingVlan) s_vlan.set_property(NM.SETTING_VLAN_ID, connection["vlan"]["id"]) From 7157713b14ec05479f471e3c2aa26a91ed64494b Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 7 Feb 2019 19:52:52 +0100 Subject: [PATCH 2/2] module: fix setting NM connection-type for "vlan" and "macvlan" Otherwise: failure: created connection failed to normalize: nm-connection-error-quark: connection.type: property is missing (6) --- library/network_connections.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/network_connections.py b/library/network_connections.py index 200b356..0d7ac94 100644 --- a/library/network_connections.py +++ b/library/network_connections.py @@ -792,6 +792,7 @@ class NMUtil: elif connection["type"] == "team": s_con.set_property(NM.SETTING_CONNECTION_TYPE, NM.SETTING_TEAM_SETTING_NAME) elif connection["type"] == "vlan": + s_con.set_property(NM.SETTING_CONNECTION_TYPE, NM.SETTING_VLAN_SETTING_NAME) s_vlan = self.connection_ensure_setting(con, NM.SettingVlan) s_vlan.set_property(NM.SETTING_VLAN_ID, connection["vlan"]["id"]) s_vlan.set_property( @@ -801,6 +802,9 @@ class NMUtil: ), ) elif connection["type"] == "macvlan": + s_con.set_property( + NM.SETTING_CONNECTION_TYPE, NM.SETTING_MACVLAN_SETTING_NAME + ) # convert mode name to a number (which is actually expected by nm) mode = connection["macvlan"]["mode"] try: