Browse Source

Update charm-helpers-hooks.yaml and sync ch

Using the new version of the sync tool which removes the charmhelpers
directory before syncing, run charm helpers sync to find any unexpected
missing dependencies.

Change-Id: Ifa5ba56af4b120903c2cc3822834c4279cd56acc
changes/78/636478/2
David Ames 3 months ago
parent
commit
d26fabe674

+ 15
- 3
hooks/charmhelpers/contrib/openstack/utils.py View File

@@ -83,7 +83,8 @@ from charmhelpers.fetch import (
83 83
     add_source as fetch_add_source,
84 84
     SourceConfigError,
85 85
     GPGKeyError,
86
-    get_upstream_version
86
+    get_upstream_version,
87
+    filter_missing_packages
87 88
 )
88 89
 
89 90
 from charmhelpers.fetch.snap import (
@@ -309,6 +310,15 @@ def error_out(msg):
309 310
     sys.exit(1)
310 311
 
311 312
 
313
+def get_installed_semantic_versioned_packages():
314
+    '''Get a list of installed packages which have OpenStack semantic versioning
315
+
316
+    :returns List of installed packages
317
+    :rtype: [pkg1, pkg2, ...]
318
+    '''
319
+    return filter_missing_packages(PACKAGE_CODENAMES.keys())
320
+
321
+
312 322
 def get_os_codename_install_source(src):
313 323
     '''Derive OpenStack release codename from a given installation source.'''
314 324
     ubuntu_rel = lsb_release()['DISTRIB_CODENAME']
@@ -972,7 +982,9 @@ def _ows_check_charm_func(state, message, charm_func_with_configs):
972 982
     """
973 983
     if charm_func_with_configs:
974 984
         charm_state, charm_message = charm_func_with_configs()
975
-        if charm_state != 'active' and charm_state != 'unknown':
985
+        if (charm_state != 'active' and
986
+                charm_state != 'unknown' and
987
+                charm_state is not None):
976 988
             state = workload_state_compare(state, charm_state)
977 989
             if message:
978 990
                 charm_message = charm_message.replace("Incomplete relations: ",
@@ -1241,7 +1253,7 @@ def remote_restart(rel_name, remote_service=None):
1241 1253
 
1242 1254
 
1243 1255
 def check_actually_paused(services=None, ports=None):
1244
-    """Check that services listed in the services object and and ports
1256
+    """Check that services listed in the services object and ports
1245 1257
     are actually closed (not listened to), to verify that the unit is
1246 1258
     properly paused.
1247 1259
 

+ 21
- 0
hooks/charmhelpers/contrib/python.py View File

@@ -0,0 +1,21 @@
1
+# Copyright 2014-2019 Canonical Limited.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#  http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.
14
+
15
+from __future__ import absolute_import
16
+
17
+# deprecated aliases for backwards compatibility
18
+from charmhelpers.fetch.python import debug  # noqa
19
+from charmhelpers.fetch.python import packages  # noqa
20
+from charmhelpers.fetch.python import rpdb  # noqa
21
+from charmhelpers.fetch.python import version  # noqa

+ 21
- 6
hooks/charmhelpers/contrib/storage/linux/ceph.py View File

@@ -856,12 +856,22 @@ def _keyring_path(service):
856 856
     return KEYRING.format(service)
857 857
 
858 858
 
859
-def create_keyring(service, key):
860
-    """Create a new Ceph keyring containing key."""
859
+def add_key(service, key):
860
+    """
861
+    Add a key to a keyring.
862
+
863
+    Creates the keyring if it doesn't already exist.
864
+
865
+    Logs and returns if the key is already in the keyring.
866
+    """
861 867
     keyring = _keyring_path(service)
862 868
     if os.path.exists(keyring):
863
-        log('Ceph keyring exists at %s.' % keyring, level=WARNING)
864
-        return
869
+        with open(keyring, 'r') as ring:
870
+            if key in ring.read():
871
+                log('Ceph keyring exists at %s and has not changed.' % keyring,
872
+                    level=DEBUG)
873
+                return
874
+            log('Updating existing keyring %s.' % keyring, level=DEBUG)
865 875
 
866 876
     cmd = ['ceph-authtool', keyring, '--create-keyring',
867 877
            '--name=client.{}'.format(service), '--add-key={}'.format(key)]
@@ -869,6 +879,11 @@ def create_keyring(service, key):
869 879
     log('Created new ceph keyring at %s.' % keyring, level=DEBUG)
870 880
 
871 881
 
882
+def create_keyring(service, key):
883
+    """Deprecated. Please use the more accurately named 'add_key'"""
884
+    return add_key(service, key)
885
+
886
+
872 887
 def delete_keyring(service):
873 888
     """Delete an existing Ceph keyring."""
874 889
     keyring = _keyring_path(service)
@@ -905,7 +920,7 @@ def get_ceph_nodes(relation='ceph'):
905 920
 
906 921
 def configure(service, key, auth, use_syslog):
907 922
     """Perform basic configuration of Ceph."""
908
-    create_keyring(service, key)
923
+    add_key(service, key)
909 924
     create_key_file(service, key)
910 925
     hosts = get_ceph_nodes()
911 926
     with open('/etc/ceph/ceph.conf', 'w') as ceph_conf:
@@ -1068,7 +1083,7 @@ def ensure_ceph_keyring(service, user=None, group=None,
1068 1083
     if not key:
1069 1084
         return False
1070 1085
 
1071
-    create_keyring(service=service, key=key)
1086
+    add_key(service=service, key=key)
1072 1087
     keyring = _keyring_path(service)
1073 1088
     if user and group:
1074 1089
         check_call(['chown', '%s.%s' % (user, group), keyring])

+ 1
- 0
hooks/charmhelpers/core/host.py View File

@@ -46,6 +46,7 @@ if __platform__ == "ubuntu":
46 46
         lsb_release,
47 47
         cmp_pkgrevno,
48 48
         CompareHostReleases,
49
+        get_distrib_codename,
49 50
     )  # flake8: noqa -- ignore F401 for this import
50 51
 elif __platform__ == "centos":
51 52
     from charmhelpers.core.host_factory.centos import (  # NOQA:F401

+ 8
- 0
hooks/charmhelpers/core/host_factory/ubuntu.py View File

@@ -72,6 +72,14 @@ def lsb_release():
72 72
     return d
73 73
 
74 74
 
75
+def get_distrib_codename():
76
+    """Return the codename of the distribution
77
+    :returns: The codename
78
+    :rtype: str
79
+    """
80
+    return lsb_release()['DISTRIB_CODENAME'].lower()
81
+
82
+
75 83
 def cmp_pkgrevno(package, revno, pkgcache=None):
76 84
     """Compare supplied revno with the revno of the installed package.
77 85
 

hooks/charmhelpers/contrib/python/__init__.py → hooks/charmhelpers/fetch/python/__init__.py View File

@@ -1,4 +1,4 @@
1
-# Copyright 2014-2015 Canonical Limited.
1
+# Copyright 2014-2019 Canonical Limited.
2 2
 #
3 3
 # Licensed under the Apache License, Version 2.0 (the "License");
4 4
 # you may not use this file except in compliance with the License.

hooks/charmhelpers/contrib/python/debug.py → hooks/charmhelpers/fetch/python/debug.py View File

@@ -20,7 +20,7 @@ from __future__ import print_function
20 20
 import atexit
21 21
 import sys
22 22
 
23
-from charmhelpers.contrib.python.rpdb import Rpdb
23
+from charmhelpers.fetch.python.rpdb import Rpdb
24 24
 from charmhelpers.core.hookenv import (
25 25
     open_port,
26 26
     close_port,

hooks/charmhelpers/contrib/python/packages.py → hooks/charmhelpers/fetch/python/packages.py View File


hooks/charmhelpers/contrib/python/rpdb.py → hooks/charmhelpers/fetch/python/rpdb.py View File


hooks/charmhelpers/contrib/python/version.py → hooks/charmhelpers/fetch/python/version.py View File


Loading…
Cancel
Save