Browse Source

Merge "VMware: Check empty provider location"

changes/65/624865/1
Zuul 3 years ago
committed by Gerrit Code Review
parent
commit
38e91b1030
  1. 7
      cinder/tests/unit/volume/drivers/vmware/test_fcd.py
  2. 6
      cinder/volume/drivers/vmware/fcd.py

7
cinder/tests/unit/volume/drivers/vmware/test_fcd.py

@ -208,9 +208,16 @@ class VMwareVStorageObjectDriverTestCase(test.TestCase):
@mock.patch.object(FCD_DRIVER, '_delete_fcd')
def test_delete_volume(self, delete_fcd):
volume = self._create_volume_obj()
volume.provider_location = 'foo@ds1'
self._driver.delete_volume(volume)
delete_fcd.assert_called_once_with(volume.provider_location)
@mock.patch.object(FCD_DRIVER, '_delete_fcd')
def test_delete_volume_empty_provider_location(self, delete_fcd):
volume = self._create_volume_obj()
self._driver.delete_volume(volume)
delete_fcd.assert_not_called()
@mock.patch.object(volumeops.FcdLocation, 'from_provider_location')
@mock.patch.object(FCD_DRIVER, '_get_adapter_type')
def test_initialize_connection(

6
cinder/volume/drivers/vmware/fcd.py

@ -123,7 +123,11 @@ class VMwareVStorageObjectDriver(vmdk.VMwareVcVmdkDriver):
:param volume: The volume to delete.
"""
self._delete_fcd(volume.provider_location)
if not volume.provider_location:
LOG.warning("FCD provider location is empty for volume %s",
volume.id)
else:
self._delete_fcd(volume.provider_location)
def initialize_connection(self, volume, connector, initiator_data=None):
"""Allow connection to connector and return connection info.

Loading…
Cancel
Save