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: Iee19bad93858db2411eb423c3c04fe9033d3a11e
changes/81/636481/2
David Ames 4 months ago
parent
commit
47ccc714c0

+ 1
- 1
charm-helpers-hooks.yaml View File

@@ -8,5 +8,5 @@ include:
8 8
     - contrib.storage
9 9
     - contrib.hahelpers
10 10
     - contrib.network.ip
11
-    - contrib.python.packages
11
+    - contrib.python
12 12
     - payload.execd

+ 8
- 8
hooks/charmhelpers/contrib/openstack/amulet/utils.py View File

@@ -88,14 +88,14 @@ class OpenStackAmuletUtils(AmuletUtils):
88 88
         validation_function = self.validate_v2_endpoint_data
89 89
         xenial_queens = OPENSTACK_RELEASES_PAIRS.index('xenial_queens')
90 90
         if openstack_release and openstack_release >= xenial_queens:
91
-                validation_function = self.validate_v3_endpoint_data
92
-                expected = {
93
-                    'id': expected['id'],
94
-                    'region': expected['region'],
95
-                    'region_id': 'RegionOne',
96
-                    'url': self.valid_url,
97
-                    'interface': self.not_null,
98
-                    'service_id': expected['service_id']}
91
+            validation_function = self.validate_v3_endpoint_data
92
+            expected = {
93
+                'id': expected['id'],
94
+                'region': expected['region'],
95
+                'region_id': 'RegionOne',
96
+                'url': self.valid_url,
97
+                'interface': self.not_null,
98
+                'service_id': expected['service_id']}
99 99
         return validation_function(endpoints, admin_port, internal_port,
100 100
                                    public_port, expected)
101 101
 

+ 5
- 5
hooks/charmhelpers/contrib/openstack/context.py View File

@@ -1427,11 +1427,11 @@ class ZeroMQContext(OSContextGenerator):
1427 1427
         ctxt = {}
1428 1428
         if is_relation_made('zeromq-configuration', 'host'):
1429 1429
             for rid in relation_ids('zeromq-configuration'):
1430
-                    for unit in related_units(rid):
1431
-                        ctxt['zmq_nonce'] = relation_get('nonce', unit, rid)
1432
-                        ctxt['zmq_host'] = relation_get('host', unit, rid)
1433
-                        ctxt['zmq_redis_address'] = relation_get(
1434
-                            'zmq_redis_address', unit, rid)
1430
+                for unit in related_units(rid):
1431
+                    ctxt['zmq_nonce'] = relation_get('nonce', unit, rid)
1432
+                    ctxt['zmq_host'] = relation_get('host', unit, rid)
1433
+                    ctxt['zmq_redis_address'] = relation_get(
1434
+                        'zmq_redis_address', unit, rid)
1435 1435
 
1436 1436
         return ctxt
1437 1437
 

+ 1
- 1
hooks/charmhelpers/contrib/openstack/templating.py View File

@@ -183,7 +183,7 @@ class OSConfigRenderer(object):
183 183
         /tmp/templates/grizzly/api-paste.ini
184 184
         /tmp/templates/havana/api-paste.ini
185 185
 
186
-    Since it was registered with the grizzly release, it first seraches
186
+    Since it was registered with the grizzly release, it first searches
187 187
     the grizzly directory for nova.conf, then the templates dir.
188 188
 
189 189
     When writing api-paste.ini, it will find the template in the grizzly

+ 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

+ 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.

+ 54
- 0
hooks/charmhelpers/fetch/python/debug.py View File

