Refresh extended in-use volumes
This change enables the 'supports_extend_volume' driver capability, updating cached information about already extended in-use volumes. Note that this will only work with passthrough disks (iSCSI/FC) for the moment. Also, this only refreshes host side disk information, a rescan is required on the guest side as well. Change-Id: Ic4ba9e0c2ed5bcd443fa8eaffac06752a97b0103 Implements: blueprint hyperv-extend-volume
This commit is contained in:
parent
7b0d1c3bfb
commit
f615b509a2
@ -103,6 +103,7 @@ class HyperVDriver(driver.ComputeDriver):
|
||||
"supports_device_tagging": True,
|
||||
"supports_tagged_attach_interface": True,
|
||||
"supports_tagged_attach_volume": True,
|
||||
"supports_extend_volume": True,
|
||||
}
|
||||
|
||||
def __init__(self, virtapi):
|
||||
@ -198,6 +199,9 @@ class HyperVDriver(driver.ComputeDriver):
|
||||
instance,
|
||||
update_device_metadata=True)
|
||||
|
||||
def extend_volume(self, connection_info, instance):
|
||||
self._volumeops.extend_volume(connection_info)
|
||||
|
||||
def get_volume_connector(self, instance):
|
||||
return self._volumeops.get_volume_connector()
|
||||
|
||||
|
@ -364,6 +364,10 @@ class VolumeOps(object):
|
||||
volume_driver = self._get_volume_driver(connection_info)
|
||||
return volume_driver.get_disk_attachment_info(connection_info)
|
||||
|
||||
def extend_volume(self, connection_info):
|
||||
volume_driver = self._get_volume_driver(connection_info)
|
||||
return volume_driver.extend_volume(connection_info)
|
||||
|
||||
|
||||
class BaseVolumeDriver(object):
|
||||
_is_block_dev = True
|
||||
@ -514,6 +518,11 @@ class BaseVolumeDriver(object):
|
||||
is_physical=self._is_block_dev,
|
||||
serial=serial)
|
||||
|
||||
def extend_volume(self, connection_info):
|
||||
# We're not actually extending the volume, we're just
|
||||
# refreshing cached information about an already extended volume.
|
||||
self._connector.extend_volume(connection_info['data'])
|
||||
|
||||
|
||||
class ISCSIVolumeDriver(BaseVolumeDriver):
|
||||
_is_block_dev = True
|
||||
|
@ -226,6 +226,14 @@ class HyperVDriverTestCase(test_base.HyperVBaseTestCase):
|
||||
mock_instance,
|
||||
update_device_metadata=True)
|
||||
|
||||
def test_extend_volume(self):
|
||||
mock_instance = fake_instance.fake_instance_obj(self.context)
|
||||
self.driver.extend_volume(
|
||||
mock.sentinel.connection_info, mock_instance)
|
||||
|
||||
self.driver._volumeops.extend_volume.assert_called_once_with(
|
||||
mock.sentinel.connection_info)
|
||||
|
||||
def test_get_volume_connector(self):
|
||||
self.driver.get_volume_connector(mock.sentinel.instance)
|
||||
self.driver._volumeops.get_volume_connector.assert_called_once_with()
|
||||
|
@ -502,6 +502,15 @@ class VolumeOpsTestCase(test_base.HyperVBaseTestCase):
|
||||
mock_vol_driver.get_disk_attachment_info.return_value,
|
||||
ret_val)
|
||||
|
||||
@mock.patch.object(volumeops.VolumeOps, '_get_volume_driver')
|
||||
def test_extend_volume(self, mock_get_volume_driver):
|
||||
fake_conn_info = get_fake_connection_info()
|
||||
self._volumeops.extend_volume(fake_conn_info)
|
||||
|
||||
mock_vol_driver = mock_get_volume_driver.return_value
|
||||
mock_vol_driver.extend_volume.assert_called_once_with(
|
||||
fake_conn_info)
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class BaseVolumeDriverTestCase(test_base.HyperVBaseTestCase):
|
||||
@ -767,6 +776,14 @@ class BaseVolumeDriverTestCase(test_base.HyperVBaseTestCase):
|
||||
is_physical=is_block_dev,
|
||||
serial=exp_serial)
|
||||
|
||||
def test_extend_volume(self):
|
||||
conn_info = get_fake_connection_info()
|
||||
|
||||
self._base_vol_driver.extend_volume(conn_info)
|
||||
|
||||
self._conn.extend_volume.assert_called_once_with(
|
||||
conn_info['data'])
|
||||
|
||||
|
||||
class ISCSIVolumeDriverTestCase(test_base.HyperVBaseTestCase):
|
||||
"""Unit tests for Hyper-V BaseVolumeDriver class."""
|
||||
|
Loading…
Reference in New Issue
Block a user