コード例 #1
0
ファイル: riaks_big.py プロジェクト: aglarendil/solar
def setup_riak(nodes_num=None, hosts_mapping=False):

    if nodes_num is None:
        nodes_num = NODES
    db.clear()

    resources = vr.create("nodes", "templates/nodes.yaml", {"count": nodes_num})
    nodes = [x for x in resources if x.name.startswith("node")]
    hosts_services = [x for x in resources if x.name.startswith("hosts_file")]

    riak_services = []
    ips = "10.0.0.%d"
    for i in xrange(nodes_num):
        num = i + 1
        r = vr.create(
            "riak_service%d" % num,
            "resources/riak_node",
            {
                "riak_self_name": "riak%d" % num,
                "riak_hostname": "riak_server%d.solar" % num,
                "riak_name": "riak%d@riak_server%d.solar" % (num, num),
            },
        )[0]
        riak_services.append(r)

    for i, riak in enumerate(riak_services):
        nodes[i].connect(riak)

    for i, riak in enumerate(riak_services[1:]):
        riak_services[0].connect(riak, {"riak_name": "join_to"})

    if hosts_mapping:
        for riak in riak_services:
            for hosts_file in hosts_services:
                riak.connect_with_events(hosts_file, {"riak_hostname": "hosts:name", "ip": "hosts:ip"})

    res_errors = resource.validate_resources()
    for r, error in res_errors:
        click.echo("ERROR: %s: %s" % (r.name, error))
    has_errors = False

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

    events = []
    for x in xrange(nodes_num):
        i = x + 1
        if hosts_mapping:
            events.append(Dep("hosts_file%d" % i, "run", "success", "riak_service%d" % i, "run"))
        if i >= 2:
            events.append(React("riak_service%d" % i, "run", "success", "riak_service%d" % i, "join"))
        events.append(React("riak_service%d" % i, "join", "success", "riak_service1", "commit"))

    for event in events:
        add_event(event)

    click.echo("Use solar changes process & orch")
    sys.exit(0)
コード例 #2
0
ファイル: riaks_big.py プロジェクト: pigmej/solar-resources
def setup_riak(nodes_num=None, hosts_mapping=False):

    if nodes_num is None:
        nodes_num = NODES
    db.clear()

    resources = cr.create('nodes', 'templates/nodes', {'count': nodes_num})
    nodes = [x for x in resources if x.name.startswith('node')]
    hosts_services = [x for x in resources if x.name.startswith('hosts_file')]

    riak_services = []
    ips = '10.0.0.%d'
    for i in xrange(nodes_num):
        num = i + 1
        r = cr.create('riak_service%d' % num,
                      'resources/riak_node',
                      {'riak_self_name': 'riak%d' % num,
                       'riak_hostname': 'riak_server%d.solar' % num,
                       'riak_name': 'riak%d@riak_server%d.solar' % (num, num)})[0]
        riak_services.append(r)

    for i, riak in enumerate(riak_services):
        nodes[i].connect(riak)

    for i, riak in enumerate(riak_services[1:]):
        riak_services[0].connect(riak, {'riak_name': 'join_to'})

    if hosts_mapping:
        for riak in riak_services:
            for hosts_file in hosts_services:
                riak.connect_with_events(hosts_file,
                    {'riak_hostname': 'hosts:name',
                     'ip': 'hosts:ip'})

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

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

    events = []
    for x in xrange(nodes_num):
        i = x + 1
        if hosts_mapping:
            events.append(Dep('hosts_file%d' % i, 'run', 'success', 'riak_service%d' % i, 'run'))
        if i >= 2:
            events.append(React('riak_service%d' % i, 'run', 'success', 'riak_service%d' % i, 'join'))
        events.append(React('riak_service%d' % i, 'join', 'success', 'riak_service1', 'commit'))

    for event in events:
        add_event(event)

    click.echo('Use solar changes process & orch')
    sys.exit(0)
