Configured plumgrid install sources

This commit is contained in:
Junaid Ali 2016-05-21 17:36:32 +05:00
commit d583e39a08
2 changed files with 22 additions and 1 deletions

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

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