Example #1
0
def setup_resources():
    ModelMeta.remove_all()

    node2 = vr.create('node2', 'resources/ro_node/', {
        'ip': '10.0.0.4',
        'ssh_key': '/vagrant/.vagrant/machines/solar-dev2/virtualbox/private_key',
        'ssh_user': '******'
    })[0]

    solar_bootstrap2 = vr.create('solar_bootstrap2', 'resources/solar_bootstrap', {'master_ip': '10.0.0.2'})[0]

    signals.connect(node2, solar_bootstrap2)

    has_errors = False
    for r in locals().values():
        if not isinstance(r, resource.Resource):
            continue

        print 'Validating {}'.format(r.name)
        errors = validation.validate_resource(r)
        if errors:
            has_errors = True
            print 'ERROR: %s: %s' % (r.name, errors)

    if has_errors:
        sys.exit(1)
Example #2
0
def setup_resources():
    ModelMeta.remove_all()

    node2 = vr.create(
        'node2', 'resources/ro_node/', {
            'ip': '10.0.0.4',
            'ssh_key':
            '/vagrant/.vagrant/machines/solar-dev2/virtualbox/private_key',
            'ssh_user': '******'
        })[0]

    solar_bootstrap2 = vr.create('solar_bootstrap2',
                                 'resources/solar_bootstrap',
                                 {'master_ip': '10.0.0.2'})[0]

    signals.connect(node2, solar_bootstrap2)

    has_errors = False
    for r in locals().values():
        if not isinstance(r, resource.Resource):
            continue

        print 'Validating {}'.format(r.name)
        errors = validation.validate_resource(r)
        if errors:
            has_errors = True
            print 'ERROR: %s: %s' % (r.name, errors)

    if has_errors:
        sys.exit(1)
Example #3
0
def run():
    ModelMeta.remove_all()

    resources = vr.create('nodes', 'templates/nodes.yaml', {'count': 2})

    node1, node2 = [x for x in resources if x.name.startswith('node')]
    hosts1, hosts2 = [x for x in resources
                      if x.name.startswith('hosts_file')]

    node1.connect(hosts1, {
        'name': 'hosts:name',
        'ip': 'hosts:ip',
    })

    node2.connect(hosts1, {
        'name': 'hosts:name',
        'ip': 'hosts:ip',
    })

    node1.connect(hosts2, {
        'name': 'hosts:name',
        'ip': 'hosts:ip',
    })

    node2.connect(hosts2, {
        'name': 'hosts:name',
        'ip': 'hosts:ip',
    })
Example #4
0
def run():
    ModelMeta.remove_all()

    node = vr.create('node', 'resources/ro_node', {
        'name': 'first' + str(time.time()),
        'ip': '10.0.0.3',
        'node_id': 'node1',
    })[0]

    transports = vr.create('transports_node1', 'resources/transports')[0]
    transports_for_solar_agent = vr.create('transports_for_solar_agent',
                                           'resources/transports')[0]

    ssh_transport = vr.create(
        'ssh_transport', 'resources/transport_ssh', {
            'ssh_key':
            '/vagrant/.vagrant/machines/solar-dev1/virtualbox/private_key',
            'ssh_user': '******'
        })[0]

    solar_agent_transport = vr.create('solar_agent_transport',
                                      'resources/transport_solar_agent', {
                                          'solar_agent_user': '******',
                                          'solar_agent_password': '******'
                                      })[0]

    transports_for_solar_agent.connect(solar_agent_transport, {})
    ssh_transport.connect(
        transports_for_solar_agent, {
            'ssh_key': 'transports:key',
            'ssh_user': '******',
            'ssh_port': 'transports:port',
            'name': 'transports:name'
        })
    # set transports_id
    transports.connect(node, {})

    # it uses reverse mappings
    ssh_transport.connect(
        transports, {
            'ssh_key': 'transports:key',
            'ssh_user': '******',
            'ssh_port': 'transports:port',
            'name': 'transports:name'
        })
    solar_agent_transport.connect(
        transports, {
            'solar_agent_user': '******',
            'solar_agent_port': 'transports:port',
            'solar_agent_password': '******',
            'name': 'transports:name'
        })

    hosts = vr.create('hosts_file', 'resources/hosts_file', {})[0]
    node.connect(hosts, {'ip': 'hosts:ip', 'name': 'hosts:name'})
Example #5
0
def undeploy():
    ModelMeta.remove_all()

    resources = resource.load_all()
    resources = {r.name: r for r in resources}

    actions.resource_action(resources['openstack_rabbitmq_user'], 'remove')
    actions.resource_action(resources['openstack_vhost'], 'remove')
    actions.resource_action(resources['rabbitmq_service1'], 'remove')

    ModelMeta.remove_all()