コード例 #3
0
def validate(check_missing_connections):
    errors = sresource.validate_resources()
    for r, error in errors:
        click.echo('ERROR: %s: %s' % (r.name, error))

    if check_missing_connections:
        missing_connections = vr.find_missing_connections()
        if missing_connections:
            click.echo('The following resources have inputs of the same value '
                       'but are not connected:')
            click.echo(
                tabulate.tabulate([['%s::%s' % (r1, i1),
                                    '%s::%s' % (r2, i2)]
                                   for r1, i1, r2, i2 in missing_connections]))
コード例 #4
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')
コード例 #5
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')
コード例 #6
0
ファイル: resource.py プロジェクト: pombredanne/solar
def validate(check_missing_connections):
    errors = sresource.validate_resources()
    for r, error in errors:
        click.echo('ERROR: %s: %s' % (r.name, error))

    if check_missing_connections:
        missing_connections = vr.find_missing_connections()
        if missing_connections:
            click.echo(
                'The following resources have inputs of the same value '
                'but are not connected:'
            )
            click.echo(
                tabulate.tabulate([
                    ['%s::%s' % (r1, i1), '%s::%s' % (r2, i2)]
                    for r1, i1, r2, i2 in missing_connections
                ])
            )
コード例 #7
0
ファイル: riaks.py プロジェクト: aglarendil/solar
def setup_riak():

    ModelMeta.remove_all()
    resources = vr.create('nodes', 'templates/nodes.yaml', {'count': 3})
    nodes = [x for x in resources if x.name.startswith('node')]
    hosts_services = [x for x in resources if x.name.startswith('hosts_file')]
    node1, node2, node3 = nodes
    hosts_services = [x for x in resources if x.name.startswith('hosts_file')]

    riak_services = []
    ips = '10.0.0.%d'
    for i in xrange(3):
        num = i + 1
        r = vr.create('riak_service%d' % num,
                      'resources/riak_node',
                      {'riak_self_name': 'riak%d' % num,
                       'storage_backend': 'leveldb',
                       'riak_hostname': 'riak_server%d.solar' % num})[0]
        r.connect(r, {'riak_self_name': 'riak_name',
                      'riak_hostname': 'riak_name'})
        riak_services.append(r)

    for i, riak in enumerate(riak_services):
        nodes[i].connect(riak)

    for i, riak in enumerate(riak_services[1:]):
        riak_services[0].connect(riak, {'riak_name': 'join_to'})

    for riak in riak_services:
        for hosts_file in hosts_services:
            riak.connect_with_events(hosts_file,
                {'riak_hostname': 'hosts:name',
                 'ip': 'hosts:ip'})

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

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

    events = [
        Dep('hosts_file1', 'run', 'success', 'riak_service1', 'run'),
        Dep('hosts_file2', 'run', 'success', 'riak_service2', 'run'),
        Dep('hosts_file3', 'run', 'success', 'riak_service3', 'run'),

        React('riak_service2', 'run', 'success', 'riak_service2', 'join'),
        React('riak_service3', 'run', 'success', 'riak_service3', 'join'),

        # Dep('riak_service1', 'run', 'success', 'riak_service2', 'join'),
        # Dep('riak_service1', 'run', 'success', 'riak_service3', 'join'),

        # React('riak_service2', 'join', 'error', 'riak_service2', 'leave'),
        # React('riak_service3', 'join', 'error', 'riak_service3', 'leave'),

        React('riak_service2', 'leave', 'success', 'riak_service2', 'join'),
        React('riak_service3', 'leave', 'success', 'riak_service3', 'join'),

        # React('riak_service2', 'leave', 'success', 'riak_service1', 'commit_leave'),
        # React('riak_service3', 'leave', 'success', 'riak_service1', 'commit_leave'),

        # Dep('riak_service1', 'commit_leave', 'success', 'riak_service2', 'join'),
        # Dep('riak_service1', 'commit_leave', 'success', 'riak_service3', 'join'),

        React('riak_service3', 'join', 'success', 'riak_service1', 'commit'),
        React('riak_service2', 'join', 'success', 'riak_service1', 'commit')
    ]

    for event in events:
        add_event(event)

    click.echo('Use solar changes process & orch')
    sys.exit(0)
