Beispiel #1
0
def test_concurrent_sequences_with_no_handler(scale, clients):
    total_resources = scale * 3
    timeout = scale * 2
    scheduler_client = clients['scheduler']

    assert len(change.staged_log()) == total_resources
    ModelMeta.session_end()
    plan = change.send_to_orchestration()
    scheduler_client.next({}, plan.graph['uid'])

    def wait_function(timeout):
        try:
            for summary in wait_finish(plan.graph['uid'], timeout):
                assert summary[states.ERROR.name] == 0
                time.sleep(0.5)
        except ExecutionTimeout:
            pass
        return summary

    waiter = gevent.spawn(wait_function, timeout)
    waiter.join(timeout=timeout)
    res = waiter.get(block=True)
    assert res[states.SUCCESS.name] == total_resources
    assert len(data.CL()) == total_resources
    clear_cache()
    assert len(change.staged_log()) == 0
def test_concurrent_sequences_with_no_handler(scale, clients):
    total_resources = scale * 3
    timeout = scale * 2
    scheduler_client = clients['scheduler']

    assert len(change.staged_log()) == total_resources
    ModelMeta.save_all_lazy()
    plan = change.send_to_orchestration()
    ModelMeta.save_all_lazy()
    scheduler_client.next({}, plan.graph['uid'])

    def wait_function(timeout):
        try:
            for summary in wait_finish(plan.graph['uid'], timeout):
                assert summary[states.ERROR.name] == 0
                time.sleep(0.5)
        except ExecutionTimeout:
            pass
        return summary
    waiter = gevent.spawn(wait_function, timeout)
    waiter.join(timeout=timeout)
    res = waiter.get(block=True)
    assert res[states.SUCCESS.name] == total_resources
    assert len(data.CL()) == total_resources
    clear_cache()
    assert len(change.staged_log()) == 0
Beispiel #3
0
def test_stage_and_process_partially():
    a = ['a']
    b = ['b']
    both = a + b
    range_a = range(1, 4)
    range_b = range(4, 6)
    with_tag_a = [create_resource(str(n), tags=a) for n in range_a]
    with_tag_b = [create_resource(str(n), tags=b) for n in range_b]
    ModelMeta.save_all_lazy()
    created_log_items_with_a = stage_resources(a, 'restart')
    assert len(created_log_items_with_a) == len(with_tag_a)
    created_log_items_with_b = stage_resources(b, 'restart')
    assert len(created_log_items_with_b) == len(with_tag_b)

    a_graph = change.send_to_orchestration(a)
    a_expected = set(['%s.restart' % n for n in range_a])
    compare_task_to_names(set(a_graph.nodes()), a_expected)
    b_graph = change.send_to_orchestration(b)
    b_expected = set(['%s.restart' % n for n in range_b])
    compare_task_to_names(set(b_graph.nodes()), b_expected)
    both_graph = change.send_to_orchestration(both)
    compare_task_to_names(set(both_graph.nodes()), a_expected | b_expected)
Beispiel #4
0
def test_stage_and_process_partially():
    a = ['a']
    b = ['b']
    both = a + b
    range_a = range(1, 4)
    range_b = range(4, 6)
    with_tag_a = [create_resource(str(n), tags=a) for n in range_a]
    with_tag_b = [create_resource(str(n), tags=b) for n in range_b]
    ModelMeta.save_all_lazy()
    created_log_items_with_a = stage_resources(a, 'restart')
    assert len(created_log_items_with_a) == len(with_tag_a)
    created_log_items_with_b = stage_resources(b, 'restart')
    assert len(created_log_items_with_b) == len(with_tag_b)

    a_graph = change.send_to_orchestration(a)
    a_expected = set(['%s.restart' % n for n in range_a])
    assert set(a_graph.nodes()) == a_expected
    b_graph = change.send_to_orchestration(b)
    b_expected = set(['%s.restart' % n for n in range_b])
    assert set(b_graph.nodes()) == b_expected
    both_graph = change.send_to_orchestration(both)
    assert set(both_graph.nodes()) == a_expected | b_expected
Beispiel #5
0
def process(tag):
    uid = change.send_to_orchestration(tag).graph['uid']
    remember_uid(uid)
    click.echo(uid)
Beispiel #6
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()
Beispiel #7
0
def process():
    uid = change.send_to_orchestration().graph['uid']
    remember_uid(uid)
    click.echo(uid)
Beispiel #8
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()