Example #1
0
    def getInstances(self):
        _instances = {}
        for d in self._instanceDirs:
            path = listPath(d)
            # For each path to scan
            for iDir in path:
                # Check if the file exists and if there is a VagrantFile and a config file in it
                if os.path.isdir(iDir) and os.path.exists(
                        os.path.join(iDir, "Vagrantfile")) and os.path.exists(
                            os.path.join(iDir, MACHINATION_CONFIGFILE_NAME)):
                    try:
                        filename = os.path.join(iDir,
                                                MACHINATION_CONFIGFILE_NAME)
                        openedFile = open(filename, "r")
                        instance = yaml.load(openedFile)
                        _instances[instance.getName()] = instance
                        REGISTRYLOGGER.debug(
                            "Instance stored in '{0}' loaded".format(filename))

                    except Exception as e:
                        REGISTRYLOGGER.error(
                            "Unable to load instance stored in '{0}': {1}".
                            format(iDir, str(e)))
                        REGISTRYLOGGER.debug(traceback.format_exc())
        return _instances
Example #2
0
 def getTemplates(self):
   machineTemplates = {}
   for d in self._templateDirs:
     files = listPath(d)
     for f in files:
       if os.path.isfile(f) and  os.path.splitext(os.path.basename(f))[1] == ".template":
         try:
           openedFile = open(os.path.join(f), "r")
           template = yaml.load(openedFile)
           machineTemplates["{0}:{1}".format(template.getName(),template.getVersion())] = template
           REGISTRYLOGGER.debug("Template stored in '{0}' loaded".format(f))
         except Exception as e:
           REGISTRYLOGGER.warning("Unable to load template stored in '{0}: {1}".format(f,str(e)))
           REGISTRYLOGGER.debug(traceback.format_exc())
   return machineTemplates
Example #3
0
 def getInstances(self):
   _instances = {}
   for d in self._instanceDirs:
     path = listPath(d)
     # For each path to scan
     for iDir in path:
       # Check if the file exists and if there is a VagrantFile and a config file in it
       if os.path.isdir(iDir) and os.path.exists(os.path.join(iDir, "Vagrantfile")) and os.path.exists(os.path.join(iDir, MACHINATION_CONFIGFILE_NAME)):
         try:
           filename = os.path.join(iDir, MACHINATION_CONFIGFILE_NAME)
           openedFile = open(filename, "r")
           instance = yaml.load(openedFile)
           _instances[instance.getName()] = instance
           REGISTRYLOGGER.debug("Instance stored in '{0}' loaded".format(filename))
           
         except Exception as e:
           REGISTRYLOGGER.error("Unable to load instance stored in '{0}': {1}".format(iDir, str(e)))
           REGISTRYLOGGER.debug(traceback.format_exc())
   return _instances
Example #4
0
 def getTemplates(self):
     machineTemplates = {}
     for d in self._templateDirs:
         files = listPath(d)
         for f in files:
             if os.path.isfile(f) and os.path.splitext(
                     os.path.basename(f))[1] == ".template":
                 try:
                     openedFile = open(os.path.join(f), "r")
                     template = yaml.load(openedFile)
                     machineTemplates["{0}:{1}".format(
                         template.getName(),
                         template.getVersion())] = template
                     REGISTRYLOGGER.debug(
                         "Template stored in '{0}' loaded".format(f))
                 except Exception as e:
                     REGISTRYLOGGER.warning(
                         "Unable to load template stored in '{0}: {1}".
                         format(f, str(e)))
                     REGISTRYLOGGER.debug(traceback.format_exc())
     return machineTemplates
Example #5
0
 def __init__(self, templateDirs):
     self._templateDirs = templateDirs
     REGISTRYLOGGER.debug(
         "Templates are searched in the following directories: {0}".format(
             ','.join(self._templateDirs)))
Example #6
0
 def __init__(self, instanceDirs):
     REGISTRYLOGGER.debug("Template registry initialized.")
     self._instanceDirs = instanceDirs
     REGISTRYLOGGER.debug(
         "Instances are searched in the following directories: {0}".format(
             ', '.join(self._instanceDirs)))
Example #7
0
 def __init__(self, templateDirs):
   self._templateDirs = templateDirs
   REGISTRYLOGGER.debug("Templates are searched in the following directories: {0}".format(','.join(self._templateDirs)))
Example #8
0
 def __init__(self, instanceDirs):
   REGISTRYLOGGER.debug("Template registry initialized.")
   self._instanceDirs = instanceDirs
   REGISTRYLOGGER.debug("Instances are searched in the following directories: {0}".format(', '.join(self._instanceDirs)))