Skip to content

Commit

Permalink
variables: support inheritance of variables
Browse files Browse the repository at this point in the history
resolves: rhbz#1374168

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
  • Loading branch information
yarda committed Apr 3, 2017
1 parent df9aa2f commit 0e7933f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions tuned/profiles/loader.py
Expand Up @@ -57,6 +57,9 @@ def load(self, profile_names):
final_profile = profiles[0]

final_profile.name = " ".join(profile_names)
if "variables" in final_profile.units:
self._variables.add_from_cfg(final_profile.units["variables"].options)
del(final_profile.units["variables"])
return final_profile

def _load_profile(self, profile_names, profiles, processed_files):
Expand Down Expand Up @@ -85,16 +88,13 @@ def _load_config_data(self, file_name):

config = collections.OrderedDict()
for section in config_obj.keys():
if section == "variables":
self._variables.add_from_cfg(config_obj[section], os.path.dirname(file_name))
else:
config[section] = collections.OrderedDict()
try:
keys = config_obj[section].keys()
except AttributeError:
raise InvalidProfileException("Error parsing section '%s' in file '%s'." % (section, file_name))
for option in keys:
config[section][option] = config_obj[section][option]
config[section] = collections.OrderedDict()
try:
keys = config_obj[section].keys()
except AttributeError:
raise InvalidProfileException("Error parsing section '%s' in file '%s'." % (section, file_name))
for option in keys:
config[section][option] = config_obj[section][option]

dir_name = os.path.dirname(file_name)
# TODO: Could we do this in the same place as the expansion of other functions?
Expand Down
4 changes: 2 additions & 2 deletions tuned/profiles/variables.py
Expand Up @@ -59,10 +59,10 @@ def add_from_file(self, filename):
else:
self.add_variable(item, config[item])

def add_from_cfg(self, cfg, dir_name):
def add_from_cfg(self, cfg):
for item in cfg:
if str(item) == "include":
self.add_from_file(os.path.normpath(os.path.join(dir_name, cfg[item])))
self.add_from_file(os.path.normpath(cfg[item]))
else:
self.add_variable(item, cfg[item])

Expand Down

0 comments on commit 0e7933f

Please sign in to comment.