Ejemplo n.º 1
0
def clone_connection(context, name, uuid, flags="TO_DISK"):
    import gi
    gi.require_version('NM', '1.0')
    from gi.repository import GLib, NM

    main_loop = GLib.MainLoop()
    nm_client = NM.Client.new(None)
    if uuid == "random":
        uuid = NM.utils_uuid_generate()
    elif uuid == "noted":
        uuid = context.noted['noted-value']
    elif uuid.startswith("noted."):
        index = uuid.replace("noted.","")
        uuid = context.noted[index]
    nm_flags = parse_NM_settings_flags_string(NM.SettingsAddConnection2Flags, flags)

    con2 = NM.SimpleConnection()
    s_con = NM.SettingConnection(type="802-3-ethernet", id=name, uuid=uuid)
    con2.add_setting(s_con)

    result = {}

    def _add_connection2_cb(cl, async_result, user_data):
        try:
            nm_client.add_connection2_finish(async_result)
        except Exception as e:
            result['error'] = e
        main_loop.quit()

    nm_client.add_connection2(con2.to_dbus(NM.ConnectionSerializationFlags.ALL), nm_flags, None, False, None, _add_connection2_cb, None)

    main_loop.run()

    if 'error' in result:
        raise Exception('add connection %s failed: %s' % (name, result['error']))
Ejemplo n.º 2
0
def clone_connection(context, con_src, con_dst, flags="TO_DISK"):
    import gi
    gi.require_version('NM', '1.0')
    from gi.repository import GLib, NM

    main_loop = GLib.MainLoop()
    nm_client = NM.Client.new(None)
    con = libnm_get_connection(nm_client, con_src)
    nm_flags = parse_NM_settings_flags_string(NM.SettingsAddConnection2Flags, flags)

    con2 = NM.SimpleConnection.new_clone(con)
    s_con = con2.get_setting_connection()
    s_con.set_property(NM.SETTING_CONNECTION_ID, con_dst)
    s_con.set_property(NM.SETTING_CONNECTION_UUID, NM.utils_uuid_generate())
    result = {}

    def _add_connection2_cb(cl, async_result, user_data):
        try:
            nm_client.add_connection2_finish(async_result)
        except Exception as e:
            result['error'] = e
        main_loop.quit()

    nm_client.add_connection2(con2.to_dbus(NM.ConnectionSerializationFlags.ALL), nm_flags, None, False, None, _add_connection2_cb, None)

    main_loop.run()

    if 'error' in result:
        raise Exception('add connection %s failed: %s' % (con_dst, result['error']))
Ejemplo n.º 3
0
def create_slave_connection(slave_type,
                            slave_idx,
                            slave,
                            master,
                            settings=None):
    """Create a slave NM connection for virtual connection (bond, team, bridge).

    :param slave_type: type of slave ("bond", "team", "bridge")
    :type slave_type: str
    :param slave_idx: index of the slave for naming
    :type slave_idx: int
    :param slave: slave's device name
    :type slave: str
    :param master: slave's master device name
    :type master: str
    :param settings: list of other settings to be added to the connection
    :type settings: list(NM.Setting)

    :return: created connection
    :rtype: NM.SimpleConnection
    """
    settings = settings or []
    slave_name = "%s slave %d" % (master, slave_idx)

    con = NM.SimpleConnection.new()
    s_con = NM.SettingConnection.new()
    s_con.props.uuid = NM.utils_uuid_generate()
    s_con.props.id = slave_name
    s_con.props.slave_type = slave_type
    s_con.props.master = master
    s_con.props.type = '802-3-ethernet'
    # HACK preventing NM to autoactivate the connection
    # The real network --onboot value (ifcfg ONBOOT) will be set later by
    # update_onboot
    s_con.props.autoconnect = False
    con.add_setting(s_con)

    s_wired = NM.SettingWired.new()
    con.add_setting(s_wired)

    for setting in settings:
        con.add_setting(setting)

    return con
