def template_unbind_group_get(): tpl_id = request.args.get('tpl_id', '') grp_id = request.args.get('grp_id', '') if not tpl_id: return jsonify(msg="tpl_id is blank") if not grp_id: return jsonify(msg="grp_id is blank") GrpTpl.unbind(grp_id, tpl_id) return jsonify(msg='')
def group_bind_template_get(): tpl_id = request.args.get('tpl_id', '').strip() grp_id = request.args.get('grp_id', '').strip() if not tpl_id: return jsonify(msg="tpl id is blank") if not grp_id: return jsonify(msg="grp id is blank") GrpTpl.bind(grp_id, tpl_id, g.user.name) return jsonify(msg='')
def template_bind_node_post(): node = request.form['node'].strip() tpl_id = request.form['tpl_id'].strip() if not node: return jsonify(msg='node is blank') if not tpl_id: return jsonify(msg='tpl id is blank') hg = HostGroup.read('grp_name=%s', [node]) if not hg: return jsonify(msg='no such node') GrpTpl.bind(hg.id, tpl_id, g.user.name) return jsonify(msg="")
def template_unbind_grp_name_get(): tpl_id = request.args.get('tpl_id', '') if not tpl_id: return jsonify(msg="tpl_id is blank") grp_name = request.args.get('grp_name', '') if not grp_name: return jsonify(msg='grp_name is blank') hg = HostGroup.read('grp_name=%s', [grp_name]) if not hg: return jsonify(msg='no such host group') GrpTpl.unbind(hg.id, tpl_id) return jsonify(msg='')
def group_templates_get(grp_id): grp_id = int(grp_id) grp = HostGroup.read(where='id = %s', params=[grp_id]) if not grp: return jsonify(msg='no such group') ts = GrpTpl.tpl_list(grp_id) return render_template('portal/group/templates.html', group=grp, ts=ts)
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): 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='')
def template_binds_get(tpl_id): tpl_id = int(tpl_id) t = Template.get(tpl_id) if not t: return jsonify(msg='no such template') groups = GrpTpl.grp_list(tpl_id) return render_template('portal/template/groups.html', data={ "gs": groups, "tpl": t, })
def host_templates_get(host_id): host_id = int(host_id) h = Host.read('id = %s', params=[host_id]) if not h: return jsonify(msg='no such host') group_ids = GroupHost.group_ids(h.id) templates = GrpTpl.tpl_set(group_ids) for v in templates: v.parent = Template.get(v.parent_id) return render_template('portal/host/templates.html', **locals())