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

Proposed by Junaid Ali
Status: Merged
Merged at revision: 17
Proposed branch: lp:~junaidali/charms/trusty/plumgrid-edge/docker-oil
Merge into: lp:charms/trusty/plumgrid-edge
Diff against target: 263 lines (+96/-26)
7 files modified
config.yaml (+1/-12)
hooks/charmhelpers/contrib/openstack/neutron.py (+1/-1)
hooks/pg_edge_hooks.py (+6/-1)
hooks/pg_edge_utils.py (+81/-10)
templates/kilo/00-pg.conf (+2/-1)
templates/kilo/plumgrid.conf (+3/-0)
unit_tests/test_pg_edge_hooks.py (+2/-1)
To merge this branch: bzr merge lp:~junaidali/charms/trusty/plumgrid-edge/docker-oil
Reviewer Review Type Date Requested Status
Review Queue (community) automated testing Needs Fixing
David Ames Pending
Review via email: mp+304249@code.launchpad.net

Description of the change

PLUMgrid docker package changes

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/5468/

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/5569/

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:25:51 +0000
3+++ config.yaml 2016-08-29 12:04:58 +0000
4@@ -5,24 +5,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 director 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-21 08:28:10 +0000
33+++ hooks/charmhelpers/contrib/openstack/neutron.py 2016-08-29 12:04:58 +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_edge_hooks.py'
45--- hooks/pg_edge_hooks.py 2016-04-06 16:43:20 +0000
46+++ hooks/pg_edge_hooks.py 2016-08-29 12:04:58 +0000
47@@ -37,7 +37,9 @@
48 fabric_interface_changed,
49 load_iptables,
50 restart_on_change,
51- director_cluster_ready
52+ director_cluster_ready,
53+ configure_pg_sources,
54+ docker_configure_sources
55 )
56
57 hooks = Hooks()
58@@ -51,6 +53,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@@ -108,6 +111,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_edge_utils.py'
77--- hooks/pg_edge_utils.py 2016-05-25 16:33:18 +0000
78+++ hooks/pg_edge_utils.py 2016-08-29 12:04:58 +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@@ -33,7 +31,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@@ -43,10 +42,11 @@
99 os_release,
100 )
101
102+SOURCES_LIST = '/etc/apt/sources.list'
103 SHARED_SECRET = "/etc/nova/secret.txt"
104 LXC_CONF = '/etc/libvirt/lxc.conf'
105 TEMPLATES = 'templates/'
106-PG_LXC_DATA_PATH = '/var/lib/libvirt/filesystems/plumgrid-data'
107+PG_LXC_DATA_PATH = '/var/lib/plumgrid/plumgrid-data'
108 PG_CONF = '%s/conf/pg/plumgrid.conf' % PG_LXC_DATA_PATH
109 PG_HN_CONF = '%s/conf/etc/hostname' % PG_LXC_DATA_PATH
110 PG_HS_CONF = '%s/conf/etc/hosts' % PG_LXC_DATA_PATH
111@@ -85,12 +85,56 @@
112 ])
113
114
115+def configure_pg_sources():
116+ '''
117+ Returns true if install sources is updated in sources.list file
118+ '''
119+ try:
120+ with open(SOURCES_LIST, 'r+') as sources:
121+ all_lines = sources.readlines()
122+ sources.seek(0)
123+ for i in (line for line in all_lines if "plumgrid" not in line):
124+ sources.write(i)
125+ sources.truncate()
126+ sources.close()
127+ except IOError:
128+ log('Unable to update /etc/apt/sources.list')
129+
130+
131+def configure_analyst_opsvm():
132+ '''
133+ Configures Anaylyst for OPSVM
134+ '''
135+ if not service_running('plumgrid'):
136+ restart_pg()
137+ opsvm_ip = pg_edge_context._pg_dir_context()['opsvm_ip']
138+ NS_ENTER = ('/opt/local/bin/nsenter -t $(ps ho pid --ppid $(cat '
139+ '/var/run/libvirt/lxc/plumgrid.pid)) -m -n -u -i -p ')
140+ sigmund_stop = NS_ENTER + '/usr/bin/service plumgrid-sigmund stop'
141+ sigmund_status = NS_ENTER \
142+ + '/usr/bin/service plumgrid-sigmund status'
143+ sigmund_autoboot = NS_ENTER \
144+ + '/usr/bin/sigmund-configure --ip {0} --start --autoboot' \
145+ .format(opsvm_ip)
146+ try:
147+ status = subprocess.check_output(sigmund_status, shell=True)
148+ if 'start/running' in status:
149+ if subprocess.call(sigmund_stop, shell=True):
150+ log('plumgrid-sigmund couldn\'t be stopped!')
151+ return
152+ subprocess.check_call(sigmund_autoboot, shell=True)
153+ except:
154+ log('plumgrid-sigmund couldn\'t be started!')
155+
156+
157 def determine_packages():
158 '''
159 Returns list of packages required by PLUMgrid Edge as specified
160 in the neutron_plugins dictionary in charmhelpers.
161 '''
162 pkgs = []
163+ pkgs.extend(docker_dependencies())
164+ pkgs.append('docker-engine')
165 tag = 'latest'
166 for pkg in neutron_plugin_attribute('plumgrid', 'packages', 'neutron'):
167 if 'plumgrid' in pkg:
168@@ -111,6 +155,35 @@
169 return pkgs
170
171
172+def docker_dependencies():
173+ '''
174+ Returns a list of packages to be installed for docker engine
175+ '''
176+ kver = subprocess.check_output(['uname', '-r']).replace('\n', '')
177+ return ['apt-transport-https', 'ca-certificates', 'apparmor',
178+ 'linux-image-extra-{}'.format(kver)]
179+
180+
181+def docker_configure_sources():
182+ '''
183+ Imports GPG key and updates apt source for docker engine
184+ '''
185+ ubuntu_rel = lsb_release()['DISTRIB_CODENAME']
186+ DOCKER_SOURCE = ('deb https://apt.dockerproject.org/repo ubuntu-%s'
187+ ' main')
188+ log('Importing GPG Key for docker engine')
189+ _exec_cmd(['apt-key', 'adv', '--keyserver',
190+ 'hkp://p80.pool.sks-keyservers.net:80',
191+ '--recv-keys', '58118E89F3A912897C070ADBF76221572C52609D'])
192+ try:
193+ with open('/etc/apt/sources.list.d/docker.list', 'w') as f:
194+ f.write(DOCKER_SOURCE % ubuntu_rel)
195+ f.close()
196+ except:
197+ raise ValueError('Unable to update /etc/apt/sources.list.d/'
198+ 'docker.list')
199+
200+
201 def register_configs(release=None):
202 '''
203 Returns an object of the Openstack Tempating Class which contains the
204@@ -221,7 +294,9 @@
205 Returns the managment interface.
206 '''
207 mgmt_interface = config('mgmt-interface')
208- if interface_exists(mgmt_interface):
209+ if not mgmt_interface:
210+ return get_iface_from_addr(unit_get('private-address'))
211+ elif interface_exists(mgmt_interface):
212 return mgmt_interface
213 else:
214 log('Provided managment interface %s does not exist'
215@@ -265,11 +340,7 @@
216 else:
217 raise ValueError('No fabric interface provided for node')
218 if interface_exists(node_fabric_interface):
219- if is_address_in_network(config('os-data-network'),
220- get_iface_addr(node_fabric_interface)[0]):
221- return node_fabric_interface
222- else:
223- raise ValueError('Fabric interface not in fabric network')
224+ return node_fabric_interface
225 else:
226 log('Provided fabric interface %s does not exist'
227 % node_fabric_interface)
228
229=== modified file 'templates/kilo/00-pg.conf'
230--- templates/kilo/00-pg.conf 2016-04-06 16:43:20 +0000
231+++ templates/kilo/00-pg.conf 2016-08-29 12:04:58 +0000
232@@ -1,2 +1,3 @@
233 $template ls_json,"{{'{'}}{{'%'}}timestamp:::date-rfc3339,jsonf:@timestamp%,%source:::jsonf:@source_host%,%msg:::json%}"
234-:syslogtag,isequal,"pg:" @{{ opsvm_ip }}:6000;ls_json
235+if $syslogtag == 'pg:' and not ($msg contains 'dht_cli_') then @{{ opsvm_ip }}:6000;ls_json
236+:msg, contains, "VM Interface Stats" ~
237
238=== modified file 'templates/kilo/plumgrid.conf'
239--- templates/kilo/plumgrid.conf 2016-03-26 22:31:19 +0000
240+++ templates/kilo/plumgrid.conf 2016-08-29 12:04:58 +0000
241@@ -5,6 +5,9 @@
242 plumgrid_rsync_port=2222
243 plumgrid_rest_addr=0.0.0.0:9180
244 fabric_mode={{ fabric_mode }}
245+plumgrid_syslog_ng_ip={{ plumgrid_syslog_ng_ip }}
246+plumgrid_syslog_ng_port={{ plumgrid_syslog_ng_port }}
247+plumgrid_monitor_interval={{ plumgrid_monitor_interval }}
248 start_plumgrid_iovisor=yes
249 start_plumgrid=`/opt/pg/scripts/pg_is_director.sh $plumgrid_ip`
250 location=
251
252=== modified file 'unit_tests/test_pg_edge_hooks.py'
253--- unit_tests/test_pg_edge_hooks.py 2016-05-01 02:20:12 +0000
254+++ unit_tests/test_pg_edge_hooks.py 2016-08-29 12:04:58 +0000
255@@ -33,7 +33,8 @@
256 'relation_ids',
257 'load_iptables',
258 'director_cluster_ready',
259- 'status_set'
260+ 'status_set',
261+ 'docker_configure_sources'
262 ]
263 NEUTRON_CONF_DIR = "/etc/neutron"
264

Subscribers

People subscribed via source and target branches

to all changes: