summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpran1990 <praneshpg@gmail.com>2014-05-30 15:17:02 -0700
committerpran1990 <praneshpg@gmail.com>2014-06-02 13:29:19 -0700
commit0f5954359cae1985d96662dc0b41136702829cfe (patch)
tree56d857c93a92a74861caeea48d8a4fb853de64d6
parent3499d899c81e290b13096d765bbedc25ef5ca0d2 (diff)
Move some file creation code from main to utils
As part of engine creation, we create files for audit and repair cfg. Move this to utils. Change-Id: I9d5075cb854ab5585fddcb58013ffa2530add970
Notes
Notes (review): Verified+2: Jenkins Code-Review+2: Joshua Harlow <harlowja@yahoo-inc.com> Workflow+1: Pranesh Pandurangan <praneshpg@gmail.com> Submitted-by: Jenkins Submitted-at: Tue, 03 Jun 2014 09:57:05 +0000 Reviewed-on: https://review.openstack.org/96969 Project: stackforge/entropy Branch: refs/heads/master
-rw-r--r--entropy/__main__.py8
-rw-r--r--entropy/utils.py9
2 files changed, 10 insertions, 7 deletions
diff --git a/entropy/__main__.py b/entropy/__main__.py
index cd641da..b310874 100644
--- a/entropy/__main__.py
+++ b/entropy/__main__.py
@@ -103,13 +103,7 @@ def start_engine(args):
103 } 103 }
104 utils.write_yaml(cfg, engine_cfg) 104 utils.write_yaml(cfg, engine_cfg)
105 # create cfg files 105 # create cfg files
106 for filename in ['audit_cfg', 'repair_cfg']: 106 utils.create_files([cfg_data['audit_cfg'], cfg_data['repair_cfg']])
107 try:
108 with open(cfg_data[filename]):
109 pass
110 except IOError:
111 with open(cfg_data[filename], 'a'):
112 pass
113 LOG.info('Added %s to engine cfg', args.name) 107 LOG.info('Added %s to engine cfg', args.name)
114 entropy_engine = Engine(args.name, **cfg_data) 108 entropy_engine = Engine(args.name, **cfg_data)
115 entropy_engine.run() 109 entropy_engine.run()
diff --git a/entropy/utils.py b/entropy/utils.py
index c419f50..55f7cf0 100644
--- a/entropy/utils.py
+++ b/entropy/utils.py
@@ -223,3 +223,12 @@ class StopWatch(object):
223 self._stopped_at = wallclock() 223 self._stopped_at = wallclock()
224 self._state = self._STOPPED 224 self._state = self._STOPPED
225 return self 225 return self
226
227
228def create_files(list_of_files):
229 if not list_of_files:
230 return
231 for filename in list_of_files:
232 if not os.path.isfile(filename):
233 with open(filename, 'w'):
234 pass