1
0
Fork 0

Support [main] include

This commit is contained in:
Jan Kaluza 2012-01-30 08:23:51 +01:00
parent 9c3c001f70
commit cf6db4d845
2 changed files with 16 additions and 8 deletions

View file

@ -102,7 +102,7 @@ class Controller(exports.interfaces.ExportableInterface):
def switch_profile(self, profile):
cfg = "/etc/tune-profiles/%s/tuned.conf" % (profile)
try:
config_file = cfg
self.config_file = cfg
except ValueError as e:
log.error("Unable to open profile's config file %s" % (cfg) )
return False
@ -111,8 +111,7 @@ class Controller(exports.interfaces.ExportableInterface):
@exports.export("", "s")
def active_profile(self):
# TODO
return "default"
return self.config_file.split("/")[-2]
@exports.export("", "a{bb}")
def status(self):

View file

@ -36,11 +36,18 @@ class Daemon(object):
self._thread = None
self._terminate = threading.Event()
def _load_plugins(self, manager):
cfg = ConfigParser.SafeConfigParser()
cfg.read(self._config_file)
# TODO: Move me to different class probably?
def _load_config(self, manager, config):
if not os.path.exists(config):
log.error("Config file %s does not exist" % (config))
return
cfg = ConfigParser.SafeConfigParser()
cfg.read(config)
if cfg.has_option("main", "include"):
self._load_config(manager, cfg.get("main", "include"))
for section in cfg.sections():
if section == "main":
continue
@ -54,7 +61,9 @@ class Daemon(object):
del plugin_cfg["type"]
p = manager.create(section, plugin, plugin_cfg)
def _load_plugins(self, manager):
self._load_config(manager, self._config_file)
def _thread_code(self):
self._terminate.clear()