def ConnectionDelete(self):
    '''Deletes a connection.

    This also
        * removes the deleted connection from any device,
        * removes any active connection(s) it might be associated with,
        * removes it from the Settings interface,
        * as well as deletes the object from the mock.

    Note: If this was the only active connection, we change the global
    connection state.
    '''
    connection_path = self.connection_path

    NM = dbusmock.get_object(MANAGER_OBJ)
    settings_obj = dbusmock.get_object(SETTINGS_OBJ)

    # Find the associated active connection(s).
    active_connections = NM.Get(MANAGER_IFACE, 'ActiveConnections')
    associated_active_connections = []
    for ac in active_connections:
        ac_obj = dbusmock.get_object(ac)
        ac_con = ac_obj.Get(ACTIVE_CONNECTION_IFACE, 'Connection')
        if ac_con == connection_path:
            associated_active_connections.append(ac)

    # We found that the connection we are deleting are associated to all
    # active connections and subsequently set the global state to
    # disconnected.
    if len(active_connections) == len(associated_active_connections):
        self.SetGlobalConnectionState(NMState.NM_STATE_DISCONNECTED)

    # Remove the connection from all associated devices.
    # We also remove all associated active connections.
    for dev_path in NM.GetDevices():
        dev_obj = dbusmock.get_object(dev_path)
        connections = dev_obj.Get(DEVICE_IFACE, 'AvailableConnections')

        for ac in associated_active_connections:
            NM.RemoveActiveConnection(dev_path, ac)

        if connection_path not in connections:
            continue

        connections.remove(dbus.ObjectPath(connection_path))
        dev_obj.Set(DEVICE_IFACE, 'AvailableConnections', connections)

    # Remove the connection from the settings interface
    main_connections = settings_obj.ListConnections()
    if connection_path not in main_connections:
        return
    main_connections.remove(connection_path)
    settings_obj.Set(SETTINGS_IFACE, 'Connections', main_connections)
    settings_obj.EmitSignal(SETTINGS_IFACE, 'ConnectionRemoved', 'o', [connection_path])

    # Remove the connection from the mock
    connection_obj = dbusmock.get_object(connection_path)
    connection_obj.EmitSignal(CSETTINGS_IFACE, 'Removed', '', [])

    self.object_manager_emit_removed(connection_path)
    self.RemoveObject(connection_path)
def ConnectionDelete ( self ) : connection_path = self . connection_path NM = dbusmock . get_object ( MANAGER_OBJ ) settings_obj = dbusmock . get_object ( SETTINGS_OBJ ) active_connections = NM . Get ( MANAGER_IFACE , 'ActiveConnections' ) associated_active_connections = [ ] for ac in active_connections : ac_obj = dbusmock . get_object ( ac ) ac_con = ac_obj . Get ( ACTIVE_CONNECTION_IFACE , 'Connection' ) if ac_con == connection_path : associated_active_connections . append ( ac ) if len ( active_connections ) == len ( associated_active_connections ) : self . SetGlobalConnectionState ( NMState . NM_STATE_DISCONNECTED ) for dev_path in NM . GetDevices ( ) : dev_obj = dbusmock . get_object ( dev_path ) connections = dev_obj . Get ( DEVICE_IFACE , 'AvailableConnections' ) for ac in associated_active_connections : NM . RemoveActiveConnection ( dev_path , ac ) if connection_path not in connections : continue connections . remove ( dbus . ObjectPath ( connection_path ) ) dev_obj . Set ( DEVICE_IFACE , 'AvailableConnections' , connections ) main_connections = settings_obj . ListConnections ( ) if connection_path not in main_connections : return main_connections . remove ( connection_path ) settings_obj . Set ( SETTINGS_IFACE , 'Connections' , main_connections ) settings_obj . EmitSignal ( SETTINGS_IFACE , 'ConnectionRemoved' , 'o' , [ connection_path ] ) connection_obj = dbusmock . get_object ( connection_path ) connection_obj . EmitSignal ( CSETTINGS_IFACE , 'Removed' , '' , [ ] ) self . object_manager_emit_removed ( connection_path ) self . RemoveObject ( connection_path )
Deletes a connection.

    This also
        * removes the deleted connection from any device,
        * removes any active connection(s) it might be associated with,
        * removes it from the Settings interface,
        * as well as deletes the object from the mock.

    Note: If this was the only active connection, we change the global
    connection state.