コード例 #1
0
ファイル: template.py プロジェクト: chuanxd/portal
def template_delete_get(tpl_id):
    tpl_id = int(tpl_id)
    t = Template.get(tpl_id)
    if not t:
        return jsonify(msg='no such template')

    if not t.writable(g.user_name):
        return jsonify(msg='no permission')

    Template.delete_one(tpl_id)
    action_id = t.action_id
    if action_id:
        Action.delete_one(action_id)

    Strategy.delete('tpl_id = %s', [tpl_id])

    GrpTpl.unbind_tpl(tpl_id)
    return jsonify(msg='')
コード例 #2
0
def template_delete_get(tpl_id):
    tpl_id = int(tpl_id)
    t = Template.get(tpl_id)
    data = {'templateId': tpl_id}
    alarmAdUrl = config.JSONCFG['shortcut'][
        'falconUIC'] + "/api/v1/alarmadjust/whentempletedeleted"
    if not t:
        return jsonify(msg='no such template')

    if not t.writable(g.user_name):
        return jsonify(msg='no permission')

    Template.delete_one(tpl_id)
    action_id = t.action_id
    if action_id:
        Action.delete_one(action_id)

    Strategy.delete('tpl_id = %s', [tpl_id])

    GrpTpl.unbind_tpl(tpl_id)
    respCode = post2FeUpdateEventCase(alarmAdUrl, data)
    if respCode != 200:
        log.error(alarmAdUrl + " got " + str(respCode) + " with " + str(data))
    return jsonify(msg='')