Merge lp:~junaidali/charms/trusty/plumgrid-gateway/oil-sapi-changes into lp:charms/trusty/plumgrid-gateway

Proposed by Junaid Ali
Status: Needs review
Proposed branch: lp:~junaidali/charms/trusty/plumgrid-gateway/oil-sapi-changes
Merge into: lp:charms/trusty/plumgrid-gateway
Diff against target: 237 lines (+59/-19)
7 files modified
README.md (+3/-2)
config.yaml (+1/-0)
hooks/install (+20/-0)
hooks/pg_gw_hooks.py (+4/-3)
hooks/pg_gw_utils.py (+27/-13)
metadata.yaml (+3/-0)
unit_tests/test_pg_gw_hooks.py (+1/-1)
To merge this branch: bzr merge lp:~junaidali/charms/trusty/plumgrid-gateway/oil-sapi-changes
Reviewer Review Type Date Requested Status
James Page Pending
Review via email: mp+308652@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Junaid Ali (junaidali) wrote :

Added charm series in metadata.yaml file
Solutions API support - PG ONS 6.X.X
Updated readme file
Wrapper to deal with Ubuntu versions don't have py2 installed
Improved get_mgmt method

20. By Junaid Ali

Changes:
  Added charm series in metadata.yaml file
  Solutions API support - PG ONS 6.X.X
  Updated readme file
  Wrapper to deal with Ubuntu versions don't have py2 installed
  Improved get_mgmt method

Unmerged revisions

20. By Junaid Ali

Changes:
  Added charm series in metadata.yaml file
  Solutions API support - PG ONS 6.X.X
  Updated readme file
  Wrapper to deal with Ubuntu versions don't have py2 installed
  Improved get_mgmt method

19. By Junaid Ali

Changes:
  Added charm series in metadata.yaml file
  Solutions API support - PG ONS 6.X.X
  Updated readme file
  Wrapper to deal with Ubuntu versions don't have py2 installed
  Improved get_mgmt method

18. By Junaid Ali

