diff --git a/config.yaml b/config.yaml index 6855a42..fd18618 100644 --- a/config.yaml +++ b/config.yaml @@ -49,3 +49,7 @@ options: default: None description: | Proxy address to install python modules behind a proxy + user-domain-name: + type: string + default: Default + description: Keystone user domain name diff --git a/hooks/neutron_plumgrid_context.py b/hooks/neutron_plumgrid_context.py index 470abec..0d2bb56 100644 --- a/hooks/neutron_plumgrid_context.py +++ b/hooks/neutron_plumgrid_context.py @@ -118,6 +118,7 @@ class NeutronPGPluginContext(context.NeutronContext): pg_ctxt['pg_metadata_port'] = '8775' pg_ctxt['metadata_mode'] = 'tunnel' pg_ctxt['connector_type'] = config('connector-type') + pg_ctxt['user_domain_name'] = config('user-domain-name') if enable_metadata: plumgrid_edge_ctxt = _edge_context() pg_ctxt['nova_metadata_proxy_secret'] = \ diff --git a/hooks/neutron_plumgrid_hooks.py b/hooks/neutron_plumgrid_hooks.py index 51658d3..21c0d85 100755 --- a/hooks/neutron_plumgrid_hooks.py +++ b/hooks/neutron_plumgrid_hooks.py @@ -32,6 +32,7 @@ from neutron_plumgrid_utils import ( restart_map, ensure_files, set_neutron_relation, + configure_pg_sources ) hooks = Hooks() @@ -65,6 +66,8 @@ def config_changed(): charm_config.changed('plumgrid-build') or charm_config.changed('install_keys')): status_set('maintenance', 'Upgrading apt packages') + if charm_config.changed('install_sources'): + configure_pg_sources() configure_sources() apt_update() pkgs = determine_packages() diff --git a/hooks/neutron_plumgrid_utils.py b/hooks/neutron_plumgrid_utils.py index bac2bf9..ffc0e32 100644 --- a/hooks/neutron_plumgrid_utils.py +++ b/hooks/neutron_plumgrid_utils.py @@ -31,7 +31,7 @@ PG_PACKAGES = [ ] NEUTRON_CONF_DIR = "/etc/neutron" - +SOURCES_LIST = '/etc/apt/sources.list' SU_FILE = '/etc/sudoers.d/neutron_sudoers' PLUMGRID_CONF = '%s/plugins/plumgrid/plumgrid.ini' % NEUTRON_CONF_DIR PGLIB_CONF = '%s/plugins/plumgrid/plumlib.ini' % NEUTRON_CONF_DIR @@ -63,6 +63,22 @@ NETWORKING_PLUMGRID_VERSION = OrderedDict([ ]) +def configure_pg_sources(): + ''' + Returns true if install sources is updated in sources.list file + ''' + try: + with open(SOURCES_LIST, 'r+') as sources: + all_lines = sources.readlines() + sources.seek(0) + for i in (line for line in all_lines if "plumgrid" not in line): + sources.write(i) + sources.truncate() + sources.close() + except IOError: + log('Unable to update /etc/apt/sources.list') + + def determine_packages(): ''' Returns list of packages required to be installed alongside neutron to diff --git a/templates/kilo/plumlib.ini b/templates/kilo/plumlib.ini index df85c02..50dc3d7 100644 --- a/templates/kilo/plumlib.ini +++ b/templates/kilo/plumlib.ini @@ -59,4 +59,5 @@ admin_password = {{ admin_password }} admin_tenant_name = {{ admin_tenant_name }} auth_uri = {{ service_protocol }}://{{ auth_host }}:{{ auth_port }}/v2.0/ identity_version = v2.0 +user_domain_name = {{ user_domain_name }} {% endif -%} diff --git a/unit_tests/test_neutron_plumgrid_plugin_context.py b/unit_tests/test_neutron_plumgrid_plugin_context.py index 91fa034..5769933 100644 --- a/unit_tests/test_neutron_plumgrid_plugin_context.py +++ b/unit_tests/test_neutron_plumgrid_plugin_context.py @@ -60,6 +60,7 @@ class NeutronPGContextTest(CharmTestCase): 'switch-username': 'plumgrid', 'switch-password': 'plumgrid', 'connector-type': 'service', + 'user-domain-name': 'Default', } def mock_config(key=None): @@ -90,6 +91,7 @@ class NeutronPGContextTest(CharmTestCase): 'switch_password': 'plumgrid', 'metadata_mode': 'tunnel', 'connector_type': 'service', + 'user_domain_name': 'Default', 'nova_metadata_proxy_secret': 'plumgrid', 'pg_metadata_ip': '169.254.169.254', 'pg_metadata_subnet': '169.254.169.254/30',