Ejemplo n.º 4
0
    def connect_to_selection(self):
        model, iterator = self.get_selection().get_selected()
        if iterator is None:
            return
        parent = model.iter_parent(iterator)
        if parent:
            try:
                devid = model[parent][0]
                ssid = model[iterator][0]
                if model[iterator][1]:
                    if not self.nm_client:
                        self.nm_client = NM.Client.new()

                    device = self.nm_client.get_device_by_path(devid)
                    ap = self.find_ap(device, ssid)

                    connection = NM.SimpleConnection()
                    connection.add_setting(NM.SettingConnection(
                        uuid=NM.utils_uuid_generate()
                    ))
                    connection.add_setting(NM.SettingWireless(
                        ssid=ap.get_property("ssid")
                    ))

                    dialog = NMA.WifiDialog.new(
                        self.nm_client,
                        connection,
                        device,
                        ap,
                        False
                    )
                    dialog.connect("response", self.connect_dialog_cb)
                    dialog.run()
                else:
                    self.wifi_model.connect_to_ap(devid, ssid)
            except Exception as e:
                dialog = Gtk.MessageDialog(
                    None, Gtk.DialogFlags.MODAL,
                    Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE,
                    "Failed to connect to wireless network"
                )
                dialog.format_secondary_text("{}".format(e))
                dialog.run()
                dialog.hide()
Ejemplo n.º 5
0
def get_default_connection(iface, device_type):
    """Get default connection to be edited by the UI."""
    connection = NM.SimpleConnection.new()
    s_con = NM.SettingConnection.new()
    s_con.props.uuid = NM.utils_uuid_generate()
    s_con.props.autoconnect = True
    s_con.props.id = iface
    s_con.props.interface_name = iface
    if device_type == NM.DeviceType.ETHERNET:
        s_con.props.type = "802-3-ethernet"
        s_wired = NM.SettingWired.new()
        connection.add_setting(s_wired)
    elif device_type == NM.DeviceType.INFINIBAND:
        s_con.props.type = "infiniband"
        s_ib = NM.SettingInfiniband.new()
        s_ib.props.transport_mode = "datagram"
        connection.add_setting(s_ib)
    connection.add_setting(s_con)
    return connection
Ejemplo n.º 6
0
def get_default_connection(iface, device_type, autoconnect=False):
    """Get default connection to be edited by the UI."""
    connection = NM.SimpleConnection.new()
    s_con = NM.SettingConnection.new()
    s_con.props.uuid = NM.utils_uuid_generate()
    s_con.props.autoconnect = autoconnect
    s_con.props.id = iface
    s_con.props.interface_name = iface
    if device_type == NM.DeviceType.ETHERNET:
        s_con.props.type = "802-3-ethernet"
        s_wired = NM.SettingWired.new()
        connection.add_setting(s_wired)
    elif device_type == NM.DeviceType.INFINIBAND:
        s_con.props.type = "infiniband"
        s_ib = NM.SettingInfiniband.new()
        s_ib.props.transport_mode = "datagram"
        connection.add_settings(s_ib)
    connection.add_setting(s_con)
    return connection
Ejemplo n.º 7
0
def create_slave_connection(slave_type, slave_idx, slave, master, settings=None):
    """Create a slave NM connection for virtual connection (bond, team, bridge).

    :param slave_type: type of slave ("bond", "team", "bridge")
    :type slave_type: str
    :param slave_idx: index of the slave for naming
    :type slave_idx: int
    :param slave: slave's device name
    :type slave: str
    :param master: slave's master device name
    :type master: str
    :param settings: list of other settings to be added to the connection
    :type settings: list(NM.Setting)

    :return: created connection
    :rtype: NM.SimpleConnection
    """
    settings = settings or []
    slave_name = "%s slave %d" % (master, slave_idx)

    con = NM.SimpleConnection.new()
    s_con = NM.SettingConnection.new()
    s_con.props.uuid = NM.utils_uuid_generate()
    s_con.props.id = slave_name
    s_con.props.slave_type = slave_type
    s_con.props.master = master
    s_con.props.type = '802-3-ethernet'
    # HACK preventing NM to autoactivate the connection
    # The real network --onboot value (ifcfg ONBOOT) will be set later by
    # update_onboot
    s_con.props.autoconnect = False
    con.add_setting(s_con)

    s_wired = NM.SettingWired.new()
    con.add_setting(s_wired)

    for setting in settings:
        con.add_setting(setting)

    return con
