Beispiel #1
0
def ha_hello_worlds(cfy, hosts, attributes, ssh_key, tmpdir, logger):
    # Pick a manager to operate on, and trust the cluster to work with us
    manager = hosts.instances[0]

    hws = []
    for i in range(0, 2):
        tenant = prepare_and_get_test_tenant(
            'clusterhello{num}'.format(num=i),
            manager,
            cfy,
        )
        hw = centos_hello_world(
            cfy,
            manager,
            attributes,
            ssh_key,
            logger,
            tmpdir,
            tenant=tenant,
            suffix=str(i),
        )
        hws.append(hw)

    yield hws
    for hw in hws:
        if hw.cleanup_required:
            logger.info('Cleaning up hello world...')
            manager.use()
            hw.cleanup()
def test_ssl(cfy, manager, module_tmpdir, attributes, ssh_key, logger):
    cert_path = join(module_tmpdir, '.cloudify', 'profiles',
                     manager.ip_address, 'public_rest_cert.crt')
    _generate_external_cert(manager, logger)
    _download_external_cert(manager, logger, local_cert_path=cert_path)

    cfy.profiles.set('-c', cert_path)

    assert 'SSL disabled' in cfy.ssl.status()
    current_profile = cfy.profiles.show()
    assert ' 80 ' in current_profile
    assert ' http ' in current_profile

    cfy.ssl.enable()
    cfy.profiles.set('--ssl', 'on', '--skip-credentials-validation')
    time.sleep(5)
    assert 'SSL enabled' in cfy.ssl.status()

    current_profile = cfy.profiles.show()
    assert ' 443 ' in current_profile
    assert ' https ' in current_profile

    _manager_client = manager.client
    ssl_client = CloudifyClient(username='******',
                                password='******',
                                host=manager.ip_address,
                                tenant='default_tenant',
                                protocol='https',
                                cert=cert_path)
    manager.client = ssl_client

    if not is_community():
        tenant_name = 'ssl_tenant'
        cfy.users.create('ssl_user', '-p', 'ssl_pass')
        cfy.tenants.create(tenant_name)

        cfy.tenants('add-user',
                    'ssl_user',
                    '-t',
                    tenant_name,
                    '-r',
                    DEFAULT_TENANT_ROLE)

    hello_world = centos_hello_world(cfy, manager, attributes, ssh_key,
                                     logger, module_tmpdir)

    hello_world.upload_and_verify_install()

    cfy.ssl.disable()
    cfy.profiles.set('--ssl', 'off', '--skip-credentials-validation')
    time.sleep(5)
    assert 'SSL disabled' in cfy.ssl.status()

    current_profile = cfy.profiles.show()
    assert ' 80 ' in current_profile
    assert ' http ' in current_profile

    manager.client = _manager_client
    hello_world.uninstall()
    hello_world.delete_deployment()
def test_ssl(cfy, manager, module_tmpdir, attributes, ssh_key, logger):
    cert_path = join(module_tmpdir, '.cloudify', 'profiles',
                     manager.ip_address, 'public_rest_cert.crt')
    _generate_external_cert(manager, logger)
    _download_external_cert(manager, logger, local_cert_path=cert_path)

    cfy.profiles.set('-c', cert_path)

    assert 'SSL disabled' in cfy.ssl.status()
    current_profile = cfy.profiles.show()
    assert ' 80 ' in current_profile
    assert ' http ' in current_profile

    cfy.ssl.enable()
    cfy.profiles.set('--ssl', 'on', '--skip-credentials-validation')
    time.sleep(5)
    assert 'SSL enabled' in cfy.ssl.status()

    current_profile = cfy.profiles.show()
    assert ' 443 ' in current_profile
    assert ' https ' in current_profile

    _manager_client = manager.client
    ssl_client = CloudifyClient(username='******',
                                password='******',
                                host=manager.ip_address,
                                tenant='default_tenant',
                                protocol='https',
                                cert=cert_path)
    manager.client = ssl_client

    if not is_community():
        tenant_name = 'ssl_tenant'
        cfy.users.create('ssl_user', '-p', 'ssl_pass')
        cfy.tenants.create(tenant_name)

        cfy.tenants('add-user', 'ssl_user', '-t', tenant_name, '-r',
                    DEFAULT_TENANT_ROLE)

    hello_world = centos_hello_world(cfy, manager, attributes, ssh_key, logger,
                                     module_tmpdir)

    hello_world.upload_and_verify_install()

    cfy.ssl.disable()
    cfy.profiles.set('--ssl', 'off', '--skip-credentials-validation')
    time.sleep(5)
    assert 'SSL disabled' in cfy.ssl.status()

    current_profile = cfy.profiles.show()
    assert ' 80 ' in current_profile
    assert ' http ' in current_profile

    manager.client = _manager_client
    hello_world.uninstall()
    hello_world.delete_deployment()
