]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
validate: check the version of python-notario
authorAndrew Schoen <aschoen@redhat.com>
Tue, 16 Oct 2018 15:20:54 +0000 (10:20 -0500)
committermergify[bot] <mergify[bot]@users.noreply.github.com>
Fri, 19 Oct 2018 09:18:39 +0000 (09:18 +0000)
If the version of python-notario is < 0.0.13 an error message is given
like "TypeError: validate() got an unexpected keyword argument
'defined_keys'", which is not helpful in figuring
out you've got an incorrect version of python-notario.

This check will avoid that situation by telling the user that they need
to upgrade python-notario before they hit that error.

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
plugins/actions/validate.py

index 12667404e4309360d806703f43314470b0ca0837..5cedd83e71a1700e127b32bce9db6042f985ed2c 100644 (file)
@@ -1,5 +1,6 @@
 
 from ansible.plugins.action import ActionBase
+from distutils.version import LooseVersion
 
 try:
     from __main__ import display
@@ -14,6 +15,11 @@ except ImportError:
     display.error(msg)
     raise SystemExit(msg)
 
+if LooseVersion(notario.__version__) < LooseVersion("0.0.13"):
+    msg = "The python-notario libary has an incompatible version. Version >= 0.0.13 is needed, current version: %s" % notario.__version__
+    display.error(msg)
+    raise SystemExit(msg)
+
 from notario.exceptions import Invalid
 from notario.validators import types, chainable, iterables
 from notario.decorators import optional