summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris MacNaughton <chris.macnaughton@canonical.com>2018-07-13 15:51:48 +0200
committerChris MacNaughton <chris.macnaughton@canonical.com>2018-07-13 15:51:58 +0200
commit43d868dc21d4a29127578e3b9f96d365a684ce43 (patch)
treecde7ba8eb3661880b53ca207e5a552475058adbd
parent4801d10da3b57a2db768d11b8bbfd7353886380b (diff)
Sync charm-helpers to ensure Rocky support
Notes
Notes (review): Verified+1: Canonical CI <uosci-testing-bot@ubuntu.com> Code-Review+2: Frode Nordahl <frode.nordahl@canonical.com> Workflow+1: Frode Nordahl <frode.nordahl@canonical.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Mon, 16 Jul 2018 07:03:08 +0000 Reviewed-on: https://review.openstack.org/582553 Project: openstack/charm-ceph-osd Branch: refs/heads/master
-rw-r--r--hooks/charmhelpers/contrib/charmsupport/nrpe.py15
-rw-r--r--hooks/charmhelpers/core/host.py14
-rw-r--r--hooks/charmhelpers/fetch/ubuntu.py2
-rw-r--r--tests/charmhelpers/core/host.py14
4 files changed, 39 insertions, 6 deletions
diff --git a/hooks/charmhelpers/contrib/charmsupport/nrpe.py b/hooks/charmhelpers/contrib/charmsupport/nrpe.py
index 1c55b30..e3d10c1 100644
--- a/hooks/charmhelpers/contrib/charmsupport/nrpe.py
+++ b/hooks/charmhelpers/contrib/charmsupport/nrpe.py
@@ -410,16 +410,21 @@ def add_init_service_checks(nrpe, services, unit_name, immediate_check=True):
410 os.chmod(checkpath, 0o644) 410 os.chmod(checkpath, 0o644)
411 411
412 412
413def copy_nrpe_checks(): 413def copy_nrpe_checks(nrpe_files_dir=None):
414 """ 414 """
415 Copy the nrpe checks into place 415 Copy the nrpe checks into place
416 416
417 """ 417 """
418 NAGIOS_PLUGINS = '/usr/local/lib/nagios/plugins' 418 NAGIOS_PLUGINS = '/usr/local/lib/nagios/plugins'
419 nrpe_files_dir = os.path.join(os.getenv('CHARM_DIR'), 'hooks', 419 default_nrpe_files_dir = os.path.join(
420 'charmhelpers', 'contrib', 'openstack', 420 os.getenv('CHARM_DIR'),
421 'files') 421 'hooks',
422 422 'charmhelpers',
423 'contrib',
424 'openstack',
425 'files')
426 if not nrpe_files_dir:
427 nrpe_files_dir = default_nrpe_files_dir
423 if not os.path.exists(NAGIOS_PLUGINS): 428 if not os.path.exists(NAGIOS_PLUGINS):
424 os.makedirs(NAGIOS_PLUGINS) 429 os.makedirs(NAGIOS_PLUGINS)
425 for fname in glob.glob(os.path.join(nrpe_files_dir, "check_*")): 430 for fname in glob.glob(os.path.join(nrpe_files_dir, "check_*")):
diff --git a/hooks/charmhelpers/core/host.py b/hooks/charmhelpers/core/host.py
index 322ab2a..e9fd38a 100644
--- a/hooks/charmhelpers/core/host.py
+++ b/hooks/charmhelpers/core/host.py
@@ -972,6 +972,20 @@ def is_container():
972 972
973 973
974def add_to_updatedb_prunepath(path, updatedb_path=UPDATEDB_PATH): 974def add_to_updatedb_prunepath(path, updatedb_path=UPDATEDB_PATH):
975 """Adds the specified path to the mlocate's udpatedb.conf PRUNEPATH list.
976
977 This method has no effect if the path specified by updatedb_path does not
978 exist or is not a file.
979
980 @param path: string the path to add to the updatedb.conf PRUNEPATHS value
981 @param updatedb_path: the path the updatedb.conf file
982 """
983 if not os.path.exists(updatedb_path) or os.path.isdir(updatedb_path):
984 # If the updatedb.conf file doesn't exist then don't attempt to update
985 # the file as the package providing mlocate may not be installed on
986 # the local system
987 return
988
975 with open(updatedb_path, 'r+') as f_id: 989 with open(updatedb_path, 'r+') as f_id:
976 updatedb_text = f_id.read() 990 updatedb_text = f_id.read()
977 output = updatedb(updatedb_text, path) 991 output = updatedb(updatedb_text, path)
diff --git a/hooks/charmhelpers/fetch/ubuntu.py b/hooks/charmhelpers/fetch/ubuntu.py
index 736be71..19aa6ba 100644
--- a/hooks/charmhelpers/fetch/ubuntu.py
+++ b/hooks/charmhelpers/fetch/ubuntu.py
@@ -315,7 +315,7 @@ def import_key(key):
315 cmd = ['apt-key', 'adv', '--keyserver', 315 cmd = ['apt-key', 'adv', '--keyserver',
316 'hkp://keyserver.ubuntu.com:80', '--recv-keys', key] 316 'hkp://keyserver.ubuntu.com:80', '--recv-keys', key]
317 try: 317 try:
318 subprocess.check_call(cmd) 318 _run_with_retries(cmd)
319 except subprocess.CalledProcessError: 319 except subprocess.CalledProcessError:
320 error = "Error importing PGP key '{}'".format(key) 320 error = "Error importing PGP key '{}'".format(key)
321 log(error) 321 log(error)
diff --git a/tests/charmhelpers/core/host.py b/tests/charmhelpers/core/host.py
index 322ab2a..e9fd38a 100644
--- a/tests/charmhelpers/core/host.py
+++ b/tests/charmhelpers/core/host.py
@@ -972,6 +972,20 @@ def is_container():
972 972
973 973
974def add_to_updatedb_prunepath(path, updatedb_path=UPDATEDB_PATH): 974def add_to_updatedb_prunepath(path, updatedb_path=UPDATEDB_PATH):
975 """Adds the specified path to the mlocate's udpatedb.conf PRUNEPATH list.
976
977 This method has no effect if the path specified by updatedb_path does not
978 exist or is not a file.
979
980 @param path: string the path to add to the updatedb.conf PRUNEPATHS value
981 @param updatedb_path: the path the updatedb.conf file
982 """
983 if not os.path.exists(updatedb_path) or os.path.isdir(updatedb_path):
984 # If the updatedb.conf file doesn't exist then don't attempt to update
985 # the file as the package providing mlocate may not be installed on
986 # the local system
987 return
988
975 with open(updatedb_path, 'r+') as f_id: 989 with open(updatedb_path, 'r+') as f_id:
976 updatedb_text = f_id.read() 990 updatedb_text = f_id.read()
977 output = updatedb(updatedb_text, path) 991 output = updatedb(updatedb_text, path)