def deactivate(request, uuid): """Deactivate the connection.""" try: active_connection = network.deactivate_connection(uuid) name = active_connection.get_id() messages.success(request, _("Deactivated connection %s.") % name) except network.ConnectionNotFound: messages.error(request, _("Failed to de-activate connection: " "Connection not found.")) return redirect(reverse_lazy("networks:index"))
def enable_connections(enable): """Activate all connections and set them to auto-connect.""" setting_name = nm.SETTING_WIREGUARD_SETTING_NAME client = network.get_nm_client() for connection in client.get_connections(): if connection.get_connection_type() != setting_name: continue network.edit_connection(connection, {'common': { 'autoconnect': enable }}) if enable: network.activate_connection(connection.get_uuid()) else: try: network.deactivate_connection(connection.get_uuid()) except network.ConnectionNotFound: pass # Connection is already inactive
def deactivate(request, uuid): """Deactivate the connection.""" try: active_connection = network.deactivate_connection(uuid) name = active_connection.get_id() messages.success(request, _('Deactivated connection %s.') % name) except network.ConnectionNotFound: messages.error(request, _('Failed to de-activate connection: ' 'Connection not found.')) return redirect(reverse_lazy('networks:index'))
def deactivate(request, uuid): """Deactivate the connection.""" try: active_connection = network.deactivate_connection(uuid) name = active_connection.Connection.GetSettings()['connection']['id'] messages.success(request, _('Deactivated connection %s.') % name) except network.ConnectionNotFound: messages.error(request, _('Failed to de-activate connection: ' 'Connection not found.')) return redirect(reverse_lazy('networks:index'))
def deactivate(request, uuid): """Deactivate the connection.""" try: active_connection = network.deactivate_connection(uuid) name = active_connection.get_id() messages.success(request, _('Deactivated connection {name}.') .format(name=name)) except network.ConnectionNotFound: messages.error(request, _('Failed to de-activate connection: ' 'Connection not found.')) return redirect(reverse_lazy('networks:index'))