Example #6
0
def undeploy():
    resources = resource.load_all()
    resources = {r.name: r for r in resources}

    for name in reversed(resources_to_run):
        try:
            actions.resource_action(resources[name], 'remove')
        except errors.SolarError as e:
            print 'WARNING: %s' % str(e)

    ModelMeta.remove_all()
Example #7
0
def undeploy():
    resources = resource.load_all()
    resources = {r.name: r for r in resources}

    for name in reversed(resources_to_run):
        try:
            actions.resource_action(resources[name], 'remove')
        except errors.SolarError as e:
            print 'WARNING: %s' % str(e)

    ModelMeta.remove_all()
Example #8
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')
Example #9
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')
Example #10
0
def run():
    ModelMeta.remove_all()

    node = cr.create('node', 'resources/ro_node', {'name': 'first' + str(time.time()),
                                                       'ip': '10.0.0.3',
                                                       'node_id': 'node1',
                                                   })[0]

    transports = cr.create('transports_node1', 'resources/transports')[0]
    transports_for_solar_agent = cr.create('transports_for_solar_agent', 'resources/transports')[0]

    ssh_transport  = cr.create('ssh_transport', 'resources/transport_ssh',
                               {'ssh_key': '/vagrant/.vagrant/machines/solar-dev1/virtualbox/private_key',
                                'ssh_user': '******'})[0]

    solar_agent_transport  = cr.create('solar_agent_transport', 'resources/transport_solar_agent',
                                  {'solar_agent_user': '******',
                                   'solar_agent_password': '******'})[0]

    transports_for_solar_agent.connect(solar_agent_transport, {})
    ssh_transport.connect(transports_for_solar_agent,{'ssh_key': 'transports:key',
                                                 'ssh_user': '******',
                                                 'ssh_port': 'transports:port',
                                                 'name': 'transports:name'})
    # set transports_id
    transports.connect(node, {})

    # it uses reverse mappings
    ssh_transport.connect(transports, {'ssh_key': 'transports:key',
                                        'ssh_user': '******',
                                        'ssh_port': 'transports:port',
                                        'name': 'transports:name'})
    solar_agent_transport.connect(transports, {'solar_agent_user': '******',
                                           'solar_agent_port': 'transports:port',
                                           'solar_agent_password': '******',
                                           'name': 'transports:name'})


    hosts = cr.create('hosts_file', 'resources/hosts_file', {})[0]
    node.connect(hosts, {
        'ip': 'hosts:ip',
        'name': 'hosts:name'
    })
Example #11
0
def deploy():
    ModelMeta.remove_all()
    resources = vr.create('nodes', 'templates/nodes.yaml', {'count': 2})
    first_node, second_node = [
        x for x in resources if x.name.startswith('node')
    ]
    first_transp = next(x for x in resources if x.name.startswith('transport'))

    library = vr.create('library1', 'resources/fuel_library', {})[0]
    first_node.connect(library)

    keys = vr.create('ceph_key', 'resources/ceph_keys', {})[0]
    first_node.connect(keys)

    remote_file = vr.create('ceph_key2', 'resources/remote_file',
                            {'dest': '/var/lib/astute/'})[0]
    second_node.connect(remote_file)
    keys.connect(remote_file, {'ip': 'remote_ip', 'path': 'remote_path'})
    first_transp.connect(remote_file, {'transports': 'remote'})

    ceph_mon = vr.create(
        'ceph_mon1', 'resources/ceph_mon', {
            'storage': STORAGE,
            'keystone': KEYSTONE,
            'network_scheme': NETWORK_SCHEMA,
            'ceph_monitor_nodes': NETWORK_METADATA,
            'ceph_primary_monitor_node': NETWORK_METADATA,
            'role': 'controller',
        })[0]

    managed_apt = vr.create('managed_apt1', 'templates/mos_repos.yaml', {
        'node': first_node.name,
        'index': 0
    })[-1]

    keys.connect(ceph_mon, {})
    first_node.connect(ceph_mon,
                       {'ip': ['ip', 'public_vip', 'management_vip']})
    library.connect(ceph_mon, {'puppet_modules': 'puppet_modules'})
    managed_apt.connect(ceph_mon, {})
