diff --git a/actions/create_crush_rule.py b/actions/create_crush_rule.py index 5fea57ba..207b4f4f 100755 --- a/actions/create_crush_rule.py +++ b/actions/create_crush_rule.py @@ -41,5 +41,6 @@ def create_crush_rule(): except subprocess.CalledProcessError as e: hookenv.action_fail(str(e)) + if __name__ == '__main__': create_crush_rule() diff --git a/actions/create_erasure_profile.py b/actions/create_erasure_profile.py index 1cee8f3f..5306baa6 100755 --- a/actions/create_erasure_profile.py +++ b/actions/create_erasure_profile.py @@ -63,7 +63,7 @@ def make_erasure_profile(): action_fail("Create erasure profile failed with " "message: {}".format(str(e))) elif plugin == "lrc": - l = action_get("locality-chunks") + locality_chunks = action_get("locality-chunks") crush_locality = action_get('crush-locality') try: create_erasure_profile(service='admin', @@ -71,7 +71,7 @@ def make_erasure_profile(): profile_name=name, data_chunks=k, coding_chunks=m, - locality=l, + locality=locality_chunks, crush_locality=crush_locality, failure_domain=failure_domain, device_class=device_class) diff --git a/actions/security_checklist.py b/actions/security_checklist.py index 7afb3c1e..23b1caf1 100755 --- a/actions/security_checklist.py +++ b/actions/security_checklist.py @@ -42,5 +42,6 @@ def main(): } return audits.action_parse_results(audits.run(config)) + if __name__ == "__main__": sys.exit(main()) diff --git a/files/nagios/check_ceph_status.py b/files/nagios/check_ceph_status.py index 844e7f2f..2f49b23b 100755 --- a/files/nagios/check_ceph_status.py +++ b/files/nagios/check_ceph_status.py @@ -291,7 +291,7 @@ def main(args): EXIT_CODES = {'ok': 0, 'warning': 1, 'critical': 2, 'unknown': 3} exitcode = 'ok' try: - msg = check_ceph_status(args) + check_ceph_status(args) except UnknownError as msg: print(msg) exitcode = 'unknown' @@ -301,7 +301,7 @@ def main(args): except WarnError as msg: print(msg) exitcode = 'warning' - except: + except Exception: print("%s raised unknown exception '%s'" % ('check_ceph_status', sys.exc_info()[0])) print('=' * 60) diff --git a/hooks/ceph_hooks.py b/hooks/ceph_hooks.py index 1e45482c..3bda8f21 100755 --- a/hooks/ceph_hooks.py +++ b/hooks/ceph_hooks.py @@ -293,9 +293,9 @@ def config_changed(): # unconditionally verify that the fsid and monitor-secret are set now # otherwise we exit until a leader does this. if leader_get('fsid') is None or leader_get('monitor-secret') is None: - log('still waiting for leader to setup keys') - status_set('waiting', 'Waiting for leader to setup keys') - return + log('still waiting for leader to setup keys') + status_set('waiting', 'Waiting for leader to setup keys') + return emit_cephconf() diff --git a/test-requirements.txt b/test-requirements.txt index 7d9c2587..44b50231 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -10,7 +10,7 @@ charm-tools>=2.4.4 requests>=2.18.4 mock>=1.2 -flake8>=2.2.4,<=2.4.1 +flake8>=2.2.4 stestr>=2.2.0 coverage>=4.5.2 pyudev # for ceph-* charm unit tests (need to fix the ceph-* charm unit tests/mocking) diff --git a/tox.ini b/tox.ini index b835733a..8080ba6d 100644 --- a/tox.ini +++ b/tox.ini @@ -116,5 +116,5 @@ commands = functest-run-suite --keep-model --bundle {posargs} [flake8] -ignore = E402,E226 +ignore = E402,E226,W504 exclude = */charmhelpers diff --git a/unit_tests/test_ceph_ops.py b/unit_tests/test_ceph_ops.py index c2e1e917..145aaf92 100644 --- a/unit_tests/test_ceph_ops.py +++ b/unit_tests/test_ceph_ops.py @@ -15,7 +15,7 @@ import json import unittest -from mock import ( +from unittest.mock import ( call, patch, )