Disconnect functionality

This commit is contained in:
Przemyslaw Kaminski 2015-04-17 11:21:23 +02:00
parent c43be7fe5f
commit d6bbb652e6
3 changed files with 26 additions and 0 deletions

View File

@ -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
View File

@ -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()

View File

@ -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]: