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
1=== modified file 'README.md'
2--- README.md 2016-04-15 11:05:58 +0000
3+++ README.md 2016-10-17 17:45:27 +0000
4@@ -29,7 +29,7 @@
5
6 ## Known Limitations and Issues
7
8-This 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.
9+This is an early access version of the PLUMgrid Gateway charm for testing with xenial and it is not meant for production deployments.
10
11 # Configuration
12
13@@ -61,4 +61,5 @@
14 # Contact Information
15
16 Bilal Baqar <bbaqar@plumgrid.com>
17-Bilal Ahmad <bilal@plumgrid.com>
18+Javeria Khan <javeriak@plumgrid.com>
19+Junaid Ali <junaidali@plumgrid.com>
20
21=== modified file 'config.yaml'
22--- config.yaml 2016-07-25 17:01:44 +0000
23+++ config.yaml 2016-10-17 17:45:27 +0000
24@@ -11,6 +11,7 @@
25 description: Public SSH key of PLUMgrid LCM which is running PG-Tools
26 mgmt-interface:
27 type: string
28+ default:
29 description: The interface connected to PLUMgrid Managment network.
30 fabric-interfaces:
31 default: 'MANAGEMENT'
32
33=== modified symlink 'hooks/install' (properties changed: -x to +x)
34=== target was u'pg_gw_hooks.py'
35--- hooks/install 1970-01-01 00:00:00 +0000
36+++ hooks/install 2016-10-17 17:45:27 +0000
37@@ -0,0 +1,20 @@
38+#!/bin/bash
39+# Wrapper to deal with newer Ubuntu versions that don't have py2 installed
40+# by default.
41+
42+declare -a DEPS=('apt' 'netaddr' 'netifaces' 'pip' 'yaml')
43+
44+check_and_install() {
45+ pkg="${1}-${2}"
46+ if ! dpkg -s ${pkg} 2>&1 > /dev/null; then
47+ apt-get -y install ${pkg}
48+ fi
49+}
50+
51+PYTHON="python"
52+
53+for dep in ${DEPS[@]}; do
54+ check_and_install ${PYTHON} ${dep}
55+done
56+
57+exec ./hooks/install.real
58
59=== added symlink 'hooks/install.real'
60=== target is u'pg_gw_hooks.py'
61=== modified file 'hooks/pg_gw_hooks.py'
62--- hooks/pg_gw_hooks.py 2016-08-29 09:43:59 +0000
63+++ hooks/pg_gw_hooks.py 2016-10-17 17:45:27 +0000
64@@ -33,24 +33,23 @@
65 fabric_interface_changed,
66 load_iptables,
67 restart_on_change,
68+ restart_pg,
69 restart_on_stop,
70 director_cluster_ready,
71 configure_pg_sources,
72- docker_configure_sources
73 )
74
75 hooks = Hooks()
76 CONFIGS = register_configs()
77
78
79-@hooks.hook()
80+@hooks.hook('install.real')
81 def install():
82 '''
83 Install hook is run when the charm is first deployed on a node.
84 '''
85 status_set('maintenance', 'Executing pre-install')
86 load_iptables()
87- docker_configure_sources()
88 configure_sources(update=True)
89 status_set('maintenance', 'Installing apt packages')
90 pkgs = determine_packages()
91@@ -72,6 +71,7 @@
92 if director_cluster_ready():
93 ensure_mtu()
94 CONFIGS.write_all()
95+ restart_pg()
96
97
98 @hooks.hook('config-changed')
99@@ -105,6 +105,7 @@
100 load_iovisor()
101 ensure_mtu()
102 CONFIGS.write_all()
103+ restart_pg()
104
105
106 @hooks.hook('upgrade-charm')
107
108=== modified file 'hooks/pg_gw_utils.py'
109--- hooks/pg_gw_utils.py 2016-08-29 09:43:59 +0000
110+++ hooks/pg_gw_utils.py 2016-10-17 17:45:27 +0000
111@@ -23,6 +23,8 @@
112 get_iface_from_addr,
113 get_bridges,
114 get_bridge_nics,
115+ get_iface_addr,
116+ get_host_ip
117 )
118 from charmhelpers.core.host import (
119 write_file,
120@@ -77,6 +79,12 @@
121 }),
122 ])
123
124+# Docker-engine version mapping - for OIL local repo
125+DOCKER_ENGINE_VERSION = {
126+ 'trusty': '1.12.2-0~trusty',
127+ 'xenial': '1.12.2-0~xenial'
128+}
129+
130
131 def configure_pg_sources():
132 '''
133@@ -101,7 +109,8 @@
134 '''
135 pkgs = []
136 pkgs.extend(docker_dependencies())
137- pkgs.append('docker-engine')
138+ pkgs.append('docker-engine=%s' %
139+ DOCKER_ENGINE_VERSION[lsb_release()['DISTRIB_CODENAME']])
140 tag = 'latest'
141 for pkg in neutron_plugin_attribute('plumgrid', 'packages', 'neutron'):
142 if 'plumgrid' in pkg:
143@@ -138,19 +147,17 @@
144 ubuntu_rel = lsb_release()['DISTRIB_CODENAME']
145 DOCKER_SOURCE = ('deb https://apt.dockerproject.org/repo ubuntu-%s'
146 ' main')
147- cmd = ('apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80'
148- ' --recv-keys 58118E89F3A912897C070ADBF76221572C52609D')
149- log('Importing GPG for docker engine')
150- try:
151- subprocess.check_call(cmd, shell=True)
152- except:
153- raise ValueError('Error importing docker GPG Key')
154+ log('Importing GPG Key for docker engine')
155+ _exec_cmd(['apt-key', 'adv', '--keyserver',
156+ 'hkp://p80.pool.sks-keyservers.net:80',
157+ '--recv-keys', '58118E89F3A912897C070ADBF76221572C52609D'])
158 try:
159 with open('/etc/apt/sources.list.d/docker.list', 'w') as f:
160 f.write(DOCKER_SOURCE % ubuntu_rel)
161 f.close()
162 except:
163- log('Unable to update /etc/apt/sources.list.d/docker.list')
164+ raise ValueError('Unable to update /etc/apt/sources.list.d/'
165+ 'docker.list')
166
167
168 def register_configs(release=None):
169@@ -201,16 +208,16 @@
170 service_start('plumgrid')
171 time.sleep(3)
172 if not service_running('plumgrid'):
173- if service_running('libvirt-bin'):
174+ if service_running('docker-engine'):
175 raise ValueError("plumgrid service couldn't be started")
176 else:
177- if service_start('libvirt-bin'):
178+ if service_start('docker-engine'):
179 time.sleep(8)
180 if not service_running('plumgrid') \
181 and not service_start('plumgrid'):
182 raise ValueError("plumgrid service couldn't be started")
183 else:
184- raise ValueError("libvirt-bin service couldn't be started")
185+ raise ValueError("docker-engine service couldn't be started")
186 status_set('active', 'Unit is ready')
187
188
189@@ -257,6 +264,13 @@
190 '''
191 mgmt_interface = config('mgmt-interface')
192 if not mgmt_interface:
193+ try:
194+ return get_iface_from_addr(unit_get('private-address'))
195+ except:
196+ for bridge_interface in get_bridges():
197+ if (get_host_ip(unit_get('private-address'))
198+ in get_iface_addr(bridge_interface)):
199+ return bridge_interface
200 return get_iface_from_addr(unit_get('private-address'))
201 elif interface_exists(mgmt_interface):
202 return mgmt_interface
203@@ -366,7 +380,7 @@
204 try:
205 fr = open(AUTH_KEY_PATH, 'r')
206 except IOError:
207- log('plumgrid-lxc not installed yet')
208+ log('plumgrid-docker package not installed yet')
209 return 0
210 for line in fr:
211 if key in line:
212
213=== modified file 'metadata.yaml'
214--- metadata.yaml 2015-07-29 18:23:55 +0000
215+++ metadata.yaml 2016-10-17 17:45:27 +0000
216@@ -7,6 +7,9 @@
217 fabric to external IP networks (such as for internet access). The PLUMgrid
218 Gateway can be deployed as a pair in Active/ Active mode for load balancing
219 of traffic and high availability of external connectivity.
220+series:
221+ - xenial
222+ - trusty
223 tags:
224 - openstack
225 requires:
226
227=== modified file 'unit_tests/test_pg_gw_hooks.py'
228--- unit_tests/test_pg_gw_hooks.py 2016-08-29 09:43:59 +0000
229+++ unit_tests/test_pg_gw_hooks.py 2016-10-17 17:45:27 +0000
230@@ -31,7 +31,7 @@
231 'load_iptables',
232 'director_cluster_ready',
233 'status_set',
234- 'docker_configure_sources'
235+ 'restart_pg'
236 ]
237 NEUTRON_CONF_DIR = "/etc/neutron"
238

Subscribers

People subscribed via source and target branches

to all changes: