Example #1
0
 def _config_adjust(self, contents, fn):
     lines = contents.splitlines()
     for line in lines:
         cleaned = line.strip()
         if(len(cleaned) == 0 or
             cleaned[0] == '#' or cleaned[0] == '['):
             #not useful to examine these
             continue
         pieces = cleaned.split("=", 1)
         if(len(pieces) != 2):
             continue
         key = pieces[0].strip()
         val = pieces[1].strip()
         if(len(key) == 0 or len(val) == 0):
             continue
         #now we take special actions
         if(key == 'log_file'):
             # Ensure that we can write to the log file
             dirname = os.path.dirname(val)
             if(len(dirname)):
                 dirsmade = mkdirslist(dirname)
                 # This trace is used to remove the dirs created
                 self.tracewriter.dir_made(*dirsmade)
             # Destroy then recreate it
             unlink(val)
             touch_file(val)
             self.tracewriter.file_touched(val)
     return contents
Example #2
0
 def _config_adjust(self, contents, fn):
     lines = contents.splitlines()
     for line in lines:
         cleaned = line.strip()
         if (len(cleaned) == 0 or cleaned[0] == '#' or cleaned[0] == '['):
             #not useful to examine these
             continue
         pieces = cleaned.split("=", 1)
         if (len(pieces) != 2):
             continue
         key = pieces[0].strip()
         val = pieces[1].strip()
         if (len(key) == 0 or len(val) == 0):
             continue
         #now we take special actions
         if (key == 'log_file'):
             # Ensure that we can write to the log file
             dirname = os.path.dirname(val)
             if (len(dirname)):
                 dirsmade = mkdirslist(dirname)
                 # This trace is used to remove the dirs created
                 self.tracewriter.dir_made(*dirsmade)
             # Destroy then recreate it
             unlink(val)
             touch_file(val)
             self.tracewriter.file_touched(val)
     return contents
Example #3
0
 def _config_adjust(self, contents, fn):
     lines = contents.splitlines()
     for line in lines:
         cleaned = line.strip()
         if len(cleaned) == 0 or cleaned[0] == "#" or cleaned[0] == "[":
             # not useful to examine these
             continue
         pieces = cleaned.split("=", 1)
         if len(pieces) != 2:
             continue
         key = pieces[0].strip()
         val = pieces[1].strip()
         if len(key) == 0 or len(val) == 0:
             continue
         # now we take special actions
         if key == "filesystem_store_datadir":
             # delete existing images
             deldir(val)
             # recreate the image directory
             dirsmade = mkdirslist(val)
             self.tracewriter.dir_made(*dirsmade)
         elif key == "log_file":
             # ensure that we can write to the log file
             dirname = os.path.dirname(val)
             if len(dirname):
                 dirsmade = mkdirslist(dirname)
                 # this trace is used to remove the dirs created
                 self.tracewriter.dir_made(*dirsmade)
             # destroy then recreate it (the log file)
             unlink(val)
             touch_file(val)
             self.tracewriter.file_touched(val)
         elif key == "image_cache_datadir":
             # destroy then recreate the image cache directory
             deldir(val)
             dirsmade = mkdirslist(val)
             # this trace is used to remove the dirs created
             self.tracewriter.dir_made(*dirsmade)
         elif key == "scrubber_datadir":
             # destroy then recreate the scrubber data directory
             deldir(val)
             dirsmade = mkdirslist(val)
             # this trace is used to remove the dirs created
             self.tracewriter.dir_made(*dirsmade)
     return contents
Example #4
0
 def _config_adjust(self, contents, fn):
     lines = contents.splitlines()
     for line in lines:
         cleaned = line.strip()
         if (len(cleaned) == 0 or cleaned[0] == '#' or cleaned[0] == '['):
             #not useful to examine these
             continue
         pieces = cleaned.split("=", 1)
         if (len(pieces) != 2):
             continue
         key = pieces[0].strip()
         val = pieces[1].strip()
         if (len(key) == 0 or len(val) == 0):
             continue
         #now we take special actions
         if (key == 'filesystem_store_datadir'):
             #delete existing images
             deldir(val)
             #recreate the image directory
             dirsmade = mkdirslist(val)
             self.tracewriter.dir_made(*dirsmade)
         elif (key == 'log_file'):
             #ensure that we can write to the log file
             dirname = os.path.dirname(val)
             if (len(dirname)):
                 dirsmade = mkdirslist(dirname)
                 #this trace is used to remove the dirs created
                 self.tracewriter.dir_made(*dirsmade)
             #destroy then recreate it (the log file)
             unlink(val)
             touch_file(val)
             self.tracewriter.file_touched(val)
         elif (key == 'image_cache_datadir'):
             #destroy then recreate the image cache directory
             deldir(val)
             dirsmade = mkdirslist(val)
             #this trace is used to remove the dirs created
             self.tracewriter.dir_made(*dirsmade)
         elif (key == 'scrubber_datadir'):
             #destroy then recreate the scrubber data directory
             deldir(val)
             dirsmade = mkdirslist(val)
             #this trace is used to remove the dirs created
             self.tracewriter.dir_made(*dirsmade)
     return contents
