Make sure get_backup_device result is an o.vo
In c-bak we're assuming we'll get a Snapshot or Volume o.vo from c-vol's get_backup_device. This isn't true when we're running Mitaka's c-vol in our environement. As we should be compatible with services in Mitaka this commit adds a check to volume.rpcapi to make sure that if we'll receive a dictionary, we're converting it to o.vo. Change-Id: Ifab88181d78481e79bc913f90b3dd1be2cbf7400 Closes-Bug: 1621836
This commit is contained in:
parent
ed20152b78
commit
4f7074c156
|
@ -137,7 +137,7 @@ class VolumeRpcAPITestCase(test.TestCase):
|
|||
else:
|
||||
rpcapi_class = volume_rpcapi.VolumeAPI
|
||||
rpcapi = rpcapi_class()
|
||||
expected_retval = 'foo' if method == 'call' else None
|
||||
expected_retval = {} if rpc_method == 'call' else None
|
||||
|
||||
target = {
|
||||
"version": kwargs.pop('version', rpcapi.RPC_API_VERSION)
|
||||
|
@ -210,7 +210,7 @@ class VolumeRpcAPITestCase(test.TestCase):
|
|||
def _fake_rpc_method(*args, **kwargs):
|
||||
self.fake_args = args
|
||||
self.fake_kwargs = kwargs
|
||||
if expected_retval:
|
||||
if expected_retval is not None:
|
||||
return expected_retval
|
||||
|
||||
self.mock_object(rpcapi.client, "prepare", _fake_prepare_method)
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
from oslo_serialization import jsonutils
|
||||
|
||||
from cinder.common import constants
|
||||
from cinder import objects
|
||||
from cinder import quota
|
||||
from cinder import rpc
|
||||
from cinder.volume import utils
|
||||
|
@ -320,7 +321,19 @@ class VolumeAPI(rpc.RPCAPI):
|
|||
|
||||
def get_backup_device(self, ctxt, backup, volume):
|
||||
cctxt = self._get_cctxt(volume.host, '2.0')
|
||||
return cctxt.call(ctxt, 'get_backup_device', backup=backup)
|
||||
backup_dict = cctxt.call(ctxt, 'get_backup_device', backup=backup)
|
||||
|
||||
# FIXME(dulek): Snippet below converts received raw dicts to o.vo. This
|
||||
# is only for a case when Mitaka's c-vol will answer us with volume
|
||||
# dict instead of an o.vo and should go away in early Ocata.
|
||||
if isinstance(backup_dict.get('backup_device'), dict):
|
||||
is_snapshot = backup_dict.get('is_snapshot')
|
||||
obj_class = objects.Snapshot if is_snapshot else objects.Volume
|
||||
obj = obj_class()
|
||||
obj_class._from_db_object(ctxt, obj, backup_dict['backup_device'])
|
||||
backup_dict['backup_device'] = obj
|
||||
|
||||
return backup_dict
|
||||
|
||||
def secure_file_operations_enabled(self, ctxt, volume):
|
||||
cctxt = self._get_cctxt(volume.host, '2.0')
|
||||
|
|
Loading…
Reference in New Issue