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

Proposed by Junaid Ali
Status: Merged
Merged at revision: 17
Proposed branch: lp:~junaidali/charms/trusty/plumgrid-gateway/docker-oil
Merge into: lp:charms/trusty/plumgrid-gateway
Diff against target: 288 lines (+80/-48)
8 files modified
config.yaml (+1/-12)
hooks/charmhelpers/contrib/openstack/neutron.py (+1/-1)
hooks/pg_gw_hooks.py (+6/-1)
hooks/pg_gw_utils.py (+64/-27)
templates/kilo/00-pg.conf (+2/-1)
templates/kilo/ifcs.conf (+1/-5)
templates/kilo/plumgrid.conf (+3/-0)
unit_tests/test_pg_gw_hooks.py (+2/-1)
To merge this branch: bzr merge lp:~junaidali/charms/trusty/plumgrid-gateway/docker-oil
Reviewer Review Type Date Requested Status
Review Queue (community) automated testing Needs Fixing
David Ames Pending
Review via email: mp+304251@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Review Queue (review-queue) wrote :

This item has failed automated testing! Results available here http://juju-ci.vapour.ws/job/charm-bundle-test-lxc/5471/

review: Needs Fixing (automated testing)
Revision history for this message
Review Queue (review-queue) wrote :

This item has failed automated testing! Results available here http://juju-ci.vapour.ws/job/charm-bundle-test-aws/5572/

