summaryrefslogtreecommitdiff
path: root/novaclient/base.py
diff options
context:
space:
mode:
authorAndrey Kurilin <andr.kurilin@gmail.com>2015-09-30 12:59:24 +0300
committerAndrey Kurilin <akurilin@mirantis.com>2015-09-30 14:20:04 +0300
commit3350a5713da9b75100d94a87908f6cb4184eb240 (patch)
tree10d6279ee89652cee22704d4216b535b1e5b9831 /novaclient/base.py
parentf1ea28349bb8e3a79457137e4d06bb599b30b6c6 (diff)
downloadpython-novaclient-3350a5713da9b75100d94a87908f6cb4184eb240.tar.gz
Change default service_type for volumes managers
Currently, novaclient's gates are broken due to missed 'volume' service_type. This patch changes default service type for all volume related managers to "volumev2" and leave ability to set "volume" service_type. Change-Id: Ia1e1d3def1e6127cc2b97797c577c15265f879bd Closes-Bug: #1501258
Diffstat (limited to 'novaclient/base.py')
-rw-r--r--novaclient/base.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/novaclient/base.py b/novaclient/base.py
index a07bd249..96aaec1d 100644
--- a/novaclient/base.py
+++ b/novaclient/base.py
@@ -89,13 +89,16 @@ class Manager(base.HookableMixin):
for res in data if res]
@contextlib.contextmanager
- def alternate_service_type(self, service_type):
+ def alternate_service_type(self, default, allowed_types=()):
original_service_type = self.api.client.service_type
- self.api.client.service_type = service_type
- try:
+ if original_service_type in allowed_types:
yield
- finally:
- self.api.client.service_type = original_service_type
+ else:
+ self.api.client.service_type = default
+ try:
+ yield
+ finally:
+ self.api.client.service_type = original_service_type
@contextlib.contextmanager
def completion_cache(self, cache_type, obj_class, mode):