Only send netapp_pool_name_search_pattern when set

netapp_pool_name_search_pattern is optional and if it is unset
then the option should not be rendered. So do not send this
option to the principle if it is unset.

Change-Id: I92a5da7cab4c212cae0f48008e852d82a7b4ce89
This commit is contained in:
Liam Young 2022-03-29 14:40:34 +00:00
parent cc44a9c785
commit 1705f540ae
2 changed files with 14 additions and 3 deletions

View File

@ -51,10 +51,11 @@ class CinderNetAppCharm(
('netapp_password', cget('netapp-password')),
('volume_driver', volumedriver),
('volume_backend_name', service),
('netapp_pool_name_search_pattern', cget(
'netapp-pool-name-search-pattern'))
]
pool_name_search_pattern = cget('netapp-pool-name-search-pattern')
if pool_name_search_pattern:
driver_options_common += [
('netapp_pool_name_search_pattern', pool_name_search_pattern)]
if cget('netapp-server-port') == 443:
driver_transport = [
('netapp_transport_type', "https")]

View File

@ -79,6 +79,16 @@ class TestCinderNetAppCharm(test_utils.PatchHelper):
self.assertIn(('nfs_shares_config',
econfig['netapp-nfs-shares-config']), config)
def test_cinder_unset_var(self):
econfig = {'netapp-storage-family': 'eseries',
'netapp-controller-ips': '10.0.0.1',
'netapp-array-password': 'abc123',
'use-multipath': True}
charm = self._patch_config_and_charm(econfig)
config = charm.cinder_configuration()
keys = [c[0] for c in config]
self.assertNotIn('netapp_pool_name_search_pattern', keys)
def test_cinder_iscsi_options(self):
econfig = {'netapp-pool-name-search-pattern': 'foo.*bar',
'netapp-lun-space-reservation': True,