コード例 #8
0
ファイル: riaks.py プロジェクト: torgartor21/solar
def setup_riak():
    db.clear()

    nodes = vr.create('nodes', 'templates/riak_nodes.yaml', {})
    node1, node2, node3 = nodes

    riak_services = []
    ips = '10.0.0.%d'
    for i in xrange(3):
        num = i + 1
        r = vr.create('riak_service%d' % num,
                      'resources/riak_node',
                      {'riak_self_name': 'riak%d' % num,
                       'riak_hostname': 'riak_server%d.solar' % num,
                       'riak_name': 'riak%d@riak_server%d.solar' % (num, num)})[0]
        riak_services.append(r)

    for i, riak in enumerate(riak_services):
        signals.connect(nodes[i], riak)

    for i, riak in enumerate(riak_services[1:]):
        signals.connect(riak_services[0], riak, {'riak_name': 'join_to'})

    hosts_services = []
    for i, riak in enumerate(riak_services):
        num = i + 1
        hosts_file = vr.create('hosts_file%d' % num,
                               'resources/hosts_file', {})[0]
        hosts_services.append(hosts_file)
        signals.connect(nodes[i], 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)

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

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

    events = [
        Dep('hosts_file1', 'run', 'success', 'riak_service1', 'run'),
        Dep('hosts_file2', 'run', 'success', 'riak_service2', 'run'),
        Dep('hosts_file3', 'run', 'success', 'riak_service3', 'run'),

        React('riak_service2', 'run', 'success', 'riak_service2', 'join'),
        React('riak_service3', 'run', 'success', 'riak_service3', 'join'),

        # Dep('riak_service1', 'run', 'success', 'riak_service2', 'join'),
        # Dep('riak_service1', 'run', 'success', 'riak_service3', 'join'),

        # React('riak_service2', 'join', 'error', 'riak_service2', 'leave'),
        # React('riak_service3', 'join', 'error', 'riak_service3', 'leave'),

        React('riak_service2', 'leave', 'success', 'riak_service2', 'join'),
        React('riak_service3', 'leave', 'success', 'riak_service3', 'join'),

        # React('riak_service2', 'leave', 'success', 'riak_service1', 'commit_leave'),
        # React('riak_service3', 'leave', 'success', 'riak_service1', 'commit_leave'),

        # Dep('riak_service1', 'commit_leave', 'success', 'riak_service2', 'join'),
        # Dep('riak_service1', 'commit_leave', 'success', 'riak_service3', 'join'),

        React('riak_service3', 'join', 'success', 'riak_service1', 'commit'),
        React('riak_service2', 'join', 'success', 'riak_service1', 'commit')
    ]

    for event in events:
        add_event(event)

    click.echo('Use solar changes process & orch')
    sys.exit(0)
コード例 #9
0
ファイル: system_log.py プロジェクト: loles/solar-1
def validate():
    errors = resource.validate_resources()
    if errors:
        for r, error in errors:
            print('ERROR: %s: %s' % (r.name, error))
        sys.exit(1)
