From f6d25c93aca70a1a33deff164971932be3e9703d Mon Sep 17 00:00:00 2001 From: yuval Date: Thu, 16 Jan 2025 11:34:02 +0200 Subject: [PATCH] lightbits: add qos support Currently Admin user will create the qos policy in the lightbits side and add the policy UUID to the volume type. Creation of new volume using the volume type will be created with the qos policy. Change-Id: Id0332c5c6a70d63c87bf63cdf4c8bd71e672a148 --- .../drivers/lightos/test_lightos_storage.py | 15 ++++++------ cinder/volume/drivers/lightos.py | 24 +++++++++++++++---- ...ightbits-qos-support-1a44a9fcdfd1ee93.yaml | 16 +++++++++++++ 3 files changed, 43 insertions(+), 12 deletions(-) create mode 100644 releasenotes/notes/lightbits-qos-support-1a44a9fcdfd1ee93.yaml diff --git a/cinder/tests/unit/volume/drivers/lightos/test_lightos_storage.py b/cinder/tests/unit/volume/drivers/lightos/test_lightos_storage.py index 728ca73e0ec..eb1048fc3ac 100644 --- a/cinder/tests/unit/volume/drivers/lightos/test_lightos_storage.py +++ b/cinder/tests/unit/volume/drivers/lightos/test_lightos_storage.py @@ -339,6 +339,7 @@ class LightOSStorageVolumeDriverTest(test.TestCase): "acl": {'values': kwargs.get('acl')}, "IPAcl": ipacl, "state": "Available", + "qosPolicyUUID": kwargs.get("qos_policy", None) } volume["ETag"] = get_vol_etag(volume) code, new_vol = self.db.create_volume(volume) @@ -577,11 +578,11 @@ class LightOSStorageVolumeDriverTest(test.TestCase): volume_type_id=vol_type2.id) volume3 = test_utils.create_volume(self.ctxt, size=4, volume_type_id=vol_type3.id) - compression, _, _ = self.driver._get_volume_specs(volume1) + compression, _, _, _ = self.driver._get_volume_specs(volume1) self.assertTrue(compression == "True") - compression, _, _ = self.driver._get_volume_specs(volume2) + compression, _, _, _ = self.driver._get_volume_specs(volume2) self.assertTrue(compression == "True") - compression, _, _ = self.driver._get_volume_specs(volume3) + compression, _, _, _ = self.driver._get_volume_specs(volume3) self.assertTrue(compression == "False") db.volume_destroy(self.ctxt, volume1.id) @@ -610,11 +611,11 @@ class LightOSStorageVolumeDriverTest(test.TestCase): volume_type_id=vol_type2.id) volume3 = test_utils.create_volume(self.ctxt, size=4, volume_type_id=vol_type3.id) - compression, _, _ = self.driver._get_volume_specs(volume1) + compression, _, _, _ = self.driver._get_volume_specs(volume1) self.assertTrue(compression == "False") - compression, _, _ = self.driver._get_volume_specs(volume2) + compression, _, _, _ = self.driver._get_volume_specs(volume2) self.assertTrue(compression == "False") - compression, _, _ = self.driver._get_volume_specs(volume3) + compression, _, _, _ = self.driver._get_volume_specs(volume3) self.assertTrue(compression == "True") db.volume_destroy(self.ctxt, volume1.id) @@ -988,7 +989,7 @@ class LightOSStorageVolumeDriverTest(test.TestCase): assert volumes_data['reserved_percentage'] == RESERVED_PERCENTAGE, \ "Expected %d, received %s" % \ (RESERVED_PERCENTAGE, volumes_data['reserved_percentage']) - assert volumes_data['QoS_support'] is False, \ + assert volumes_data['QoS_support'] is True, \ "Expected False, received %s" % volumes_data['QoS_support'] assert volumes_data['online_extend_support'] is True, \ "Expected True, received %s" % \ diff --git a/cinder/volume/drivers/lightos.py b/cinder/volume/drivers/lightos.py index 23c5026bf9a..0a6f216268b 100644 --- a/cinder/volume/drivers/lightos.py +++ b/cinder/volume/drivers/lightos.py @@ -251,6 +251,9 @@ class LightOSConnection(object): kwargs.get("snapshot_name")), {}) } + if kwargs.get("qos_policy", None) is not None: + lightos_commands['create_volume'][2]['qosPolicyUUID'] = \ + str(kwargs.get("qos_policy")) if cmd not in lightos_commands: raise exception.UnknownCmd(cmd=cmd) else: @@ -609,10 +612,11 @@ class LightOSVolumeDriver(driver.VolumeDriver): compression = self._parse_extra_spec(type_compression, default_compression) num_replicas = str(specs.get('lightos:num_replicas', num_replicas)) + qos_policy = specs.get('lightos:qos_policy', None) project_name = specs.get( 'lightos:project_name', LIGHTOS_DEFAULT_PROJECT_NAME) - return (compression, num_replicas, project_name) + return (compression, num_replicas, project_name, qos_policy) def _create_new_lightos_volume(self, os_volume, @@ -620,7 +624,8 @@ class LightOSVolumeDriver(driver.VolumeDriver): lightos_name, src_snapshot_lightos_name=None): """Create a new LightOS volume for this openstack volume.""" - (compression, num_replicas, _) = self._get_volume_specs(os_volume) + (compression, num_replicas, _, qos_policy) = \ + self._get_volume_specs(os_volume) vol_ipAcl = ['ALLOW_NONE'] if self.use_ip_acl() else ['ALLOW_ANY'] return self.cluster.send_cmd( cmd='create_volume', @@ -632,8 +637,8 @@ class LightOSVolumeDriver(driver.VolumeDriver): compression=compression, src_snapshot_name=src_snapshot_lightos_name, acl=['ALLOW_NONE'], - ip_acl=vol_ipAcl - ) + ip_acl=vol_ipAcl, + qos_policy=qos_policy) def _get_lightos_uuid(self, project_name, volume): lightos_name = self._lightos_volname(volume) @@ -1025,7 +1030,7 @@ class LightOSVolumeDriver(driver.VolumeDriver): 'driver_version': self.VERSION, 'storage_protocol': constants.LIGHTOS, 'reserved_percentage': res_percentage, - 'QoS_support': False, + 'QoS_support': True, 'online_extend_support': True, 'thin_provisioning_support': True, 'compression': [True, False], @@ -1622,6 +1627,15 @@ class LightOSVolumeDriver(driver.VolumeDriver): minimum=1, maximun=3, default=3) + self._set_property( + properties, + "lightos:qos_policy", + "Lightbits volume QoS policy UUID", + _( + "Specifies the Lightbits volume QoS policy UUID to use for \ + the LightOS volume."), + "string", + default=None) return properties, 'lightos' diff --git a/releasenotes/notes/lightbits-qos-support-1a44a9fcdfd1ee93.yaml b/releasenotes/notes/lightbits-qos-support-1a44a9fcdfd1ee93.yaml new file mode 100644 index 00000000000..c425bb20b15 --- /dev/null +++ b/releasenotes/notes/lightbits-qos-support-1a44a9fcdfd1ee93.yaml @@ -0,0 +1,16 @@ +--- +features: + - | + Lightbits driver: allows administrators to better manage and optimize + storage performance by associating QoS policies with volume types. + + * Administrators must first create the required QoS policy on the vendor + side. + * Once the QoS policy is created, it can be linked to a volume type in + the system using the policy's unique UUID. + + Example: + + .. code-block:: bash + + openstack volume type create LightbitsWithQos --property volume_backend_name= --property=lightos:qos_policy=