X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=yardstick%2Fcommon%2Fopenstack_utils.py;h=f027b7922554698fd047b7fb314ced35ed783d25;hb=11b2a73549df60bdd19aecb98dc4b9e71a40c0ac;hp=1f08344e45ded4ca6a7ad2478e539376c0ef131a;hpb=90032ba61345752b014002dda629f84c42780e6c;p=yardstick.git diff --git a/yardstick/common/openstack_utils.py b/yardstick/common/openstack_utils.py index 1f08344e4..f027b7922 100644 --- a/yardstick/common/openstack_utils.py +++ b/yardstick/common/openstack_utils.py @@ -15,6 +15,7 @@ import logging from keystoneauth1 import loading from keystoneauth1 import session +from cinderclient import client as cinderclient from novaclient import client as novaclient from glanceclient import client as glanceclient from neutronclient.neutron import client as neutronclient @@ -79,7 +80,8 @@ def get_session(): except KeyError: return session.Session(auth=auth) else: - cacert = False if cacert.lower() == "false" else cacert + insecure = os.getenv('OS_INSECURE', '').lower() == 'true' + cacert = False if insecure else cacert return session.Session(auth=auth, verify=cacert) @@ -107,6 +109,21 @@ def get_heat_api_version(): # pragma: no cover return api_version +def get_cinder_client_version(): # pragma: no cover + try: + api_version = os.environ['OS_VOLUME_API_VERSION'] + except KeyError: + return DEFAULT_API_VERSION + else: + log.info("OS_VOLUME_API_VERSION is set in env as '%s'", api_version) + return api_version + + +def get_cinder_client(): # pragma: no cover + sess = get_session() + return cinderclient.Client(get_cinder_client_version(), session=sess) + + def get_nova_client_version(): # pragma: no cover try: api_version = os.environ['OS_COMPUTE_API_VERSION'] @@ -429,3 +446,11 @@ def get_port_id_by_ip(neutron_client, ip_address): # pragma: no cover def get_image_id(glance_client, image_name): # pragma: no cover images = glance_client.images.list() return next((i.id for i in images if i.name == image_name), None) + + +# ********************************************* +# CINDER +# ********************************************* +def get_volume_id(volume_name): # pragma: no cover + volumes = get_cinder_client().volumes.list() + return next((v.id for v in volumes if v.name == volume_name), None)