diff options
| author | Jeffrey Zhang <jeffrey.zhang@99cloud.net> | 2016-03-08 10:43:19 +0800 |
|---|---|---|
| committer | Jeffrey Zhang <jeffrey.zhang@99cloud.net> | 2016-05-31 01:40:55 +0000 |
| commit | 476da0f43acda64f660427cc0457b1fffaf4c0b7 (patch) | |
| tree | 572a1d1bae107c138ffc22c7bcd7219c90e75aea | |
| parent | 3545e6d503c7451921333134fb75d3fef3713952 (diff) | |
| download | kolla-476da0f43acda64f660427cc0457b1fffaf4c0b7.tar.gz kolla-476da0f43acda64f660427cc0457b1fffaf4c0b7.zip | |
Log the traceback in the kolla libraries
The traceback is logged also and will be helpful when the
library failed. We can get which line is failed from the log.
TrivialFix
Change-Id: Ia417232007e2f34c83d2e7cad6ed08dee49ce836
| -rw-r--r-- | ansible/library/bslurp.py | 6 | ||||
| -rw-r--r-- | ansible/library/kolla_docker.py | 6 | ||||
| -rw-r--r-- | docker/kolla-toolbox/kolla_keystone_service.py | 7 | ||||
| -rw-r--r-- | docker/kolla-toolbox/kolla_keystone_user.py | 7 | ||||
| -rw-r--r-- | docker/kolla-toolbox/kolla_sanity.py | 7 | ||||
| -rw-r--r-- | docker/kolla-toolbox/kolla_zookeeper.py | 6 |
6 files changed, 27 insertions, 12 deletions
diff --git a/ansible/library/bslurp.py b/ansible/library/bslurp.py index a4479c244..b342da3f4 100644 --- a/ansible/library/bslurp.py +++ b/ansible/library/bslurp.py @@ -109,6 +109,7 @@ Distribute a to file many host without compression; Change permissions on dest: import base64 import hashlib import os +import traceback import zlib @@ -180,8 +181,9 @@ def main(): copy_to_host(module) else: copy_from_host(module) - except Exception as e: - module.exit_json(failed=True, changed=True, msg=repr(e)) + except Exception: + module.exit_json(failed=True, changed=True, + msg=repr(traceback.format_exc())) # import module snippets diff --git a/ansible/library/kolla_docker.py b/ansible/library/kolla_docker.py index 4930ad490..7c60deb5d 100644 --- a/ansible/library/kolla_docker.py +++ b/ansible/library/kolla_docker.py @@ -188,6 +188,7 @@ EXAMPLES = ''' ''' import os +import traceback import docker @@ -728,8 +729,9 @@ def main(): # meaningful data, we need to refactor all methods to return dicts. result = bool(getattr(dw, module.params.get('action'))()) module.exit_json(changed=dw.changed, result=result) - except Exception as e: - module.exit_json(failed=True, changed=True, msg=repr(e)) + except Exception: + module.exit_json(failed=True, changed=True, + msg=repr(traceback.format_exc())) # import module snippets from ansible.module_utils.basic import * # noqa diff --git a/docker/kolla-toolbox/kolla_keystone_service.py b/docker/kolla-toolbox/kolla_keystone_service.py index bc06fd61f..9559c3dbc 100644 --- a/docker/kolla-toolbox/kolla_keystone_service.py +++ b/docker/kolla-toolbox/kolla_keystone_service.py @@ -22,6 +22,8 @@ # in upstream shade we will be able to use more of the shade module. Until then # if we want to be 'stable' we really need to be using it as a passthrough +import traceback + import shade @@ -74,8 +76,9 @@ def main(): region=endpoint_region) module.exit_json(changed=changed) - except Exception as e: - module.exit_json(failed=True, changed=True, msg=e) + except Exception: + module.exit_json(failed=True, changed=True, + msg=repr(traceback.format_exc())) # import module snippets from ansible.module_utils.basic import * # noqa diff --git a/docker/kolla-toolbox/kolla_keystone_user.py b/docker/kolla-toolbox/kolla_keystone_user.py index 789019788..d8af461ae 100644 --- a/docker/kolla-toolbox/kolla_keystone_user.py +++ b/docker/kolla-toolbox/kolla_keystone_user.py @@ -22,6 +22,8 @@ # in upstream shade we will be able to use more of the shade module. Until then # if we want to be 'stable' we really need to be using it as a passthrough +import traceback + import shade @@ -78,8 +80,9 @@ def main(): project=project) module.exit_json(changed=changed) - except Exception as e: - module.exit_json(failed=True, changed=True, msg=e) + except Exception: + module.exit_json(failed=True, changed=True, + msg=repr(traceback.format_exc())) # import module snippets from ansible.module_utils.basic import * # noqa diff --git a/docker/kolla-toolbox/kolla_sanity.py b/docker/kolla-toolbox/kolla_sanity.py index 167663dec..c13854e9f 100644 --- a/docker/kolla-toolbox/kolla_sanity.py +++ b/docker/kolla-toolbox/kolla_sanity.py @@ -22,6 +22,8 @@ # in upstream shade we will be able to use more of the shade module. Until then # if we want to be 'stable' we really need to be using it as a passthrough +import traceback + import shade @@ -61,8 +63,9 @@ def main(): getattr(SanityChecks, module.params.pop("service"))(cloud) module.exit_json(changed=changed) - except Exception as e: - module.exit_json(failed=True, changed=True, msg=e) + except Exception: + module.exit_json(failed=True, changed=True, + msg=repr(traceback.format_exc())) # import module snippets from ansible.module_utils.basic import * # noqa diff --git a/docker/kolla-toolbox/kolla_zookeeper.py b/docker/kolla-toolbox/kolla_zookeeper.py index d6326f46a..3142c0f5a 100644 --- a/docker/kolla-toolbox/kolla_zookeeper.py +++ b/docker/kolla-toolbox/kolla_zookeeper.py @@ -15,6 +15,7 @@ # under the License. import contextlib +import traceback import kazoo.client import kazoo.exceptions @@ -56,8 +57,9 @@ def main(): changed = True module.exit_json(changed=changed) - except Exception as e: - module.exit_json(failed=True, changed=True, msg=e) + except Exception: + module.exit_json(failed=True, changed=True, + msg=repr(traceback.format_exc())) # import module snippets |
