Ejemplo n.º 1
0
 def resources(self):
     resources = []
     for file_path in utils.find_by_mask(self.FILE_MASK):
         res = utils.yaml_load(file_path)
         res['parent_path'] = file_path
         resources.append(res)
     return resources
Ejemplo n.º 2
0
    def _get_resources_list():
        result = []
        for path in utils.find_by_mask(utils.read_config()['resources-files-mask']):
            resource = utils.yaml_load(path)
            resource['path'] = path
            resource['dir_path'] = os.path.dirname(path)
            result.append(resource)

        return result
Ejemplo n.º 3
0
def read_meta(base_path):
    base_meta_file = os.path.join(base_path, 'meta.yaml')

    metadata = utils.yaml_load(base_meta_file)
    metadata['version'] = '1.0.0'
    metadata['base_path'] = os.path.abspath(base_path)
    actions_path = os.path.join(metadata['base_path'], 'actions')
    metadata['actions_path'] = actions_path
    metadata['base_name'] = os.path.split(metadata['base_path'])[-1]

    return metadata
Ejemplo n.º 4
0
def read_meta(base_path):
    base_meta_file = os.path.join(base_path, "meta.yaml")

    metadata = utils.yaml_load(base_meta_file)
    metadata["version"] = "1.0.0"
    metadata["base_path"] = os.path.abspath(base_path)
    actions_path = os.path.join(metadata["base_path"], "actions")
    metadata["actions_path"] = actions_path
    metadata["base_name"] = os.path.split(metadata["base_path"])[-1]

    return metadata
Ejemplo n.º 5
0
def compile_all():
    from solar.core.resource import compiler

    destination_path = utils.read_config()['resources-compiled-file']

    if os.path.exists(destination_path):
        os.remove(destination_path)

    for path in utils.find_by_mask(utils.read_config()['resources-files-mask']):
        meta = utils.yaml_load(path)
        meta['base_path'] = os.path.dirname(path)

        compiler.compile(meta)
Ejemplo n.º 6
0
def read_meta(base_path):
    base_meta_file = os.path.join(base_path, 'meta.yaml')

    metadata = utils.yaml_load(base_meta_file)
    metadata.setdefault('version', '1.0.0')
    # NOTE(jnowak): when `version: 0.1` then it's float
    metadata['version'] = str(metadata['version'])
    metadata['base_path'] = os.path.abspath(base_path)
    actions_path = os.path.join(metadata['base_path'], 'actions')
    metadata['actions_path'] = actions_path
    metadata['base_name'] = os.path.split(metadata['base_path'])[-1]

    return metadata
Ejemplo n.º 7
0
def parse_plan(plan_path):
    """ parses yaml definition and returns graph
    """
    plan = utils.yaml_load(plan_path)
    dg = nx.MultiDiGraph()
    dg.graph["name"] = plan["name"]
    for task in plan["tasks"]:
        defaults = {"status": "PENDING", "errmsg": None}
        defaults.update(task["parameters"])
        dg.add_node(task["uid"], **defaults)
        for v in task.get("before", ()):
            dg.add_edge(task["uid"], v)
        for u in task.get("after", ()):
            dg.add_edge(u, task["uid"])
    return dg
Ejemplo n.º 8
0
def parse_plan(plan_path):
    """parses yaml definition and returns graph"""
    plan = utils.yaml_load(plan_path)
    dg = nx.MultiDiGraph()
    dg.graph['name'] = plan['name']
    for task in plan['tasks']:
        defaults = {
            'status': 'PENDING',
            'errmsg': '',
        }
        defaults.update(task['parameters'])
        dg.add_node(
            task['uid'], **defaults)
        for v in task.get('before', ()):
            dg.add_edge(task['uid'], v)
        for u in task.get('after', ()):
            dg.add_edge(u, task['uid'])
    return dg
Ejemplo n.º 9
0
def create_resource(name, base_path, args, virtual_resource=None):
    if isinstance(base_path, provider.BaseProvider):
        base_path = base_path.directory

    base_meta_file = os.path.join(base_path, "meta.yaml")
    actions_path = os.path.join(base_path, "actions")

    metadata = utils.yaml_load(base_meta_file)
    metadata["id"] = name
    metadata["version"] = "1.0.0"
    metadata["base_path"] = os.path.abspath(base_path)

    prepare_meta(metadata)

    tags = metadata.get("tags", [])

    resource = Resource(name, metadata, args, tags, virtual_resource)
    return resource