Merge lp:~james-page/charms/trusty/neutron-openvswitch/16.01-resync into lp:~openstack-charmers-archive/charms/trusty/neutron-openvswitch/next

Proposed by James Page on 2016-01-26
Status: Merged
Merged at revision: 105
Proposed branch: lp:~james-page/charms/trusty/neutron-openvswitch/16.01-resync
Merge into: lp:~openstack-charmers-archive/charms/trusty/neutron-openvswitch/next
Diff against target: 476 lines (+127/-67)
6 files modified
hooks/charmhelpers/contrib/openstack/amulet/deployment.py (+2/-1)
hooks/charmhelpers/contrib/openstack/neutron.py (+14/-6)
hooks/charmhelpers/contrib/openstack/utils.py (+63/-30)
hooks/charmhelpers/core/host.py (+41/-26)
hooks/charmhelpers/fetch/giturl.py (+5/-3)
tests/charmhelpers/contrib/openstack/amulet/deployment.py (+2/-1)
To merge this branch: bzr merge lp:~james-page/charms/trusty/neutron-openvswitch/16.01-resync
Reviewer Review Type Date Requested Status
Liam Young 2016-01-26 Approve on 2016-01-26
Review via email: mp+283933@code.launchpad.net
To post a comment you must log in.
Liam Young (gnuoy) wrote :

Approved assuming osci is happy

review: Approve

charm_unit_test #16948 neutron-openvswitch-next for james-page mp283933
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/16948/

charm_lint_check #18189 neutron-openvswitch-next for james-page mp283933
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/18189/

charm_amulet_test #9064 neutron-openvswitch-next for james-page mp283933
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/14674425/
Build: http://10.245.162.77:8080/job/charm_amulet_test/9064/

charm_amulet_test #9066 neutron-openvswitch-next for james-page mp283933
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/14675971/
Build: http://10.245.162.77:8080/job/charm_amulet_test/9066/

