def main(argv):
    parser = argparse.ArgumentParser()
    default_machines = ["precise:m1.small:1", "cirros:m1.tiny:1"]
    parser.add_argument("machines", default=default_machines, nargs="*")
    parser.add_argument("--active_wait", default=180)
    parser.add_argument("--cloudinit_wait", default=180)
    parser.add_argument("--ping_wait", default=180)
    options = parser.parse_args()
    machines = mojo_utils.parse_mojo_arg(options, 'machines', multiargs=True)
    active_wait = int(mojo_utils.parse_mojo_arg(options, 'active_wait'))
    cloudinit_wait = int(mojo_utils.parse_mojo_arg(options, 'cloudinit_wait'))
    ping_wait = int(mojo_utils.parse_mojo_arg(options, 'ping_wait'))
    logging.basicConfig(level=logging.INFO)
    overcloud_novarc = mojo_utils.get_overcloud_auth()
    novac = mojo_os_utils.get_nova_client(overcloud_novarc)
    priv_key = mojo_os_utils.create_keypair(novac, 'mojo')
    mojo_os_utils.add_secgroup_rules(novac)
    for instanceset in machines:
        image_name, flavor_name, count = instanceset.split(":")
        mojo_os_utils.boot_and_test(novac,
                                    image_name=image_name,
                                    flavor_name=flavor_name,
                                    number=int(count),
                                    privkey=priv_key,
                                    active_wait=active_wait,
                                    cloudinit_wait=cloudinit_wait,
                                    ping_wait=ping_wait)
Ejemplo n.º 2
0
def main(argv):
    mojo_utils.setup_logging()
    parser = argparse.ArgumentParser()
    default_machines = ["cirros:m1.tiny:1"]
    parser.add_argument("machines", default=default_machines, nargs="*")
    parser.add_argument("--active_wait", default=180)
    parser.add_argument("--cloudinit_wait", default=180)
    parser.add_argument("--ping_wait", default=180)
    options = parser.parse_args()
    machines = mojo_utils.parse_mojo_arg(options, 'machines', multiargs=True)
    active_wait = int(mojo_utils.parse_mojo_arg(options, 'active_wait'))
    cloudinit_wait = int(mojo_utils.parse_mojo_arg(options, 'cloudinit_wait'))
    ping_wait = int(mojo_utils.parse_mojo_arg(options, 'ping_wait'))
    overcloud_novarc = mojo_utils.get_overcloud_auth()
    keystone_session = mojo_os_utils.get_keystone_session(overcloud_novarc,
                                                          scope='PROJECT')
    os_version = mojo_os_utils.get_current_os_versions('keystone')['keystone']
    # Keystone policy.json shipped the charm with liberty requires a domain
    # scoped token. Bug #1649106
    if os_version == 'liberty':
        project_query_session = mojo_os_utils.get_keystone_session(
            overcloud_novarc, scope='DOMAIN')
    else:
        project_query_session = keystone_session
    keystonec = mojo_os_utils.get_keystone_session_client(
        project_query_session)
    domain = overcloud_novarc.get('OS_PROJECT_DOMAIN_NAME')
    project_id = mojo_os_utils.get_project_id(
        keystonec,
        'admin',
        api_version=overcloud_novarc['API_VERSION'],
        domain_name=domain)
    novac = mojo_os_utils.get_nova_session_client(keystone_session)
    neutronc = mojo_os_utils.get_neutron_session_client(keystone_session)

    init_flavors(novac)

    priv_key = mojo_os_utils.create_keypair(novac, 'mojo')
    mojo_os_utils.add_neutron_secgroup_rules(neutronc, project_id)
    for server in novac.servers.list():
        novac.servers.delete(server.id)
    for instanceset in machines:
        image_name, flavor_name, count = instanceset.split(":")
        mojo_os_utils.boot_and_test(novac,
                                    neutronc,
                                    image_name=image_name,
                                    flavor_name=flavor_name,
                                    number=int(count),
                                    privkey=priv_key,
                                    active_wait=active_wait,
                                    cloudinit_wait=cloudinit_wait,
                                    ping_wait=ping_wait)
