move repair-related code to backend
Add two functions in filebackend, to retrieve all repairs, and to retrieve an repair script's config given the name. Replace occurences of utils.load_yaml in engine.py with calls to above functions Change-Id: If7ed5c44b771aa76b94697cca16b251a167e4956
This commit is contained in:
parent
e7c8fee0a8
commit
e9f7137ceb
|
@ -36,8 +36,18 @@ class FileBackend(base.Backend):
|
||||||
audits = utils.load_yaml(self._audit_cfg)
|
audits = utils.load_yaml(self._audit_cfg)
|
||||||
return audits
|
return audits
|
||||||
|
|
||||||
|
def get_repairs(self):
|
||||||
|
repairs = utils.load_yaml(self._repair_cfg)
|
||||||
|
return repairs
|
||||||
|
|
||||||
def audit_cfg_from_name(self, name):
|
def audit_cfg_from_name(self, name):
|
||||||
audits = self.get_audits()
|
audits = self.get_audits()
|
||||||
conf = audits[name]['cfg']
|
conf = audits[name]['cfg']
|
||||||
audit_cfg = dict(utils.load_yaml(conf))
|
audit_cfg = dict(utils.load_yaml(conf))
|
||||||
return audit_cfg
|
return audit_cfg
|
||||||
|
|
||||||
|
def repair_cfg_from_name(self, name):
|
||||||
|
repairs = self.get_repairs()
|
||||||
|
conf = repairs[name]['cfg']
|
||||||
|
repair_cfg = dict(utils.load_yaml(conf))
|
||||||
|
return repair_cfg
|
||||||
|
|
|
@ -217,12 +217,12 @@ class Engine(object):
|
||||||
audit_list, execution_time)
|
audit_list, execution_time)
|
||||||
|
|
||||||
def start_react_scripts(self):
|
def start_react_scripts(self):
|
||||||
scripts = utils.load_yaml(self.repair_cfg)
|
repairs = self._backend_driver.get_repairs()
|
||||||
futures = []
|
futures = []
|
||||||
if scripts:
|
if repairs:
|
||||||
for script in scripts:
|
for script in repairs:
|
||||||
if script not in self.running_repairs:
|
if script not in self.running_repairs:
|
||||||
future = self.setup_react(script, **scripts[script])
|
future = self.setup_react(script, **repairs[script])
|
||||||
if future is not None:
|
if future is not None:
|
||||||
futures.append(future)
|
futures.append(future)
|
||||||
LOG.info('Running repair scripts %s', ', '.join(self.running_repairs))
|
LOG.info('Running repair scripts %s', ', '.join(self.running_repairs))
|
||||||
|
@ -232,7 +232,7 @@ class Engine(object):
|
||||||
LOG.info('Setting up reactor %s', script)
|
LOG.info('Setting up reactor %s', script)
|
||||||
|
|
||||||
# Pick out relevant info
|
# Pick out relevant info
|
||||||
data = dict(utils.load_yaml(script_args['cfg']))
|
data = self._backend_driver.repair_cfg_from_name(script)
|
||||||
react_script = data['script']
|
react_script = data['script']
|
||||||
search_path, reactor = utils.get_filename_and_path(react_script)
|
search_path, reactor = utils.get_filename_and_path(react_script)
|
||||||
available_modules = imp.find_module(reactor, [search_path])
|
available_modules = imp.find_module(reactor, [search_path])
|
||||||
|
|
Loading…
Reference in New Issue