diff --git a/cinder/tests/unit/volume/drivers/hpe/test_hpe3par.py b/cinder/tests/unit/volume/drivers/hpe/test_hpe3par.py index 2bf2045ce66..6cb47a051a9 100644 --- a/cinder/tests/unit/volume/drivers/hpe/test_hpe3par.py +++ b/cinder/tests/unit/volume/drivers/hpe/test_hpe3par.py @@ -5451,6 +5451,26 @@ class TestHPE3PARDriverBase(HPE3PARBaseDriver): expected) self.assertTrue(common._replication_enabled) + def test_init_vendor_properties(self): + conf = self.setup_configuration() + mock_client = self.setup_driver(config=conf) + + with mock.patch.object( + hpecommon.HPE3PARCommon, + '_create_client') as mock_create_client: + mock_create_client.return_value = mock_client + with mock.patch.object(self.driver, + 'get_volume_stats') as stats: + stats.return_value = {} + # calling vendor properties from driver. + self.driver.init_capabilities() + # calling vendor properties from specific 3par driver. + properties, vendor_name = self.driver._init_vendor_properties() + for key in self.driver.capabilities['properties']: + new_key = key.replace('_', ':') + if 'HP:3PAR' in new_key: + self.assertIn(new_key, properties) + class TestHPE3PARFCDriver(HPE3PARBaseDriver): diff --git a/cinder/volume/drivers/hpe/hpe_3par_base.py b/cinder/volume/drivers/hpe/hpe_3par_base.py index 90fcfb76474..b79d100d346 100644 --- a/cinder/volume/drivers/hpe/hpe_3par_base.py +++ b/cinder/volume/drivers/hpe/hpe_3par_base.py @@ -54,10 +54,11 @@ class HPE3PARDriverBase(driver.ManageableVD, 1.0.0 - Initial base driver 1.0.1 - Adds consistency group capability in generic volume groups. + 1.0.2 - Adds capability. """ - VERSION = "1.0.1" + VERSION = "1.0.2" def __init__(self, *args, **kwargs): super(HPE3PARDriverBase, self).__init__(*args, **kwargs) @@ -381,3 +382,217 @@ class HPE3PARDriverBase(driver.ManageableVD, def initialize_connection(self, volume, connector): pass + + @utils.trace + def _init_vendor_properties(self): + """Create a dictionary of vendor unique properties. + + This method creates a dictionary of vendor unique properties + and returns both created dictionary and vendor name. + Returned vendor name is used to check for name of vendor + unique properties. + + - Vendor name shouldn't include colon(:) because of the separator + and it is automatically replaced by underscore(_). + ex. abc:d -> abc_d + - Vendor prefix is equal to vendor name. + ex. abcd + - Vendor unique properties must start with vendor prefix + ':'. + ex. abcd:maxIOPS + + Each backend driver needs to override this method to expose + its own properties using _set_property() like this: + + self._set_property( + properties, + "vendorPrefix:specific_property", + "Title of property", + _("Description of property"), + "type") + + : return dictionary of vendor unique properties + : return vendor name + + prefix: HPE:3PAR --> HPE_3PAR + """ + + properties = {} + valid_prov_values = ['thin', 'full', 'dedup'] + valid_persona_values = ['2 - Generic-ALUA', + '1 - Generic', + '3 - Generic-legacy', + '4 - HPEUX-legacy', + '5 - AIX-legacy', + '6 - EGENERA', + '7 - ONTAP-legacy', + '8 - VMware', + '9 - OpenVMS', + '10 - HPEUX', + '11 - WindowsServer'] + + self._set_property( + properties, + "HPE:3PAR:hpe3par:snap_cpg", + "Snap CPG Extra-specs.", + _("Specifies the Snap CPG for a volume type. It overrides the " + "hpe3par_cpg_snap setting. Defaults to the hpe3par_cpg_snap " + "setting in the cinder.conf file. If hpe3par_cpg_snap is not " + "set, it defaults to the hpe3par_cpg setting."), + "string") + + self._set_property( + properties, + "HPE:3PAR:hpe3par:persona", + "Host Persona Extra-specs.", + _("Specifies the host persona property for a volume type. It " + "overrides the hpe3par_cpg_snap setting. Defaults to the " + "hpe3par_cpg_snap setting in the cinder.conf file. " + "If hpe3par_cpg_snap is not set, " + "it defaults to the hpe3par_cpg setting."), + "string", + enum=valid_persona_values, + default="2 - Generic-ALUA") + + self._set_property( + properties, + "HPE:3PAR:hpe3par:vvs", + "Virtual Volume Set Extra-specs.", + _("The virtual volume set name that has been set up by the " + "administrator that would have predefined QoS rules " + "associated with it. If you specify extra_specs " + "hpe3par:vvs, the qos_specs minIOPS, maxIOPS, minBWS, " + "and maxBWS settings are ignored."), + "string") + + self._set_property( + properties, + "HPE:3PAR:hpe3par:flash_cache", + "Flash cache Extra-specs.", + _("Enables Flash cache setting for a volume type."), + "boolean", + default=False) + + self._set_property( + properties, + "HPE:3PAR:hpe3par:provisioning", + "Storage Provisioning Extra-specs.", + _("Specifies the provisioning for a volume type."), + "string", + enum=valid_prov_values, + default="thin") + + self._set_property( + properties, + "HPE:3PAR:hpe3par:compression", + "Storage Provisioning Extra-specs.", + _("Enables compression for a volume type. " + "Minimum requirement of 3par OS version is 3.3.1 " + "with SSD drives only. " + "Volume size must have > 16 GB to enable " + "compression on volume. " + "A full provisioned volume cannot be compressed."), + "boolean", + default=False) + + self._set_property( + properties, + "HPE:3PAR:replication_enabled", + "Volume Replication Extra-specs.", + _("The valid value is: True " + "If True, the volume is to be replicated, if supported, " + "by the backend driver. If the option is not specified or " + "false, then replication is not enabled. This option is " + "required to enable replication."), + "string", + enum=[" True"], + default=False) + + self._set_property( + properties, + "HPE:3PAR:replication:mode", + "Replication Mode Extra-specs.", + _("Sets the replication mode for 3par."), + "string", + enum=["sync", "periodic"], + default="periodic") + + self._set_property( + properties, + "HPE:3PAR:replication:sync_period", + "Sync Period for Volume Replication Extra-specs.", + _("Sets the time interval for synchronization. " + "Only needed if replication:mode is periodic."), + "integer", + default=900) + + self._set_property( + properties, + "HPE:3PAR:replication:retention_count", + "Retention Count for Replication Extra-specs.", + _("Sets the number of snapshots that will be " + "saved on the primary array."), + "integer", + default=5) + + self._set_property( + properties, + "HPE:3PAR:replication:remote_retention_count", + "Remote Retention Count for Replication Extra-specs.", + _("Sets the number of snapshots that will be " + "saved on the secondary array."), + "integer", + default=5) + + # ###### QoS Settings ###### # + + self._set_property( + properties, + "HPE:3PAR:minIOPS", + "Minimum IOPS QoS.", + _("Sets the QoS, I/O issue count minimum goal. " + "If not specified, there is no limit on I/O issue count."), + "integer") + + self._set_property( + properties, + "HPE:3PAR:maxIOPS", + "Maximum IOPS QoS.", + _("Sets the QoS, I/O issue count rate limit. " + "If not specified, there is no limit on I/O issue count."), + "integer") + + self._set_property( + properties, + "HPE:3PAR:minBWS", + "Minimum Bandwidth QoS.", + _("Sets the QoS, I/O issue bandwidth minimum goal. " + "If not specified, there is no limit on " + "I/O issue bandwidth rate."), + "integer") + + self._set_property( + properties, + "HPE:3PAR:maxBWS", + "Maximum Bandwidth QoS.", + _("Sets the QoS, I/O issue bandwidth rate limit. " + "If not specified, there is no limit on I/O issue " + "bandwidth rate."), + "integer") + + self._set_property( + properties, + "HPE:3PAR:latency", + "Latency QoS.", + _("Sets the latency goal in milliseconds."), + "integer") + + self._set_property( + properties, + "HPE:3PAR:priority", + "Priority QoS.", + _("Sets the priority of the QoS rule over other rules."), + "string", + enum=["low", "normal", "high"], + default="normal") + + return properties, 'HPE:3PAR' diff --git a/releasenotes/notes/3par-get-capability-de60c9bc7ae51c14.yaml b/releasenotes/notes/3par-get-capability-de60c9bc7ae51c14.yaml new file mode 100644 index 00000000000..077c9d12baa --- /dev/null +++ b/releasenotes/notes/3par-get-capability-de60c9bc7ae51c14.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Added get capability feature for HPE-3PAR. \ No newline at end of file