Make set_config.py compatible with both Py2 and Py3
When asserting the validity of config files, we currently use viewkeys(), which has been removed in Python3, so a kolla container cannot set the config with Python3 only. "Traceback (most recent call last):", " File \"/usr/local/bin/kolla_set_configs\", line 406, in main", " config = load_config()", " File \"/usr/local/bin/kolla_set_configs\", line 297, in load_config", " validate_config(config)", " File \"/usr/local/bin/kolla_set_configs\", line 238, in validate_config", " if not data.viewkeys() >= required_keys:", "AttributeError: 'dict' object has no attribute 'viewkeys'" Use keys() instead, which is compatible with both Python2 and Python3, and has no visible performance disadvantage and wrap it in a set() call so that we are guranteed to compare sets. Change-Id: I5f53c8f5a390a9df3ebb60659ebdcef41e3a9cad Co-Authored-By: Michele Baldessari <michele@acksyn.org>
This commit is contained in:
parent
453ad6ca43
commit
8344c8ea21
|
@ -235,7 +235,7 @@ def validate_config(config):
|
|||
# Validate config sections
|
||||
for data in config.get('config_files', list()):
|
||||
# Verify required keys exist.
|
||||
if not data.viewkeys() >= required_keys:
|
||||
if not set(data.keys()) >= required_keys:
|
||||
message = 'Config is missing required keys: %s' % required_keys
|
||||
raise InvalidConfig(message)
|
||||
if ('owner' not in data or 'perm' not in data) \
|
||||
|
|
Loading…
Reference in New Issue