From 561ee23925dfd96adc015802a121466361f928c8 Mon Sep 17 00:00:00 2001 From: Junaid Ali Date: Sat, 21 May 2016 16:54:18 +0500 Subject: [PATCH 1/3] Changes: Updated template files Configured plumgrid install sources --- hooks/pg_gw_hooks.py | 6 +++++- hooks/pg_gw_utils.py | 18 ++++++++++++++++++ templates/kilo/00-pg.conf | 3 ++- templates/kilo/ifcs.conf | 4 ++-- templates/kilo/plumgrid.conf | 3 +++ 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/hooks/pg_gw_hooks.py b/hooks/pg_gw_hooks.py index 4ccb4b6..10b5791 100755 --- a/hooks/pg_gw_hooks.py +++ b/hooks/pg_gw_hooks.py @@ -34,7 +34,8 @@ from pg_gw_utils import ( load_iptables, restart_on_change, restart_on_stop, - director_cluster_ready + director_cluster_ready, + configure_pg_sources ) hooks = Hooks() @@ -92,6 +93,9 @@ def config_changed(): charm_config.changed('iovisor-build')): stop_pg() 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(update=True) pkgs = determine_packages() for pkg in pkgs: diff --git a/hooks/pg_gw_utils.py b/hooks/pg_gw_utils.py index c628cf9..7e77a06 100644 --- a/hooks/pg_gw_utils.py +++ b/hooks/pg_gw_utils.py @@ -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' @@ -78,6 +79,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 Gateway as specified diff --git a/templates/kilo/00-pg.conf b/templates/kilo/00-pg.conf index e744a27..ac09811 100644 --- a/templates/kilo/00-pg.conf +++ b/templates/kilo/00-pg.conf @@ -1,2 +1,3 @@ $template ls_json,"{{'{'}}{{'%'}}timestamp:::date-rfc3339,jsonf:@timestamp%,%source:::jsonf:@source_host%,%msg:::json%}" -:syslogtag,isequal,"pg:" @{{ opsvm_ip }}:6000;ls_json +if $syslogtag == 'pg:' and not ($msg contains 'dht_cli_') then @{{ opsvm_ip }}:6000;ls_json +:msg, contains, "VM Interface Stats" ~ diff --git a/templates/kilo/ifcs.conf b/templates/kilo/ifcs.conf index 657fbd5..e7535cb 100644 --- a/templates/kilo/ifcs.conf +++ b/templates/kilo/ifcs.conf @@ -1,7 +1,7 @@ {{ fabric_interface }} = fabric_core host {% if ext_interfaces -%} -{% for ip in ext_interfaces -%} -{{ ip }} = access_phys +{% for dev in ext_interfaces -%} +{{ dev }} = access_phys {% endfor -%} {% endif -%} diff --git a/templates/kilo/plumgrid.conf b/templates/kilo/plumgrid.conf index acb8e9b..f56f11f 100644 --- a/templates/kilo/plumgrid.conf +++ b/templates/kilo/plumgrid.conf @@ -5,6 +5,9 @@ label={{ label}} plumgrid_rsync_port=2222 plumgrid_rest_addr=0.0.0.0:9180 fabric_mode={{ fabric_mode }} +plumgrid_syslog_ng_ip={{ plumgrid_syslog_ng_ip }} +plumgrid_syslog_ng_port={{ plumgrid_syslog_ng_port }} +plumgrid_monitor_interval={{ plumgrid_monitor_interval }} start_plumgrid_iovisor=yes start_plumgrid=`/opt/pg/scripts/pg_is_director.sh $plumgrid_ip` location= From 4999e4d5f3a356f271b15b5983a51a914dca22d3 Mon Sep 17 00:00:00 2001 From: Junaid Ali Date: Sun, 22 May 2016 11:19:46 -0400 Subject: [PATCH 2/3] Updated configure_pg_sources --- hooks/pg_gw_hooks.py | 3 +-- hooks/pg_gw_utils.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/hooks/pg_gw_hooks.py b/hooks/pg_gw_hooks.py index 10b5791..5818cea 100755 --- a/hooks/pg_gw_hooks.py +++ b/hooks/pg_gw_hooks.py @@ -94,8 +94,7 @@ def config_changed(): stop_pg() 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(update=True) pkgs = determine_packages() for pkg in pkgs: diff --git a/hooks/pg_gw_utils.py b/hooks/pg_gw_utils.py index 7e77a06..98ad4a4 100644 --- a/hooks/pg_gw_utils.py +++ b/hooks/pg_gw_utils.py @@ -91,9 +91,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 1c19fadbc4b8bdad7d66666c629d11728d43c741 Mon Sep 17 00:00:00 2001 From: Junaid Ali Date: Mon, 23 May 2016 06:31:14 -0400 Subject: [PATCH 3/3] logging IOError for sources.list --- hooks/pg_gw_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/pg_gw_utils.py b/hooks/pg_gw_utils.py index 98ad4a4..cb9250e 100644 --- a/hooks/pg_gw_utils.py +++ b/hooks/pg_gw_utils.py @@ -92,7 +92,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():