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
This commit is contained in:
parent
f1ea28349b
commit
3350a5713d
@ -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):
|
||||
|
@ -61,7 +61,8 @@ class SnapshotManager(base.ManagerWithFind):
|
||||
'deprecated and will be removed after Nova 13.0.0 is '
|
||||
'released. Use python-cinderclient or '
|
||||
'python-openstacksdk instead.', DeprecationWarning)
|
||||
with self.alternate_service_type('volume'):
|
||||
with self.alternate_service_type(
|
||||
'volumev2', allowed_types=('volume', 'volumev2')):
|
||||
body = {'snapshot': {'volume_id': volume_id,
|
||||
'force': force,
|
||||
'display_name': display_name,
|
||||
@ -79,7 +80,9 @@ class SnapshotManager(base.ManagerWithFind):
|
||||
'deprecated and will be removed after Nova 13.0.0 is '
|
||||
'released. Use python-cinderclient or '
|
||||
'python-openstacksdk instead.', DeprecationWarning)
|
||||
with self.alternate_service_type('volume'):
|
||||
with self.alternate_service_type(
|
||||
'volumev2', allowed_types=('volume', 'volumev2')):
|
||||
|
||||
return self._get("/snapshots/%s" % snapshot_id, "snapshot")
|
||||
|
||||
def list(self, detailed=True):
|
||||
@ -92,7 +95,8 @@ class SnapshotManager(base.ManagerWithFind):
|
||||
'deprecated and will be removed after Nova 13.0.0 is '
|
||||
'released. Use python-cinderclient or '
|
||||
'python-openstacksdk instead.', DeprecationWarning)
|
||||
with self.alternate_service_type('volume'):
|
||||
with self.alternate_service_type(
|
||||
'volumev2', allowed_types=('volume', 'volumev2')):
|
||||
if detailed is True:
|
||||
return self._list("/snapshots/detail", "snapshots")
|
||||
else:
|
||||
@ -108,5 +112,6 @@ class SnapshotManager(base.ManagerWithFind):
|
||||
'deprecated and will be removed after Nova 13.0.0 is '
|
||||
'released. Use python-cinderclient or '
|
||||
'python-openstacksdk instead.', DeprecationWarning)
|
||||
with self.alternate_service_type('volume'):
|
||||
with self.alternate_service_type(
|
||||
'volumev2', allowed_types=('volume', 'volumev2')):
|
||||
self._delete("/snapshots/%s" % base.getid(snapshot))
|
||||
|
@ -47,7 +47,8 @@ class VolumeTypeManager(base.ManagerWithFind):
|
||||
'and will be removed after Nova 13.0.0 is released. Use '
|
||||
'python-cinderclient or python-openstacksdk instead.',
|
||||
DeprecationWarning)
|
||||
with self.alternate_service_type('volume'):
|
||||
with self.alternate_service_type(
|
||||
'volumev2', allowed_types=('volume', 'volumev2')):
|
||||
return self._list("/types", "volume_types")
|
||||
|
||||
def get(self, volume_type):
|
||||
@ -61,7 +62,8 @@ class VolumeTypeManager(base.ManagerWithFind):
|
||||
'and will be removed after Nova 13.0.0 is released. Use '
|
||||
'python-cinderclient or python-openstacksdk instead.',
|
||||
DeprecationWarning)
|
||||
with self.alternate_service_type('volume'):
|
||||
with self.alternate_service_type(
|
||||
'volumev2', allowed_types=('volume', 'volumev2')):
|
||||
return self._get("/types/%s" % base.getid(volume_type),
|
||||
"volume_type")
|
||||
|
||||
@ -75,7 +77,8 @@ class VolumeTypeManager(base.ManagerWithFind):
|
||||
'and will be removed after Nova 13.0.0 is released. Use '
|
||||
'python-cinderclient or python-openstacksdk instead.',
|
||||
DeprecationWarning)
|
||||
with self.alternate_service_type('volume'):
|
||||
with self.alternate_service_type(
|
||||
'volumev2', allowed_types=('volume', 'volumev2')):
|
||||
self._delete("/types/%s" % base.getid(volume_type))
|
||||
|
||||
def create(self, name):
|
||||
@ -89,7 +92,8 @@ class VolumeTypeManager(base.ManagerWithFind):
|
||||
'and will be removed after Nova 13.0.0 is released. Use '
|
||||
'python-cinderclient or python-openstacksdk instead.',
|
||||
DeprecationWarning)
|
||||
with self.alternate_service_type('volume'):
|
||||
with self.alternate_service_type(
|
||||
'volumev2', allowed_types=('volume', 'volumev2')):
|
||||
body = {
|
||||
"volume_type": {
|
||||
"name": name,
|
||||
|
@ -68,7 +68,8 @@ class VolumeManager(base.ManagerWithFind):
|
||||
'13.0.0 is released. Use python-cinderclient or '
|
||||
'python-openstacksdk instead.', DeprecationWarning)
|
||||
# NOTE(melwitt): Ensure we use the volume endpoint for this call
|
||||
with self.alternate_service_type('volume'):
|
||||
with self.alternate_service_type(
|
||||
'volumev2', allowed_types=('volume', 'volumev2')):
|
||||
body = {'volume': {'size': size,
|
||||
'snapshot_id': snapshot_id,
|
||||
'display_name': display_name,
|
||||
@ -89,7 +90,8 @@ class VolumeManager(base.ManagerWithFind):
|
||||
'method is deprecated and will be removed after Nova '
|
||||
'13.0.0 is released. Use python-cinderclient or '
|
||||
'python-openstacksdk instead.', DeprecationWarning)
|
||||
with self.alternate_service_type('volume'):
|
||||
with self.alternate_service_type(
|
||||
'volumev2', allowed_types=('volume', 'volumev2')):
|
||||
return self._get("/volumes/%s" % volume_id, "volume")
|
||||
|
||||
def list(self, detailed=True, search_opts=None):
|
||||
@ -102,7 +104,8 @@ class VolumeManager(base.ManagerWithFind):
|
||||
'method is deprecated and will be removed after Nova '
|
||||
'13.0.0 is released. Use python-cinderclient or '
|
||||
'python-openstacksdk instead.', DeprecationWarning)
|
||||
with self.alternate_service_type('volume'):
|
||||
with self.alternate_service_type(
|
||||
'volumev2', allowed_types=('volume', 'volumev2')):
|
||||
search_opts = search_opts or {}
|
||||
|
||||
if 'name' in search_opts.keys():
|
||||
@ -128,7 +131,8 @@ class VolumeManager(base.ManagerWithFind):
|
||||
'method is deprecated and will be removed after Nova '
|
||||
'13.0.0 is released. Use python-cinderclient or '
|
||||
'python-openstacksdk instead.', DeprecationWarning)
|
||||
with self.alternate_service_type('volume'):
|
||||
with self.alternate_service_type(
|
||||
'volumev2', allowed_types=('volume', 'volumev2')):
|
||||
self._delete("/volumes/%s" % base.getid(volume))
|
||||
|
||||
def create_server_volume(self, server_id, volume_id, device=None):
|
||||
|
Loading…
Reference in New Issue
Block a user