Ejemplo n.º 8
0
def create_connections_from_ksdata(nm_client,
                                   network_data,
                                   device_name,
                                   ifname_option_values=None):
    """Create NM connections from kickstart configuration.

    :param network_data: kickstart configuration
    :type network_data: pykickstart NetworkData
    :param device_name: name of the device to be configured by kickstart
    :type device_name: str
    :param ifname_option_values: list of ifname boot option values
    :type ifname_option_values: list(str)
    :return: list of tuples (CONNECTION, NAME_OF_DEVICE_TO_BE_ACTIVATED)
    :rtype: list((NM.RemoteConnection, str))
    """
    ifname_option_values = ifname_option_values or []
    connections = []
    device_to_activate = device_name

    con_uuid = NM.utils_uuid_generate()
    con = NM.SimpleConnection.new()

    update_connection_ip_settings_from_ksdata(con, network_data)

    s_con = NM.SettingConnection.new()
    s_con.props.uuid = con_uuid
    s_con.props.id = device_name
    s_con.props.interface_name = device_name
    s_con.props.autoconnect = network_data.onboot
    con.add_setting(s_con)

    # type "bond"
    if network_data.bondslaves:
        _update_bond_connection_from_ksdata(con, network_data)

        for i, slave in enumerate(network_data.bondslaves.split(","), 1):
            slave_con = create_slave_connection('bond', i, slave, device_name)
            bind_connection(nm_client, slave_con, network_data.bindto, slave)
            connections.append((slave_con, slave))

    # type "team"
    elif network_data.teamslaves:
        _update_team_connection_from_ksdata(con, network_data)

        for i, (slave, cfg) in enumerate(network_data.teamslaves, 1):
            s_team_port = NM.SettingTeamPort.new()
            s_team_port.props.config = cfg
            slave_con = create_slave_connection('team',
                                                i,
                                                slave,
                                                device_name,
                                                settings=[s_team_port])
            bind_connection(nm_client, slave_con, network_data.bindto, slave)
            connections.append((slave_con, slave))

    # type "vlan"
    elif network_data.vlanid:
        device_to_activate = _update_vlan_connection_from_ksdata(
            con, network_data)

    # type "bridge"
    elif network_data.bridgeslaves:
        # bridge connection is autoactivated
        _update_bridge_connection_from_ksdata(con, network_data)

        for i, slave in enumerate(network_data.bridgeslaves.split(","), 1):
            slave_con = create_slave_connection('bridge', i, slave,
                                                device_name)
            bind_connection(nm_client, slave_con, network_data.bindto, slave)
            connections.append((slave_con, slave))

    # type "infiniband"
    elif is_infiniband_device(nm_client, device_name):
        _update_infiniband_connection_from_ksdata(con, network_data)

    # type "802-3-ethernet"
    else:
        bound_mac = bound_hwaddr_of_device(nm_client, device_name,
                                           ifname_option_values)
        _update_ethernet_connection_from_ksdata(con, network_data, bound_mac)
        if bound_mac:
            log.debug("add connection: mac %s is bound to name %s", bound_mac,
                      device_name)
        else:
            bind_connection(nm_client, con, network_data.bindto, device_name)

        # Add s390 settings
        if is_s390():
            s390cfg = get_s390_settings(device_name)
            _update_wired_connection_with_s390_settings(con, s390cfg)

    connections.insert(0, (con, device_to_activate))

    return connections
