From 4263b6e8345d7243e8f1a41fe33b9b8c3c09680c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Sat, 26 Sep 2015 17:32:55 +0200 Subject: [PATCH 1/4] Fix riak cluster virtual resource after removing ssh_* inputs --- examples/riak/riak_cluster.yaml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/examples/riak/riak_cluster.yaml b/examples/riak/riak_cluster.yaml index 288eb47d..b2e605bc 100644 --- a/examples/riak/riak_cluster.yaml +++ b/examples/riak/riak_cluster.yaml @@ -8,8 +8,6 @@ resources: riak_hostname: 'riak_server0.solar' riak_name: 'riak0@riak_server0.solar' ip: '{{nodes[0]}}::ip' - ssh_user: '{{nodes[0]}}::ssh_user' - ssh_key: '{{nodes[0]}}::ssh_key' {% for i in range(1, idx|int) %} - id: riak_service{{i}} @@ -20,8 +18,6 @@ resources: riak_name: 'riak{{i}}@riak_server{{i}}.solar' join_to: 'riak_service0::riak_name' ip: '{{nodes[i]}}::ip' - ssh_user: '{{nodes[i]}}::ssh_user' - ssh_key: '{{nodes[i]}}::ssh_key' {% endfor %} {% for i in range(idx|int) %} @@ -36,9 +32,6 @@ resources: {% for j in range(idx|int) %} - riak_service{{j}}::ip::NO_EVENTS {% endfor %} - ip: '{{nodes[i]}}::ip' - ssh_user: '{{nodes[i]}}::ssh_user' - ssh_key: '{{nodes[i]}}::ssh_key' {% endfor %} {% for i in range(idx|int) %} @@ -92,8 +85,6 @@ resources: - haproxy_service_config_http{{i}}::backends - haproxy_service_config_pb{{i}}::backends ip: '{{nodes[i]}}::ip' - ssh_user: '{{nodes[i]}}::ssh_user' - ssh_key: '{{nodes[i]}}::ssh_key' {% endfor %} {% for i in range(idx|int) %} @@ -101,8 +92,6 @@ resources: from: resources/haproxy_service values: ip: '{{nodes[i]}}::ip' - ssh_user: '{{nodes[i]}}::ssh_user' - ssh_key: '{{nodes[i]}}::ssh_key' {% endfor %} From 12d19f73954c5c91c8d21a4c39195571c52806ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Sat, 26 Sep 2015 17:34:56 +0200 Subject: [PATCH 2/4] Guess mapping only if it is None It allows to pass {} as a mapping and guessing will not be used --- solar/solar/core/signals.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/solar/solar/core/signals.py b/solar/solar/core/signals.py index 4cef5dde..8ad10179 100644 --- a/solar/solar/core/signals.py +++ b/solar/solar/core/signals.py @@ -90,7 +90,8 @@ def location_and_transports(emitter, receiver, orig_mapping): def connect(emitter, receiver, mapping=None, events=None): - mapping = mapping or guess_mapping(emitter, receiver) + if mapping is None: + mapping = guess_mapping(emitter, receiver) # XXX: we didn't agree on that "reverse" there location_and_transports(emitter, receiver, mapping) From dbd9833607a4660fd15768ea8eb2a21c3aa28b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Sat, 26 Sep 2015 17:37:24 +0200 Subject: [PATCH 3/4] Add location key to Virtual Resources After ssh_* were removed key location will be used to define where resource will be run --- examples/riak/riak_cluster.yaml | 7 +++++++ solar/solar/core/resource/virtual_resource.py | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/examples/riak/riak_cluster.yaml b/examples/riak/riak_cluster.yaml index b2e605bc..32d9cd3e 100644 --- a/examples/riak/riak_cluster.yaml +++ b/examples/riak/riak_cluster.yaml @@ -3,6 +3,7 @@ id: riak_node resources: - id: riak_service0 from: resources/riak_node + location: {{nodes[0]}} values: riak_self_name: 'riak0' riak_hostname: 'riak_server0.solar' @@ -12,6 +13,7 @@ resources: {% for i in range(1, idx|int) %} - id: riak_service{{i}} from: resources/riak_node + location: {{nodes[i]}} values: riak_self_name: 'riak{{i}}' riak_hostname: 'riak_server{{i}}.solar' @@ -23,6 +25,7 @@ resources: {% for i in range(idx|int) %} - id: hosts_file{{i}} from: resources/hosts_file + location: {{nodes[i]}} values: hosts:name: {% for j in range(idx|int) %} @@ -37,6 +40,7 @@ resources: {% for i in range(idx|int) %} - id: haproxy_service_config_http{{i}} from: resources/haproxy_service_config + location: {{nodes[i]}} values: listen_port: 8098 protocol: 'http' @@ -54,6 +58,7 @@ resources: {% for i in range(idx|int) %} - id: haproxy_service_config_pb{{i}} from: resources/haproxy_service_config + location: {{nodes[i]}} values: listen_port: 8087 protocol: 'tcp' @@ -71,6 +76,7 @@ resources: {% for i in range(idx|int) %} - id: haproxy_config{{i}} from: resources/haproxy_config + location: {{nodes[i]}} values: config:protocol: - haproxy_service_config_http{{i}}::protocol @@ -89,6 +95,7 @@ resources: {% for i in range(idx|int) %} - id: haproxy_service{{i}} + location: {{nodes[i]}} from: resources/haproxy_service values: ip: '{{nodes[i]}}::ip' diff --git a/solar/solar/core/resource/virtual_resource.py b/solar/solar/core/resource/virtual_resource.py index 0de2986d..a9359050 100644 --- a/solar/solar/core/resource/virtual_resource.py +++ b/solar/solar/core/resource/virtual_resource.py @@ -117,11 +117,16 @@ def create_resources(resources): for r in resources: resource_name = r['id'] args = r['values'] + node = r.get('location', None) from_path = r.get('from', None) base_path = os.path.join(cwd, from_path) new_resources = create(resource_name, base_path) created_resources += new_resources if not is_virtual(base_path): + if node: + node = load_resource(node) + r = load_resource(resource_name) + signals.connect(node, r, {}) update_inputs(resource_name, args) return created_resources From 8e5912939e2d0f9b228325f31b5037f59ed94bbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Sat, 26 Sep 2015 17:59:52 +0200 Subject: [PATCH 4/4] VR optimalization for riak cluster Only one haproxy_riak_config_http and one haproxy_riak_config_pb is required. --- examples/riak/riak_cluster.yaml | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/examples/riak/riak_cluster.yaml b/examples/riak/riak_cluster.yaml index 32d9cd3e..4fc93e91 100644 --- a/examples/riak/riak_cluster.yaml +++ b/examples/riak/riak_cluster.yaml @@ -37,14 +37,12 @@ resources: {% endfor %} {% endfor %} -{% for i in range(idx|int) %} - - id: haproxy_service_config_http{{i}} + - id: haproxy_riak_config_http from: resources/haproxy_service_config - location: {{nodes[i]}} values: listen_port: 8098 protocol: 'http' - name: 'riak_haproxy_http{{i}}' + name: 'riak_haproxy_http' backends:server: {% for j in range(idx|int) %} - riak_service{{j}}::riak_hostname @@ -53,16 +51,13 @@ resources: {% for j in range(idx|int) %} - riak_service{{j}}::riak_port_http {% endfor %} -{% endfor %} -{% for i in range(idx|int) %} - - id: haproxy_service_config_pb{{i}} + - id: haproxy_riak_config_pb from: resources/haproxy_service_config - location: {{nodes[i]}} values: listen_port: 8087 protocol: 'tcp' - name: 'riak_haproxy_pb{{i}}' + name: 'riak_haproxy_pb' backends:server: {% for j in range(idx|int) %} - riak_service{{j}}::riak_hostname @@ -71,7 +66,6 @@ resources: {% for j in range(idx|int) %} - riak_service{{j}}::riak_port_pb {% endfor %} -{% endfor %} {% for i in range(idx|int) %} - id: haproxy_config{{i}} @@ -79,17 +73,17 @@ resources: location: {{nodes[i]}} values: config:protocol: - - haproxy_service_config_http{{i}}::protocol - - haproxy_service_config_pb{{i}}::protocol + - haproxy_riak_config_http::protocol + - haproxy_riak_config_pb::protocol config:listen_port: - - haproxy_service_config_http{{i}}::listen_port - - haproxy_service_config_pb{{i}}::listen_port + - haproxy_riak_config_http::listen_port + - haproxy_riak_config_pb::listen_port config:name: - - haproxy_service_config_http{{i}}::name - - haproxy_service_config_pb{{i}}::name + - haproxy_riak_config_http::name + - haproxy_riak_config_pb::name config:backends: - - haproxy_service_config_http{{i}}::backends - - haproxy_service_config_pb{{i}}::backends + - haproxy_riak_config_http::backends + - haproxy_riak_config_pb::backends ip: '{{nodes[i]}}::ip' {% endfor %}