Fix hosts_file/riak and solard examples
This commit is contained in:
parent
a08e512804
commit
4d5d2c8040
@ -20,22 +20,22 @@ def run():
|
||||
|
||||
hosts1 = vr.create('hosts_file1', 'resources/hosts_file', {})[0]
|
||||
hosts2 = vr.create('hosts_file2', 'resources/hosts_file', {})[0]
|
||||
node1.connect_with_defaults(hosts1, {
|
||||
node1.connect(hosts1, {
|
||||
'name': 'hosts:name',
|
||||
'ip': 'hosts:ip',
|
||||
})
|
||||
|
||||
node2.connect_with_defaults(hosts1, {
|
||||
node2.connect(hosts1, {
|
||||
'name': 'hosts:name',
|
||||
'ip': 'hosts:ip',
|
||||
})
|
||||
|
||||
node1.connect_with_defaults(hosts2, {
|
||||
node1.connect(hosts2, {
|
||||
'name': 'hosts:name',
|
||||
'ip': 'hosts:ip',
|
||||
})
|
||||
|
||||
node2.connect_with_defaults(hosts2, {
|
||||
node2.connect(hosts2, {
|
||||
'name': 'hosts:name',
|
||||
'ip': 'hosts:ip',
|
||||
})
|
||||
|
@ -32,7 +32,7 @@ db = get_db()
|
||||
def setup_riak():
|
||||
db.clear()
|
||||
|
||||
resources = vr.create('nodes', 'templates/riak_nodes.yaml', {'count': 3})
|
||||
resources = vr.create('nodes', 'templates/nodes.yaml', {'count': 3})
|
||||
nodes = [x for x in resources if x.name.startswith('node')]
|
||||
node1, node2, node3 = nodes
|
||||
|
||||
@ -48,10 +48,10 @@ def setup_riak():
|
||||
riak_services.append(r)
|
||||
|
||||
for i, riak in enumerate(riak_services):
|
||||
signals.connect(nodes[i], riak)
|
||||
nodes[i].connect(riak)
|
||||
|
||||
for i, riak in enumerate(riak_services[1:]):
|
||||
signals.connect(riak_services[0], riak, {'riak_name': 'join_to'})
|
||||
riak_services[0].connect(riak, {'riak_name': 'join_to'})
|
||||
|
||||
hosts_services = []
|
||||
for i, riak in enumerate(riak_services):
|
||||
@ -59,14 +59,13 @@ def setup_riak():
|
||||
hosts_file = vr.create('hosts_file%d' % num,
|
||||
'resources/hosts_file', {})[0]
|
||||
hosts_services.append(hosts_file)
|
||||
signals.connect(nodes[i], hosts_file)
|
||||
nodes[i].connect(hosts_file)
|
||||
|
||||
for riak in riak_services:
|
||||
for hosts_file in hosts_services:
|
||||
signals.connect(riak, hosts_file,
|
||||
{'riak_hostname': 'hosts:name',
|
||||
'ip': 'hosts:ip'},
|
||||
events=False)
|
||||
riak.connect_with_events(hosts_file,
|
||||
{'riak_hostname': 'hosts:name',
|
||||
'ip': 'hosts:ip'})
|
||||
|
||||
errors = resource.validate_resources()
|
||||
for r, error in errors:
|
||||
@ -142,24 +141,26 @@ def setup_haproxies():
|
||||
|
||||
for single_hpsc in hpsc_http:
|
||||
for riak in riaks:
|
||||
signals.connect(riak, single_hpsc, {'riak_hostname': 'backends:server',
|
||||
'riak_port_http': 'backends:port'})
|
||||
riak.connect(single_hpsc, {
|
||||
'riak_hostname': 'backends:server',
|
||||
'riak_port_http': 'backends:port'})
|
||||
|
||||
for single_hpsc in hpsc_pb:
|
||||
for riak in riaks:
|
||||
signals.connect(riak, single_hpsc, {'riak_hostname': 'backends:server',
|
||||
'riak_port_pb': 'backends:port'})
|
||||
riak.connect(single_hpsc,
|
||||
{'riak_hostname': 'backends:server',
|
||||
'riak_port_pb': 'backends:port'})
|
||||
|
||||
# haproxy config to haproxy service
|
||||
|
||||
for single_hpc, single_hpsc in zip(hpc, hpsc_http):
|
||||
signals.connect(single_hpsc, single_hpc, {"backends": "config:backends",
|
||||
single_hpsc.connect(single_hpc, {"backends": "config:backends",
|
||||
"listen_port": "config:listen_port",
|
||||
"protocol": "config:protocol",
|
||||
"name": "config:name"})
|
||||
|
||||
for single_hpc, single_hpsc in zip(hpc, hpsc_pb):
|
||||
signals.connect(single_hpsc, single_hpc, {"backends": "config:backends",
|
||||
single_hpsc.connect(single_hpc, {"backends": "config:backends",
|
||||
"listen_port": "config:listen_port",
|
||||
"protocol": "config:protocol",
|
||||
"name": "config:name"})
|
||||
@ -173,10 +174,10 @@ def setup_haproxies():
|
||||
nodes = [node1, node2, node3]
|
||||
|
||||
for single_node, single_hps in zip(nodes, hps):
|
||||
signals.connect(single_node, single_hps)
|
||||
single_node.connect(single_hps)
|
||||
|
||||
for single_node, single_hpc in zip(nodes, hpc):
|
||||
signals.connect(single_node, single_hpc)
|
||||
single_node.connect(single_hpc)
|
||||
|
||||
has_errors = False
|
||||
for r in locals().values():
|
||||
|
@ -32,29 +32,27 @@ def run():
|
||||
{'solard_user': 'vagrant',
|
||||
'solard_password': 'password'})[0]
|
||||
|
||||
signals.connect(transports_for_solard, solard_transport, {})
|
||||
|
||||
signals.connect(ssh_transport, transports_for_solard, {'ssh_key': 'transports:key',
|
||||
'ssh_user': 'transports:user',
|
||||
'ssh_port': 'transports:port',
|
||||
'name': 'transports:name'})
|
||||
transports_for_solard.connect(solard_transport, {})
|
||||
ssh_transport.connect(transports_for_solard,{'ssh_key': 'transports:key',
|
||||
'ssh_user': 'transports:user',
|
||||
'ssh_port': 'transports:port',
|
||||
'name': 'transports:name'})
|
||||
# set transports_id
|
||||
signals.connect(transports, node, {})
|
||||
transports.connect(node, {})
|
||||
|
||||
# it uses reverse mappings
|
||||
signals.connect(ssh_transport, transports, {'ssh_key': 'transports:key',
|
||||
'ssh_user': 'transports:user',
|
||||
'ssh_port': 'transports:port',
|
||||
'name': 'transports:name'})
|
||||
|
||||
signals.connect(solard_transport, transports, {'solard_user': 'transports:user',
|
||||
'solard_port': 'transports:port',
|
||||
'solard_password': 'transports:password',
|
||||
'name': 'transports:name'})
|
||||
ssh_transport.connect(transports, {'ssh_key': 'transports:key',
|
||||
'ssh_user': 'transports:user',
|
||||
'ssh_port': 'transports:port',
|
||||
'name': 'transports:name'})
|
||||
solard_transport.connect(transports, {'solard_user': 'transports:user',
|
||||
'solard_port': 'transports:port',
|
||||
'solard_password': 'transports:password',
|
||||
'name': 'transports:name'})
|
||||
|
||||
|
||||
hosts = vr.create('hosts_file', 'resources/hosts_file', {})[0]
|
||||
signals.connect(node, hosts, {
|
||||
node.connect(hosts, {
|
||||
'ip': 'hosts:ip',
|
||||
'name': 'hosts:name'
|
||||
})
|
||||
|
@ -258,7 +258,7 @@ class Resource(object):
|
||||
if events:
|
||||
api.add_events(self.name, events)
|
||||
|
||||
def connect_with_defaults(self, receiver, mapping=None, events=None):
|
||||
def connect(self, receiver, mapping=None, events=None):
|
||||
return self.connect_with_events(
|
||||
receiver, mapping=mapping, events=events, use_defaults=True)
|
||||
|
||||
|
@ -129,7 +129,7 @@ def create_resources(resources, tags=None):
|
||||
if node:
|
||||
node = load_resource(node)
|
||||
r = new_resources[0]
|
||||
signals.connect(node, r, {})
|
||||
node.connect(r, mapping={})
|
||||
r.add_tags('location={}'.format(node.name))
|
||||
update_inputs(resource_name, args)
|
||||
return created_resources
|
||||
@ -167,8 +167,10 @@ def update_inputs(child, args):
|
||||
mapping = {}
|
||||
parent = load_resource(c['parent'])
|
||||
events = c['events']
|
||||
use_defaults = not c['events'] is False
|
||||
mapping[c['parent_input']] = c['child_input']
|
||||
parent.connect_with_events(child, mapping, events)
|
||||
parent.connect_with_events(
|
||||
child, mapping, events, use_defaults=use_defaults)
|
||||
|
||||
child.update(assignments)
|
||||
|
||||
|
@ -127,9 +127,9 @@ def location_and_transports(emitter, receiver, orig_mapping):
|
||||
return
|
||||
|
||||
|
||||
|
||||
def connect(emitter, receiver, mapping=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)
|
||||
|
Loading…
Reference in New Issue
Block a user