Browse Source

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
pran1990 4 years ago
parent
commit
e9f7137ceb
2 changed files with 15 additions and 5 deletions
  1. 10
    0
      entropy/backends/file_backend.py
  2. 5
    5
      entropy/engine.py

+ 10
- 0
entropy/backends/file_backend.py View File

@@ -36,8 +36,18 @@ class FileBackend(base.Backend):
36 36
         audits = utils.load_yaml(self._audit_cfg)
37 37
         return audits
38 38
 
39
+    def get_repairs(self):
40
+        repairs = utils.load_yaml(self._repair_cfg)
41
+        return repairs
42
+
39 43
     def audit_cfg_from_name(self, name):
40 44
         audits = self.get_audits()
41 45
         conf = audits[name]['cfg']
42 46
         audit_cfg = dict(utils.load_yaml(conf))
43 47
         return audit_cfg
48
+
49
+    def repair_cfg_from_name(self, name):
50
+        repairs = self.get_repairs()
51
+        conf = repairs[name]['cfg']
52
+        repair_cfg = dict(utils.load_yaml(conf))
53
+        return repair_cfg

+ 5
- 5
entropy/engine.py View File

@@ -217,12 +217,12 @@ class Engine(object):
217 217
                           audit_list, execution_time)
218 218
 
219 219
     def start_react_scripts(self):
220
-        scripts = utils.load_yaml(self.repair_cfg)
220
+        repairs = self._backend_driver.get_repairs()
221 221
         futures = []
222
-        if scripts:
223
-            for script in scripts:
222
+        if repairs:
223
+            for script in repairs:
224 224
                 if script not in self.running_repairs:
225
-                    future = self.setup_react(script, **scripts[script])
225
+                    future = self.setup_react(script, **repairs[script])
226 226
                     if future is not None:
227 227
                         futures.append(future)
228 228
         LOG.info('Running repair scripts %s', ', '.join(self.running_repairs))
@@ -232,7 +232,7 @@ class Engine(object):
232 232
         LOG.info('Setting up reactor %s', script)
233 233
 
234 234
         # Pick out relevant info
235
-        data = dict(utils.load_yaml(script_args['cfg']))
235
+        data = self._backend_driver.repair_cfg_from_name(script)
236 236
         react_script = data['script']
237 237
         search_path, reactor = utils.get_filename_and_path(react_script)
238 238
         available_modules = imp.find_module(reactor, [search_path])

Loading…
Cancel
Save