configuring pg install sources

This commit is contained in:
Junaid Ali 2016-05-21 16:13:01 +05:00
commit 070bbdfd1b
2 changed files with 23 additions and 1 deletions

View File

@ -40,7 +40,8 @@ from pg_dir_utils import (
fabric_interface_changed,
load_iptables,
restart_on_change,
director_cluster_ready
director_cluster_ready,
configure_pg_sources
)
hooks = Hooks()
@ -135,6 +136,9 @@ def config_changed():
charm_config.changed('iovisor-build')):
status_set('maintenance', 'Upgrading apt packages')
stop_pg()
if charm_config.changed('install_sources'):
if not configure_pg_sources():
log('IOError: /etc/apt/sources.list couldn\'t be updated')
configure_sources(update=True)
pkgs = determine_packages()
for pkg in pkgs:

View File

@ -42,6 +42,7 @@ from charmhelpers.contrib.openstack.utils import (
os_release,
)
SOURCES_LIST = '/etc/apt/sources.list'
LXC_CONF = '/etc/libvirt/lxc.conf'
TEMPLATES = 'templates/'
PG_LXC_DATA_PATH = '/var/lib/libvirt/filesystems/plumgrid-data'
@ -88,6 +89,23 @@ BASE_RESOURCE_MAP = 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 by PLUMgrid director as specified