コード例 #1
0
ファイル: riaks-template.py プロジェクト: aglarendil/solar
def setup_riak():

    ModelMeta.remove_all()
    nodes = template.nodes_from('templates/riak_nodes.yaml')

    riak_services = nodes.on_each(
        'resources/riak_node',
        args={
            'riak_self_name': 'riak{num}',
            'riak_hostname': 'riak_server{num}.solar',
            'riak_name': 'riak{num}@riak_server{num}.solar',
        }
    )

    slave_riak_services = riak_services.tail()

    riak_services.take(0).connect_list(
        slave_riak_services,
        mapping={
            'riak_name': 'join_to',
        }
    )

    hosts_files = nodes.on_each('resources/hosts_file')

    riak_services.connect_list_to_each(
        hosts_files,
        mapping={
            'ip': 'hosts:ip',
            'riak_hostname': 'hosts:name',
        },
        events=False
    )

    errors = resource.validate_resources()
    for r, error in errors:
        click.echo('ERROR: %s: %s' % (r.name, error))

    if errors:
        click.echo("ERRORS")
        sys.exit(1)

    hosts_files.add_deps('run/success', riak_services, 'run')
    slave_riak_services.add_reacts('run/success', slave_riak_services, 'join')
    slave_riak_services.add_reacts('leave/success', slave_riak_services, 'join')
    slave_riak_services.add_react('run/success', riak_services.take(0), 'commit')
コード例 #2
0
def setup_riak():

    ModelMeta.remove_all()
    nodes = template.nodes_from('templates/riak_nodes.yaml')

    riak_services = nodes.on_each('resources/riak_node',
                                  args={
                                      'riak_self_name':
                                      'riak{num}',
                                      'riak_hostname':
                                      'riak_server{num}.solar',
                                      'riak_name':
                                      'riak{num}@riak_server{num}.solar',
                                  })

    slave_riak_services = riak_services.tail()

    riak_services.take(0).connect_list(slave_riak_services,
                                       mapping={
                                           'riak_name': 'join_to',
                                       })

    hosts_files = nodes.on_each('resources/hosts_file')

    riak_services.connect_list_to_each(hosts_files,
                                       mapping={
                                           'ip': 'hosts:ip',
                                           'riak_hostname': 'hosts:name',
                                       },
                                       events=False)

    errors = resource.validate_resources()
    for r, error in errors:
        click.echo('ERROR: %s: %s' % (r.name, error))

    if errors:
        click.echo("ERRORS")
        sys.exit(1)

    hosts_files.add_deps('run/success', riak_services, 'run')
    slave_riak_services.add_reacts('run/success', slave_riak_services, 'join')
    slave_riak_services.add_reacts('leave/success', slave_riak_services,
                                   'join')
    slave_riak_services.add_react('run/success', riak_services.take(0),
                                  'commit')
コード例 #3
0
ファイル: riaks-template.py プロジェクト: CGenie/solar
# WARNING: this might not be most up-to-date script and not all things might
# work here, for most up-to-date version see example-riaks.py
# This is just a demo of the template language of Solar

from solar.interfaces.db import get_db
from solar.core import signals

db = get_db()
db.clear()
signals.Connections.clear()

from solar import template


nodes = template.nodes_from('templates/riak_nodes.yml')

riak_services = nodes.on_each(
    'resources/riak_node',
    {
        'riak_self_name': 'riak{num}',
        'riak_hostname': 'riak_server{num}.solar',
        'riak_name': 'riak{num}@riak_server{num}.solar',
})

slave_riak_services = riak_services.tail()

riak_services.take(0).connect_list(
    slave_riak_services,
    {
        'riak_name': 'join_to',