def proxy_helloworld(cfy, proxy_hosts, attributes, ssh_key, tmpdir, logger):
    # don't use MultiNetworkTestHosts - we're testing with the default
    # network, so no need to set manager network name
    hw = centos_hello_world(
        cfy, proxy_hosts[1], attributes, ssh_key, logger, tmpdir)

    yield hw
    if hw.cleanup_required:
        logger.info('Hello world cleanup required..')
        hw.cleanup()
def proxy_helloworld(cfy, proxy_hosts, attributes, ssh_key, tmpdir, logger):
    # don't use MultiNetworkTestHosts - we're testing with the default
    # network, so no need to set manager network name
    hw = centos_hello_world(cfy, proxy_hosts[1], attributes, ssh_key, logger,
                            tmpdir)

    yield hw
    if hw.cleanup_required:
        logger.info('Hello world cleanup required..')
        hw.cleanup()
def hello_world(cfy, manager, attributes, ssh_key, tmpdir, logger):
    tenant = prepare_and_get_test_tenant('dep_update', manager, cfy)
    hw = centos_hello_world(cfy,
                            manager,
                            attributes,
                            ssh_key,
                            logger,
                            tmpdir,
                            tenant=tenant,
                            suffix='update')
    yield hw
    hw.cleanup()
def hello_world(cfy, manager, attributes, ssh_key, tmpdir, logger):
    tenant = prepare_and_get_test_tenant('dep_update', manager, cfy)
    hw = centos_hello_world(cfy,
                            manager,
                            attributes,
                            ssh_key,
                            logger,
                            tmpdir,
                            tenant=tenant,
                            suffix='update')
    yield hw
    hw.cleanup()
Beispiel #8
0
def web_app(cfy, manager, attributes, ssh_key, logger, tmpdir):
    hw = centos_hello_world(cfy,
                            manager,
                            attributes,
                            ssh_key,
                            logger,
                            tmpdir)
    hw.blueprint_file = util.get_resource_path(
        'blueprints/deployment_proxy/web_app.yaml'
    )
    hw.inputs.clear()
    yield hw
    hw.cleanup()
Beispiel #9
0
def vm_infrastructure(cfy, manager, attributes, ssh_key, logger, tmpdir):
    hw = centos_hello_world(cfy,
                            manager,
                            attributes,
                            ssh_key,
                            logger,
                            tmpdir)
    hw.blueprint_file = util.get_resource_path(
        'blueprints/deployment_proxy/vm_infrastructure.yaml'
    )
    hw.blueprint_id = 'os_infra'
    hw.deployment_id = 'os_infra'
    yield hw
    hw.cleanup()
def _make_network_hello_worlds(cfy, managers, attributes, ssh_key, tmpdir,
                               logger):
    # The first manager is the initial one
    manager = managers[0]
    manager.use()
    hellos = []

    # Add a MultiNetworkHelloWorld per management network
    for network_name, network_id in attributes.network_names.iteritems():
        tenant = prepare_and_get_test_tenant('{0}_tenant'.format(network_name),
                                             manager, cfy)
        hello = MultiNetworkHelloWorld(cfy,
                                       manager,
                                       attributes,
                                       ssh_key,
                                       logger,
                                       tmpdir,
                                       tenant=tenant,
                                       suffix=network_name)
        hello.blueprint_file = 'openstack-blueprint.yaml'
        hello.inputs.update({
            'agent_user': attributes.centos_7_username,
            'image': attributes.centos_7_image_name,
            'manager_network_name': network_name,
            'network_name': network_id
        })

        # Make sure the post_bootstrap network is first
        if network_name == NETWORK_2:
            hellos.insert(0, hello)
        else:
            hellos.append(hello)

    # Add one more hello world, that will run on the `default` network
    # implicitly
    hw = centos_hello_world(cfy,
                            manager,
                            attributes,
                            ssh_key,
                            logger,
                            tmpdir,
                            tenant=DEFAULT_TENANT_NAME,
                            suffix='default_network')
    hellos.append(hw)

    yield hellos
    for hello in hellos:
        hello.cleanup()
def _make_network_hello_worlds(cfy, managers, attributes, ssh_key, tmpdir,
                               logger):
    # The first manager is the initial one
    manager = managers[0]
    manager.use()
    hellos = []

    # Add a MultiNetworkHelloWorld per management network
    for network_name, network_id in attributes.network_names.iteritems():
        tenant = prepare_and_get_test_tenant(
            '{0}_tenant'.format(network_name), manager, cfy
        )
        hello = MultiNetworkHelloWorld(
            cfy, manager, attributes, ssh_key, logger, tmpdir,
            tenant=tenant, suffix=network_name)
        hello.blueprint_file = 'openstack-blueprint.yaml'
        hello.inputs.update({
            'agent_user': attributes.centos_7_username,
            'image': attributes.centos_7_image_name,
            'manager_network_name': network_name,
            'network_name': network_id
        })

        # Make sure the post_bootstrap network is first
        if network_name == NETWORK_2:
            hellos.insert(0, hello)
        else:
            hellos.append(hello)

    # Add one more hello world, that will run on the `default` network
    # implicitly
    hw = centos_hello_world(cfy, manager, attributes, ssh_key, logger, tmpdir,
                            tenant=DEFAULT_TENANT_NAME,
                            suffix='default_network')
    hellos.append(hw)

    yield hellos
    for hello in hellos:
        hello.cleanup()
def test_nonempty_manager_join_cluster_negative(cfy, attributes, ssh_key,
                                                logger, tmpdir, module_tmpdir):
    logger.info('Creating HA cluster of 2 managers')
    hosts = TestHosts(cfy,
                      ssh_key,
                      module_tmpdir,
                      attributes,
                      logger,
                      number_of_instances=2)

    try:
        hosts.create()
        manager1 = hosts.instances[0]
        manager2 = hosts.instances[1]

        ha_helper.delete_active_profile()
        manager1.use()
        cfy.cluster.start(timeout=600,
                          cluster_host_ip=manager1.private_ip_address,
                          cluster_node_name=manager1.ip_address)

        cfy.cluster.nodes.list()

        ha_helper.delete_active_profile()
        manager2.use()
        hello_world = centos_hello_world(cfy, manager2, attributes, ssh_key,
                                         logger, tmpdir)

        hello_world.upload_blueprint()

        logger.info('Joining HA cluster from a non-empty manager')
        with pytest.raises(Exception):
            cfy.cluster.join(manager1.ip_address,
                             timeout=600,
                             cluster_host_ip=manager2.private_ip_address,
                             cluster_node_name=manager2.ip_address)

    finally:
        hosts.destroy()
def distributed_ha_hello_worlds(cfy, distributed_installation, attributes,
                                ssh_key, tmpdir, logger):
    # Pick a manager to operate on, and trust the cluster to work with us
    manager = distributed_installation.instances[0]

    hws = []
    for i in range(0, 2):
        tenant = prepare_and_get_test_tenant(
            'clusterhello{num}'.format(num=i),
            manager,
            cfy,
        )
        hw = centos_hello_world(
            cfy, manager, attributes, ssh_key, logger, tmpdir,
            tenant=tenant, suffix=str(i),
        )
        hws.append(hw)

    yield hws
    for hw in hws:
        if hw.cleanup_required:
            logger.info('Cleaning up hello world...')
            manager.use()
            hw.cleanup()