diff --git a/README.md b/README.md index 4cbddf53..79327b87 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/cli.py b/cli.py index ce803853..dab27e11 100644 --- a/cli.py +++ b/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() diff --git a/x/signals.py b/x/signals.py index 85d1bb26..bb9f6210 100644 --- a/x/signals.py +++ b/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]: