From 1e44f3c00ff05bab6b20747653dd635ae8a7bc4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Thu, 1 Oct 2015 13:13:54 +0200 Subject: [PATCH 1/2] Add ip->db_host connection --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5df9a4d9..1181d1c6 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ Some very simple cluster setup: cd /vagrant solar resource create node1 resources/ro_node/ '{"ip":"10.0.0.3", "ssh_key" : "/vagrant/.vagrant/machines/solar-dev1/virtualbox/private_key", "ssh_user":"vagrant"}' -solar resource create mariadb_service resources/mariadb_service '{"image": "mariadb", "root_password": "mariadb", "port": 3306}' +solar resource create mariadb_service resources/mariadb_service '{"image": "mariadb", "root_password": "mariadb", "port": 3306, "ip": "db_host"}' solar resource create keystone_db resources/mariadb_keystone_db/ '{"db_name": "keystone_db", "login_user": "root"}' solar resource create keystone_db_user resources/mariadb_user/ user_name=keystone user_password=keystone # another valid format From b36713afd43946321f4b3bea3428663668ff239e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Thu, 1 Oct 2015 15:01:40 +0200 Subject: [PATCH 2/2] If mapping is not provided pass None to connect --- README.md | 4 ++-- solar/solar/cli/main.py | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index c2a8ec9e..20c5b3b5 100644 --- a/README.md +++ b/README.md @@ -72,13 +72,13 @@ Some very simple cluster setup: cd /vagrant solar resource create nodes templates/nodes.yaml '{"count": 2}' -solar resource create mariadb_service resources/mariadb_service '{"image": "mariadb", "root_password": "mariadb", "port": 3306, "ip": "db_host"}' +solar resource create mariadb_service resources/mariadb_service '{"image": "mariadb", "root_password": "mariadb", "port": 3306}' solar resource create keystone_db resources/mariadb_db/ '{"db_name": "keystone_db", "login_user": "root"}' solar resource create keystone_db_user resources/mariadb_user/ user_name=keystone user_password=keystone # another valid format solar connect node1 mariadb_service solar connect node1 keystone_db -solar connect mariadb_service keystone_db '{"root_password": "login_password", "port": "login_port"}' +solar connect mariadb_service keystone_db '{"root_password": "login_password", "port": "login_port", "ip": "db_host"}' # solar connect mariadb_service keystone_db_user 'root_password->login_password port->login_port' # another valid format solar connect keystone_db keystone_db_user diff --git a/solar/solar/cli/main.py b/solar/solar/cli/main.py index e7231ecb..c6b6f227 100644 --- a/solar/solar/cli/main.py +++ b/solar/solar/cli/main.py @@ -107,17 +107,19 @@ def init_cli_connect(): @click.argument('receiver') @click.argument('mapping', default='') def connect(mapping, receiver, emitter): - mapping_parsed = {} - - click.echo('Connect {} to {}'.format(emitter, receiver)) + mapping_parsed = None emitter = sresource.load(emitter) receiver = sresource.load(receiver) - try: - mapping_parsed.update(json.loads(mapping)) - except ValueError: - for m in mapping.split(): - k, v = m.split('->') - mapping_parsed.update({k: v}) + click.echo('Connect {} to {}'.format(emitter, receiver)) + + if mapping: + mapping_parsed = {} + try: + mapping_parsed.update(json.loads(mapping)) + except ValueError: + for m in mapping.split(): + k, v = m.split('->') + mapping_parsed.update({k: v}) signals.connect(emitter, receiver, mapping=mapping_parsed) show_emitter_connections(emitter)