diff --git a/cinder/tests/unit/volume/drivers/emc/vnx/test_common.py b/cinder/tests/unit/volume/drivers/emc/vnx/test_common.py index 5d8e8f5614b..a3502a369cc 100644 --- a/cinder/tests/unit/volume/drivers/emc/vnx/test_common.py +++ b/cinder/tests/unit/volume/drivers/emc/vnx/test_common.py @@ -209,6 +209,22 @@ class TestReplicationDeviceList(test.TestCase): self.assertEqual('global', device.storage_vnx_authentication_type) self.assertEqual('/home/stack/', device.storage_vnx_security_file_dir) + def test_device_no_backend_id(self): + device = {'san_ip': '192.168.1.2'} + config = FakeConfiguration() + config.replication_device = [device] + self.assertRaises( + exception.InvalidInput, + common.ReplicationDeviceList, config) + + def test_device_no_secfile(self): + device = {'backend_id': 'test_id', + 'san_ip': '192.168.1.2'} + config = FakeConfiguration() + config.replication_device = [device] + rep_list = common.ReplicationDeviceList(config) + self.assertIsNone(rep_list[0].storage_vnx_security_file_dir) + def test_get_device_not_found(self): devices_list = common.ReplicationDeviceList(self.configuration) device = devices_list.get_device('array_id_not_existed') diff --git a/cinder/volume/drivers/emc/vnx/common.py b/cinder/volume/drivers/emc/vnx/common.py index 81eb78f03b4..63db19ab08f 100644 --- a/cinder/volume/drivers/emc/vnx/common.py +++ b/cinder/volume/drivers/emc/vnx/common.py @@ -359,27 +359,29 @@ class ReplicationDevice(object): @property def backend_id(self): - return self.replication_device['backend_id'] + return self.replication_device.get('backend_id') @property def san_ip(self): - return self.replication_device['san_ip'] + return self.replication_device.get('san_ip') @property def san_login(self): - return self.replication_device['san_login'] + return self.replication_device.get('san_login') @property def san_password(self): - return self.replication_device['san_password'] + return self.replication_device.get('san_password') @property def storage_vnx_authentication_type(self): - return self.replication_device['storage_vnx_authentication_type'] + return self.replication_device.get( + 'storage_vnx_authentication_type', + 'global') @property def storage_vnx_security_file_dir(self): - return self.replication_device['storage_vnx_security_file_dir'] + return self.replication_device.get('storage_vnx_security_file_dir') class ReplicationDeviceList(list): @@ -399,6 +401,10 @@ class ReplicationDeviceList(list): if self.configuration.replication_device: for replication_device in self.configuration.replication_device: rd = ReplicationDevice(replication_device) + if not rd.backend_id or not rd.san_ip: + msg = _('backend_id or san_ip cannot be empty for ' + 'replication_device.') + raise exception.InvalidInput(reason=msg) self._device_map[rd.backend_id] = rd self.list.append(rd) return self._device_map diff --git a/releasenotes/notes/vnx-repv2.1-config-update-cc2f60c20aec88dd.yaml b/releasenotes/notes/vnx-repv2.1-config-update-cc2f60c20aec88dd.yaml new file mode 100644 index 00000000000..15df89f1c5a --- /dev/null +++ b/releasenotes/notes/vnx-repv2.1-config-update-cc2f60c20aec88dd.yaml @@ -0,0 +1,8 @@ +--- +upgrade: + - In VNX Cinder driver, ``replication_device`` keys, ``backend_id`` and + ``san_ip`` are mandatory now. If you prefer security file authentication, + please append ``storage_vnx_security_file_dir`` in ``replication_device``, + otherwise, append ``san_login``, ``san_password``, + ``storage_vnx_authentication_type`` in ``replication_device``. +