Ejemplo n.º 3
0
def get_cirros_server(clients, image_password):
    logging.info('Looking for existing cirros server')
    cirros_server = lookup_cirros_server(clients)
    if cirros_server:
        ip = get_server_floating_ip(cirros_server)
        logging.info('Checking connectivity to cirros guest')
        if not mojo_os_utils.ssh_test(
                'cirros', ip, cirros_server.name, password=image_password):
            raise Exception('Cirros guest inaccessable')
    else:
        logging.info('Creating new cirros guest')
        mojo_os_utils.boot_and_test(
            clients['nova'],
            clients['neutron'],
            image_name='cirros',
            flavor_name='m1.small',
            number=1,
            privkey=None,
        )
        cirros_server = lookup_cirros_server(clients)
        ip = get_server_floating_ip(cirros_server)
    return cirros_server, ip
def main(argv):
    cli_utils.setup_logging()
    parser = argparse.ArgumentParser()
    default_machines = ["cirros:m1.tiny:1"]
    parser.add_argument("machines", default=default_machines, nargs="*")
    parser.add_argument("--active_wait", default=600)
    parser.add_argument("--cloudinit_wait", default=600)
    parser.add_argument("--ping_wait", default=600)
    options = parser.parse_args()
    machines = cli_utils.parse_arg(options, 'machines', multiargs=True)
    active_wait = int(cli_utils.parse_arg(options, 'active_wait'))
    cloudinit_wait = int(cli_utils.parse_arg(options, 'cloudinit_wait'))
    ping_wait = int(cli_utils.parse_arg(options, 'ping_wait'))
    overcloud_novarc = openstack_utils.get_overcloud_auth()
    try:
        cacert = os.path.join(os.environ.get('MOJO_LOCAL_DIR'), 'cacert.pem')
        os.stat(cacert)
        logging.info("Using cacert file: {}".format(cacert))
    except FileNotFoundError:
        logging.info("Not using a cacert pem file")
        cacert = None

    logging.info("Initializing client sessions")
    keystone_session = openstack_utils.get_overcloud_keystone_session(
        verify=cacert)
    keystonec = openstack_utils.get_keystone_session_client(keystone_session)
    domain = overcloud_novarc.get('OS_PROJECT_DOMAIN_NAME')
    project_id = openstack_utils.get_project_id(
        keystonec,
        'admin',
        api_version=overcloud_novarc['API_VERSION'],
        domain_name=domain)
    novac = openstack_utils.get_nova_session_client(keystone_session)
    neutronc = openstack_utils.get_neutron_session_client(keystone_session)

    init_flavors(novac)

    priv_key = mojo_os_utils.create_keypair(novac, 'mojo')
    openstack_utils.add_neutron_secgroup_rules(neutronc, project_id)
    for server in novac.servers.list(search_opts={'all_tenants': 1}):
        if server.name.startswith('mojo'):
            logging.info("Deleting nova instance {}".format(server.id))
            novac.servers.delete(server.id)
    for instanceset in machines:
        image_name, flavor_name, count = instanceset.split(":")
        # when instance count allows boot instances off both regular instance
        # storage and volume storage
        #
        # account for count=1 and odd numbers

        # NOTE(fnordahl) temporarilly disable test while tests settle
        # regular_boot_count = int(int(count) / 2) + (int(count) % 2)
        # volume_boot_count = int(int(count) / 2)
        regular_boot_count = int(count)
        volume_boot_count = 0
        mojo_os_utils.boot_and_test(
            novac,
            neutronc,
            image_name=image_name,
            flavor_name=flavor_name,
            number=regular_boot_count,
            privkey=priv_key,
            active_wait=active_wait,
            cloudinit_wait=cloudinit_wait,
            ping_wait=ping_wait,
        )
        mojo_os_utils.boot_and_test(
            novac,
            neutronc,
            image_name=image_name,
            flavor_name=flavor_name,
            number=volume_boot_count,
            privkey=priv_key,
            active_wait=active_wait,
            cloudinit_wait=cloudinit_wait,
            ping_wait=ping_wait,
            boot_from_volume=True,
        )