示例#1
0
文件: change.py 项目: CGenie/solar
def _stage_changes(staged_resources, conn_graph,
                   commited_resources, staged_log):

    try:
        srt = nx.topological_sort(conn_graph)
    except:
        for cycle in nx.simple_cycles(conn_graph):
            log.debug('CYCLE: %s', cycle)
        raise

    for res_uid in srt:
        commited_data = commited_resources.get(res_uid, {})
        staged_data = staged_resources.get(res_uid, {})

        df = create_diff(staged_data, commited_data)

        if df:
            action = guess_action(commited_data, staged_data)
            log_item = data.LogItem(
                utils.generate_uuid(),
                res_uid,
                '{}.{}'.format(res_uid, action),
                df)
            staged_log.append(log_item)
    return staged_log
示例#2
0
def create_logitem(resource, action, diffed, connections_diffed,
                   base_path=None):
    return data.LogItem(
                utils.generate_uuid(),
                resource,
                action,
                diffed,
                connections_diffed,
                base_path=base_path)
示例#3
0
文件: main.py 项目: sand8080/solar
def profile(id, tags, create):
    if not id:
        id = utils.generate_uuid()
    if create:
        params = {'tags': tags, 'id': id}
        profile_template_path = os.path.join(
            utils.read_config()['template-dir'], 'profile.yml')
        data = yaml.load(utils.render_template(profile_template_path, params))
        db.store('profiles', data)
    else:
        pprint.pprint(db.get_list('profiles'))