Ejemplo n.º 9
0
def main():

    main_loop = GLib.MainLoop()

    nm_client = NM.Client.new(None)

    arg_mode = None
    arg_block_autoconnect = NM.SettingsAddConnection2Flags.NONE
    arg_id = None
    arg_uuid = None

    cons = []

    argv = list(sys.argv[1:])
    while argv:
        if argv[0] == "--clone":
            match_type = None
            if len(argv) < 2:
                die("missing argument for --clone option")
            if argv[0] in ["id", "uuid"]:
                match_type = argv[0]
                if len(argv) < 3:
                    die('missing argument for "--clone %s" option' %
                        (match_type))
                argv = argv[1:]
            if cons:
                die("cannot specify --clone argument more than once")
            cons.extend(find_connections(nm_client, match_type, argv[1]))
            if len(cons) == 0:
                die('could not find connection for "--clone %s%s"' %
                    ((match_type or ""), argv[1]))
            if len(cons) != 1:
                die('could not find unique connection for "--clone %s%s"' %
                    ((match_type or ""), argv[1]))
            argv = argv[2:]
            continue
        if argv[0] in ["--block-autoconnect"]:
            arg_block_autoconnect = NM.SettingsAddConnection2Flags.BLOCK_AUTOCONNECT
            argv = argv[1:]
            continue
        if argv[0] in ["--to-disk", "--in-memory"]:
            if argv[0] == "--to-disk":
                v = NM.SettingsAddConnection2Flags.TO_DISK
            elif argv[0] == "--in-memory":
                v = NM.SettingsAddConnection2Flags.IN_MEMORY
            else:
                assert False
            if arg_mode is not None:
                die('duplicate storage modes ("%s")' % (argv[0]))
            arg_mode = v
            argv = argv[1:]
            continue
        if argv[0] in ["--id"]:
            if len(argv) < 2:
                die("missing argument for --id option")
            arg_id = argv[1]
            argv = argv[2:]
            continue
        if argv[0] in ["--uuid"]:
            if len(argv) < 2:
                die("missing argument for --uuid option")
            arg_uuid = argv[1]
            argv = argv[2:]
            continue
        die('unknown argument "%s"' % (argv[0]))

    if len(cons) != 1:
        die("missing --clone argument", True)

    con = cons[0]

    con2 = NM.SimpleConnection.new_clone(con)

    s_con = con2.get_setting_connection()
    if arg_id:
        s_con.set_property(NM.SETTING_CONNECTION_ID, arg_id)
    s_con.set_property(NM.SETTING_CONNECTION_UUID, arg_uuid
                       or NM.utils_uuid_generate())

    result = {}

    def _add_connection2_cb(cl, async_result, user_data):
        try:
            c, r = nm_client.add_connection2_finish(async_result)
        except Exception as e:
            result["error"] = e
        else:
            result["result"] = r
            result["connection"] = c
        main_loop.quit()

    nm_client.add_connection2(
        con2.to_dbus(NM.ConnectionSerializationFlags.ALL),
        (arg_mode
         if arg_mode is not None else NM.SettingsAddConnection2Flags.TO_DISK)
        | arg_block_autoconnect,
        None,
        False,
        None,
        _add_connection2_cb,
        None,
    )

    main_loop.run()

    if "error" in result:
        die("update connection %s failed [%s]: %s" %
            (con_to_str(con2), " ".join(sys.argv), result["error"]))

    print("update connection %s succeeded [%s]: %s, %s" % (
        con_to_str(con2),
        " ".join(sys.argv),
        result["connection"].get_path(),
        result["result"],
    ))
Ejemplo n.º 10
0
def add_bridges_vlans_range(context, begin, end, ifname):
    try:
        begin = int(begin)
        end = int(end)
        assert begin > 0, f"invalid range: begin is not positive integer: {begin}"
        assert end > 0, f"invalid range: end is not positive integer: {end}"
        assert begin <= end, f"invalid range: begin is not less than end: {begin} > {end}"
    except Exception:
        assert False, f"begin and end must be positive integers: {begin}, {end}"

    vlan_range = [f"{ifname}.{id}" for id in range(begin, end + 1)]
    vlan_range += [f"br{id}" for id in range(begin, end + 1)]
    context.vlan_range = getattr(context, "vlan_range", [])
    context.vlan_range += vlan_range

    from nmci.util import GLib, NM
    nm_client = NM.Client.new(None)
    result = {}

    def _add_connection_cb(cl, async_result, user_data):
        try:
            cl.add_connection_finish(async_result)
        except Exception as e:
            result['error'] = e
        if user_data is not None:
            user_data.quit()

    for id in range(begin, end + 1):

        main_loop = GLib.MainLoop()
        con = NM.SimpleConnection.new()
        uuid = NM.utils_uuid_generate()
        s_con = NM.SettingConnection(type="bridge", id=f"br{id}", uuid=uuid)
        s_con.set_property(NM.SETTING_CONNECTION_INTERFACE_NAME, f"br{id}")
        s_bridge = NM.SettingBridge.new()
        s_ip4 = NM.SettingIP4Config.new()
        s_ip4.set_property(NM.SETTING_IP_CONFIG_METHOD, "disabled")
        s_ip6 = NM.SettingIP6Config.new()
        s_ip6.set_property(NM.SETTING_IP_CONFIG_METHOD, "disabled")
        con.add_setting(s_con)
        con.add_setting(s_bridge)
        con.add_setting(s_ip4)
        con.add_setting(s_ip6)
        nm_client.add_connection_async(con, True, None, _add_connection_cb,
                                       main_loop)
        main_loop.run()

        main_loop = GLib.MainLoop()
        con = NM.SimpleConnection.new()
        uuid = NM.utils_uuid_generate()
        s_con = NM.SettingConnection(type="vlan",
                                     id=f"{ifname}.{id}",
                                     uuid=uuid)
        s_con.set_property(NM.SETTING_CONNECTION_INTERFACE_NAME,
                           f"{ifname}.{id}")
        s_con.set_property(NM.SETTING_CONNECTION_SLAVE_TYPE, "bridge")
        s_con.set_property(NM.SETTING_CONNECTION_MASTER, f"br{id}")
        s_vlan = NM.SettingVlan(id=id, parent=ifname)
        con.add_setting(s_con)
        con.add_setting(s_vlan)
        nm_client.add_connection_async(con, True, None, _add_connection_cb,
                                       main_loop)
        main_loop.run()

        assert 'error' not in result, \
            'add connection %s failed: %s' % (result['error'])
