From c5609c54c6c04d78405ac0649b249c49aa195f91 Mon Sep 17 00:00:00 2001 From: Zhang Hua Date: Wed, 20 Jul 2016 15:39:09 +0800 Subject: [PATCH] Support to inject config-flags for neutron-api charm This patch is just to enable adding custom options to neutron.conf by the following command: juju set neutron-api config-flags='key1=val1, ...' Change-Id: I46bc32c250295a511508ced4cbca8f9748229415 Closes-Bug: #1585508 --- config.yaml | 17 +++++++++++++++++ hooks/neutron_api_utils.py | 1 + templates/icehouse/neutron.conf | 6 ++++++ templates/juno/neutron.conf | 6 ++++++ templates/kilo/neutron.conf | 6 ++++++ templates/liberty/neutron.conf | 6 ++++++ templates/mitaka/neutron.conf | 6 ++++++ 7 files changed, 48 insertions(+) diff --git a/config.yaml b/config.yaml index e6cf7881..5aee8fe3 100755 --- a/config.yaml +++ b/config.yaml @@ -597,3 +597,20 @@ options: description: | Apply system hardening. Supports a space-delimited list of modules to run. Supported modules currently include os, ssh, apache and mysql. + config-flags: + type: string + default: + description: | + Comma-separated list of key=value config flags. These values will be + placed in the neutron.conf [DEFAULT] section. + . + WARNING: this is not the recommended way to configure the underlying + services that this charm installs and is used at the user's own risk. + This option is mainly provided as a stop-gap for users that either + want to test the effect of modifying some config or who have found + a critical bug in the way the charm has configured their services + and need it fixed immediately. We ask that whenever this is used, + that the user consider opening a bug on this charm at + http://bugs.launchpad.net/charms providing an explanation of why the + config was needed so that we may consider it for inclusion as a + natively supported config in the the charm. diff --git a/hooks/neutron_api_utils.py b/hooks/neutron_api_utils.py index ab8480e5..051e2a90 100755 --- a/hooks/neutron_api_utils.py +++ b/hooks/neutron_api_utils.py @@ -163,6 +163,7 @@ BASE_RESOURCE_MAP = OrderedDict([ neutron_api_context.IdentityServiceContext( service='neutron', service_user='neutron'), + context.OSConfigFlagContext(), neutron_api_context.NeutronCCContext(), context.SyslogContext(), context.ZeroMQContext(), diff --git a/templates/icehouse/neutron.conf b/templates/icehouse/neutron.conf index d7e89e2a..dcc09871 100644 --- a/templates/icehouse/neutron.conf +++ b/templates/icehouse/neutron.conf @@ -70,6 +70,12 @@ nova_admin_auth_url = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/v2.0 {% endfor -%} {% endif %} +{% if user_config_flags -%} +{% for key, value in user_config_flags.iteritems() -%} +{{ key }} = {{ value }} +{% endfor -%} +{% endif -%} + [quotas] {% if quota_driver -%} quota_driver = {{ quota_driver }} diff --git a/templates/juno/neutron.conf b/templates/juno/neutron.conf index 8e7dfb46..19dd106a 100644 --- a/templates/juno/neutron.conf +++ b/templates/juno/neutron.conf @@ -70,6 +70,12 @@ nova_admin_auth_url = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/v2.0 {% endfor -%} {% endif %} +{% if user_config_flags -%} +{% for key, value in user_config_flags.iteritems() -%} +{{ key }} = {{ value }} +{% endfor -%} +{% endif -%} + [quotas] {% if quota_driver -%} quota_driver = {{ quota_driver }} diff --git a/templates/kilo/neutron.conf b/templates/kilo/neutron.conf index 8741e5ae..89358d79 100644 --- a/templates/kilo/neutron.conf +++ b/templates/kilo/neutron.conf @@ -72,6 +72,12 @@ nova_admin_auth_url = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/v2.0 {% endfor -%} {% endif %} +{% if user_config_flags -%} +{% for key, value in user_config_flags.iteritems() -%} +{{ key }} = {{ value }} +{% endfor -%} +{% endif -%} + {% include "section-zeromq" %} [quotas] diff --git a/templates/liberty/neutron.conf b/templates/liberty/neutron.conf index c7c9a148..f01dc527 100644 --- a/templates/liberty/neutron.conf +++ b/templates/liberty/neutron.conf @@ -67,6 +67,12 @@ notify_nova_on_port_data_changes = True {% endfor -%} {% endif %} +{% if user_config_flags -%} +{% for key, value in user_config_flags.iteritems() -%} +{{ key }} = {{ value }} +{% endfor -%} +{% endif -%} + {% include "section-zeromq" %} [quotas] diff --git a/templates/mitaka/neutron.conf b/templates/mitaka/neutron.conf index a81ba6ad..209a6063 100644 --- a/templates/mitaka/neutron.conf +++ b/templates/mitaka/neutron.conf @@ -62,6 +62,12 @@ notify_nova_on_port_data_changes = True {% endfor -%} {% endif %} +{% if user_config_flags -%} +{% for key, value in user_config_flags.iteritems() -%} +{{ key }} = {{ value }} +{% endfor -%} +{% endif -%} + {% include "section-zeromq" %} [quotas]