From c2a2100b01a168e356d0f18fbe55ae01a1582cf2 Mon Sep 17 00:00:00 2001 From: Junaid Ali Date: Sat, 21 May 2016 17:28:31 +0500 Subject: [PATCH 1/5] Configured plumgrid install sources --- hooks/neutron_plumgrid_hooks.py | 4 ++++ hooks/neutron_plumgrid_utils.py | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/hooks/neutron_plumgrid_hooks.py b/hooks/neutron_plumgrid_hooks.py index 51658d3..f50e0d8 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,9 @@ 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'): + if not configure_pg_sources(): + log('IOError: /etc/apt/sources.list couldn\'t be updated') configure_sources() apt_update() pkgs = determine_packages() diff --git a/hooks/neutron_plumgrid_utils.py b/hooks/neutron_plumgrid_utils.py index bac2bf9..797d353 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,23 @@ 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() + return True + except IOError: + return False + + def determine_packages(): ''' Returns list of packages required to be installed alongside neutron to From 2bd6e0690fbea4c5e9c1021351ddc50cacf8b515 Mon Sep 17 00:00:00 2001 From: Junaid Ali Date: Sun, 22 May 2016 11:53:34 -0400 Subject: [PATCH 2/5] Updated configure_pg_sources --- hooks/neutron_plumgrid_hooks.py | 3 +-- hooks/neutron_plumgrid_utils.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/hooks/neutron_plumgrid_hooks.py b/hooks/neutron_plumgrid_hooks.py index f50e0d8..21c0d85 100755 --- a/hooks/neutron_plumgrid_hooks.py +++ b/hooks/neutron_plumgrid_hooks.py @@ -67,8 +67,7 @@ def config_changed(): charm_config.changed('install_keys')): status_set('maintenance', 'Upgrading apt packages') if charm_config.changed('install_sources'): - if not configure_pg_sources(): - log('IOError: /etc/apt/sources.list couldn\'t be updated') + 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 797d353..782f65a 100644 --- a/hooks/neutron_plumgrid_utils.py +++ b/hooks/neutron_plumgrid_utils.py @@ -75,9 +75,8 @@ def configure_pg_sources(): sources.write(i) sources.truncate() sources.close() - return True except IOError: - return False + raise IOError('Unable to access /etc/apt/sources.list') def determine_packages(): From 0b357bb262248c4b031d5f6f30b680f4825ce070 Mon Sep 17 00:00:00 2001 From: Junaid Ali Date: Mon, 23 May 2016 03:21:51 -0400 Subject: [PATCH 3/5] added user-domain-name config --- config.yaml | 5 +++++ hooks/neutron_plumgrid_context.py | 1 + templates/kilo/plumlib.ini | 1 + 3 files changed, 7 insertions(+) diff --git a/config.yaml b/config.yaml index 6855a42..e30e843 100644 --- a/config.yaml +++ b/config.yaml @@ -49,3 +49,8 @@ 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/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 -%} From 0eab21c1d70ef9ea00a733d5bd41cf6f80c0bbed Mon Sep 17 00:00:00 2001 From: Junaid Ali Date: Mon, 23 May 2016 06:27:44 -0400 Subject: [PATCH 4/5] logging IOError for sources.list --- hooks/neutron_plumgrid_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/neutron_plumgrid_utils.py b/hooks/neutron_plumgrid_utils.py index 782f65a..ffc0e32 100644 --- a/hooks/neutron_plumgrid_utils.py +++ b/hooks/neutron_plumgrid_utils.py @@ -76,7 +76,7 @@ def configure_pg_sources(): sources.truncate() sources.close() except IOError: - raise IOError('Unable to access /etc/apt/sources.list') + log('Unable to update /etc/apt/sources.list') def determine_packages(): From 1d79b40e7554f58f60862ad6137beecc15c3cffd Mon Sep 17 00:00:00 2001 From: Junaid Ali Date: Tue, 24 May 2016 00:58:18 -0400 Subject: [PATCH 5/5] Updating unit tests --- config.yaml | 3 +-- unit_tests/test_neutron_plumgrid_plugin_context.py | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config.yaml b/config.yaml index e30e843..fd18618 100644 --- a/config.yaml +++ b/config.yaml @@ -52,5 +52,4 @@ options: user-domain-name: type: string default: Default - description: | - Keystone user domain name + description: Keystone user domain name 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',