Example #12
0
def deploy():
    ModelMeta.remove_all()
    resources = cr.create('nodes', 'templates/nodes', {'count': 2})
    first_node, second_node = [x for x in resources if x.name.startswith('node')]
    first_transp = next(x for x in resources if x.name.startswith('transport'))

    library = cr.create('library1', 'resources/fuel_library', {})[0]
    first_node.connect(library)

    keys = cr.create('ceph_key', 'resources/ceph_keys', {})[0]
    first_node.connect(keys)

    remote_file = cr.create('ceph_key2', 'resources/remote_file',
      {'dest': '/var/lib/astute/'})[0]
    second_node.connect(remote_file)
    keys.connect(remote_file, {'ip': 'remote_ip', 'path': 'remote_path'})
    first_transp.connect(remote_file, {'transports': 'remote'})


    ceph_mon = cr.create('ceph_mon1', 'resources/ceph_mon',
        {'storage': STORAGE,
         'keystone': KEYSTONE,
         'network_scheme': NETWORK_SCHEMA,
         'ceph_monitor_nodes': NETWORK_METADATA,
         'ceph_primary_monitor_node': NETWORK_METADATA,
         'role': 'controller',
         })[0]

    managed_apt = cr.create(
      'managed_apt1', 'templates/mos_repos',
      {'node': first_node.name, 'index': 0})[-1]

    keys.connect(ceph_mon, {})
    first_node.connect(ceph_mon,
        {'ip': ['ip', 'public_vip', 'management_vip']})
    library.connect(ceph_mon, {'puppet_modules': 'puppet_modules'})
    managed_apt.connect(ceph_mon, {})
Example #13
0
def deploy():
    ModelMeta.remove_all()
    signals.Connections.clear()

    node1 = resources_compiled.RoNodeResource('node1', None, {})
    node1.ip = '10.0.0.3'
    node1.ssh_key = '/vagrant/.vagrant/machines/solar-dev1/virtualbox/private_key'
    node1.ssh_user = '******'

    rabbitmq_service1 = resources_compiled.RabbitmqServiceResource('rabbitmq_service1', None, {'management_port': 15672, 'port': 5672, 'container_name': 'rabbitmq_service1', 'image': 'rabbitmq:3-management'})
    openstack_vhost = resource.create('openstack_vhost', 'resources/rabbitmq_vhost/', {'vhost_name': 'openstack'})[0]
    openstack_rabbitmq_user = resource.create('openstack_rabbitmq_user', 'resources/rabbitmq_user/', {'user_name': 'openstack', 'password': '******'})[0]

    ####
    # connections
    ####

    # rabbitmq
    signals.connect(node1, rabbitmq_service1)
    signals.connect(rabbitmq_service1, openstack_vhost)
    signals.connect(rabbitmq_service1, openstack_rabbitmq_user)
    signals.connect(openstack_vhost, openstack_rabbitmq_user, {'vhost_name': 'vhost_name'})


    errors = vr.validate_resources()
    if errors:
        for r, error in errors:
            print 'ERROR: %s: %s' % (r.name, error)
        sys.exit(1)


    # run
    actions.resource_action(rabbitmq_service1, 'run')
    actions.resource_action(openstack_vhost, 'run')
    actions.resource_action(openstack_rabbitmq_user, 'run')
    time.sleep(10)
Example #14
0
def clear():
    ModelMeta.remove_all()
Example #15
0
def create_all():
    ModelMeta.remove_all()
    r = prepare_nodes(2)
    r.update(create_controller('node1'))
    r.update(create_compute('node2'))
    print '\n'.join(r.keys())
Example #16
0
def clear_all():
    from solar.dblayer.model import ModelMeta
    click.echo('Clearing all resources and connections')
    ModelMeta.remove_all()
