summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShobhi Jain <shobhi.jain@intel.com>2018-03-26 16:04:49 +0100
committerShobhi Jain <shobhi.jain@intel.com>2018-04-23 13:09:42 +0000
commit2ca15a8c87e171cbd82b1e748dfc60903662b73b (patch)
tree42a3e783e58432a350920d4a14e7dca48d5d6588
parent05f97c4e4ce1e8c7c97cda16f12215e663a13c23 (diff)
Remove unused nova client functions.
Following funtions are not required by shade client also not been used in any of the scenario files: *create_aggregate *create_aggregate_with_host *create_instance *add_host_to_aggregate *create_aggregate_with_host *get_availability_zones *get_availability_zone_names *remove_hosts_from_aggregate *remove_host_from_aggregate *delete_aggregate *get_image_by_name *check_status JIRA: YARDSTICK-1088 Change-Id: I7ba0fbce6aa3e636aa55581a993c1ec1b48fbead Signed-off-by: Shobhi Jain <shobhi.jain@intel.com>
-rw-r--r--yardstick/common/openstack_utils.py136
1 files changed, 0 insertions, 136 deletions
diff --git a/yardstick/common/openstack_utils.py b/yardstick/common/openstack_utils.py
index e542a1d07..d469929e3 100644
--- a/yardstick/common/openstack_utils.py
+++ b/yardstick/common/openstack_utils.py
@@ -8,7 +8,6 @@
##############################################################################
import os
-import time
import sys
import logging
@@ -163,76 +162,6 @@ def get_shade_client():
# *********************************************
# NOVA
# *********************************************
-def get_aggregates(nova_client): # pragma: no cover
- try:
- return nova_client.aggregates.list()
- except Exception: # pylint: disable=broad-except
- log.exception("Error [get_aggregates(nova_client)]")
-
-
-def get_availability_zones(nova_client): # pragma: no cover
- try:
- return nova_client.availability_zones.list()
- except Exception: # pylint: disable=broad-except
- log.exception("Error [get_availability_zones(nova_client)]")
-
-
-def get_availability_zone_names(nova_client): # pragma: no cover
- try:
- return [az.zoneName for az in get_availability_zones(nova_client)]
- except Exception: # pylint: disable=broad-except
- log.exception("Error [get_availability_zone_names(nova_client)]")
-
-
-def create_aggregate(nova_client, aggregate_name, av_zone): # pragma: no cover
- try:
- nova_client.aggregates.create(aggregate_name, av_zone)
- except Exception: # pylint: disable=broad-except
- log.exception("Error [create_aggregate(nova_client, %s, %s)]",
- aggregate_name, av_zone)
- return False
- else:
- return True
-
-
-def get_aggregate_id(nova_client, aggregate_name): # pragma: no cover
- try:
- aggregates = get_aggregates(nova_client)
- _id = next((ag.id for ag in aggregates if ag.name == aggregate_name))
- except Exception: # pylint: disable=broad-except
- log.exception("Error [get_aggregate_id(nova_client, %s)]",
- aggregate_name)
- else:
- return _id
-
-
-def add_host_to_aggregate(nova_client, aggregate_name,
- compute_host): # pragma: no cover
- try:
- aggregate_id = get_aggregate_id(nova_client, aggregate_name)
- nova_client.aggregates.add_host(aggregate_id, compute_host)
- except Exception: # pylint: disable=broad-except
- log.exception("Error [add_host_to_aggregate(nova_client, %s, %s)]",
- aggregate_name, compute_host)
- return False
- else:
- return True
-
-
-def create_aggregate_with_host(nova_client, aggregate_name, av_zone,
- compute_host): # pragma: no cover
- try:
- create_aggregate(nova_client, aggregate_name, av_zone)
- add_host_to_aggregate(nova_client, aggregate_name, compute_host)
- except Exception: # pylint: disable=broad-except
- log.exception("Error [create_aggregate_with_host("
- "nova_client, %s, %s, %s)]",
- aggregate_name, av_zone, compute_host)
- return False
- else:
- return True
-
-
def create_keypair(name, key_path=None): # pragma: no cover
try:
with open(key_path) as fpubkey:
@@ -243,14 +172,6 @@ def create_keypair(name, key_path=None): # pragma: no cover
log.exception("Error [create_keypair(nova_client)]")
-def create_instance(json_body): # pragma: no cover
- try:
- return get_nova_client().servers.create(**json_body)
- except Exception: # pylint: disable=broad-except
- log.exception("Error create instance failed")
- return None
-
-
def create_instance_and_wait_for_active(shade_client, name, image,
flavor, auto_ip=True, ips=None,
ip_pool=None, root_volume=None,
@@ -376,40 +297,6 @@ def delete_instance(shade_client, name_or_id, wait=False, timeout=180,
return False
-def remove_host_from_aggregate(nova_client, aggregate_name,
- compute_host): # pragma: no cover
- try:
- aggregate_id = get_aggregate_id(nova_client, aggregate_name)
- nova_client.aggregates.remove_host(aggregate_id, compute_host)
- except Exception: # pylint: disable=broad-except
- log.exception("Error remove_host_from_aggregate(nova_client, %s, %s)",
- aggregate_name, compute_host)
- return False
- else:
- return True
-
-
-def remove_hosts_from_aggregate(nova_client,
- aggregate_name): # pragma: no cover
- aggregate_id = get_aggregate_id(nova_client, aggregate_name)
- hosts = nova_client.aggregates.get(aggregate_id).hosts
- assert(
- all(remove_host_from_aggregate(nova_client, aggregate_name, host)
- for host in hosts))
-
-
-def delete_aggregate(nova_client, aggregate_name): # pragma: no cover
- try:
- remove_hosts_from_aggregate(nova_client, aggregate_name)
- nova_client.aggregates.delete(aggregate_name)
- except Exception: # pylint: disable=broad-except
- log.exception("Error [delete_aggregate(nova_client, %s)]",
- aggregate_name)
- return False
- else:
- return True
-
-
def get_server_by_name(name): # pragma: no cover
try:
return get_nova_client().servers.list(search_opts={'name': name})[0]
@@ -428,14 +315,6 @@ def create_flavor(name, ram, vcpus, disk, **kwargs): # pragma: no cover
return None
-def get_image_by_name(name): # pragma: no cover
- images = get_nova_client().images.list()
- try:
- return next((a for a in images if a.name == name))
- except StopIteration:
- log.exception('No image matched')
-
-
def get_flavor_id(nova_client, flavor_name): # pragma: no cover
flavors = nova_client.flavors.list(detailed=True)
flavor_id = ''
@@ -454,21 +333,6 @@ def get_flavor_by_name(name): # pragma: no cover
log.exception('No flavor matched')
-def check_status(status, name, iterations, interval): # pragma: no cover
- for _ in range(iterations):
- try:
- server = get_server_by_name(name)
- except IndexError:
- log.error('Cannot found %s server', name)
- raise
-
- if server.status == status:
- return True
-
- time.sleep(interval)
- return False
-
-
def delete_flavor(flavor_id): # pragma: no cover
try:
get_nova_client().flavors.delete(flavor_id)