VMware: Add volume name in vCenter to conn info

The VMware Nova driver uses the volume reference in vCenter
which is passed in the connection info to identify the volume
during attach and detach. If the vCenter inventory is restored
from a backup using backup solutions such as HP data protector,
the volume reference in vCenter may change, but the volume name
(in vCenter) remains the same. This patch adds the volume name
in vCenter to the connection info so that the VMware Nova driver
can use it to identify the volume during detach as a fallback
option.

Change-Id: I0bc2f73a8b50f2b2247531df200c07b4eeb02bf7
Partial-bug: #1593742
(cherry-picked from commit ddabae3ce8)
This commit is contained in:
Vipin Balachandran 2016-07-18 20:14:37 +05:30 committed by chinmay
parent 83294d4f75
commit 98d24ae8aa
2 changed files with 7 additions and 6 deletions

View File

@ -1608,7 +1608,7 @@ class VMwareVcVmdkDriverTestCase(test.TestCase):
host = mock.sentinel.host
vops.get_host.return_value = host
volume = {'name': 'vol-1', 'id': 1}
volume = self._create_volume_dict()
conn_info = self._driver.initialize_connection(volume, connector)
relocate_backing.assert_called_once_with(volume, backing, host)
@ -1635,7 +1635,7 @@ class VMwareVcVmdkDriverTestCase(test.TestCase):
backing = mock.Mock(value=mock.sentinel.backing_value)
create_backing.return_value = backing
volume = {'name': 'vol-1', 'id': 1}
volume = self._create_volume_dict()
conn_info = self._driver.initialize_connection(volume, connector)
create_backing.assert_called_once_with(volume, host)
@ -1643,8 +1643,8 @@ class VMwareVcVmdkDriverTestCase(test.TestCase):
self.assertEqual('vmdk', conn_info['driver_volume_type'])
self.assertEqual(backing.value, conn_info['data']['volume'])
self.assertEqual(volume['id'],
conn_info['data']['volume_id'])
self.assertEqual(volume['id'], conn_info['data']['volume_id'])
self.assertEqual(volume['name'], conn_info['data']['name'])
@mock.patch.object(VMDK_DRIVER, 'volumeops')
@mock.patch.object(VMDK_DRIVER, '_relocate_backing')

View File

@ -536,9 +536,10 @@ class VMwareVcVmdkDriver(driver.VolumeDriver):
# Create backing
backing = self._create_backing(volume)
# Set volume's moref value and name
# Set volume ID and backing moref value and name.
connection_info['data'] = {'volume': backing.value,
'volume_id': volume['id']}
'volume_id': volume['id'],
'name': volume['name']}
LOG.info(_LI("Returning connection_info: %(info)s for volume: "
"%(volume)s with connector: %(connector)s."),