@mock.patch(NIMBLE_CLIENT)
@mock.patch.object(obj_volume.VolumeList, 'get_all',
mock.Mock(return_value=[]))
+ @mock.patch.object(volume_types, 'get_volume_type_extra_specs',
+ mock.Mock(type_id=FAKE_TYPE_ID, return_value={
+ 'nimble:perfpol-name': 'default',
+ 'nimble:encryption': 'yes',
+ 'nimble:multi-initiator': 'false'}))
@NimbleDriverBaseTestCase.client_mock_decorator(create_configuration(
'nimble', 'nimble_pass', '10.18.108.55', 'default', '*', False))
@mock.patch(NIMBLE_RANDOM)
'provider_location': '172.18.108.21:3260 iqn.test 0',
'provider_auth': None},
self.driver.create_cloned_volume({'name': 'volume',
- 'size': 5},
+ 'size': 5,
+ 'volume_type_id': FAKE_TYPE_ID},
{'name': 'testvolume',
'size': 5}))
expected_calls = [mock.call.service.snapVol(
'reserve': 5368709120,
'online': True,
'warn-level': 4294967296,
+ 'encryptionAttr': {'cipher': 2},
+ 'multi-initiator': 'false',
'perfpol-name': 'default',
'agent-type': 5},
'name': 'testvolume',
def test_get_volume_stats(self):
self.mock_client_service.service.getGroupConfig.return_value = \
FAKE_POSITIVE_GROUP_CONFIG_RESPONSE
- expected_res = {'driver_version': '2.0.0',
+ expected_res = {'driver_version': '2.0.2',
'vendor_name': 'Nimble',
'volume_backend_name': 'NIMBLE',
'storage_protocol': 'iSCSI',
@mock.patch(NIMBLE_CLIENT)
@mock.patch.object(obj_volume.VolumeList, 'get_all',
mock.Mock(return_value=[]))
+ @mock.patch.object(volume_types, 'get_volume_type_extra_specs',
+ mock.Mock(type_id=FAKE_TYPE_ID, return_value={
+ 'nimble:perfpol-name': 'default',
+ 'nimble:encryption': 'yes',
+ 'nimble:multi-initiator': 'false'}))
@NimbleDriverBaseTestCase.client_mock_decorator(create_configuration(
'nimble', 'nimble_pass', '10.18.108.55', 'default', '*'))
def test_create_volume_from_snapshot(self):
'provider_auth': None},
self.driver.create_volume_from_snapshot(
{'name': 'clone-testvolume',
- 'size': 2},
+ 'size': 2,
+ 'volume_type_id': FAKE_TYPE_ID},
{'volume_name': 'testvolume',
'name': 'testvolume-snap1',
'volume_size': 1}))
'reserve': 0,
'warn-level': 858993459,
'perfpol-name': 'default',
+ 'encryptionAttr': {'cipher': 2},
+ 'multi-initiator': 'false',
'agent-type': 5},
'name': 'testvolume',
'sid': 'a9b9aba7'}),
from cinder.volume import volume_types
-DRIVER_VERSION = '2.0.0'
+DRIVER_VERSION = '2.0.2'
AES_256_XTS_CIPHER = 2
DEFAULT_CIPHER = 3
EXTRA_SPEC_ENCRYPTION = 'nimble:encryption'
2.0.0 - Added Extra Spec Capability
Correct capacity reporting
Added Manage/Unmanage volume support
+ 2.0.1 - Added multi-initiator support through extra-specs
+ 2.0.2 - Fixed supporting extra specs while cloning vols
"""
VERSION = DRIVER_VERSION
clone_name = volume['name']
snap_size = snapshot['volume_size']
reserve_size = snap_size * units.Gi if reserve else 0
+
+ specs = self._get_volumetype_extraspecs(volume)
+ extra_specs_map = self._get_extra_spec_values(specs)
+ perf_policy_name = extra_specs_map.get(EXTRA_SPEC_PERF_POLICY)
+ encrypt = extra_specs_map.get(EXTRA_SPEC_ENCRYPTION)
+ multi_initiator = extra_specs_map.get(EXTRA_SPEC_MULTI_INITIATOR)
+ # default value of cipher for encryption
+ cipher = DEFAULT_CIPHER
+ if encrypt.lower() == 'yes':
+ cipher = AES_256_XTS_CIPHER
+
LOG.info(_LI('Cloning volume from snapshot volume=%(vol)s '
- 'snapshot=%(snap)s clone=%(clone)s snap_size=%(size)s'
- 'reserve=%(reserve)s' 'agent-type=%(agent-type)s'),
+ 'snapshot=%(snap)s clone=%(clone)s snap_size=%(size)s '
+ 'reserve=%(reserve)s' 'agent-type=%(agent-type)s '
+ 'perfpol-name=%(perfpol-name)s '
+ 'encryption=%(encryption)s cipher=%(cipher)s '
+ 'multi-initiator=%(multi-initiator)s'),
{'vol': volume_name,
'snap': snap_name,
'clone': clone_name,
'size': snap_size,
'reserve': reserve,
- 'agent-type': AGENT_TYPE_OPENSTACK})
+ 'agent-type': AGENT_TYPE_OPENSTACK,
+ 'perfpol-name': perf_policy_name,
+ 'encryption': encrypt,
+ 'cipher': cipher,
+ 'multi-initiator': multi_initiator})
clone_size = snap_size * units.Gi
return self.client.service.cloneVol(
request={'sid': self.sid,
'name': volume_name,
'attr': {'name': clone_name,
- 'perfpol-name': 'default',
'reserve': reserve_size,
'warn-level': int(clone_size * WARN_LEVEL),
'quota': clone_size,
'snap-quota': DEFAULT_SNAP_QUOTA,
'online': True,
- 'agent-type': AGENT_TYPE_OPENSTACK},
+ 'agent-type': AGENT_TYPE_OPENSTACK,
+ 'perfpol-name': perf_policy_name,
+ 'encryptionAttr': {'cipher': cipher},
+ 'multi-initiator': multi_initiator},
'snap-name': snap_name})
@_connection_checker