diff options
author | Juha Kosonen <juha.kosonen@nokia.com> | 2016-01-28 12:32:36 +0000 |
---|---|---|
committer | Morgan Richomme <morgan.richomme@orange.com> | 2016-01-28 13:39:43 +0000 |
commit | 72ffd5d00b6f9ac2494659463bff84dc97c2712d (patch) | |
tree | d79639ee7a117b5f080e2d297fca2d94176209fe | |
parent | 755d64d0e25e5354b6fd50fdfc55c66068ba3cdf (diff) |
Refactor functest_utils.py
The order of volume type related functions and the error handling changed
to conform general approach used in functest_utils.py.
Signed-off-by: Juha Kosonen <juha.kosonen@nokia.com>
(cherry picked from commit 09f1b2201aaee2c3deee5936c819089bcc86692b)
Change-Id: I1461380ae0c579e5557bf4bfec4ec68f2766ee40
-rw-r--r-- | testcases/functest_utils.py | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/testcases/functest_utils.py b/testcases/functest_utils.py index b3549ee93..c548c899a 100644 --- a/testcases/functest_utils.py +++ b/testcases/functest_utils.py @@ -511,6 +511,28 @@ def get_volumes(cinder_client): return None +def list_volume_types(cinder_client, public=True, private=True): + try: + volume_types = cinder_client.volume_types.list() + if not public: + volume_types = [vt for vt in volume_types if not vt.is_public] + if not private: + volume_types = [vt for vt in volume_types if vt.is_public] + return volume_types + except Exception, e: + print "Error [list_volume_types(cinder_client)]:", e + return None + + +def create_volume_type(cinder_client, name): + try: + volume_type = cinder_client.volume_types.create(name) + return volume_type + except Exception, e: + print "Error [create_volume_type(cinder_client, '%s')]:" % name, e + return None + + def update_cinder_quota(cinder_client, tenant_id, vols_quota, snapshots_quota, gigabytes_quota): quotas_values = {"volumes": vols_quota, @@ -544,33 +566,12 @@ def delete_volume(cinder_client, volume_id, forced=False): return False -def list_volume_types(cinder_client, public=True, private=True): - try: - volume_types = cinder_client.volume_types.list() - if not public: - volume_types = [vt for vt in volume_types if not vt.is_public] - if not private: - volume_types = [vt for vt in volume_types if vt.is_public] - return volume_types - except: - return None - - -def create_volume_type(cinder_client, name): - try: - volume_type = cinder_client.volume_types.create(name) - return volume_type - except: - print "Error:", sys.exc_info()[0] - return None - - def delete_volume_type(cinder_client, volume_type): try: cinder_client.volume_types.delete(volume_type) return True - except: - print "Error:", sys.exc_info()[0] + except Exception, e: + print "Error [delete_volume_type(cinder_client, '%s')]:" % volume_type, e return False |