Ejemplo n.º 11
0
def add_connection_from_ksdata(nm_client,
                               network_data,
                               device_name,
                               activate=False,
                               ifname_option_values=None):
    """Add NM connection created from kickstart configuration.

    :param network_data: kickstart configuration
    :type network_data: pykickstart NetworkData
    :param device_name: name of the device to be configured by kickstart
    :type device_name: str
    :param activate: activate the added connection
    :type activate: bool
    :param ifname_option_values: list of ifname boot option values
    :type ifname_option_values: list(str)
    """
    ifname_option_values = ifname_option_values or []
    added_connections = []
    device_to_activate = device_name

    con_uuid = NM.utils_uuid_generate()
    con = NM.SimpleConnection.new()

    update_connection_ip_settings_from_ksdata(con, network_data)

    s_con = NM.SettingConnection.new()
    s_con.props.uuid = con_uuid
    s_con.props.id = device_name
    s_con.props.interface_name = device_name
    # HACK preventing NM to autoactivate the connection
    # The real network --onboot value (ifcfg ONBOOT) will be set later by
    # update_onboot
    s_con.props.autoconnect = False
    con.add_setting(s_con)

    # type "bond"
    if network_data.bondslaves:
        _update_bond_connection_from_ksdata(con, network_data)

        for i, slave in enumerate(network_data.bondslaves.split(","), 1):
            slave_con = create_slave_connection('bond', i, slave, device_name)
            bind_connection(nm_client, slave_con, network_data.bindto, slave)
            added_connections.append((slave_con, slave))

    # type "team"
    elif network_data.teamslaves:
        _update_team_connection_from_ksdata(con, network_data)

        for i, (slave, cfg) in enumerate(network_data.teamslaves, 1):
            s_team_port = NM.SettingTeamPort.new()
            s_team_port.props.config = cfg
            slave_con = create_slave_connection('team',
                                                i,
                                                slave,
                                                device_name,
                                                settings=[s_team_port])
            bind_connection(nm_client, slave_con, network_data.bindto, slave)
            added_connections.append((slave_con, slave))

    # type "vlan"
    elif network_data.vlanid:
        device_to_activate = _update_vlan_connection_from_ksdata(
            con, network_data)

    # type "bridge"
    elif network_data.bridgeslaves:
        # bridge connection is autoactivated
        _update_bridge_connection_from_ksdata(con, network_data)

        for i, slave in enumerate(network_data.bridgeslaves.split(","), 1):
            slave_con = create_slave_connection('bridge', i, slave,
                                                device_name)
            bind_connection(nm_client, slave_con, network_data.bindto, slave)
            added_connections.append((slave_con, slave))

    # type "infiniband"
    elif is_infiniband_device(nm_client, device_name):
        _update_infiniband_connection_from_ksdata(con, network_data)

    # type "802-3-ethernet"
    else:
        bound_mac = bound_hwaddr_of_device(nm_client, device_name,
                                           ifname_option_values)
        _update_ethernet_connection_from_ksdata(con, network_data, bound_mac)
        if bound_mac:
            log.debug("add connection: mac %s is bound to name %s", bound_mac,
                      device_name)
        else:
            bind_connection(nm_client, con, network_data.bindto, device_name)

        # Add s390 settings
        if is_s390():
            s390cfg = get_s390_settings(device_name)
            _update_wired_connection_with_s390_settings(con, s390cfg)

    added_connections.insert(0, (con, device_to_activate))

    for con, device_name in added_connections:
        log.debug("add connection: %s for %s\n%s", con_uuid, device_name,
                  con.to_dbus(NM.ConnectionSerializationFlags.NO_SECRETS))
        device_to_activate = device_name if activate else None
        nm_client.add_connection_async(con, True, None, _connection_added_cb,
                                       device_to_activate)

    return added_connections