コード例 #10
0
def setup_riak(nodes_num=None, hosts_mapping=False):

    if nodes_num is None:
        nodes_num = NODES
    db.clear()

    resources = vr.create('nodes', 'templates/nodes.yaml',
                          {'count': nodes_num})
    nodes = [x for x in resources if x.name.startswith('node')]
    hosts_services = [x for x in resources if x.name.startswith('hosts_file')]

    riak_services = []
    ips = '10.0.0.%d'
    for i in xrange(nodes_num):
        num = i + 1
        r = vr.create(
            'riak_service%d' % num, 'resources/riak_node', {
                'riak_self_name': 'riak%d' % num,
                'riak_hostname': 'riak_server%d.solar' % num,
                'riak_name': 'riak%d@riak_server%d.solar' % (num, num)
            })[0]
        riak_services.append(r)

    for i, riak in enumerate(riak_services):
        nodes[i].connect(riak)

    for i, riak in enumerate(riak_services[1:]):
        riak_services[0].connect(riak, {'riak_name': 'join_to'})

    if hosts_mapping:
        for riak in riak_services:
            for hosts_file in hosts_services:
                riak.connect_with_events(hosts_file, {
                    'riak_hostname': 'hosts:name',
                    'ip': 'hosts:ip'
                })

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

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

    events = []
    for x in xrange(nodes_num):
        i = x + 1
        if hosts_mapping:
            events.append(
                Dep('hosts_file%d' % i, 'run', 'success', 'riak_service%d' % i,
                    'run'))
        if i >= 2:
            events.append(
                React('riak_service%d' % i, 'run', 'success',
                      'riak_service%d' % i, 'join'))
        events.append(
            React('riak_service%d' % i, 'join', 'success', 'riak_service1',
                  'commit'))

    for event in events:
        add_event(event)

    click.echo('Use solar changes process & orch')
    sys.exit(0)
コード例 #11
0
ファイル: riaks-template.py プロジェクト: aglarendil/solar
def setup_haproxies():
    # TODO: VR loading needs to be supported, then we can do something like
    # nodes = template.load('nodes')

    nodes = template.ResourceListTemplate([
        resource.load('node1'),
        resource.load('node2'),
        resource.load('node3'),
    ])
    riak_services = template.ResourceListTemplate([
        resource.load('riak_node-0'),
        resource.load('riak_node-1'),
        resource.load('riak_node-2'),
    ])

    haproxy_services = nodes.on_each(
        'resources/haproxy_service'
    )
    haproxy_configs = nodes.on_each(
        'resources/haproxy_config'
    )
    haproxy_service_configs_http = riak_services.on_each(
        'resources/haproxy_service_config',
        {
            'listen_port': 8098,
            'protocol': 'http',
            'name': 'riak_haproxy_http{num}',
        }
    )
    haproxy_service_configs_pb = riak_services.on_each(
        'resources/haproxy_service_config',
        {
            'listen_port': 8087,
            'protocol': 'tcp',
            'name': 'riak_haproxy_pb{num}',
        }
    )

    riak_services.connect_list_to_each(
        haproxy_service_configs_http,
        {
            'riak_hostname': 'backends:server',
            'riak_port_http': 'backends:port',
        }
    )
    riak_services.connect_list_to_each(
        haproxy_service_configs_pb,
        {
            'riak_hostname': 'backends:server',
            'riak_port_pb': 'backends:port',
        }
    )
    haproxy_service_configs_http.connect_list(
        haproxy_configs,
        {
            'backends': 'config:backends',
            'listen_port': 'config:listen_port',
            'protocol': 'config:protocol',
            'name': 'config:name',
        }
    )
    haproxy_service_configs_pb.connect_list(
        haproxy_configs,
        {
            'backends': 'config:backends',
            'listen_port': 'config:listen_port',
            'protocol': 'config:protocol',
            'name': 'config:name',
        }
    )

    #nodes.add_reacts('run/success', haproxy_services, 'install')
    haproxy_services.add_deps('run/success', haproxy_configs, 'run')
    haproxy_configs.add_reacts('run/success', haproxy_services, 'apply_config')
    haproxy_configs.add_reacts('update/success', haproxy_services, 'apply_config')

    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)
