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

Proposed by James Page
Status: Merged
Merged at revision: 108
Proposed branch: lp:~james-page/charms/trusty/neutron-openvswitch/optmize-headers
Merge into: lp:~openstack-charmers-archive/charms/trusty/neutron-openvswitch/next
Diff against target: 433 lines (+114/-65)
6 files modified
hooks/charmhelpers/contrib/openstack/amulet/deployment.py (+2/-1)
hooks/charmhelpers/contrib/openstack/neutron.py (+6/-6)
hooks/charmhelpers/contrib/openstack/utils.py (+63/-30)
hooks/charmhelpers/core/host.py (+39/-25)
hooks/charmhelpers/fetch/giturl.py (+2/-2)
tests/charmhelpers/contrib/openstack/amulet/deployment.py (+2/-1)
To merge this branch: bzr merge lp:~james-page/charms/trusty/neutron-openvswitch/optmize-headers
Reviewer Review Type Date Requested Status
Liam Young Approve
Review via email: mp+282931@code.launchpad.net
To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #17573 neutron-openvswitch-next for james-page mp282931
    LINT OK: passed

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

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #16418 neutron-openvswitch-next for james-page mp282931
    UNIT OK: passed

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

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #8880 neutron-openvswitch-next for james-page mp282931
    AMULET OK: passed

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

Revision history for this message
Liam Young (gnuoy) wrote :

Approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/charmhelpers/contrib/openstack/amulet/deployment.py'
--- hooks/charmhelpers/contrib/openstack/amulet/deployment.py 2016-01-08 13:11:21 +0000
+++ hooks/charmhelpers/contrib/openstack/amulet/deployment.py 2016-01-18 12:00:43 +0000
@@ -125,7 +125,8 @@
125125
126 # Charms which can not use openstack-origin, ie. many subordinates126 # Charms which can not use openstack-origin, ie. many subordinates
127 no_origin = ['cinder-ceph', 'hacluster', 'neutron-openvswitch', 'nrpe',127 no_origin = ['cinder-ceph', 'hacluster', 'neutron-openvswitch', 'nrpe',
128 'openvswitch-odl', 'neutron-api-odl', 'odl-controller']128 'openvswitch-odl', 'neutron-api-odl', 'odl-controller',
129 'cinder-backup']
129130
130 if self.openstack:131 if self.openstack:
131 for svc in services:132 for svc in services:
132133
=== modified file 'hooks/charmhelpers/contrib/openstack/neutron.py'
--- hooks/charmhelpers/contrib/openstack/neutron.py 2016-01-08 13:11:21 +0000
+++ hooks/charmhelpers/contrib/openstack/neutron.py 2016-01-18 12:00:43 +0000
@@ -50,7 +50,7 @@
50 if kernel_version() >= (3, 13):50 if kernel_version() >= (3, 13):
51 return []51 return []
52 else:52 else:
53 return ['openvswitch-datapath-dkms']53 return [headers_package(), 'openvswitch-datapath-dkms']
5454
5555
56# legacy56# legacy
@@ -70,7 +70,7 @@
70 relation_prefix='neutron',70 relation_prefix='neutron',
71 ssl_dir=QUANTUM_CONF_DIR)],71 ssl_dir=QUANTUM_CONF_DIR)],
72 'services': ['quantum-plugin-openvswitch-agent'],72 'services': ['quantum-plugin-openvswitch-agent'],
73 'packages': [[headers_package()] + determine_dkms_package(),73 'packages': [determine_dkms_package(),
74 ['quantum-plugin-openvswitch-agent']],74 ['quantum-plugin-openvswitch-agent']],
75 'server_packages': ['quantum-server',75 'server_packages': ['quantum-server',
76 'quantum-plugin-openvswitch'],76 'quantum-plugin-openvswitch'],
@@ -111,7 +111,7 @@
111 relation_prefix='neutron',111 relation_prefix='neutron',
112 ssl_dir=NEUTRON_CONF_DIR)],112 ssl_dir=NEUTRON_CONF_DIR)],
113 'services': ['neutron-plugin-openvswitch-agent'],113 'services': ['neutron-plugin-openvswitch-agent'],
114 'packages': [[headers_package()] + determine_dkms_package(),114 'packages': [determine_dkms_package(),
115 ['neutron-plugin-openvswitch-agent']],115 ['neutron-plugin-openvswitch-agent']],
116 'server_packages': ['neutron-server',116 'server_packages': ['neutron-server',
117 'neutron-plugin-openvswitch'],117 'neutron-plugin-openvswitch'],
@@ -155,7 +155,7 @@
155 relation_prefix='neutron',155 relation_prefix='neutron',
156 ssl_dir=NEUTRON_CONF_DIR)],156 ssl_dir=NEUTRON_CONF_DIR)],
157 'services': [],157 'services': [],
158 'packages': [[headers_package()] + determine_dkms_package(),158 'packages': [determine_dkms_package(),
159 ['neutron-plugin-cisco']],159 ['neutron-plugin-cisco']],
160 'server_packages': ['neutron-server',160 'server_packages': ['neutron-server',
161 'neutron-plugin-cisco'],161 'neutron-plugin-cisco'],
@@ -174,7 +174,7 @@
174 'neutron-dhcp-agent',174 'neutron-dhcp-agent',
175 'nova-api-metadata',175 'nova-api-metadata',
176 'etcd'],176 'etcd'],
177 'packages': [[headers_package()] + determine_dkms_package(),177 'packages': [determine_dkms_package(),
178 ['calico-compute',178 ['calico-compute',
179 'bird',179 'bird',
180 'neutron-dhcp-agent',180 'neutron-dhcp-agent',
@@ -219,7 +219,7 @@
219 relation_prefix='neutron',219 relation_prefix='neutron',
220 ssl_dir=NEUTRON_CONF_DIR)],220 ssl_dir=NEUTRON_CONF_DIR)],
221 'services': [],221 'services': [],
222 'packages': [[headers_package()] + determine_dkms_package()],222 'packages': [determine_dkms_package()],
223 'server_packages': ['neutron-server',223 'server_packages': ['neutron-server',
224 'python-neutron-plugin-midonet'],224 'python-neutron-plugin-midonet'],
225 'server_services': ['neutron-server']225 'server_services': ['neutron-server']
226226
=== modified file 'hooks/charmhelpers/contrib/openstack/utils.py'
--- hooks/charmhelpers/contrib/openstack/utils.py 2016-01-08 21:04:45 +0000
+++ hooks/charmhelpers/contrib/openstack/utils.py 2016-01-18 12:00:43 +0000
@@ -103,29 +103,28 @@
103 ('2016.1', 'mitaka'),103 ('2016.1', 'mitaka'),
104])104])
105105
106# The ugly duckling106# The ugly duckling - must list releases oldest to newest
107SWIFT_CODENAMES = OrderedDict([107SWIFT_CODENAMES = OrderedDict([
108 ('1.4.3', 'diablo'),108 ('diablo',
109 ('1.4.8', 'essex'),109 ['1.4.3']),
110 ('1.7.4', 'folsom'),110 ('essex',
111 ('1.8.0', 'grizzly'),111 ['1.4.8']),
112 ('1.7.7', 'grizzly'),112 ('folsom',
113 ('1.7.6', 'grizzly'),113 ['1.7.4']),
114 ('1.10.0', 'havana'),114 ('grizzly',
115 ('1.9.1', 'havana'),115 ['1.7.6', '1.7.7', '1.8.0']),
116 ('1.9.0', 'havana'),116 ('havana',
117 ('1.13.1', 'icehouse'),117 ['1.9.0', '1.9.1', '1.10.0']),
118 ('1.13.0', 'icehouse'),118 ('icehouse',
119 ('1.12.0', 'icehouse'),119 ['1.11.0', '1.12.0', '1.13.0', '1.13.1']),
120 ('1.11.0', 'icehouse'),120 ('juno',
121 ('2.0.0', 'juno'),121 ['2.0.0', '2.1.0', '2.2.0']),
122 ('2.1.0', 'juno'),122 ('kilo',
123 ('2.2.0', 'juno'),123 ['2.2.1', '2.2.2']),
124 ('2.2.1', 'kilo'),124 ('liberty',
125 ('2.2.2', 'kilo'),125 ['2.3.0', '2.4.0', '2.5.0']),
126 ('2.3.0', 'liberty'),126 ('mitaka',
127 ('2.4.0', 'liberty'),127 ['2.5.0']),
128 ('2.5.0', 'liberty'),
129])128])
130129
131# >= Liberty version->codename mapping130# >= Liberty version->codename mapping
@@ -227,6 +226,33 @@
227 error_out(e)226 error_out(e)
228227
229228
229def get_os_version_codename_swift(codename):
230 '''Determine OpenStack version number of swift from codename.'''
231 for k, v in six.iteritems(SWIFT_CODENAMES):
232 if k == codename:
233 return v[-1]
234 e = 'Could not derive swift version for '\
235 'codename: %s' % codename
236 error_out(e)
237
238
239def get_swift_codename(version):
240 '''Determine OpenStack codename that corresponds to swift version.'''
241 codenames = [k for k, v in six.iteritems(SWIFT_CODENAMES) if version in v]
242 if len(codenames) > 1:
243 # If more than one release codename contains this version we determine
244 # the actual codename based on the highest available install source.
245 for codename in reversed(codenames):
246 releases = UBUNTU_OPENSTACK_RELEASE
247 release = [k for k, v in six.iteritems(releases) if codename in v]
248 ret = subprocess.check_output(['apt-cache', 'policy', 'swift'])
249 if codename in ret or release[0] in ret:
250 return codename
251 elif len(codenames) == 1:
252 return codenames[0]
253 return None
254
255
230def get_os_codename_package(package, fatal=True):256def get_os_codename_package(package, fatal=True):
231 '''Derive OpenStack release codename from an installed package.'''257 '''Derive OpenStack release codename from an installed package.'''
232 import apt_pkg as apt258 import apt_pkg as apt
@@ -270,7 +296,7 @@
270 # < Liberty co-ordinated project versions296 # < Liberty co-ordinated project versions
271 try:297 try:
272 if 'swift' in pkg.name:298 if 'swift' in pkg.name:
273 return SWIFT_CODENAMES[vers]299 return get_swift_codename(vers)
274 else:300 else:
275 return OPENSTACK_CODENAMES[vers]301 return OPENSTACK_CODENAMES[vers]
276 except KeyError:302 except KeyError:
@@ -289,12 +315,14 @@
289315
290 if 'swift' in pkg:316 if 'swift' in pkg:
291 vers_map = SWIFT_CODENAMES317 vers_map = SWIFT_CODENAMES
318 for cname, version in six.iteritems(vers_map):
319 if cname == codename:
320 return version[-1]
292 else:321 else:
293 vers_map = OPENSTACK_CODENAMES322 vers_map = OPENSTACK_CODENAMES
294323 for version, cname in six.iteritems(vers_map):
295 for version, cname in six.iteritems(vers_map):324 if cname == codename:
296 if cname == codename:325 return version
297 return version
298 # e = "Could not determine OpenStack version for package: %s" % pkg326 # e = "Could not determine OpenStack version for package: %s" % pkg
299 # error_out(e)327 # error_out(e)
300328
@@ -460,11 +488,16 @@
460 cur_vers = get_os_version_package(package)488 cur_vers = get_os_version_package(package)
461 if "swift" in package:489 if "swift" in package:
462 codename = get_os_codename_install_source(src)490 codename = get_os_codename_install_source(src)
463 available_vers = get_os_version_codename(codename, SWIFT_CODENAMES)491 avail_vers = get_os_version_codename_swift(codename)
464 else:492 else:
465 available_vers = get_os_version_install_source(src)493 avail_vers = get_os_version_install_source(src)
466 apt.init()494 apt.init()
467 return apt.version_compare(available_vers, cur_vers) == 1495 if "swift" in package:
496 major_cur_vers = cur_vers.split('.', 1)[0]
497 major_avail_vers = avail_vers.split('.', 1)[0]
498 major_diff = apt.version_compare(major_avail_vers, major_cur_vers)
499 return avail_vers > cur_vers and (major_diff == 1 or major_diff == 0)
500 return apt.version_compare(avail_vers, cur_vers) == 1
468501
469502
470def ensure_block_device(block_device):503def ensure_block_device(block_device):
471504
=== modified file 'hooks/charmhelpers/core/host.py'
--- hooks/charmhelpers/core/host.py 2016-01-08 21:04:45 +0000
+++ hooks/charmhelpers/core/host.py 2016-01-18 12:00:43 +0000
@@ -160,13 +160,13 @@
160160
161161
162def init_is_systemd():162def init_is_systemd():
163 """Return True if the host system uses systemd, False otherwise."""
163 return os.path.isdir(SYSTEMD_SYSTEM)164 return os.path.isdir(SYSTEMD_SYSTEM)
164165
165166
166def adduser(username, password=None, shell='/bin/bash', system_user=False,167def adduser(username, password=None, shell='/bin/bash', system_user=False,
167 primary_group=None, secondary_groups=None):168 primary_group=None, secondary_groups=None):
168 """169 """Add a user to the system.
169 Add a user to the system.
170170
171 Will log but otherwise succeed if the user already exists.171 Will log but otherwise succeed if the user already exists.
172172
@@ -174,7 +174,7 @@
174 :param str password: Password for user; if ``None``, create a system user174 :param str password: Password for user; if ``None``, create a system user
175 :param str shell: The default shell for the user175 :param str shell: The default shell for the user
176 :param bool system_user: Whether to create a login or system user176 :param bool system_user: Whether to create a login or system user
177 :param str primary_group: Primary group for user; defaults to their username177 :param str primary_group: Primary group for user; defaults to username
178 :param list secondary_groups: Optional list of additional groups178 :param list secondary_groups: Optional list of additional groups
179179
180 :returns: The password database entry struct, as returned by `pwd.getpwnam`180 :returns: The password database entry struct, as returned by `pwd.getpwnam`
@@ -300,14 +300,12 @@
300300
301301
302def fstab_remove(mp):302def fstab_remove(mp):
303 """Remove the given mountpoint entry from /etc/fstab303 """Remove the given mountpoint entry from /etc/fstab"""
304 """
305 return Fstab.remove_by_mountpoint(mp)304 return Fstab.remove_by_mountpoint(mp)
306305
307306
308def fstab_add(dev, mp, fs, options=None):307def fstab_add(dev, mp, fs, options=None):
309 """Adds the given device entry to the /etc/fstab file308 """Adds the given device entry to the /etc/fstab file"""
310 """
311 return Fstab.add(dev, mp, fs, options=options)309 return Fstab.add(dev, mp, fs, options=options)
312310
313311
@@ -363,8 +361,7 @@
363361
364362
365def file_hash(path, hash_type='md5'):363def file_hash(path, hash_type='md5'):
366 """364 """Generate a hash checksum of the contents of 'path' or None if not found.
367 Generate a hash checksum of the contents of 'path' or None if not found.
368365
369 :param str hash_type: Any hash alrgorithm supported by :mod:`hashlib`,366 :param str hash_type: Any hash alrgorithm supported by :mod:`hashlib`,
370 such as md5, sha1, sha256, sha512, etc.367 such as md5, sha1, sha256, sha512, etc.
@@ -379,10 +376,9 @@
379376
380377
381def path_hash(path):378def path_hash(path):
382 """379 """Generate a hash checksum of all files matching 'path'. Standard
383 Generate a hash checksum of all files matching 'path'. Standard wildcards380 wildcards like '*' and '?' are supported, see documentation for the 'glob'
384 like '*' and '?' are supported, see documentation for the 'glob' module for381 module for more information.
385 more information.
386382
387 :return: dict: A { filename: hash } dictionary for all matched files.383 :return: dict: A { filename: hash } dictionary for all matched files.
388 Empty if none found.384 Empty if none found.
@@ -394,8 +390,7 @@
394390
395391
396def check_hash(path, checksum, hash_type='md5'):392def check_hash(path, checksum, hash_type='md5'):
397 """393 """Validate a file using a cryptographic checksum.
398 Validate a file using a cryptographic checksum.
399394
400 :param str checksum: Value of the checksum used to validate the file.395 :param str checksum: Value of the checksum used to validate the file.
401 :param str hash_type: Hash algorithm used to generate `checksum`.396 :param str hash_type: Hash algorithm used to generate `checksum`.
@@ -410,6 +405,7 @@
410405
411406
412class ChecksumError(ValueError):407class ChecksumError(ValueError):
408 """A class derived from Value error to indicate the checksum failed."""
413 pass409 pass
414410
415411
@@ -515,7 +511,7 @@
515511
516512
517def list_nics(nic_type=None):513def list_nics(nic_type=None):
518 '''Return a list of nics of given type(s)'''514 """Return a list of nics of given type(s)"""
519 if isinstance(nic_type, six.string_types):515 if isinstance(nic_type, six.string_types):
520 int_types = [nic_type]516 int_types = [nic_type]
521 else:517 else:
@@ -557,12 +553,13 @@
557553
558554
559def set_nic_mtu(nic, mtu):555def set_nic_mtu(nic, mtu):
560 '''Set MTU on a network interface'''556 """Set the Maximum Transmission Unit (MTU) on a network interface."""
561 cmd = ['ip', 'link', 'set', nic, 'mtu', mtu]557 cmd = ['ip', 'link', 'set', nic, 'mtu', mtu]
562 subprocess.check_call(cmd)558 subprocess.check_call(cmd)
563559
564560
565def get_nic_mtu(nic):561def get_nic_mtu(nic):
562 """Return the Maximum Transmission Unit (MTU) for a network interface."""
566 cmd = ['ip', 'addr', 'show', nic]563 cmd = ['ip', 'addr', 'show', nic]
567 ip_output = subprocess.check_output(cmd).decode('UTF-8').split('\n')564 ip_output = subprocess.check_output(cmd).decode('UTF-8').split('\n')
568 mtu = ""565 mtu = ""
@@ -574,6 +571,7 @@
574571
575572
576def get_nic_hwaddr(nic):573def get_nic_hwaddr(nic):
574 """Return the Media Access Control (MAC) for a network interface."""
577 cmd = ['ip', '-o', '-0', 'addr', 'show', nic]575 cmd = ['ip', '-o', '-0', 'addr', 'show', nic]
578 ip_output = subprocess.check_output(cmd).decode('UTF-8')576 ip_output = subprocess.check_output(cmd).decode('UTF-8')
579 hwaddr = ""577 hwaddr = ""
@@ -584,7 +582,7 @@
584582
585583
586def cmp_pkgrevno(package, revno, pkgcache=None):584def cmp_pkgrevno(package, revno, pkgcache=None):
587 '''Compare supplied revno with the revno of the installed package585 """Compare supplied revno with the revno of the installed package
588586
589 * 1 => Installed revno is greater than supplied arg587 * 1 => Installed revno is greater than supplied arg
590 * 0 => Installed revno is the same as supplied arg588 * 0 => Installed revno is the same as supplied arg
@@ -593,7 +591,7 @@
593 This function imports apt_cache function from charmhelpers.fetch if591 This function imports apt_cache function from charmhelpers.fetch if
594 the pkgcache argument is None. Be sure to add charmhelpers.fetch if592 the pkgcache argument is None. Be sure to add charmhelpers.fetch if
595 you call this function, or pass an apt_pkg.Cache() instance.593 you call this function, or pass an apt_pkg.Cache() instance.
596 '''594 """
597 import apt_pkg595 import apt_pkg
598 if not pkgcache:596 if not pkgcache:
599 from charmhelpers.fetch import apt_cache597 from charmhelpers.fetch import apt_cache
@@ -603,19 +601,27 @@
603601
604602
605@contextmanager603@contextmanager
606def chdir(d):604def chdir(directory):
605 """Change the current working directory to a different directory for a code
606 block and return the previous directory after the block exits. Useful to
607 run commands from a specificed directory.
608
609 :param str directory: The directory path to change to for this context.
610 """
607 cur = os.getcwd()611 cur = os.getcwd()
608 try:612 try:
609 yield os.chdir(d)613 yield os.chdir(directory)
610 finally:614 finally:
611 os.chdir(cur)615 os.chdir(cur)
612616
613617
614def chownr(path, owner, group, follow_links=True, chowntopdir=False):618def chownr(path, owner, group, follow_links=True, chowntopdir=False):
615 """619 """Recursively change user and group ownership of files and directories
616 Recursively change user and group ownership of files and directories
617 in given path. Doesn't chown path itself by default, only its children.620 in given path. Doesn't chown path itself by default, only its children.
618621
622 :param str path: The string path to start changing ownership.
623 :param str owner: The owner string to use when looking up the uid.
624 :param str group: The group string to use when looking up the gid.
619 :param bool follow_links: Also Chown links if True625 :param bool follow_links: Also Chown links if True
620 :param bool chowntopdir: Also chown path itself if True626 :param bool chowntopdir: Also chown path itself if True
621 """627 """
@@ -639,15 +645,23 @@
639645
640646
641def lchownr(path, owner, group):647def lchownr(path, owner, group):
648 """Recursively change user and group ownership of files and directories
649 in a given path, not following symbolic links. See the documentation for
650 'os.lchown' for more information.
651
652 :param str path: The string path to start changing ownership.
653 :param str owner: The owner string to use when looking up the uid.
654 :param str group: The group string to use when looking up the gid.
655 """
642 chownr(path, owner, group, follow_links=False)656 chownr(path, owner, group, follow_links=False)
643657
644658
645def get_total_ram():659def get_total_ram():
646 '''The total amount of system RAM in bytes.660 """The total amount of system RAM in bytes.
647661
648 This is what is reported by the OS, and may be overcommitted when662 This is what is reported by the OS, and may be overcommitted when
649 there are multiple containers hosted on the same machine.663 there are multiple containers hosted on the same machine.
650 '''664 """
651 with open('/proc/meminfo', 'r') as f:665 with open('/proc/meminfo', 'r') as f:
652 for line in f.readlines():666 for line in f.readlines():
653 if line:667 if line:
654668
=== modified file 'hooks/charmhelpers/fetch/giturl.py'
--- hooks/charmhelpers/fetch/giturl.py 2016-01-08 21:04:45 +0000
+++ hooks/charmhelpers/fetch/giturl.py 2016-01-18 12:00:43 +0000
@@ -49,8 +49,8 @@
49 cmd = ['git', '-C', dest, 'pull', source, branch]49 cmd = ['git', '-C', dest, 'pull', source, branch]
50 else:50 else:
51 cmd = ['git', 'clone', source, dest, '--branch', branch]51 cmd = ['git', 'clone', source, dest, '--branch', branch]
52 if depth:52 if depth:
53 cmd.extend(['--depth', depth])53 cmd.extend(['--depth', depth])
54 check_call(cmd)54 check_call(cmd)
5555
56 def install(self, source, branch="master", dest=None, depth=None):56 def install(self, source, branch="master", dest=None, depth=None):
5757
=== modified file 'tests/charmhelpers/contrib/openstack/amulet/deployment.py'
--- tests/charmhelpers/contrib/openstack/amulet/deployment.py 2016-01-08 13:11:21 +0000
+++ tests/charmhelpers/contrib/openstack/amulet/deployment.py 2016-01-18 12:00:43 +0000
@@ -125,7 +125,8 @@
125125
126 # Charms which can not use openstack-origin, ie. many subordinates126 # Charms which can not use openstack-origin, ie. many subordinates
127 no_origin = ['cinder-ceph', 'hacluster', 'neutron-openvswitch', 'nrpe',127 no_origin = ['cinder-ceph', 'hacluster', 'neutron-openvswitch', 'nrpe',
128 'openvswitch-odl', 'neutron-api-odl', 'odl-controller']128 'openvswitch-odl', 'neutron-api-odl', 'odl-controller',
129 'cinder-backup']
129130
130 if self.openstack:131 if self.openstack:
131 for svc in services:132 for svc in services:

Subscribers

People subscribed via source and target branches