From 0176726e7df4e6205f87f7d19da2eccc85fcf382 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowak Date: Thu, 24 Sep 2015 17:00:22 +0200 Subject: [PATCH] Riak example ported to new transports --- examples/riak/riaks.py | 3 +- templates/riak_nodes.yaml | 65 +++++++++++++++++++++++++++------------ 2 files changed, 47 insertions(+), 21 deletions(-) mode change 100644 => 100755 examples/riak/riaks.py diff --git a/examples/riak/riaks.py b/examples/riak/riaks.py old mode 100644 new mode 100755 index e4a93e7..8c8b474 --- a/examples/riak/riaks.py +++ b/examples/riak/riaks.py @@ -32,7 +32,8 @@ db = get_db() def setup_riak(): db.clear() - nodes = vr.create('nodes', 'templates/riak_nodes.yaml', {}) + resources = vr.create('nodes', 'templates/riak_nodes.yaml', {'count': 3}) + nodes = [x for x in resources if x.name.startswith('node')] node1, node2, node3 = nodes riak_services = [] diff --git a/templates/riak_nodes.yaml b/templates/riak_nodes.yaml index 57cce6d..8575c25 100644 --- a/templates/riak_nodes.yaml +++ b/templates/riak_nodes.yaml @@ -1,23 +1,48 @@ -id: simple_riak_cluster +id: simple_riak_with_transports resources: - - id: node1 +{% for i in range(count|int) %} + {% set j = i +1 %} + - id: ssh_transport{{j}} + from: resources/transport_ssh + values: + ssh_user: 'vagrant' + ssh_key: '/vagrant/.vagrant/machines/solar-dev{{j}}/virtualbox/private_key' + - id: transports{{j}} + from: resources/transports + values: + transports:key: ssh_transport{{j}}::ssh_key + transports:user: ssh_transport{{j}}::ssh_user + transports:port: ssh_transport{{j}}::ssh_port + transports:name: ssh_transport{{j}}::name + - id: node{{j}} from: resources/ro_node values: - ip: '10.0.0.3' - name: 'node1' - ssh_key: '/vagrant/.vagrant/machines/solar-dev1/virtualbox/private_key' - ssh_user: 'vagrant' - - id: node2 - from: resources/ro_node - values: - ip: '10.0.0.4' - name: 'node2' - ssh_key: '/vagrant/.vagrant/machines/solar-dev2/virtualbox/private_key' - ssh_user: 'vagrant' - - id: node3 - from: resources/ro_node - values: - ip: '10.0.0.5' - name: 'node3' - ssh_key: '/vagrant/.vagrant/machines/solar-dev3/virtualbox/private_key' - ssh_user: 'vagrant' + name: node{{j}} + ip: '10.0.0.{{i + 3}}' + transports_id: transports{{j}}::transports_id +{% endfor %} + + +# id: simple_riak_cluster +# resources: +# - id: node1 +# from: resources/ro_node +# values: +# ip: '10.0.0.3' +# name: 'node1' +# ssh_key: '/vagrant/.vagrant/machines/solar-dev1/virtualbox/private_key' +# ssh_user: 'vagrant' +# - id: node2 +# from: resources/ro_node +# values: +# ip: '10.0.0.4' +# name: 'node2' +# ssh_key: '/vagrant/.vagrant/machines/solar-dev2/virtualbox/private_key' +# ssh_user: 'vagrant' +# - id: node3 +# from: resources/ro_node +# values: +# ip: '10.0.0.5' +# name: 'node3' +# ssh_key: '/vagrant/.vagrant/machines/solar-dev3/virtualbox/private_key' +# ssh_user: 'vagrant'