コード例 #12
0
ファイル: riaks.py プロジェクト: openstack/solar-resources
def setup_riak():
    nodes = rs.load_all(startswith="node")
    hosts_services = rs.load_all(startswith="hosts_file")
    node1, node2, node3 = nodes[:3]

    riak_services = []
    ips = "10.0.0.%d"
    for i in xrange(3):
        num = i + 1
        r = cr.create(
            "riak_service%d" % num,
            "resources/riak_node",
            {
                "riak_self_name": "riak%d" % num,
                "storage_backend": "leveldb",
                "riak_hostname": "riak_server%d.solar" % num,
            },
        )[0]
        r.connect(r, {"riak_self_name": "riak_name", "riak_hostname": "riak_name"})
        riak_services.append(r)

    for i, riak in enumerate(riak_services):
        nodes[i].connect(riak)

    for i, riak in enumerate(riak_services[1:]):
        riak_services[0].connect(riak, {"riak_name": "join_to"})

    for riak in riak_services:
        for hosts_file in hosts_services:
            riak.connect_with_events(hosts_file, {"riak_hostname": "hosts:name", "ip": "hosts:ip"})

    Resource.save_all_lazy()
    errors = resource.validate_resources()
    for r, error in errors:
        click.echo("ERROR: %s: %s" % (r.name, error))
    has_errors = False

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

    events = [
        Dep("hosts_file_node_node1", "run", "success", "riak_service1", "run"),
        Dep("hosts_file_node_node2", "run", "success", "riak_service2", "run"),
        Dep("hosts_file_node_node3", "run", "success", "riak_service3", "run"),
        React("riak_service2", "run", "success", "riak_service2", "join"),
        React("riak_service3", "run", "success", "riak_service3", "join"),
        # Dep('riak_service1', 'run', 'success', 'riak_service2', 'join'),
        # Dep('riak_service1', 'run', 'success', 'riak_service3', 'join'),
        # React('riak_service2', 'join', 'error', 'riak_service2', 'leave'),
        # React('riak_service3', 'join', 'error', 'riak_service3', 'leave'),
        React("riak_service2", "leave", "success", "riak_service2", "join"),
        React("riak_service3", "leave", "success", "riak_service3", "join"),
        # React('riak_service2', 'leave', 'success', 'riak_service1', 'commit_leave'),
        # React('riak_service3', 'leave', 'success', 'riak_service1', 'commit_leave'),
        # Dep('riak_service1', 'commit_leave', 'success', 'riak_service2', 'join'),
        # Dep('riak_service1', 'commit_leave', 'success', 'riak_service3', 'join'),
        React("riak_service3", "join", "success", "riak_service1", "commit"),
        React("riak_service2", "join", "success", "riak_service1", "commit"),
    ]

    for event in events:
        add_event(event)

    click.echo("Use solar changes process & orch")
    sys.exit(0)
コード例 #13
0
ファイル: riaks.py プロジェクト: cvieri/solar
def setup_riak():

    ModelMeta.remove_all()
    resources = vr.create('nodes', 'templates/nodes.yaml', {'count': 3})
    nodes = [x for x in resources if x.name.startswith('node')]
    hosts_services = [x for x in resources if x.name.startswith('hosts_file')]
    node1, node2, node3 = nodes
    hosts_services = [x for x in resources if x.name.startswith('hosts_file')]

    riak_services = []
    ips = '10.0.0.%d'
    for i in xrange(3):
        num = i + 1
        r = vr.create('riak_service%d' % num,
                      'resources/riak_node',
                      {'riak_self_name': 'riak%d' % num,
                       'storage_backend': 'leveldb',
                       'riak_hostname': 'riak_server%d.solar' % num,
                       'riak_name': 'riak%d@riak_server%d.solar' % (num, num)})[0]
        riak_services.append(r)

    for i, riak in enumerate(riak_services):
        nodes[i].connect(riak)

    for i, riak in enumerate(riak_services[1:]):
        riak_services[0].connect(riak, {'riak_name': 'join_to'})

    for riak in riak_services:
        for hosts_file in hosts_services:
            riak.connect_with_events(hosts_file,
                {'riak_hostname': 'hosts:name',
                 'ip': 'hosts:ip'})

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

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

    events = [
        Dep('hosts_file1', 'run', 'success', 'riak_service1', 'run'),
        Dep('hosts_file2', 'run', 'success', 'riak_service2', 'run'),
        Dep('hosts_file3', 'run', 'success', 'riak_service3', 'run'),

        React('riak_service2', 'run', 'success', 'riak_service2', 'join'),
        React('riak_service3', 'run', 'success', 'riak_service3', 'join'),

        # Dep('riak_service1', 'run', 'success', 'riak_service2', 'join'),
        # Dep('riak_service1', 'run', 'success', 'riak_service3', 'join'),

        # React('riak_service2', 'join', 'error', 'riak_service2', 'leave'),
        # React('riak_service3', 'join', 'error', 'riak_service3', 'leave'),

        React('riak_service2', 'leave', 'success', 'riak_service2', 'join'),
        React('riak_service3', 'leave', 'success', 'riak_service3', 'join'),

        # React('riak_service2', 'leave', 'success', 'riak_service1', 'commit_leave'),
        # React('riak_service3', 'leave', 'success', 'riak_service1', 'commit_leave'),

        # Dep('riak_service1', 'commit_leave', 'success', 'riak_service2', 'join'),
        # Dep('riak_service1', 'commit_leave', 'success', 'riak_service3', 'join'),

        React('riak_service3', 'join', 'success', 'riak_service1', 'commit'),
        React('riak_service2', 'join', 'success', 'riak_service1', 'commit')
    ]

    for event in events:
        add_event(event)

    click.echo('Use solar changes process & orch')
    sys.exit(0)