charm_amulet_test #9096 neutron-openvswitch-next for james-page mp283933
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/9096/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/charmhelpers/contrib/openstack/amulet/deployment.py'
2--- hooks/charmhelpers/contrib/openstack/amulet/deployment.py 2016-01-08 13:11:21 +0000
3+++ hooks/charmhelpers/contrib/openstack/amulet/deployment.py 2016-01-26 12:00:08 +0000
4@@ -125,7 +125,8 @@
5
6 # Charms which can not use openstack-origin, ie. many subordinates
7 no_origin = ['cinder-ceph', 'hacluster', 'neutron-openvswitch', 'nrpe',
8- 'openvswitch-odl', 'neutron-api-odl', 'odl-controller']
9+ 'openvswitch-odl', 'neutron-api-odl', 'odl-controller',
10+ 'cinder-backup']
11
12 if self.openstack:
13 for svc in services:
14
15=== modified file 'hooks/charmhelpers/contrib/openstack/neutron.py'
16--- hooks/charmhelpers/contrib/openstack/neutron.py 2016-01-08 13:11:21 +0000
17+++ hooks/charmhelpers/contrib/openstack/neutron.py 2016-01-26 12:00:08 +0000
18@@ -50,7 +50,7 @@
19 if kernel_version() >= (3, 13):
20 return []
21 else:
22- return ['openvswitch-datapath-dkms']
23+ return [headers_package(), 'openvswitch-datapath-dkms']
24
25
26 # legacy
27@@ -70,7 +70,7 @@
28 relation_prefix='neutron',
29 ssl_dir=QUANTUM_CONF_DIR)],
30 'services': ['quantum-plugin-openvswitch-agent'],
31- 'packages': [[headers_package()] + determine_dkms_package(),
32+ 'packages': [determine_dkms_package(),
33 ['quantum-plugin-openvswitch-agent']],
34 'server_packages': ['quantum-server',
35 'quantum-plugin-openvswitch'],
36@@ -111,7 +111,7 @@
37 relation_prefix='neutron',
38 ssl_dir=NEUTRON_CONF_DIR)],
39 'services': ['neutron-plugin-openvswitch-agent'],
40- 'packages': [[headers_package()] + determine_dkms_package(),
41+ 'packages': [determine_dkms_package(),
42 ['neutron-plugin-openvswitch-agent']],
43 'server_packages': ['neutron-server',
44 'neutron-plugin-openvswitch'],
45@@ -155,7 +155,7 @@
46 relation_prefix='neutron',
47 ssl_dir=NEUTRON_CONF_DIR)],
48 'services': [],
49- 'packages': [[headers_package()] + determine_dkms_package(),
50+ 'packages': [determine_dkms_package(),
51 ['neutron-plugin-cisco']],
52 'server_packages': ['neutron-server',
53 'neutron-plugin-cisco'],
54@@ -174,7 +174,7 @@
55 'neutron-dhcp-agent',
56 'nova-api-metadata',
57 'etcd'],
58- 'packages': [[headers_package()] + determine_dkms_package(),
59+ 'packages': [determine_dkms_package(),
60 ['calico-compute',
61 'bird',
62 'neutron-dhcp-agent',
63@@ -219,7 +219,7 @@
64 relation_prefix='neutron',
65 ssl_dir=NEUTRON_CONF_DIR)],
66 'services': [],
67- 'packages': [[headers_package()] + determine_dkms_package()],
68+ 'packages': [determine_dkms_package()],
69 'server_packages': ['neutron-server',
70 'python-neutron-plugin-midonet'],
71 'server_services': ['neutron-server']
72@@ -233,6 +233,14 @@
73 'neutron-plugin-ml2']
74 # NOTE: patch in vmware renames nvp->nsx for icehouse onwards
75 plugins['nvp'] = plugins['nsx']
76+ if release >= 'kilo':
77+ plugins['midonet']['driver'] = (
78+ 'neutron.plugins.midonet.plugin.MidonetPluginV2')
79+ if release >= 'liberty':
80+ midonet_origin = config('midonet-origin')
81+ if midonet_origin is not None and midonet_origin[4:5] == '1':
82+ plugins['midonet']['driver'] = (
83+ 'midonet.neutron.plugin_v1.MidonetPluginV2')
84 return plugins
85
86
87
88=== modified file 'hooks/charmhelpers/contrib/openstack/utils.py'
89--- hooks/charmhelpers/contrib/openstack/utils.py 2016-01-08 21:04:45 +0000
90+++ hooks/charmhelpers/contrib/openstack/utils.py 2016-01-26 12:00:08 +0000
91@@ -103,29 +103,28 @@
92 ('2016.1', 'mitaka'),
93 ])
94
95-# The ugly duckling
96+# The ugly duckling - must list releases oldest to newest
97 SWIFT_CODENAMES = OrderedDict([
98- ('1.4.3', 'diablo'),
99- ('1.4.8', 'essex'),
100- ('1.7.4', 'folsom'),
101- ('1.8.0', 'grizzly'),
102- ('1.7.7', 'grizzly'),
103- ('1.7.6', 'grizzly'),
104- ('1.10.0', 'havana'),
105- ('1.9.1', 'havana'),
106- ('1.9.0', 'havana'),
107- ('1.13.1', 'icehouse'),
108- ('1.13.0', 'icehouse'),
109- ('1.12.0', 'icehouse'),
110- ('1.11.0', 'icehouse'),
111- ('2.0.0', 'juno'),
112- ('2.1.0', 'juno'),
113- ('2.2.0', 'juno'),
114- ('2.2.1', 'kilo'),
115- ('2.2.2', 'kilo'),
116- ('2.3.0', 'liberty'),
117- ('2.4.0', 'liberty'),
118- ('2.5.0', 'liberty'),
119+ ('diablo',
120+ ['1.4.3']),
121+ ('essex',
122+ ['1.4.8']),
123+ ('folsom',
124+ ['1.7.4']),
125+ ('grizzly',
126+ ['1.7.6', '1.7.7', '1.8.0']),
127+ ('havana',
128+ ['1.9.0', '1.9.1', '1.10.0']),
129+ ('icehouse',
130+ ['1.11.0', '1.12.0', '1.13.0', '1.13.1']),
131+ ('juno',
132+ ['2.0.0', '2.1.0', '2.2.0']),
133+ ('kilo',
134+ ['2.2.1', '2.2.2']),
135+ ('liberty',
136+ ['2.3.0', '2.4.0', '2.5.0']),
137+ ('mitaka',
138+ ['2.5.0']),
139 ])
140
141 # >= Liberty version->codename mapping
142@@ -227,6 +226,33 @@
143 error_out(e)
144
145
146+def get_os_version_codename_swift(codename):
147+ '''Determine OpenStack version number of swift from codename.'''
148+ for k, v in six.iteritems(SWIFT_CODENAMES):
149+ if k == codename:
150+ return v[-1]
151+ e = 'Could not derive swift version for '\
152+ 'codename: %s' % codename
153+ error_out(e)
154+
155+
156+def get_swift_codename(version):
157+ '''Determine OpenStack codename that corresponds to swift version.'''
158+ codenames = [k for k, v in six.iteritems(SWIFT_CODENAMES) if version in v]
159+ if len(codenames) > 1:
160+ # If more than one release codename contains this version we determine
161+ # the actual codename based on the highest available install source.
162+ for codename in reversed(codenames):
163+ releases = UBUNTU_OPENSTACK_RELEASE
164+ release = [k for k, v in six.iteritems(releases) if codename in v]
165+ ret = subprocess.check_output(['apt-cache', 'policy', 'swift'])
166+ if codename in ret or release[0] in ret:
167+ return codename
168+ elif len(codenames) == 1:
169+ return codenames[0]
170+ return None
171+
172+
173 def get_os_codename_package(package, fatal=True):
174 '''Derive OpenStack release codename from an installed package.'''
175 import apt_pkg as apt
176@@ -270,7 +296,7 @@
177 # < Liberty co-ordinated project versions
178 try:
179 if 'swift' in pkg.name:
180- return SWIFT_CODENAMES[vers]
181+ return get_swift_codename(vers)
182 else:
183 return OPENSTACK_CODENAMES[vers]
184 except KeyError:
185@@ -289,12 +315,14 @@
186
187 if 'swift' in pkg:
188 vers_map = SWIFT_CODENAMES
189+ for cname, version in six.iteritems(vers_map):
190+ if cname == codename:
191+ return version[-1]
192 else:
193 vers_map = OPENSTACK_CODENAMES
194-
195- for version, cname in six.iteritems(vers_map):
196- if cname == codename:
197- return version
198+ for version, cname in six.iteritems(vers_map):
199+ if cname == codename:
200+ return version
201 # e = "Could not determine OpenStack version for package: %s" % pkg
202 # error_out(e)
203
204@@ -460,11 +488,16 @@
205 cur_vers = get_os_version_package(package)
206 if "swift" in package:
207 codename = get_os_codename_install_source(src)
208- available_vers = get_os_version_codename(codename, SWIFT_CODENAMES)
209+ avail_vers = get_os_version_codename_swift(codename)
210 else:
211- available_vers = get_os_version_install_source(src)
212+ avail_vers = get_os_version_install_source(src)
213 apt.init()
214- return apt.version_compare(available_vers, cur_vers) == 1
215+ if "swift" in package:
216+ major_cur_vers = cur_vers.split('.', 1)[0]
217+ major_avail_vers = avail_vers.split('.', 1)[0]
218+ major_diff = apt.version_compare(major_avail_vers, major_cur_vers)
219+ return avail_vers > cur_vers and (major_diff == 1 or major_diff == 0)
220+ return apt.version_compare(avail_vers, cur_vers) == 1
221
222
223 def ensure_block_device(block_device):
224
225=== modified file 'hooks/charmhelpers/core/host.py'
226--- hooks/charmhelpers/core/host.py 2016-01-08 21:04:45 +0000
227+++ hooks/charmhelpers/core/host.py 2016-01-26 12:00:08 +0000
228@@ -138,7 +138,8 @@
229 except subprocess.CalledProcessError:
230 return False
231 else:
232- if ("start/running" in output or "is running" in output):
233+ if ("start/running" in output or "is running" in output or
234+ "up and running" in output):
235 return True
236 else:
237 return False
238@@ -160,13 +161,13 @@
239
240
241 def init_is_systemd():
242+ """Return True if the host system uses systemd, False otherwise."""
243 return os.path.isdir(SYSTEMD_SYSTEM)
244
245
246 def adduser(username, password=None, shell='/bin/bash', system_user=False,
247 primary_group=None, secondary_groups=None):
248- """
249- Add a user to the system.
250+ """Add a user to the system.
251
252 Will log but otherwise succeed if the user already exists.
253
254@@ -174,7 +175,7 @@
255 :param str password: Password for user; if ``None``, create a system user
256 :param str shell: The default shell for the user
257 :param bool system_user: Whether to create a login or system user
258- :param str primary_group: Primary group for user; defaults to their username
259+ :param str primary_group: Primary group for user; defaults to username
260 :param list secondary_groups: Optional list of additional groups
261
262 :returns: The password database entry struct, as returned by `pwd.getpwnam`
263@@ -300,14 +301,12 @@
264
265
266 def fstab_remove(mp):
267- """Remove the given mountpoint entry from /etc/fstab
268- """
269+ """Remove the given mountpoint entry from /etc/fstab"""
270 return Fstab.remove_by_mountpoint(mp)
271
272
273 def fstab_add(dev, mp, fs, options=None):
274- """Adds the given device entry to the /etc/fstab file
275- """
276+ """Adds the given device entry to the /etc/fstab file"""
277 return Fstab.add(dev, mp, fs, options=options)
278
279
280@@ -363,8 +362,7 @@
281
282
283 def file_hash(path, hash_type='md5'):
284- """
285- Generate a hash checksum of the contents of 'path' or None if not found.
286+ """Generate a hash checksum of the contents of 'path' or None if not found.
287
288 :param str hash_type: Any hash alrgorithm supported by :mod:`hashlib`,
289 such as md5, sha1, sha256, sha512, etc.
290@@ -379,10 +377,9 @@
291
292
293 def path_hash(path):
294- """
295- Generate a hash checksum of all files matching 'path'. Standard wildcards
296- like '*' and '?' are supported, see documentation for the 'glob' module for
297- more information.
298+ """Generate a hash checksum of all files matching 'path'. Standard
299+ wildcards like '*' and '?' are supported, see documentation for the 'glob'
300+ module for more information.
301
302 :return: dict: A { filename: hash } dictionary for all matched files.
303 Empty if none found.
304@@ -394,8 +391,7 @@
305
306
307 def check_hash(path, checksum, hash_type='md5'):
308- """
309- Validate a file using a cryptographic checksum.
310+ """Validate a file using a cryptographic checksum.
311
312 :param str checksum: Value of the checksum used to validate the file.
313 :param str hash_type: Hash algorithm used to generate `checksum`.
314@@ -410,6 +406,7 @@
315
316
317 class ChecksumError(ValueError):
318+ """A class derived from Value error to indicate the checksum failed."""
319 pass
320
321
322@@ -515,7 +512,7 @@
323
324
325 def list_nics(nic_type=None):
326- '''Return a list of nics of given type(s)'''
327+ """Return a list of nics of given type(s)"""
328 if isinstance(nic_type, six.string_types):
329 int_types = [nic_type]
330 else:
331@@ -557,12 +554,13 @@
332
333
334 def set_nic_mtu(nic, mtu):
335- '''Set MTU on a network interface'''
336+ """Set the Maximum Transmission Unit (MTU) on a network interface."""
337 cmd = ['ip', 'link', 'set', nic, 'mtu', mtu]
338 subprocess.check_call(cmd)
339
340
341 def get_nic_mtu(nic):
342+ """Return the Maximum Transmission Unit (MTU) for a network interface."""
343 cmd = ['ip', 'addr', 'show', nic]
344 ip_output = subprocess.check_output(cmd).decode('UTF-8').split('\n')
345 mtu = ""
346@@ -574,6 +572,7 @@
347
348
349 def get_nic_hwaddr(nic):
350+ """Return the Media Access Control (MAC) for a network interface."""
351 cmd = ['ip', '-o', '-0', 'addr', 'show', nic]
352 ip_output = subprocess.check_output(cmd).decode('UTF-8')
353 hwaddr = ""
354@@ -584,7 +583,7 @@
355
356
357 def cmp_pkgrevno(package, revno, pkgcache=None):
358- '''Compare supplied revno with the revno of the installed package
359+ """Compare supplied revno with the revno of the installed package
360
361 * 1 => Installed revno is greater than supplied arg
362 * 0 => Installed revno is the same as supplied arg
363@@ -593,7 +592,7 @@
364 This function imports apt_cache function from charmhelpers.fetch if
365 the pkgcache argument is None. Be sure to add charmhelpers.fetch if
366 you call this function, or pass an apt_pkg.Cache() instance.
367- '''
368+ """
369 import apt_pkg
370 if not pkgcache:
371 from charmhelpers.fetch import apt_cache
372@@ -603,19 +602,27 @@
373
374
375 @contextmanager
376-def chdir(d):
377+def chdir(directory):
378+ """Change the current working directory to a different directory for a code
379+ block and return the previous directory after the block exits. Useful to
380+ run commands from a specificed directory.
381+
382+ :param str directory: The directory path to change to for this context.
383+ """
384 cur = os.getcwd()
385 try:
386- yield os.chdir(d)
387+ yield os.chdir(directory)
388 finally:
389 os.chdir(cur)
390
391
392 def chownr(path, owner, group, follow_links=True, chowntopdir=False):
393- """
394- Recursively change user and group ownership of files and directories
395+ """Recursively change user and group ownership of files and directories
396 in given path. Doesn't chown path itself by default, only its children.
397
398+ :param str path: The string path to start changing ownership.
399+ :param str owner: The owner string to use when looking up the uid.
400+ :param str group: The group string to use when looking up the gid.
401 :param bool follow_links: Also Chown links if True
402 :param bool chowntopdir: Also chown path itself if True
403 """
404@@ -639,15 +646,23 @@
405
406
407 def lchownr(path, owner, group):
408+ """Recursively change user and group ownership of files and directories
409+ in a given path, not following symbolic links. See the documentation for
410+ 'os.lchown' for more information.
411+
412+ :param str path: The string path to start changing ownership.
413+ :param str owner: The owner string to use when looking up the uid.
414+ :param str group: The group string to use when looking up the gid.
415+ """
416 chownr(path, owner, group, follow_links=False)
417
418
419 def get_total_ram():
420- '''The total amount of system RAM in bytes.
421+ """The total amount of system RAM in bytes.
422
423 This is what is reported by the OS, and may be overcommitted when
424 there are multiple containers hosted on the same machine.
425- '''
426+ """
427 with open('/proc/meminfo', 'r') as f:
428 for line in f.readlines():
429 if line:
430
431=== modified file 'hooks/charmhelpers/fetch/giturl.py'
432--- hooks/charmhelpers/fetch/giturl.py 2016-01-08 21:04:45 +0000
433+++ hooks/charmhelpers/fetch/giturl.py 2016-01-26 12:00:08 +0000
434@@ -15,7 +15,7 @@
435 # along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
436
437 import os
438-from subprocess import check_call
439+from subprocess import check_call, CalledProcessError
440 from charmhelpers.fetch import (
441 BaseFetchHandler,
442 UnhandledSource,
443@@ -49,8 +49,8 @@
444 cmd = ['git', '-C', dest, 'pull', source, branch]
445 else:
446 cmd = ['git', 'clone', source, dest, '--branch', branch]
447- if depth:
448- cmd.extend(['--depth', depth])
449+ if depth:
450+ cmd.extend(['--depth', depth])
451 check_call(cmd)
452
453 def install(self, source, branch="master", dest=None, depth=None):
454@@ -63,6 +63,8 @@
455 branch_name)
456 try:
457 self.clone(source, dest_dir, branch, depth)
458+ except CalledProcessError as e:
459+ raise UnhandledSource(e)
460 except OSError as e:
461 raise UnhandledSource(e.strerror)
462 return dest_dir
463
464=== modified file 'tests/charmhelpers/contrib/openstack/amulet/deployment.py'
465--- tests/charmhelpers/contrib/openstack/amulet/deployment.py 2016-01-08 13:11:21 +0000
466+++ tests/charmhelpers/contrib/openstack/amulet/deployment.py 2016-01-26 12:00:08 +0000
467@@ -125,7 +125,8 @@
468
469 # Charms which can not use openstack-origin, ie. many subordinates
470 no_origin = ['cinder-ceph', 'hacluster', 'neutron-openvswitch', 'nrpe',
471- 'openvswitch-odl', 'neutron-api-odl', 'odl-controller']
472+ 'openvswitch-odl', 'neutron-api-odl', 'odl-controller',
473+ 'cinder-backup']
474
475 if self.openstack:
476 for svc in services:

Subscribers

People subscribed via source and target branches