Example #5
0
def _gitdownload(storewhere, uri, branch=None):
    dirsmade = mkdirslist(storewhere)
    LOG.info("Downloading from %s to %s" % (uri, storewhere))
    cmd = ["git", "clone"] + [uri, storewhere]
    execute(*cmd)
    if(branch and branch != MASTER_BRANCH):
        LOG.info("Adjusting git branch to %s" % (branch))
        cmd = ['git', 'checkout'] + [branch]
        execute(*cmd, cwd=storewhere)
    return dirsmade
Example #6
0
def _gitdownload(storewhere, uri, branch=None):
    dirsmade = mkdirslist(storewhere)
    LOG.info("Downloading from %s to %s" % (uri, storewhere))
    cmd = ["git", "clone"] + [uri, storewhere]
    execute(*cmd)
    if (branch and branch != MASTER_BRANCH):
        LOG.info("Adjusting git branch to %s" % (branch))
        cmd = ['git', 'checkout'] + [branch]
        execute(*cmd, cwd=storewhere)
    return dirsmade
Example #7
0
 def _start(self):
     if(self.started):
         return
     else:
         dirs = mkdirslist(self.root)
         self.fn = touch_trace(self.root, self.name)
         self.tracer = Trace(self.fn)
         self.tracer.trace(TRACE_VERSION, str(TRACE_VER))
         if(len(dirs)):
             for d in dirs:
                 self.tracer.trace(DIR_MADE, d)
         self.started = True
Example #8
0
 def _python_install(self):
     pips = get_pip_list(self.distro, self.component_name)
     #install any need pip items
     if(len(pips)):
         Pip.install(pips)
         for name in pips.keys():
             self.tracewriter.pip_install(name, pips.get(name))
     #do the actual python install
     dirsmade = mkdirslist(self.tracedir)
     self.tracewriter.dir_made(*dirsmade)
     recordwhere = touch_trace(self.tracedir, PY_TRACE)
     self.tracewriter.py_install(recordwhere)
     (sysout, stderr) = execute(*PY_INSTALL, cwd=self.appdir, run_as_root=True)
     write_file(recordwhere, sysout)
Example #9
0
 def _python_install(self):
     pips = get_pip_list(self.distro, self.component_name)
     #install any need pip items
     if (len(pips)):
         Pip.install(pips)
         for name in pips.keys():
             self.tracewriter.pip_install(name, pips.get(name))
     #do the actual python install
     dirsmade = mkdirslist(self.tracedir)
     self.tracewriter.dir_made(*dirsmade)
     recordwhere = touch_trace(self.tracedir, PY_TRACE)
     self.tracewriter.py_install(recordwhere)
     (sysout, stderr) = execute(*PY_INSTALL,
                                cwd=self.appdir,
                                run_as_root=True)
     write_file(recordwhere, sysout)
Example #10
0
 def configure(self):
     dirsmade = mkdirslist(self.cfgdir)
     self.tracewriter.dir_made(*dirsmade)
     configs = self._get_config_files()
     if(configs and len(configs)):
         for fn in configs:
             parameters = self._get_param_map(fn)
             sourcefn = joinpths(STACK_CONFIG_DIR, self.component_name, fn)
             tgtfn = joinpths(self.cfgdir, fn)
             LOG.info("Configuring template file %s" % (sourcefn))
             contents = load_file(sourcefn)
             LOG.info("Replacing parameters in file %s" % (sourcefn))
             LOG.debug("Replacements = %s" % (parameters))
             contents = param_replace(contents, parameters)
             LOG.debug("Applying side-effects of param replacement for template %s" % (sourcefn))
             contents = self._config_adjust(contents, fn)
             LOG.info("Writing configuration file %s" % (tgtfn))
             write_file(tgtfn, contents)
             #this trace is used to remove the files configured
             self.tracewriter.cfg_write(tgtfn)
     return self.tracedir
Example #11
0
 def configure(self):
     dirsmade = mkdirslist(self.cfgdir)
     self.tracewriter.dir_made(*dirsmade)
     configs = self._get_config_files()
     if (configs and len(configs)):
         for fn in configs:
             parameters = self._get_param_map(fn)
             sourcefn = joinpths(STACK_CONFIG_DIR, self.component_name, fn)
             tgtfn = joinpths(self.cfgdir, fn)
             LOG.info("Configuring template file %s" % (sourcefn))
             contents = load_file(sourcefn)
             LOG.info("Replacing parameters in file %s" % (sourcefn))
             LOG.debug("Replacements = %s" % (parameters))
             contents = param_replace(contents, parameters)
             LOG.debug(
                 "Applying side-effects of param replacement for template %s"
                 % (sourcefn))
             contents = self._config_adjust(contents, fn)
             LOG.info("Writing configuration file %s" % (tgtfn))
             write_file(tgtfn, contents)
             #this trace is used to remove the files configured
             self.tracewriter.cfg_write(tgtfn)
     return self.tracedir