From f0eeba5c8c63cf78b2433df05cae90c0d9f28785 Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Fri, 20 Nov 2020 14:31:19 +0200 Subject: [PATCH] hyper-v rbd volume support Ceph 16 (Pacific) will support attaching RBD images to Windows hosts as well as Hyper-V VMs [1]. This patch updates the Hyper-V driver so that it may be able to consume RBD volumes. We're also updating the os-win requirement to 5.4.0. It should've been bumped by [2], vms won't spawn without it. Note this introduces no new or unmet direct or in-direct version dependencies and so is included as part of this change. [1] https://github.com/ceph/ceph/pull/33750 [2] Ibe6aff4edeb32208bc9865e9216a7432caddab2b Implements: blueprint hyperv-rbd Change-Id: I9ad90817648ca12f80a6b53f6ba728df15cbafab --- lower-constraints.txt | 2 +- nova/tests/unit/virt/hyperv/test_volumeops.py | 25 +++++++++++++++++++ nova/virt/hyperv/constants.py | 1 + nova/virt/hyperv/volumeops.py | 9 ++++++- .../rbd-hyperv-support-672a34b1d87e68eb.yaml | 4 +++ requirements.txt | 2 +- 6 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/rbd-hyperv-support-672a34b1d87e68eb.yaml diff --git a/lower-constraints.txt b/lower-constraints.txt index b1d7d73b2d0e..5743295b53d5 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -64,7 +64,7 @@ os-resource-classes==0.4.0 os-service-types==1.7.0 os-traits==2.5.0 os-vif==1.14.0 -os-win==5.1.0 +os-win==5.4.0 os-xenapi==0.3.4 osc-lib==1.10.0 oslo.cache==1.26.0 diff --git a/nova/tests/unit/virt/hyperv/test_volumeops.py b/nova/tests/unit/virt/hyperv/test_volumeops.py index 630ee2d600b4..da7262085d85 100644 --- a/nova/tests/unit/virt/hyperv/test_volumeops.py +++ b/nova/tests/unit/virt/hyperv/test_volumeops.py @@ -599,3 +599,28 @@ class SMBFSVolumeDriverTestCase(test_base.HyperVBaseTestCase): mock_set_qos_specs.assert_called_once_with( mock.sentinel.disk_path, fake_total_iops_sec) + + +class RBDVolumeDriver(test_base.HyperVBaseTestCase): + def test_get_vol_driver(self): + self._volumeops = volumeops.VolumeOps() + self._volumeops._volutils = mock.MagicMock() + self._volumeops._vmutils = mock.Mock() + + connection_info = get_fake_connection_info() + connection_info['driver_volume_type'] = 'rbd' + + drv = self._volumeops._get_volume_driver(connection_info) + + # Not much to test here. The Hyper-V driver volume attach code + # is mostly generic and all the RBD related plumbing is handled + # by os-brick. + # + # We'll just ensure that the RBD driver can be retrieved and that it + # has the right fields. + self.assertTrue(drv._is_block_dev) + self.assertEqual('rbd', drv._protocol) + # Hyper-V requires a virtual SCSI disk so we'll ask for a + # local attach. + self.assertEqual(dict(do_local_attach=True), + drv._extra_connector_args) diff --git a/nova/virt/hyperv/constants.py b/nova/virt/hyperv/constants.py index 7873e1fc8ada..851dd7076dee 100644 --- a/nova/virt/hyperv/constants.py +++ b/nova/virt/hyperv/constants.py @@ -90,3 +90,4 @@ IOPS_BASE_SIZE = 8 * units.Ki STORAGE_PROTOCOL_ISCSI = 'iscsi' STORAGE_PROTOCOL_FC = 'fibre_channel' STORAGE_PROTOCOL_SMBFS = 'smbfs' +STORAGE_PROTOCOL_RBD = 'rbd' diff --git a/nova/virt/hyperv/volumeops.py b/nova/virt/hyperv/volumeops.py index d81d34ae9fd8..da5b40f37511 100644 --- a/nova/virt/hyperv/volumeops.py +++ b/nova/virt/hyperv/volumeops.py @@ -46,7 +46,8 @@ class VolumeOps(object): self.volume_drivers = { constants.STORAGE_PROTOCOL_SMBFS: SMBFSVolumeDriver(), constants.STORAGE_PROTOCOL_ISCSI: ISCSIVolumeDriver(), - constants.STORAGE_PROTOCOL_FC: FCVolumeDriver()} + constants.STORAGE_PROTOCOL_FC: FCVolumeDriver(), + constants.STORAGE_PROTOCOL_RBD: RBDVolumeDriver()} def _get_volume_driver(self, connection_info): driver_type = connection_info.get('driver_volume_type') @@ -369,3 +370,9 @@ class SMBFSVolumeDriver(BaseVolumeDriver): class FCVolumeDriver(BaseVolumeDriver): _is_block_dev = True _protocol = constants.STORAGE_PROTOCOL_FC + + +class RBDVolumeDriver(BaseVolumeDriver): + _is_block_dev = True + _protocol = constants.STORAGE_PROTOCOL_RBD + _extra_connector_args = dict(do_local_attach=True) diff --git a/releasenotes/notes/rbd-hyperv-support-672a34b1d87e68eb.yaml b/releasenotes/notes/rbd-hyperv-support-672a34b1d87e68eb.yaml new file mode 100644 index 000000000000..7917500f3e2e --- /dev/null +++ b/releasenotes/notes/rbd-hyperv-support-672a34b1d87e68eb.yaml @@ -0,0 +1,4 @@ +features: + - | + The Hyper-V driver can now attach Cinder RBD volumes. The minimum + requirements are Ceph 16 (Pacific) and Windows Server 2016. diff --git a/requirements.txt b/requirements.txt index 655075042c6e..4d943060f8f7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -55,7 +55,7 @@ os-brick>=4.2.0 # Apache-2.0 os-resource-classes>=0.4.0 # Apache-2.0 os-traits>=2.5.0 # Apache-2.0 os-vif>=1.14.0 # Apache-2.0 -os-win>=5.1.0 # Apache-2.0 +os-win>=5.4.0 # Apache-2.0 castellan>=0.16.0 # Apache-2.0 microversion-parse>=0.2.1 # Apache-2.0 os-xenapi>=0.3.4 # Apache-2.0