Changes:
  Added charm series in metadata.yaml file
  Solutions API support - PG ONS 6.X.X
  Updated readme file
  Wrapper to deal with Ubuntu versions don't have py2 installed
  Improved get_mgmt method

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'README.md'
--- README.md 2016-04-15 11:05:58 +0000
+++ README.md 2016-10-17 17:45:27 +0000
@@ -29,7 +29,7 @@
2929
30## Known Limitations and Issues30## Known Limitations and Issues
3131
32This is an early access version of the PLUMgrid Gateway charm and it is not meant for production deployments. The charm currently only supports Kilo Openstack Release.32This is an early access version of the PLUMgrid Gateway charm for testing with xenial and it is not meant for production deployments.
3333
34# Configuration34# Configuration
3535
@@ -61,4 +61,5 @@
61# Contact Information61# Contact Information
6262
63Bilal Baqar <bbaqar@plumgrid.com>63Bilal Baqar <bbaqar@plumgrid.com>
64Bilal Ahmad <bilal@plumgrid.com>64Javeria Khan <javeriak@plumgrid.com>
65Junaid Ali <junaidali@plumgrid.com>
6566
=== modified file 'config.yaml'
--- config.yaml 2016-07-25 17:01:44 +0000
+++ config.yaml 2016-10-17 17:45:27 +0000
@@ -11,6 +11,7 @@
11 description: Public SSH key of PLUMgrid LCM which is running PG-Tools11 description: Public SSH key of PLUMgrid LCM which is running PG-Tools
12 mgmt-interface:12 mgmt-interface:
13 type: string13 type: string
14 default:
14 description: The interface connected to PLUMgrid Managment network.15 description: The interface connected to PLUMgrid Managment network.
15 fabric-interfaces:16 fabric-interfaces:
16 default: 'MANAGEMENT'17 default: 'MANAGEMENT'
1718
=== modified symlink 'hooks/install' (properties changed: -x to +x)
=== target was u'pg_gw_hooks.py'
--- hooks/install 1970-01-01 00:00:00 +0000
+++ hooks/install 2016-10-17 17:45:27 +0000
@@ -0,0 +1,20 @@
1#!/bin/bash
2# Wrapper to deal with newer Ubuntu versions that don't have py2 installed
3# by default.
4
5declare -a DEPS=('apt' 'netaddr' 'netifaces' 'pip' 'yaml')
6
7check_and_install() {
8 pkg="${1}-${2}"
9 if ! dpkg -s ${pkg} 2>&1 > /dev/null; then
10 apt-get -y install ${pkg}
11 fi
12}
13
14PYTHON="python"
15
16for dep in ${DEPS[@]}; do
17 check_and_install ${PYTHON} ${dep}
18done
19
20exec ./hooks/install.real
021
=== added symlink 'hooks/install.real'
=== target is u'pg_gw_hooks.py'
=== modified file 'hooks/pg_gw_hooks.py'
--- hooks/pg_gw_hooks.py 2016-08-29 09:43:59 +0000
+++ hooks/pg_gw_hooks.py 2016-10-17 17:45:27 +0000
@@ -33,24 +33,23 @@
33 fabric_interface_changed,33 fabric_interface_changed,
34 load_iptables,34 load_iptables,
35 restart_on_change,35 restart_on_change,
36 restart_pg,
36 restart_on_stop,37 restart_on_stop,
37 director_cluster_ready,38 director_cluster_ready,
38 configure_pg_sources,39 configure_pg_sources,
39 docker_configure_sources
40)40)
4141
42hooks = Hooks()42hooks = Hooks()
43CONFIGS = register_configs()43CONFIGS = register_configs()
4444
4545
46@hooks.hook()46@hooks.hook('install.real')
47def install():47def install():
48 '''48 '''
49 Install hook is run when the charm is first deployed on a node.49 Install hook is run when the charm is first deployed on a node.
50 '''50 '''
51 status_set('maintenance', 'Executing pre-install')51 status_set('maintenance', 'Executing pre-install')
52 load_iptables()52 load_iptables()
53 docker_configure_sources()
54 configure_sources(update=True)53 configure_sources(update=True)
55 status_set('maintenance', 'Installing apt packages')54 status_set('maintenance', 'Installing apt packages')
56 pkgs = determine_packages()55 pkgs = determine_packages()
@@ -72,6 +71,7 @@
72 if director_cluster_ready():71 if director_cluster_ready():
73 ensure_mtu()72 ensure_mtu()
74 CONFIGS.write_all()73 CONFIGS.write_all()
74 restart_pg()
7575
7676
77@hooks.hook('config-changed')77@hooks.hook('config-changed')
@@ -105,6 +105,7 @@
105 load_iovisor()105 load_iovisor()
106 ensure_mtu()106 ensure_mtu()
107 CONFIGS.write_all()107 CONFIGS.write_all()
108 restart_pg()
108109
109110
110@hooks.hook('upgrade-charm')111@hooks.hook('upgrade-charm')
111112
=== modified file 'hooks/pg_gw_utils.py'
--- hooks/pg_gw_utils.py 2016-08-29 09:43:59 +0000
+++ hooks/pg_gw_utils.py 2016-10-17 17:45:27 +0000
@@ -23,6 +23,8 @@
23 get_iface_from_addr,23 get_iface_from_addr,
24 get_bridges,24 get_bridges,
25 get_bridge_nics,25 get_bridge_nics,
26 get_iface_addr,
27 get_host_ip
26)28)
27from charmhelpers.core.host import (29from charmhelpers.core.host import (
28 write_file,30 write_file,
@@ -77,6 +79,12 @@
77 }),79 }),
78])80])
7981
82# Docker-engine version mapping - for OIL local repo
83DOCKER_ENGINE_VERSION = {
84 'trusty': '1.12.2-0~trusty',
85 'xenial': '1.12.2-0~xenial'
86}
87
8088
81def configure_pg_sources():89def configure_pg_sources():
82 '''90 '''
@@ -101,7 +109,8 @@
101 '''109 '''
102 pkgs = []110 pkgs = []
103 pkgs.extend(docker_dependencies())111 pkgs.extend(docker_dependencies())
104 pkgs.append('docker-engine')112 pkgs.append('docker-engine=%s' %
113 DOCKER_ENGINE_VERSION[lsb_release()['DISTRIB_CODENAME']])
105 tag = 'latest'114 tag = 'latest'
106 for pkg in neutron_plugin_attribute('plumgrid', 'packages', 'neutron'):115 for pkg in neutron_plugin_attribute('plumgrid', 'packages', 'neutron'):
107 if 'plumgrid' in pkg:116 if 'plumgrid' in pkg:
@@ -138,19 +147,17 @@
138 ubuntu_rel = lsb_release()['DISTRIB_CODENAME']147 ubuntu_rel = lsb_release()['DISTRIB_CODENAME']
139 DOCKER_SOURCE = ('deb https://apt.dockerproject.org/repo ubuntu-%s'148 DOCKER_SOURCE = ('deb https://apt.dockerproject.org/repo ubuntu-%s'
140 ' main')149 ' main')
141 cmd = ('apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80'150 log('Importing GPG Key for docker engine')
142 ' --recv-keys 58118E89F3A912897C070ADBF76221572C52609D')151 _exec_cmd(['apt-key', 'adv', '--keyserver',
143 log('Importing GPG for docker engine')152 'hkp://p80.pool.sks-keyservers.net:80',
144 try:153 '--recv-keys', '58118E89F3A912897C070ADBF76221572C52609D'])
145 subprocess.check_call(cmd, shell=True)
146 except:
147 raise ValueError('Error importing docker GPG Key')
148 try:154 try:
149 with open('/etc/apt/sources.list.d/docker.list', 'w') as f:155 with open('/etc/apt/sources.list.d/docker.list', 'w') as f:
150 f.write(DOCKER_SOURCE % ubuntu_rel)156 f.write(DOCKER_SOURCE % ubuntu_rel)
151 f.close()157 f.close()
152 except:158 except:
153 log('Unable to update /etc/apt/sources.list.d/docker.list')159 raise ValueError('Unable to update /etc/apt/sources.list.d/'
160 'docker.list')
154161
155162
156def register_configs(release=None):163def register_configs(release=None):
@@ -201,16 +208,16 @@
201 service_start('plumgrid')208 service_start('plumgrid')
202 time.sleep(3)209 time.sleep(3)
203 if not service_running('plumgrid'):210 if not service_running('plumgrid'):
204 if service_running('libvirt-bin'):211 if service_running('docker-engine'):
205 raise ValueError("plumgrid service couldn't be started")212 raise ValueError("plumgrid service couldn't be started")
206 else:213 else:
207 if service_start('libvirt-bin'):214 if service_start('docker-engine'):
208 time.sleep(8)215 time.sleep(8)
209 if not service_running('plumgrid') \216 if not service_running('plumgrid') \
210 and not service_start('plumgrid'):217 and not service_start('plumgrid'):
211 raise ValueError("plumgrid service couldn't be started")218 raise ValueError("plumgrid service couldn't be started")
212 else:219 else:
213 raise ValueError("libvirt-bin service couldn't be started")220 raise ValueError("docker-engine service couldn't be started")
214 status_set('active', 'Unit is ready')221 status_set('active', 'Unit is ready')
215222
216223
@@ -257,6 +264,13 @@
257 '''264 '''
258 mgmt_interface = config('mgmt-interface')265 mgmt_interface = config('mgmt-interface')
259 if not mgmt_interface:266 if not mgmt_interface:
267 try:
268 return get_iface_from_addr(unit_get('private-address'))
269 except:
270 for bridge_interface in get_bridges():
271 if (get_host_ip(unit_get('private-address'))
272 in get_iface_addr(bridge_interface)):
273 return bridge_interface
260 return get_iface_from_addr(unit_get('private-address'))274 return get_iface_from_addr(unit_get('private-address'))
261 elif interface_exists(mgmt_interface):275 elif interface_exists(mgmt_interface):
262 return mgmt_interface276 return mgmt_interface
@@ -366,7 +380,7 @@
366 try:380 try:
367 fr = open(AUTH_KEY_PATH, 'r')381 fr = open(AUTH_KEY_PATH, 'r')
368 except IOError:382 except IOError:
369 log('plumgrid-lxc not installed yet')383 log('plumgrid-docker package not installed yet')
370 return 0384 return 0
371 for line in fr:385 for line in fr:
372 if key in line:386 if key in line:
373387
=== modified file 'metadata.yaml'
--- metadata.yaml 2015-07-29 18:23:55 +0000
+++ metadata.yaml 2016-10-17 17:45:27 +0000
@@ -7,6 +7,9 @@
7 fabric to external IP networks (such as for internet access). The PLUMgrid7 fabric to external IP networks (such as for internet access). The PLUMgrid
8 Gateway can be deployed as a pair in Active/ Active mode for load balancing8 Gateway can be deployed as a pair in Active/ Active mode for load balancing
9 of traffic and high availability of external connectivity.9 of traffic and high availability of external connectivity.
10series:
11 - xenial
12 - trusty
10tags:13tags:
11 - openstack14 - openstack
12requires:15requires:
1316
=== modified file 'unit_tests/test_pg_gw_hooks.py'
--- unit_tests/test_pg_gw_hooks.py 2016-08-29 09:43:59 +0000
+++ unit_tests/test_pg_gw_hooks.py 2016-10-17 17:45:27 +0000
@@ -31,7 +31,7 @@
31 'load_iptables',31 'load_iptables',
32 'director_cluster_ready',32 'director_cluster_ready',
33 'status_set',33 'status_set',
34 'docker_configure_sources'34 'restart_pg'
35]35]
36NEUTRON_CONF_DIR = "/etc/neutron"36NEUTRON_CONF_DIR = "/etc/neutron"
3737

Subscribers

People subscribed via source and target branches

to all changes: