def get_mimic_manager_cli(auth_url=None, username=None,
                          password=None, tenant_name=None):
    auth_url = auth_url if auth_url else os_auth_url
    username = username if username else os_username
    password = password if password else os_password
    tenant_name = tenant_name if tenant_name else username
    cli_mgr = utils.get_mimic_manager_cli(auth_url, username,
                                          password, tenant_name)
    return cli_mgr
Ejemplo n.º 2
0
def create_solaris(adm, os_auth_url, halt=False,
                   password="******"):
    if halt:
        import pdb;
        pdb.set_trace()

    # get-or-create Sun solaris system's admin Sun
    try:
        tenant = utils.fgrep(adm.keys('tenant-list'), name=r'^Sun$')
        if len(tenant) < 1:
            Sun = icreds.create_admin_project('Sun', password)
        sun = utils.get_mimic_manager_cli(os_auth_url, 'Sun', password)
    except Exception:
        tb_str = traceback.format_exc()
        mesg = ("ERROR creating/retriving Admin user[%s]:\n%s" % (
            'Sun', tb_str))
        utils.log_msg(mesg)

    # our solar system has 8 planets'
    sun_planets = ['Mercury', 'Venus', 'Earth', 'Mars',
                   'Jupiter', 'Satun', 'Uranus', 'Neptune']
    dwarf_planets = ["Haumea", "Eris", "Ceres", "Pluto", "Makemake"]
    tenants = {}
    for planet in sun_planets + dwarf_planets + ["Moon"]:
        tenant = utils.fgrep(adm.keys('tenant-list'), name=planet)
        if len(tenant) < 1:
            # tenant not exist, create it; default password=itempest
            tenant = icreds.create_primary_project(planet, password)
            try:
                tenant = adm.keys('tenant_get_by_name', planet)
                tenants[planet] = tenant
                # by default tenant can only have instances=10
                adm.nova('quota-update', tenant['id'],
                         instances=tenant_max_instances)
                adm.qsvc('quota-incr-by', tenant['id'], 2)
            except Exception:
                pass
        else:
            tenants[planet] = tenant[0]
    return tenants
Ejemplo n.º 3
0
# Copyright 2015 OpenStack Foundation
# Copyright 2015 VMware Inc.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
#  the
#    License for the specific language governing permissions and limitations
#    under the License.

import os

from itempest.lib import utils

os_auth_url = os.environ.get('OS_AUTH_URL', 'http://10.8.3.1:5000/v2.0')
os_username = os.environ.get('OS_USERNAME', 'Earth')
os_password = os.environ.get('OS_PASSWORD', 'itempest8@OS')
os_tenant_name = os.environ.get('OS_TENANT_NAME', os_username)
os_lbaasv2 = int(os.environ.get('OS_LABAASV2', 0))

tenant = utils.get_mimic_manager_cli(os_auth_url, os_username, os_password,
                                     os_tenant_name,
                                     lbaasv2=os_lbaasv2)
def get_mcli(tenant_name, **kwargs):
    psw = kwargs.pop('password', 'itempest8@OS')
    mcli_mgr = utils.get_mimic_manager_cli(os_auth_url, tenant_name, psw,
                                           **kwargs)
    return mcli_mgr
                tenant = adm.keys('tenant_get_by_name', planet)
                tenants[planet] = tenant
                # by default tenant can only have instances=10
                adm.nova('quota-update', tenant['id'],
                         instances=tenant_max_instances)
                adm.qsvc('quota-incr-by', tenant['id'], 2)
            except Exception:
                pass
        else:
            tenants[planet] = tenant[0]
    return tenants


# sun-has-8-planets, earth-is-the-3rd and has-1-moon
os_auth_url = os.environ.get('OS_AUTH_URL', 'http://10.8.3.1:5000/v2.0')
os_password = os.environ.get('OS_PASSWORD', 'itempest8@OS')
tenant_max_instances = os.environ.get('OS_TENANT_MAX_INSTANCES', 20)
os_lbaasv2 = int(os.environ.get('OS_LBAASV2', 1))

# accounts created by devstack
adm = utils.get_mimic_manager_cli(os_auth_url, 'admin', os_password,
                                  lbaasv2=os_lbaasv2)
try:
    # not every Openstack and devstack create demo project/tenant
    demo = utils.get_mimic_manager_cli(os_auth_url, 'demo', os_password,
                                       lbaasv2=os_lbaasv2)
except Exception:
    pass

tenants = create_solaris()