user-domain-name config added

configure-pg-sources function added
This commit is contained in:
Bilal Baqar 2016-05-29 00:04:16 +02:00
commit 7845f465a1
6 changed files with 28 additions and 1 deletions

View File

@ -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

View File

@ -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'] = \

View File

@ -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()

View File

@ -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

View File

@ -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 -%}

View File

@ -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',