Disconnect functionality
This commit is contained in:
parent
c43be7fe5f
commit
d6bbb652e6
@ -77,4 +77,7 @@ python cli.py connect rs/mariadb_nova_data rs/node1 --mapping '{"host" : "node1.
|
||||
# View connections
|
||||
python cli.py connections show
|
||||
python cli.py connections graph
|
||||
|
||||
# Disconnect
|
||||
python cli.py disconnect rs/mariadb_nova_data rs/node1
|
||||
```
|
||||
|
13
cli.py
13
cli.py
@ -55,6 +55,19 @@ def init_cli_connect():
|
||||
|
||||
cli.add_command(connect)
|
||||
|
||||
@click.command()
|
||||
@click.argument('emitter')
|
||||
@click.argument('receiver')
|
||||
def disconnect(receiver, emitter):
|
||||
print 'Disconnect', emitter, receiver
|
||||
emitter = xr.load(emitter)
|
||||
receiver = xr.load(receiver)
|
||||
print emitter
|
||||
print receiver
|
||||
xs.disconnect(emitter, receiver)
|
||||
|
||||
cli.add_command(disconnect)
|
||||
|
||||
|
||||
def init_cli_connections():
|
||||
@click.group()
|
||||
|
10
x/signals.py
10
x/signals.py
@ -61,6 +61,16 @@ def connect(emitter, receiver, mapping=None):
|
||||
utils.save_to_config_file(CLIENTS_CONFIG_KEY, CLIENTS)
|
||||
|
||||
|
||||
def disconnect(emitter, receiver):
|
||||
for src, destinations in CLIENTS[emitter.name].items():
|
||||
CLIENTS[emitter.name][src] = [
|
||||
destination for destination in destinations
|
||||
if destination[0] != receiver.name
|
||||
]
|
||||
|
||||
utils.save_to_config_file(CLIENTS_CONFIG_KEY, CLIENTS)
|
||||
|
||||
|
||||
def notify(source, key, value):
|
||||
CLIENTS.setdefault(source.name, [])
|
||||
if key in CLIENTS[source.name]:
|
||||
|
Loading…
Reference in New Issue
Block a user