Example #1
0
def load(filename):
    nodes = {}
    with open(filename, 'r') as yaml:
        data = util.load(yaml)
    for hostname, node in data.items():
        nodes[hostname] = LoomNode(hostname, **node)
    return nodes
Example #2
0
 def loadBaseConf(self):
     "load base configuration"
     config_paths = self.config_paths
     if not config_paths:
         config_paths = default_config_paths
     for path in config_paths:
         if os.path.isfile(path):
             self.watcher.watch(path)
             return util.load(open(path, 'r'))
     raise Exception('No configuration could be found!')
Example #3
0
def load(scheduler, jobs_path, data_path=None):
    "load all jobs from specified yaml file"
    # load yaml front-matter data
    front_matter = ''
    if data_path:
        with open(data_path, 'r') as yaml:
            front_matter = util.load(yaml) + "\n\n"
    # find all job files under jobs path
    job_files = []
    for r,d,f in os.walk(jobs_path):
        for files in f:
            if files.endswith(".yaml"):
                job_files.append(os.path.join(r,files))
    # load each job file found
    jobs = {}
    for job_file in job_files:
        with open(job_file, 'r') as yaml:
            data = util.load(front_matter + yaml.read())
        if 'jobs' in data:
            scheduler.watcher.watch(job_file)
            for name, job in data['jobs'].items():
                jobs[name] = LoomJob(scheduler, name, **job)
    print len(jobs), "jobs loaded."
    return jobs