@@ -0,0 +1,54 @@
1
+#!/usr/bin/env python
2
+# coding: utf-8
3
+
4
+# Copyright 2014-2015 Canonical Limited.
5
+#
6
+# Licensed under the Apache License, Version 2.0 (the "License");
7
+# you may not use this file except in compliance with the License.
8
+# You may obtain a copy of the License at
9
+#
10
+#  http://www.apache.org/licenses/LICENSE-2.0
11
+#
12
+# Unless required by applicable law or agreed to in writing, software
13
+# distributed under the License is distributed on an "AS IS" BASIS,
14
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+# See the License for the specific language governing permissions and
16
+# limitations under the License.
17
+
18
+from __future__ import print_function
19
+
20
+import atexit
21
+import sys
22
+
23
+from charmhelpers.fetch.python.rpdb import Rpdb
24
+from charmhelpers.core.hookenv import (
25
+    open_port,
26
+    close_port,
27
+    ERROR,
28
+    log
29
+)
30
+
31
+__author__ = "Jorge Niedbalski <jorge.niedbalski@canonical.com>"
32
+
33
+DEFAULT_ADDR = "0.0.0.0"
34
+DEFAULT_PORT = 4444
35
+
36
+
37
+def _error(message):
38
+    log(message, level=ERROR)
39
+
40
+
41
+def set_trace(addr=DEFAULT_ADDR, port=DEFAULT_PORT):
42
+    """
43
+    Set a trace point using the remote debugger
44
+    """
45
+    atexit.register(close_port, port)
46
+    try:
47
+        log("Starting a remote python debugger session on %s:%s" % (addr,
48
+                                                                    port))
49
+        open_port(port)
50
+        debugger = Rpdb(addr=addr, port=port)
51
+        debugger.set_trace(sys._getframe().f_back)
52
+    except Exception:
53
+        _error("Cannot start a remote debug session on %s:%s" % (addr,
54
+                                                                 port))

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


+ 56
- 0
hooks/charmhelpers/fetch/python/rpdb.py View File

@@ -0,0 +1,56 @@
1
+# Copyright 2014-2015 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
+"""Remote Python Debugger (pdb wrapper)."""
16
+
17
+import pdb
18
+import socket
19
+import sys
20
+
21
+__author__ = "Bertrand Janin <b@janin.com>"
22
+__version__ = "0.1.3"
23
+
24
+
25
+class Rpdb(pdb.Pdb):
26
+
27
+    def __init__(self, addr="127.0.0.1", port=4444):
28
+        """Initialize the socket and initialize pdb."""
29
+
30
+        # Backup stdin and stdout before replacing them by the socket handle
31
+        self.old_stdout = sys.stdout
32
+        self.old_stdin = sys.stdin
33
+
34
+        # Open a 'reusable' socket to let the webapp reload on the same port
35
+        self.skt = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
36
+        self.skt.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, True)
37
+        self.skt.bind((addr, port))
38
+        self.skt.listen(1)
39
+        (clientsocket, address) = self.skt.accept()
40
+        handle = clientsocket.makefile('rw')
41
+        pdb.Pdb.__init__(self, completekey='tab', stdin=handle, stdout=handle)
42
+        sys.stdout = sys.stdin = handle
43
+
44
+    def shutdown(self):
45
+        """Revert stdin and stdout, close the socket."""
46
+        sys.stdout = self.old_stdout
47
+        sys.stdin = self.old_stdin
48
+        self.skt.close()
49
+        self.set_continue()
50
+
51
+    def do_continue(self, arg):
52
+        """Stop all operation on ``continue``."""
53
+        self.shutdown()
54
+        return 1
55
+
56
+    do_EOF = do_quit = do_exit = do_c = do_cont = do_continue

+ 32
- 0
hooks/charmhelpers/fetch/python/version.py View File

@@ -0,0 +1,32 @@
1
+#!/usr/bin/env python
2
+# coding: utf-8
3
+
4
+# Copyright 2014-2015 Canonical Limited.
5
+#
6
+# Licensed under the Apache License, Version 2.0 (the "License");
7
+# you may not use this file except in compliance with the License.
8
+# You may obtain a copy of the License at
9
+#
10
+#  http://www.apache.org/licenses/LICENSE-2.0
11
+#
12
+# Unless required by applicable law or agreed to in writing, software
13
+# distributed under the License is distributed on an "AS IS" BASIS,
14
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+# See the License for the specific language governing permissions and
16
+# limitations under the License.
17
+
18
+import sys
19
+
20
+__author__ = "Jorge Niedbalski <jorge.niedbalski@canonical.com>"
21
+
22
+
23
+def current_version():
24
+    """Current system python version"""
25
+    return sys.version_info
26
+
27
+
28
+def current_version_string():
29
+    """Current system python version as string major.minor.micro"""
30
+    return "{0}.{1}.{2}".format(sys.version_info.major,
31
+                                sys.version_info.minor,
32
+                                sys.version_info.micro)

Loading…
Cancel
Save