Merge "fix create_consistencygroup in xiv"

This commit is contained in:
Jenkins 2017-02-11 03:16:56 +00:00 committed by Gerrit Code Review
commit b522111cfa
2 changed files with 9 additions and 5 deletions

View File

@ -21,6 +21,7 @@ from cinder import context
from cinder import exception from cinder import exception
from cinder.objects import consistencygroup from cinder.objects import consistencygroup
from cinder.objects import fields from cinder.objects import fields
from cinder.tests.unit import fake_constants as fake
from cinder.tests.unit.volume.drivers.ibm import fake_pyxcli from cinder.tests.unit.volume.drivers.ibm import fake_pyxcli
import cinder.volume.drivers.ibm.ibm_storage as storage import cinder.volume.drivers.ibm.ibm_storage as storage
from cinder.volume.drivers.ibm.ibm_storage import cryptish from cinder.volume.drivers.ibm.ibm_storage import cryptish
@ -43,6 +44,7 @@ TEST_VOLUME = {
'name': 'BLA', 'name': 'BLA',
'id': 23, 'id': 23,
'size': 17, 'size': 17,
'consistencygroup_id': fake.CONSISTENCY_GROUP_ID,
} }
TEST_CLONED_VOLUME = { TEST_CLONED_VOLUME = {
'name': 'CLONE', 'name': 'CLONE',
@ -135,7 +137,8 @@ class XIVProxyTest(unittest.TestCase):
"""Tests the main Proxy driver""" """Tests the main Proxy driver"""
test_cg = consistencygroup.ConsistencyGroup( test_cg = consistencygroup.ConsistencyGroup(
context=None, name='WTF32', id='WTF32', volume_type_id='WTF32', context=None, name='WTF32', id=fake.CONSISTENCY_GROUP_ID,
volume_type_id=fake.VOLUME_TYPE_ID,
status=fields.ConsistencyGroupStatus.AVAILABLE) status=fields.ConsistencyGroupStatus.AVAILABLE)
def setUp(self): def setUp(self):
@ -1122,7 +1125,7 @@ class XIVProxyTest(unittest.TestCase):
model_update = p.create_consistencygroup({}, self.test_cg) model_update = p.create_consistencygroup({}, self.test_cg)
p.ibm_storage_cli.cmd.cg_create.assert_called_once_with( p.ibm_storage_cli.cmd.cg_create.assert_called_once_with(
cg='cg_WTF32', cg=p._cg_name_from_id(fake.CONSISTENCY_GROUP_ID),
pool='WTF32') pool='WTF32')
self.assertEqual('available', model_update['status']) self.assertEqual('available', model_update['status'])
@ -1213,7 +1216,7 @@ class XIVProxyTest(unittest.TestCase):
TEST_CG_SNAPSHOT, [TEST_SNAPSHOT], None, None) TEST_CG_SNAPSHOT, [TEST_SNAPSHOT], None, None)
p.ibm_storage_cli.cmd.cg_create.assert_called_once_with( p.ibm_storage_cli.cmd.cg_create.assert_called_once_with(
cg='cg_WTF32', cg=p._cg_name_from_volume(TEST_VOLUME),
pool='WTF32') pool='WTF32')
self.assertEqual('available', model_update['status']) self.assertEqual('available', model_update['status'])
@ -1240,7 +1243,7 @@ class XIVProxyTest(unittest.TestCase):
None, None, TEST_CONS_GROUP, [TEST_CLONED_VOLUME]) None, None, TEST_CONS_GROUP, [TEST_CLONED_VOLUME])
p.ibm_storage_cli.cmd.cg_create.assert_called_once_with( p.ibm_storage_cli.cmd.cg_create.assert_called_once_with(
cg='cg_WTF32', cg=p._cg_name_from_volume(TEST_VOLUME),
pool='WTF32') pool='WTF32')
self.assertEqual('available', model_update['status']) self.assertEqual('available', model_update['status'])

View File

@ -1645,12 +1645,13 @@ class XIVProxy(proxy.IBMStorageProxy):
if isinstance(group, objects.Group): if isinstance(group, objects.Group):
volume_type_ids = group.volume_type_ids volume_type_ids = group.volume_type_ids
elif isinstance(group, objects.ConsistencyGroup): elif isinstance(group, objects.ConsistencyGroup):
volume_type_ids = [group.volume_type_id] volume_type_ids = [filter(None, group.volume_type_id.split(","))]
else: else:
msg = (_("Consistency group %(group)s has no volume_type_ids") % msg = (_("Consistency group %(group)s has no volume_type_ids") %
{'group': cgname}) {'group': cgname})
LOG.error(msg) LOG.error(msg)
raise self.meta['exception'].VolumeBackendAPIException(data=msg) raise self.meta['exception'].VolumeBackendAPIException(data=msg)
LOG.debug("volume_type_ids: %s", volume_type_ids)
for volume_type_id in volume_type_ids: for volume_type_id in volume_type_ids:
specs = self._get_extra_specs(volume_type_id) specs = self._get_extra_specs(volume_type_id)
replication_info = self._get_replication_info(specs) replication_info = self._get_replication_info(specs)