コード例 #1
0
def deactivate_active_connection(nm_ac, timeout, check_mode):
    if not nm_ac or nm_ac.props.state == client.NM.ActiveConnectionState.DEACTIVATED:
        logging.info("Connection is not active, no need to deactivate")
        return False
    if not check_mode:
        main_loop = client.get_mainloop(timeout)
        logging.debug(
            "Deactivating {id} with timeout {timeout}".format(
                id=nm_ac.get_id(), timeout=timeout
            )
        )
        user_data = main_loop
        handler_id = nm_ac.connect(
            NM_AC_STATE_CHANGED_SIGNAL, _nm_ac_state_change_callback, user_data
        )
        logging.debug(
            "Registered {signal} on client.NM.ActiveConnection {id}".format(
                signal=NM_AC_STATE_CHANGED_SIGNAL, id=nm_ac.get_id()
            )
        )
        if nm_ac.props.state != client.NM.ActiveConnectionState.DEACTIVATING:
            nm_client = client.get_client()
            user_data = (main_loop, nm_ac, nm_ac.get_id(), handler_id)
            nm_client.deactivate_connection_async(
                nm_ac,
                main_loop.cancellable,
                _nm_ac_deactivate_call_back,
                user_data,
            )
            logging.debug(
                "Deactivating client.NM.ActiveConnection {0}".format(nm_ac.get_id())
            )
        main_loop.run()
    return True
コード例 #2
0
ファイル: provider.py プロジェクト: tyll/network
 def reload_configuration(self):
     timeout = 10
     nm_client = client.get_client()
     main_loop = client.get_mainloop(timeout)
     logging.debug("Reloading configuration with timeout %s", timeout)
     nm_client.reload_connections_async(main_loop.cancellable,
                                        _reload_config_callback, main_loop)
     main_loop.run()
コード例 #3
0
ファイル: provider.py プロジェクト: tyll/network
    def deactivate_connection(self, connection_name, timeout, check_mode):
        """
        Return True if changed.
        """
        nm_client = client.get_client()
        changed = False
        for nm_ac in nm_client.get_active_connections():
            nm_profile = nm_ac.get_connection()
            if nm_profile and nm_profile.get_id() == connection_name:
                changed |= active_connection.deactivate_active_connection(
                    nm_ac, timeout, check_mode)
        if not changed:
            logging.info("No active connection for %s", connection_name)

        return changed
コード例 #4
0
ファイル: provider.py プロジェクト: tyll/network
    def volatilize_connection_by_uuid(self, uuid, timeout, check_mode):
        """
        Mark NM.RemoteConnection as volatile(delete on deactivation) via Update2,
        if not supported, delete the profile.

        Return True if changed.
        """
        nm_client = client.get_client()
        changed = False
        for nm_profile in nm_client.get_connections():
            if nm_profile and nm_profile.get_uuid() == uuid:
                if hasattr(nm_profile, "update2"):
                    changed |= connection.volatilize_remote_connection(
                        nm_profile, timeout, check_mode)
                else:
                    changed |= connection.delete_remote_connection(
                        nm_profile, timeout, check_mode)
        if not changed:
            logging.info("No connection with UUID %s to volatilize", uuid)

        return changed
コード例 #5
0
 def get_connections(self):
     nm_client = client.get_client()
     return nm_client.get_connections()
コード例 #6
0
ファイル: provider.py プロジェクト: tyll/network
 def get_client_version(self):
     nm_client = client.get_client()
     return nm_client.get_version()