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