Merge lp:~gnuoy/charms/trusty/openstack-dashboard/stable-charmhelper-sync into lp:~openstack-charmers-archive/charms/trusty/openstack-dashboard/trunk

Proposed by Liam Young
Status: Merged
Approved by: Chris Glass
Approved revision: 33
Merged at revision: 33
Proposed branch: lp:~gnuoy/charms/trusty/openstack-dashboard/stable-charmhelper-sync
Merge into: lp:~openstack-charmers-archive/charms/trusty/openstack-dashboard/trunk
Diff against target: 84 lines (+16/-22)
3 files modified
hooks/charmhelpers/contrib/openstack/utils.py (+3/-8)
hooks/charmhelpers/core/host.py (+2/-6)
hooks/charmhelpers/fetch/__init__.py (+11/-8)
To merge this branch: bzr merge lp:~gnuoy/charms/trusty/openstack-dashboard/stable-charmhelper-sync
Reviewer Review Type Date Requested Status
Chris Glass (community) Approve
Review via email: mp+232358@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Chris Glass (tribaal) wrote :

+1

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/utils.py'
--- hooks/charmhelpers/contrib/openstack/utils.py 2014-05-19 11:42:57 +0000
+++ hooks/charmhelpers/contrib/openstack/utils.py 2014-08-27 07:23:31 +0000
@@ -24,7 +24,7 @@
24)24)
2525
26from charmhelpers.core.host import lsb_release, mounts, umount26from charmhelpers.core.host import lsb_release, mounts, umount
27from charmhelpers.fetch import apt_install27from charmhelpers.fetch import apt_install, apt_cache
28from charmhelpers.contrib.storage.linux.utils import is_block_device, zap_disk28from charmhelpers.contrib.storage.linux.utils import is_block_device, zap_disk
29from charmhelpers.contrib.storage.linux.loopback import ensure_loopback_device29from charmhelpers.contrib.storage.linux.loopback import ensure_loopback_device
3030
@@ -130,13 +130,8 @@
130130
131def get_os_codename_package(package, fatal=True):131def get_os_codename_package(package, fatal=True):
132 '''Derive OpenStack release codename from an installed package.'''132 '''Derive OpenStack release codename from an installed package.'''
133 apt.init()133
134134 cache = apt_cache()
135 # Tell apt to build an in-memory cache to prevent race conditions (if
136 # another process is already building the cache).
137 apt.config.set("Dir::Cache::pkgcache", "")
138
139 cache = apt.Cache()
140135
141 try:136 try:
142 pkg = cache[package]137 pkg = cache[package]
143138
=== modified file 'hooks/charmhelpers/core/host.py'
--- hooks/charmhelpers/core/host.py 2014-08-13 15:55:59 +0000
+++ hooks/charmhelpers/core/host.py 2014-08-27 07:23:31 +0000
@@ -318,12 +318,8 @@
318 0 => Installed revno is the same as supplied arg318 0 => Installed revno is the same as supplied arg
319 -1 => Installed revno is less than supplied arg319 -1 => Installed revno is less than supplied arg
320 '''320 '''
321 from charmhelpers.fetch import apt_cache
321 if not pkgcache:322 if not pkgcache:
322 apt_pkg.init()323 pkgcache = apt_cache()
323 # Force Apt to build its cache in memory. That way we avoid race
324 # conditions with other applications building the cache in the same
325 # place.
326 apt_pkg.config.set("Dir::Cache::pkgcache", "")
327 pkgcache = apt_pkg.Cache()
328 pkg = pkgcache[package]324 pkg = pkgcache[package]
329 return apt_pkg.version_compare(pkg.current_ver.ver_str, revno)325 return apt_pkg.version_compare(pkg.current_ver.ver_str, revno)
330326
=== modified file 'hooks/charmhelpers/fetch/__init__.py'
--- hooks/charmhelpers/fetch/__init__.py 2014-08-13 15:55:59 +0000
+++ hooks/charmhelpers/fetch/__init__.py 2014-08-27 07:23:31 +0000
@@ -108,14 +108,8 @@
108108
109def filter_installed_packages(packages):109def filter_installed_packages(packages):
110 """Returns a list of packages that require installation"""110 """Returns a list of packages that require installation"""
111 apt_pkg.init()111
112112 cache = apt_cache()
113 # Tell apt to build an in-memory cache to prevent race conditions (if
114 # another process is already building the cache).
115 apt_pkg.config.set("Dir::Cache::pkgcache", "")
116 apt_pkg.config.set("Dir::Cache::srcpkgcache", "")
117
118 cache = apt_pkg.Cache()
119 _pkgs = []113 _pkgs = []
120 for package in packages:114 for package in packages:
121 try:115 try:
@@ -128,6 +122,15 @@
128 return _pkgs122 return _pkgs
129123
130124
125def apt_cache(in_memory=True):
126 """Build and return an apt cache"""
127 apt_pkg.init()
128 if in_memory:
129 apt_pkg.config.set("Dir::Cache::pkgcache", "")
130 apt_pkg.config.set("Dir::Cache::srcpkgcache", "")
131 return apt_pkg.Cache()
132
133
131def apt_install(packages, options=None, fatal=False):134def apt_install(packages, options=None, fatal=False):
132 """Install one or more packages"""135 """Install one or more packages"""
133 if options is None:136 if options is None:

Subscribers

People subscribed via source and target branches