]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
[BZ-1219310] when overriding, interpret truthy values before setting them
authorAlfredo Deza <adeza@redhat.com>
Wed, 27 May 2015 12:59:50 +0000 (08:59 -0400)
committerAlfredo Deza <adeza@redhat.com>
Wed, 27 May 2015 19:01:24 +0000 (15:01 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
ceph_deploy/conf/cephdeploy.py

index 3397153e3f479b7753c1229b912811d8eaa5ff8c..3df09deb837a1380ddcd7c011b215114ea3ef4a6 100644 (file)
@@ -101,6 +101,7 @@ def set_overrides(args, _conf=None):
     subcommand = args.func.__name__
     command_section = 'ceph-deploy-%s' % subcommand
     conf = _conf or load()
+
     for section_name in conf.sections():
         if section_name in ['ceph-deploy-global', command_section]:
             override_subcommand(
@@ -121,8 +122,22 @@ def override_subcommand(section_name, section_items, args):
     """
     # XXX We are not coercing here any int-like values, so if ArgParse
     # does that in the CLI we are totally non-compliant with that expectation
+    # but we will try and infer a few boolean values
+
+    # acceptable boolean states for flags
+    _boolean_states = {'yes': True, 'true': True, 'on': True,
+                       'no': False, 'false': False, 'off': False}
+
     for k, v, in section_items:
-        setattr(args, k, v)
+        # get the lower case value of `v`, fallback to the booleanized
+        # (original) value of `v`
+        try:
+            normalized_value = v.lower()
+        except AttributeError:
+            # probably not a string object that has .lower
+            normalized_value = v
+        value = _boolean_states.get(normalized_value, v)
+        setattr(args, k, value)
     return args