Example #17
0
def run():
    ModelMeta.remove_all()

    node = vr.create('node', 'resources/ro_node', {'name': 'first' + str(time.time()),
                                                   'ip': '10.0.0.3',
                                                   'node_id': 'node1',
                                                   })[0]

    transports = vr.create('transports_node1', 'resources/transports')[0]

    ssh_transport = vr.create('ssh_transport', 'resources/transport_ssh',
                              {'ssh_key': '/vagrant/.vagrant/machines/solar-dev1/virtualbox/private_key',
                               'ssh_user': '******'})[0]

    transports.connect(node, {})

    # it uses reverse mappings
    ssh_transport.connect(transports, {'ssh_key': 'transports:key',
                                       'ssh_user': '******',
                                       'ssh_port': 'transports:port',
                                       'name': 'transports:name'})

    hosts = vr.create('hosts_file', 'resources/hosts_file', {})[0]

    # let's add torrent transport for hosts file deployment (useless in real life)

    torrent_transport = vr.create('torrent_transport',
                                  'resources/transport_torrent',
                                  {'trackers': ['udp://open.demonii.com:1337',
                                                'udp://tracker.openbittorrent.com:80']})[0]
    # you could use any trackers as you want

    transports_for_torrent = vr.create(
        'transports_for_torrent', 'resources/transports')[0]

    transports_for_torrent.connect(torrent_transport, {})

    ssh_transport.connect_with_events(transports_for_torrent, {'ssh_key': 'transports:key',
                                                               'ssh_user': '******',
                                                               'ssh_port': 'transports:port',
                                                               'name': 'transports:name'},
                                      events={})

    transports_for_hosts = vr.create(
        'transports_for_hosts', 'resources/transports')[0]

    torrent_transport.connect(transports_for_hosts, {'trackers': 'transports:trackers',
                                                     'name': 'transports:name'})

    ssh_transport.connect(transports_for_hosts, {'ssh_key': 'transports:key',
                                                 'ssh_user': '******',
                                                 'ssh_port': 'transports:port',
                                                 'name': 'transports:name'})

    transports_for_hosts.connect(hosts)
    transports_for_hosts.connect_with_events(node, events={})

    node.connect(hosts, {
        'ip': 'hosts:ip',
        'name': 'hosts:name'
    })
Example #18
0
def deploy():
    ModelMeta.remove_all()

    node1 = vr.create('nodes', 'templates/nodes.yaml', {})[0]
    seed = vr.create('nodes', 'templates/seed_node.yaml', {})[0]

    ssh_key = vr.create('ssh_key1', 'resources/ssh_key', {
        'keys_dir': '/vagrant/.ssh',
        'private_key': '/vagrant/.ssh/id_rsa',
        'public_key': '/vagrant/.ssh/id_rsa.pub',
        'passphrase': '',
    })[0]
    signals.connect(seed, ssh_key)

    cnets1 = vr.create('cnets1', 'resources/container_networks', {
        'networks':
            {'mgmt': {
                'bridge': 'br-int53',
                'bridge_address': '172.18.11.254/24'
            }}
        })[0]
    cnets2 = vr.create('cnets2', 'resources/container_networks', {
        'networks':
            {'mgmt': {
                'bridge': 'br-int53',
                'bridge_address': '172.18.11.253/24'
            }}
        })[0]
    signals.connect(seed, cnets1)
    signals.connect(node1, cnets2)

    vxlan_mesh1 = vr.create('vxlan_mesh1', 'resources/vxlan_mesh', {
        'id': 53,
        'parent': 'eth1',
        'master': 'br-int53'
    })[0]
    vxlan_mesh2 = vr.create('vxlan_mesh2', 'resources/vxlan_mesh', {
        'id': 53,
        'parent': 'eth1',
        'master': 'br-int53'
    })[0]
    # seed node should be connected anyway, because we need to be able to ssh
    # into containers from any node
    signals.connect(seed, vxlan_mesh1)
    signals.connect(node1, vxlan_mesh2)

    lxc_infra1 = vr.create('lxc_infra1', 'resources/lxc_host', {})[0]
    signals.connect(node1, lxc_infra1)

    lxc_hosts = range(28, 35)
    hosts_map = {}
    for idx in lxc_hosts:

        lxc_host_idx = vr.create(
            'lxc_host{}'.format(idx),
            'resources/lxc_container', lxc_template(idx))[0]
        hosts_map[idx] = lxc_host_idx

        signals.connect(node1, lxc_host_idx, {
            'ip': ['ansible_ssh_host', 'physical_host'],
            })
        # this is a required to introduce depends on relationship between lxc infre
        # and lxc container
        signals.connect(lxc_infra1, lxc_host_idx, {'provides': 'requires'})
        signals.connect(cnets2, lxc_host_idx)
        signals.connect(ssh_key, lxc_host_idx, {
            'public_key': 'pub_key',
            'private_key': 'user_key'})

    # RABBIT
    rabbitmq_service1 = vr.create('rabbitmq_service1', 'resources/rabbitmq_service/', {
        'management_port': 15672,
        'port': 5672,
    })[0]
    openstack_vhost = vr.create('openstack_vhost', 'resources/rabbitmq_vhost/', {
        'vhost_name': 'openstack'
    })[0]

    openstack_rabbitmq_user = vr.create('openstack_rabbitmq_user', 'resources/rabbitmq_user/', {
        'user_name': 'openstack',
        'password': '******'
    })[0]

    signals.connect(hosts_map[28], rabbitmq_service1, {
        'mgmt_ip': 'ip',
        'user_key': 'ssh_key',
        'user': '******'})
    signals.connect(rabbitmq_service1, openstack_vhost)
    signals.connect(rabbitmq_service1, openstack_rabbitmq_user)
    signals.connect(openstack_vhost, openstack_rabbitmq_user, {
        'vhost_name',
    })

    print change.send_to_orchestration()