コード例 #14
0
ファイル: system_log.py プロジェクト: torgartor21/solar
def validate():
    errors = resource.validate_resources()
    if errors:
        for r, error in errors:
            print 'ERROR: %s: %s' % (r.name, error)
        sys.exit(1)
コード例 #15
0
def setup_haproxies():
    # TODO: VR loading needs to be supported, then we can do something like
    # nodes = template.load('nodes')

    nodes = template.ResourceListTemplate([
        resource.load('node1'),
        resource.load('node2'),
        resource.load('node3'),
    ])
    riak_services = template.ResourceListTemplate([
        resource.load('riak_node-0'),
        resource.load('riak_node-1'),
        resource.load('riak_node-2'),
    ])

    haproxy_services = nodes.on_each('resources/haproxy_service')
    haproxy_configs = nodes.on_each('resources/haproxy_config')
    haproxy_service_configs_http = riak_services.on_each(
        'resources/haproxy_service_config', {
            'listen_port': 8098,
            'protocol': 'http',
            'name': 'riak_haproxy_http{num}',
        })
    haproxy_service_configs_pb = riak_services.on_each(
        'resources/haproxy_service_config', {
            'listen_port': 8087,
            'protocol': 'tcp',
            'name': 'riak_haproxy_pb{num}',
        })

    riak_services.connect_list_to_each(haproxy_service_configs_http, {
        'riak_hostname': 'backends:server',
        'riak_port_http': 'backends:port',
    })
    riak_services.connect_list_to_each(haproxy_service_configs_pb, {
        'riak_hostname': 'backends:server',
        'riak_port_pb': 'backends:port',
    })
    haproxy_service_configs_http.connect_list(
        haproxy_configs, {
            'backends': 'config:backends',
            'listen_port': 'config:listen_port',
            'protocol': 'config:protocol',
            'name': 'config:name',
        })
    haproxy_service_configs_pb.connect_list(
        haproxy_configs, {
            'backends': 'config:backends',
            'listen_port': 'config:listen_port',
            'protocol': 'config:protocol',
            'name': 'config:name',
        })

    #nodes.add_reacts('run/success', haproxy_services, 'install')
    haproxy_services.add_deps('run/success', haproxy_configs, 'run')
    haproxy_configs.add_reacts('run/success', haproxy_services, 'apply_config')
    haproxy_configs.add_reacts('update/success', haproxy_services,
                               'apply_config')

    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)
コード例 #16
0
ファイル: resource.py プロジェクト: loles/solar-1
def validate():
    errors = sresource.validate_resources()
    for r, error in errors:
        click.echo('ERROR: %s: %s' % (r.name, error))