Пример #1
0
 def run(self, config):
     """execute a configuration"""
     amis_burned = []
     errors = []
     if config == self.ALL_CONFIGS:
         configs = self.getConfigs()
     else:
         configs = [os.path.splitext(config)[0]]
     sys.path = [util.getCurDir()] + sys.path
     for cfg in configs:
         logging.info("processing: " + cfg + " in: " + os.getcwd())
         if config == self.ALL_CONFIGS:
             c = __import__(os.path.basename(self.CONFIG_DIR) + "." + cfg)
             mod = "c." + cfg + "."
         else:
             c = __import__(cfg)
             mod = "c."
         skip_me = eval(mod + self.SKIP_ME)
         if skip_me:
             logging.info("skipping execution of config: %s due to its configuration skip_me=true" % cfg)
             continue
         amis = eval(mod + self.AMIS)
         commands =  eval(mod + self.CMDS)
         user =  eval(mod + self.USER)
         burn_at_the_end = eval(mod + self.BURN_OR_NOT)
         a,e = self._processConfig(amis, commands, user, burn_at_the_end, eval(mod + self.KEY_NAME), 
                                   eval(mod + self.SECURITY_GROUPS), eval(mod + self.INSTANCE_TYPE))
         amis_burned += a
         errors += e
     self.printErrors(errors)
     logging.info("total of ami's burned:%s" % len(amis_burned))
     for a in amis_burned:
         logging.info(str(a))
     return 0 if len(errors)==0 else 1
Пример #2
0
 def provision(self, configuration, user, hostname, pk):
     """execute a configuration"""
     configs = os.path.splitext(configuration)[0]
     cfg = configs
     sys.path = [util.getCurDir()] + sys.path
     logging.info("processing: " + cfg + " in: " + os.getcwd())
     module_name = os.path.basename(cfg) 
     c = util.importModule(cfg)
     commands = self.getVal(c, module_name, self.CMDS, None)
     user =  self.getVal(c, module_name, self.USER, user)
     key_name = self.getVal(c, module_name, self.KEY_NAME, pk)
     util.waitForSSHReady(user, key_name, hostname)
     errors = self._processConfig(str(configuration), commands, user, key_name, hostname)
     self.printErrors(errors)
     return 0 if len(errors)==0 else 1