Example #19
0
def clear():
    ModelMeta.remove_all()
Example #20
0
def create_all():
    ModelMeta.remove_all()
    r = prepare_nodes(2)
    r.update(create_controller('node0'))
    r.update(create_compute('node1'))
    print '\n'.join(r.keys())
Example #21
0
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)
Example #22
0
def deploy():
    ModelMeta.remove_all()

    node1 = vr.create('nodes', 'templates/nodes.yaml', {})[0]
    seed = vr.create('nodes', 'templates/seed_node.yaml', {})[0]

    ssh_key = vr.create(
        'ssh_key1', 'resources/ssh_key', {
            'keys_dir': '/vagrant/.ssh',
            'private_key': '/vagrant/.ssh/id_rsa',
            'public_key': '/vagrant/.ssh/id_rsa.pub',
            'passphrase': '',
        })[0]
    signals.connect(seed, ssh_key)

    cnets1 = vr.create(
        'cnets1', 'resources/container_networks', {
            'networks': {
                'mgmt': {
                    'bridge': 'br-int53',
                    'bridge_address': '172.18.11.254/24'
                }
            }
        })[0]
    cnets2 = vr.create(
        'cnets2', 'resources/container_networks', {
            'networks': {
                'mgmt': {
                    'bridge': 'br-int53',
                    'bridge_address': '172.18.11.253/24'
                }
            }
        })[0]
    signals.connect(seed, cnets1)
    signals.connect(node1, cnets2)

    vxlan_mesh1 = vr.create('vxlan_mesh1', 'resources/vxlan_mesh', {
        'id': 53,
        'parent': 'eth1',
        'master': 'br-int53'
    })[0]
    vxlan_mesh2 = vr.create('vxlan_mesh2', 'resources/vxlan_mesh', {
        'id': 53,
        'parent': 'eth1',
        'master': 'br-int53'
    })[0]
    # seed node should be connected anyway, because we need to be able to ssh
    # into containers from any node
    signals.connect(seed, vxlan_mesh1)
    signals.connect(node1, vxlan_mesh2)

    lxc_infra1 = vr.create('lxc_infra1', 'resources/lxc_host', {})[0]
    signals.connect(node1, lxc_infra1)

    lxc_hosts = range(28, 35)
    hosts_map = {}
    for idx in lxc_hosts:

        lxc_host_idx = vr.create('lxc_host{}'.format(idx),
                                 'resources/lxc_container',
                                 lxc_template(idx))[0]
        hosts_map[idx] = lxc_host_idx

        signals.connect(node1, lxc_host_idx, {
            'ip': ['ansible_ssh_host', 'physical_host'],
        })
        # this is a required to introduce depends on relationship between lxc infre
        # and lxc container
        signals.connect(lxc_infra1, lxc_host_idx, {'provides': 'requires'})
        signals.connect(cnets2, lxc_host_idx)
        signals.connect(ssh_key, lxc_host_idx, {
            'public_key': 'pub_key',
            'private_key': 'user_key'
        })

    # RABBIT
    rabbitmq_service1 = vr.create('rabbitmq_service1',
                                  'resources/rabbitmq_service/', {
                                      'management_port': 15672,
                                      'port': 5672,
                                  })[0]
    openstack_vhost = vr.create('openstack_vhost', 'resources/rabbitmq_vhost/',
                                {'vhost_name': 'openstack'})[0]

    openstack_rabbitmq_user = vr.create('openstack_rabbitmq_user',
                                        'resources/rabbitmq_user/', {
                                            'user_name': 'openstack',
                                            'password': '******'
                                        })[0]

    signals.connect(hosts_map[28], rabbitmq_service1, {
        'mgmt_ip': 'ip',
        'user_key': 'ssh_key',
        'user': '******'
    })
    signals.connect(rabbitmq_service1, openstack_vhost)
    signals.connect(rabbitmq_service1, openstack_rabbitmq_user)
    signals.connect(openstack_vhost, openstack_rabbitmq_user, {
        'vhost_name',
    })

    print change.send_to_orchestration()
Example #23
0
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)
Example #24
0
def clear_all():
    from solar.dblayer.model import ModelMeta
    click.echo('Clearing all resources and connections')
    ModelMeta.remove_all()