review: Needs Fixing (automated testing)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2015-11-22 03:26:23 +0000
3+++ config.yaml 2016-08-29 12:05:09 +0000
4@@ -11,24 +11,13 @@
5 description: Public SSH key of PLUMgrid LCM which is running PG-Tools
6 mgmt-interface:
7 type: string
8- default: 'juju-br0'
9 description: The interface connected to PLUMgrid Managment network.
10- os-data-network:
11- type: string
12- default:
13- description: |
14- The IP address and netmask of the OpenStack Data network (e.g.,
15- 192.168.0.0/24)
16- .
17- This network will be used for tenant network traffic in overlay
18- networks.
19 fabric-interfaces:
20 default: 'MANAGEMENT'
21 type: string
22 description: |
23 Interfaces that will provide fabric connectivity on the gateway nodes.
24- Provided in form of json in a string. These interfaces have to be connected
25- to the os-data-network specified in the config. Default value is MANAGEMENT which
26+ Provided in form of json in a string. Default value is MANAGEMENT which
27 will configure the management interface as the fabric interface on each
28 director.
29 network-device-mtu:
30
31=== modified file 'hooks/charmhelpers/contrib/openstack/neutron.py'
32--- hooks/charmhelpers/contrib/openstack/neutron.py 2016-04-22 08:15:33 +0000
33+++ hooks/charmhelpers/contrib/openstack/neutron.py 2016-08-29 12:05:09 +0000
34@@ -204,7 +204,7 @@
35 database=config('database'),
36 ssl_dir=NEUTRON_CONF_DIR)],
37 'services': [],
38- 'packages': ['plumgrid-lxc',
39+ 'packages': ['plumgrid-edge-docker',
40 'iovisor-dkms'],
41 'server_packages': ['neutron-server',
42 'neutron-plugin-plumgrid'],
43
44=== modified file 'hooks/pg_gw_hooks.py'
45--- hooks/pg_gw_hooks.py 2016-04-06 16:45:27 +0000
46+++ hooks/pg_gw_hooks.py 2016-08-29 12:05:09 +0000
47@@ -34,7 +34,9 @@
48 load_iptables,
49 restart_on_change,
50 restart_on_stop,
51- director_cluster_ready
52+ director_cluster_ready,
53+ configure_pg_sources,
54+ docker_configure_sources
55 )
56
57 hooks = Hooks()
58@@ -48,6 +50,7 @@
59 '''
60 status_set('maintenance', 'Executing pre-install')
61 load_iptables()
62+ docker_configure_sources()
63 configure_sources(update=True)
64 status_set('maintenance', 'Installing apt packages')
65 pkgs = determine_packages()
66@@ -92,6 +95,8 @@
67 charm_config.changed('iovisor-build')):
68 stop_pg()
69 status_set('maintenance', 'Upgrading apt packages')
70+ if charm_config.changed('install_sources'):
71+ configure_pg_sources()
72 configure_sources(update=True)
73 pkgs = determine_packages()
74 for pkg in pkgs:
75
76=== modified file 'hooks/pg_gw_utils.py'
77--- hooks/pg_gw_utils.py 2016-05-01 02:22:48 +0000
78+++ hooks/pg_gw_utils.py 2016-08-29 12:05:09 +0000
79@@ -23,8 +23,6 @@
80 get_iface_from_addr,
81 get_bridges,
82 get_bridge_nics,
83- is_address_in_network,
84- get_iface_addr
85 )
86 from charmhelpers.core.host import (
87 write_file,
88@@ -32,7 +30,8 @@
89 service_stop,
90 service_running,
91 path_hash,
92- set_nic_mtu
93+ set_nic_mtu,
94+ lsb_release
95 )
96 from charmhelpers.fetch import (
97 apt_cache,
98@@ -42,16 +41,17 @@
99 os_release,
100 )
101
102+SOURCES_LIST = '/etc/apt/sources.list'
103 LXC_CONF = "/etc/libvirt/lxc.conf"
104 TEMPLATES = 'templates/'
105-PG_LXC_DATA_PATH = '/var/lib/libvirt/filesystems/plumgrid-data'
106+PG_LXC_DATA_PATH = '/var/lib/plumgrid/plumgrid-data'
107 PG_CONF = '%s/conf/pg/plumgrid.conf' % PG_LXC_DATA_PATH
108 PG_HN_CONF = '%s/conf/etc/hostname' % PG_LXC_DATA_PATH
109 PG_HS_CONF = '%s/conf/etc/hosts' % PG_LXC_DATA_PATH
110 PG_IFCS_CONF = '%s/conf/pg/ifcs.conf' % PG_LXC_DATA_PATH
111 OPS_CONF = '%s/conf/etc/00-pg.conf' % PG_LXC_DATA_PATH
112 AUTH_KEY_PATH = '%s/root/.ssh/authorized_keys' % PG_LXC_DATA_PATH
113-IFC_LIST_GW = '/var/run/plumgrid/lxc/ifc_list_gateway'
114+IFC_LIST_GW = '/var/run/plumgrid/ifc_list_gateway'
115 SUDOERS_CONF = '/etc/sudoers.d/ifc_ctl_sudoers'
116
117 BASE_RESOURCE_MAP = OrderedDict([
118@@ -78,12 +78,30 @@
119 ])
120
121
122+def configure_pg_sources():
123+ '''
124+ Returns true if install sources is updated in sources.list file
125+ '''
126+ try:
127+ with open(SOURCES_LIST, 'r+') as sources:
128+ all_lines = sources.readlines()
129+ sources.seek(0)
130+ for i in (line for line in all_lines if "plumgrid" not in line):
131+ sources.write(i)
132+ sources.truncate()
133+ sources.close()
134+ except IOError:
135+ log('Unable to update /etc/apt/sources.list')
136+
137+
138 def determine_packages():
139 '''
140 Returns list of packages required by PLUMgrid Gateway as specified
141 in the neutron_plugins dictionary in charmhelpers.
142 '''
143 pkgs = []
144+ pkgs.extend(docker_dependencies())
145+ pkgs.append('docker-engine')
146 tag = 'latest'
147 for pkg in neutron_plugin_attribute('plumgrid', 'packages', 'neutron'):
148 if 'plumgrid' in pkg:
149@@ -104,6 +122,37 @@
150 return pkgs
151
152
153+def docker_dependencies():
154+ '''
155+ Returns a list of packages to be installed for docker engine
156+ '''
157+ kver = subprocess.check_output(['uname', '-r']).replace('\n', '')
158+ return ['apt-transport-https', 'ca-certificates', 'apparmor',
159+ 'linux-image-extra-{}'.format(kver)]
160+
161+
162+def docker_configure_sources():
163+ '''
164+ Imports GPG key and updates apt source for docker engine
165+ '''
166+ ubuntu_rel = lsb_release()['DISTRIB_CODENAME']
167+ DOCKER_SOURCE = ('deb https://apt.dockerproject.org/repo ubuntu-%s'
168+ ' main')
169+ cmd = ('apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80'
170+ ' --recv-keys 58118E89F3A912897C070ADBF76221572C52609D')
171+ log('Importing GPG for docker engine')
172+ try:
173+ subprocess.check_call(cmd, shell=True)
174+ except:
175+ raise ValueError('Error importing docker GPG Key')
176+ try:
177+ with open('/etc/apt/sources.list.d/docker.list', 'w') as f:
178+ f.write(DOCKER_SOURCE % ubuntu_rel)
179+ f.close()
180+ except:
181+ log('Unable to update /etc/apt/sources.list.d/docker.list')
182+
183+
184 def register_configs(release=None):
185 '''
186 Returns an object of the Openstack Tempating Class which contains the
187@@ -207,7 +256,9 @@
188 Returns the managment interface.
189 '''
190 mgmt_interface = config('mgmt-interface')
191- if interface_exists(mgmt_interface):
192+ if not mgmt_interface:
193+ return get_iface_from_addr(unit_get('private-address'))
194+ elif interface_exists(mgmt_interface):
195 return mgmt_interface
196 else:
197 log('Provided managment interface %s does not exist'
198@@ -251,11 +302,7 @@
199 else:
200 raise ValueError('No fabric interface provided for node')
201 if interface_exists(node_fabric_interface):
202- if is_address_in_network(config('os-data-network'),
203- get_iface_addr(node_fabric_interface)[0]):
204- return node_fabric_interface
205- else:
206- raise ValueError('Fabric interface not in fabric network')
207+ return node_fabric_interface
208 else:
209 log('Provided fabric interface %s does not exist'
210 % node_fabric_interface)
211@@ -268,22 +315,12 @@
212 Gateway node can have multiple interfaces. This function parses json
213 provided in config to get all gateway interfaces for this node.
214 '''
215- node_interfaces = []
216- try:
217- all_interfaces = json.loads(config('external-interfaces'))
218- except ValueError:
219- raise ValueError("Invalid json provided for gateway interfaces")
220- hostname = get_unit_hostname()
221- if hostname in all_interfaces:
222- node_interfaces = all_interfaces[hostname].split(',')
223- elif 'DEFAULT' in all_interfaces:
224- node_interfaces = all_interfaces['DEFAULT'].split(',')
225- for interface in node_interfaces:
226- if not interface_exists(interface):
227- log('Provided gateway interface %s does not exist'
228- % interface)
229- raise ValueError('Provided gateway interface does not exist')
230- return node_interfaces
231+ interface = config('external-interfaces')
232+ if not interface_exists(interface):
233+ log('Provided gateway interface %s does not exist'
234+ % interface)
235+ raise ValueError('Provided gateway interface does not exist')
236+ return interface
237
238
239 def ensure_mtu():
240
241=== modified file 'templates/kilo/00-pg.conf'
242--- templates/kilo/00-pg.conf 2016-04-06 16:45:27 +0000
243+++ templates/kilo/00-pg.conf 2016-08-29 12:05:09 +0000
244@@ -1,2 +1,3 @@
245 $template ls_json,"{{'{'}}{{'%'}}timestamp:::date-rfc3339,jsonf:@timestamp%,%source:::jsonf:@source_host%,%msg:::json%}"
246-:syslogtag,isequal,"pg:" @{{ opsvm_ip }}:6000;ls_json
247+if $syslogtag == 'pg:' and not ($msg contains 'dht_cli_') then @{{ opsvm_ip }}:6000;ls_json
248+:msg, contains, "VM Interface Stats" ~
249
250=== modified file 'templates/kilo/ifcs.conf'
251--- templates/kilo/ifcs.conf 2015-11-22 03:26:23 +0000
252+++ templates/kilo/ifcs.conf 2016-08-29 12:05:09 +0000
253@@ -1,7 +1,3 @@
254 {{ fabric_interface }} = fabric_core host
255-{% if ext_interfaces -%}
256-{% for ip in ext_interfaces -%}
257-{{ ip }} = access_phys
258-{% endfor -%}
259-{% endif -%}
260+{{ ext_interfaces }} = access_phys
261
262
263=== modified file 'templates/kilo/plumgrid.conf'
264--- templates/kilo/plumgrid.conf 2016-03-27 15:24:34 +0000
265+++ templates/kilo/plumgrid.conf 2016-08-29 12:05:09 +0000
266@@ -5,6 +5,9 @@
267 plumgrid_rsync_port=2222
268 plumgrid_rest_addr=0.0.0.0:9180
269 fabric_mode={{ fabric_mode }}
270+plumgrid_syslog_ng_ip={{ plumgrid_syslog_ng_ip }}
271+plumgrid_syslog_ng_port={{ plumgrid_syslog_ng_port }}
272+plumgrid_monitor_interval={{ plumgrid_monitor_interval }}
273 start_plumgrid_iovisor=yes
274 start_plumgrid=`/opt/pg/scripts/pg_is_director.sh $plumgrid_ip`
275 location=
276
277=== modified file 'unit_tests/test_pg_gw_hooks.py'
278--- unit_tests/test_pg_gw_hooks.py 2016-05-01 02:22:48 +0000
279+++ unit_tests/test_pg_gw_hooks.py 2016-08-29 12:05:09 +0000
280@@ -30,7 +30,8 @@
281 'determine_packages',
282 'load_iptables',
283 'director_cluster_ready',
284- 'status_set'
285+ 'status_set',
286+ 'docker_configure_sources'
287 ]
288 NEUTRON_CONF_DIR = "/etc/neutron"
289

Subscribers

People subscribed via source and target branches

to all changes: