Exemple #1
0
def test_get_flavor_id(nova_api):
    flavor_id_1 = utils.get_flavor_id(nova_api, 'resource_1')
    assert flavor_id_1 == "f8a7cee0-b7c5-11e5-ae52-0021ccd9d101"
    flavor_id_2 = utils.get_flavor_id(nova_api, 'resource_2')
    assert flavor_id_2 == "16a695de-b7c6-11e5-9c4c-0021ccd9d101"
    flavor_id = utils.get_flavor_id(nova_api, 'not_available')
    assert None == flavor_id
def deploy_host0(os_auth_url, os_username, os_password, os_tenant_name, config):
    provisioner = config['provisioner']
    if provisioner['type'] == 'openstack':
        LOG.info("using 'openstack' provisioner")
        nova_api = os_utils.build_nova_api(os_auth_url, os_username,
                                           os_password, os_tenant_name)

        image_id_to_boot_from = os_utils.get_image_id(nova_api,
                                                      provisioner['image']['name'])
        flavor_id = os_utils.get_flavor_id(nova_api, provisioner['flavor'])
        keypair_id = os_utils.get_keypair_id(nova_api, provisioner['keypair'])
        network_id = os_utils.get_network_id(nova_api, provisioner['network'])
        nics = [{'net-id': network_id}]

        instance_name = "%s-%s" % (provisioner['instance_name_prefix'],
                                   str(datetime.datetime.utcnow()))
        LOG.info("building instance '%s'" % instance_name)

        os_instance = os_libvirt.build_openstack_instance(
            nova_api,
            instance_name,
            image_id_to_boot_from,
            flavor_id,
            keypair_id,
            nics)

        if os_instance:
            host0_ip = os_utils.add_a_floating_ip(nova_api, os_instance)
            LOG.info("add floating ip '%s'" % host0_ip)
            os_utils.add_security_groups(os_instance,
                                         provisioner['security-groups'])
            LOG.info("add security groups '%s'" %
                     provisioner['security-groups'])
            LOG.info("instance '%s' ready to use" % instance_name)
        else:
            LOG.error("instance '%s' failed" % instance_name)
            sys.exit(1)

        host0 = rdomhelper.host0.Host0(hostname=host0_ip,
                                       user=config['provisioner']['image'].get('user', 'root'),
                                       key_filename=config['ssh']['private_key'])
        host0.rhsm_register(
            config['rhsm']['login'],
            config['rhsm'].get('password', os.environ.get('RHN_PW')),
            config['rhsm']['pool_id'])
        return host0
Exemple #3
0
def deploy_host0(os_auth_url, os_username, os_password, os_tenant_name,
                 config):
    provisioner = config['provisioner']
    if provisioner['type'] == 'openstack':
        LOG.info("using 'openstack' provisioner")
        nova_api = os_utils.build_nova_api(os_auth_url, os_username,
                                           os_password, os_tenant_name)

        image_id_to_boot_from = os_utils.get_image_id(
            nova_api, provisioner['image']['name'])
        flavor_id = os_utils.get_flavor_id(nova_api, provisioner['flavor'])
        keypair_id = os_utils.get_keypair_id(nova_api, provisioner['keypair'])
        network_id = os_utils.get_network_id(nova_api, provisioner['network'])
        nics = [{'net-id': network_id}]

        instance_name = "%s-%s" % (provisioner['instance_name_prefix'],
                                   str(datetime.datetime.utcnow()))
        LOG.info("building instance '%s'" % instance_name)

        os_instance = os_libvirt.build_openstack_instance(
            nova_api, instance_name, image_id_to_boot_from, flavor_id,
            keypair_id, nics)

        if os_instance:
            host0_ip = os_utils.add_a_floating_ip(nova_api, os_instance)
            LOG.info("add floating ip '%s'" % host0_ip)
            os_utils.add_security_groups(os_instance,
                                         provisioner['security-groups'])
            LOG.info("add security groups '%s'" %
                     provisioner['security-groups'])
            LOG.info("instance '%s' ready to use" % instance_name)
        else:
            LOG.error("instance '%s' failed" % instance_name)
            sys.exit(1)

        host0 = rdomhelper.host0.Host0(
            hostname=host0_ip,
            user=config['provisioner']['image'].get('user', 'root'),
            key_filename=config['ssh']['private_key'])
        host0.rhsm_register(
            config['rhsm']['login'],
            config['rhsm'].get('password', os.environ.get('RHN_PW')),
            config['rhsm']['pool_id'])
        return host0