aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-11-02 20:21:39 -0700
committerRoss Brattain <ross.b.brattain@intel.com>2017-12-14 07:55:02 +0000
commitf6aeffdfb89cd82d89dd8cd6d9e4711015a27d1d (patch)
treeb376eb5cce5d9a351fbc9182d9ef37cd54bb4cf0 /yardstick
parente9973c86a548ea2b62cd85b25e52e5a3063c9415 (diff)
Ansible: fix lowercasing issue with ConfigParser
by default ConfigParser will lowercase everything, unless you override optionxform. also sort key value in inventory line for consistency https://docs.python.org/3/library/configparser.html#configparser.ConfigParser.optionxform Transforms the option name option as found in an input file or as passed in by client code to the form that should be used in the internal structures. The default implementation returns a lower-case version of option; subclasses may override this or client code can set an attribute of this name on instances to affect this behavior. You don’t need to subclass the parser to use this method, you can also set it on an instance, to a function that takes a string argument and returns a string. Setting it to str, for example, would make option names case sensitive: cfgparser = ConfigParser() cfgparser.optionxform = str Note that when reading configuration files, whitespace around the option names is stripped before optionxform() is called. YARDSTICK-833 Change-Id: Ia1810b0c77922d84e11c9e538540b38816338593 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com> (cherry picked from commit 3e93bb8ff3ef9ff454d6be13295198dbeac75df7)
Diffstat (limited to 'yardstick')
-rw-r--r--yardstick/common/ansible_common.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/yardstick/common/ansible_common.py b/yardstick/common/ansible_common.py
index 0cafa9708..9a4426bf9 100644
--- a/yardstick/common/ansible_common.py
+++ b/yardstick/common/ansible_common.py
@@ -298,8 +298,9 @@ class AnsibleNode(MutableMapping):
def gen_inventory_line(self):
inventory_params = self.get_inventory_params()
# use format to convert ints
+ # sort to ensure consistent key value ordering
formatted_args = (u"{}={}".format(*entry) for entry in
- inventory_params.items())
+ sorted(inventory_params.items()))
line = u" ".join(chain([self['name']], formatted_args))
return line
@@ -472,6 +473,8 @@ class AnsibleCommon(object):
prefix = '_'.join([self.prefix, prefix, 'inventory'])
ini_temp_file = IniMapTemporaryFile(directory=directory, prefix=prefix)
inventory_config = ConfigParser.ConfigParser(allow_no_value=True)
+ # disable default lowercasing
+ inventory_config.optionxform = str
return ini_temp_file.make_context(self.inventory_dict, write_func,
descriptor='inventory')