Enable multiple arbitrary config-flags
The config flags are a comma-seperated list of keys and values. This enables an operator to pass arbitrary configuration into the masakari-monitors configuration. Closes-Bug: #1941650 Change-Id: I3571bf7dfcb092ce5d04f439806e9a25465e16c5
This commit is contained in:
parent
06d34eb980
commit
01679e56a3
|
@ -3,3 +3,11 @@ options:
|
||||||
type: string
|
type: string
|
||||||
default: RegionOne
|
default: RegionOne
|
||||||
description: OpenStack Region
|
description: OpenStack Region
|
||||||
|
config-flags:
|
||||||
|
type: string
|
||||||
|
default:
|
||||||
|
description: |
|
||||||
|
Setting multiple arbitrary config variables and these
|
||||||
|
will be converted into dictionary and masakarimonitors.conf will be populated
|
||||||
|
accordingly. This will enable an operator to have the flexibility for having
|
||||||
|
multiple arbitrary config flags.
|
||||||
|
|
|
@ -59,3 +59,9 @@ class MasakariMonitorsCharm(charms_openstack.charm.OpenStackCharm):
|
||||||
|
|
||||||
def install(self):
|
def install(self):
|
||||||
super(MasakariMonitorsCharm, self).install()
|
super(MasakariMonitorsCharm, self).install()
|
||||||
|
|
||||||
|
# convert comma seprated list of config_flags into a dictionary
|
||||||
|
@charms_openstack.adapters.config_property
|
||||||
|
def user_config_flags(self):
|
||||||
|
return dict(map(lambda x: x.split('='),
|
||||||
|
self.config.get('config-flags').split(', ')))
|
||||||
|
|
|
@ -19,6 +19,9 @@ password = {{ identity_credentials.credentials_password }}
|
||||||
project_domain_id = {{ identity_credentials.credentials_project_domain_id }}
|
project_domain_id = {{ identity_credentials.credentials_project_domain_id }}
|
||||||
user_domain_id = {{ identity_credentials.credentials_user_domain_id }}
|
user_domain_id = {{ identity_credentials.credentials_user_domain_id }}
|
||||||
region = {{ options.region }}
|
region = {{ options.region }}
|
||||||
|
{% for key, value in options.config_flags.items() -%}
|
||||||
|
{{ key }} = {{ value }}
|
||||||
|
{% endfor -%}
|
||||||
[callback]
|
[callback]
|
||||||
[cors]
|
[cors]
|
||||||
[healthcheck]
|
[healthcheck]
|
||||||
|
|
|
@ -51,3 +51,11 @@ class TestMasakariMonitorsCharm(Helper):
|
||||||
c.request_credentials()
|
c.request_credentials()
|
||||||
keystone_relation.request_credentials.assert_called_once_with(
|
keystone_relation.request_credentials.assert_called_once_with(
|
||||||
'masakari-monitors', project='services')
|
'masakari-monitors', project='services')
|
||||||
|
|
||||||
|
def test_user_config_flags(self):
|
||||||
|
charm = self.\
|
||||||
|
_patch_config_and_charm({'config-flags': 'k1=v1, k2=v2'})
|
||||||
|
config = charm.user_config_flags()
|
||||||
|
# Add check here that configuration is as expected.
|
||||||
|
self.assertEqual(config.get('k1'), "v1")
|
||||||
|
self.assertEqual(config.get('k2'), "v2")
|
||||||
|
|
Loading…
Reference in New Issue