Ejemplo n.º 12
0
def add_connection_from_ksdata(nm_client, network_data, device_name, activate=False, ifname_option_values=None):
    """Add NM connection created from kickstart configuration.

    :param network_data: kickstart configuration
    :type network_data: pykickstart NetworkData
    :param device_name: name of the device to be configured by kickstart
    :type device_name: str
    :param activate: activate the added connection
    :type activate: bool
    :param ifname_option_values: list of ifname boot option values
    :type ifname_option_values: list(str)
    """
    ifname_option_values = ifname_option_values or []
    added_connections = []
    device_to_activate = device_name

    con_uuid = NM.utils_uuid_generate()
    con = NM.SimpleConnection.new()

    update_connection_ip_settings_from_ksdata(con, network_data)

    s_con = NM.SettingConnection.new()
    s_con.props.uuid = con_uuid
    s_con.props.id = device_name
    s_con.props.interface_name = device_name
    # HACK preventing NM to autoactivate the connection
    # The real network --onboot value (ifcfg ONBOOT) will be set later by
    # update_onboot
    s_con.props.autoconnect = False
    con.add_setting(s_con)

    # type "bond"
    if network_data.bondslaves:
        _update_bond_connection_from_ksdata(con, network_data)

        for i, slave in enumerate(network_data.bondslaves.split(","), 1):
            slave_con = create_slave_connection('bond', i, slave, device_name)
            bind_connection(nm_client, slave_con, network_data.bindto, slave)
            added_connections.append((slave_con, slave))

    # type "team"
    elif network_data.teamslaves:
        _update_team_connection_from_ksdata(con, network_data)

        for i, (slave, cfg) in enumerate(network_data.teamslaves, 1):
            s_team_port = NM.SettingTeamPort.new()
            s_team_port.props.config = cfg
            slave_con = create_slave_connection('team', i, slave, device_name,
                                                settings=[s_team_port])
            bind_connection(nm_client, slave_con, network_data.bindto, slave)
            added_connections.append((slave_con, slave))

    # type "vlan"
    elif network_data.vlanid:
        device_to_activate = _update_vlan_connection_from_ksdata(con, network_data)

    # type "bridge"
    elif network_data.bridgeslaves:
        # bridge connection is autoactivated
        _update_bridge_connection_from_ksdata(con, network_data)

        for i, slave in enumerate(network_data.bridgeslaves.split(","), 1):
            slave_con = create_slave_connection('bridge', i, slave, device_name)
            bind_connection(nm_client, slave_con, network_data.bindto, slave)
            added_connections.append((slave_con, slave))

    # type "infiniband"
    elif is_infiniband_device(nm_client, device_name):
        _update_infiniband_connection_from_ksdata(con, network_data)

    # type "802-3-ethernet"
    else:
        bound_mac = bound_hwaddr_of_device(nm_client, device_name, ifname_option_values)
        _update_ethernet_connection_from_ksdata(con, network_data, bound_mac)
        if bound_mac:
            log.debug("add connection: mac %s is bound to name %s",
                      bound_mac, device_name)
        else:
            bind_connection(nm_client, con, network_data.bindto, device_name)

        # Add s390 settings
        if is_s390():
            s390cfg = get_s390_settings(device_name)
            _update_wired_connection_with_s390_settings(con, s390cfg)

    added_connections.insert(0, (con, device_to_activate))

    for con, device_name in added_connections:
        log.debug("add connection: %s for %s\n%s", con_uuid, device_name,
                  con.to_dbus(NM.ConnectionSerializationFlags.NO_SECRETS))
        device_to_activate = device_name if activate else None
        nm_client.add_connection_async(con, True, None,
                                       _connection_added_cb,
                                       device_to_activate)

    return added_connections