Beispiel #1
0
 def templates(self, request):
     group_id = request.GET['id']
     f = Falcon()
     data = f.get_templates_of_hostgroup(group_id)
     hostgroup_info = data['hostgroup']
     data = data['templates']
     all_template_list = f.get_all_template_list()
     all_template_list = all_template_list['templates']
     return render(request, 'alarm/hostgroup_templates.html', locals())
Beispiel #2
0
 def update(self, request):
     template_id = request.GET['id']
     f = Falcon()
     hostgroups = f.get_hostgroups_of_template(template_id)  #当前模板下已关联的机器组
     current_hostgroup_ids = [i['id'] for i in hostgroups['hostgroups']]
     template_info = f.get_template_info(template_id)
     print template_info
     all_template_list = f.get_all_template_list()
     all_template_list = all_template_list['templates']
     print all_template_list
     all_hostgroup_list = f.get_all_hostgroup_list()
     op_list = ['==', '!=', '<', '<=', '>', '>=']
     cur_uic = template_info['action']['uic']
     cur_uic_list = cur_uic.split(',')
     all_uic = f.query_team()
     all_uic_list = [i['team']['name'] for i in all_uic]
     return render(request, 'alarm/template_update.html', locals())
Beispiel #3
0
 def data(self, request):
     limit = int(request.GET['limit'])
     page = int(request.GET['page'])
     name = request.GET['name']
     f = Falcon()
     result = f.get_all_template_list(q=name)
     result = result['templates']
     total = len(result)
     result = result[(page - 1) * limit:page * limit]
     data = []
     for i in result:
         data.append({
             'tpl_name': i['template']['tpl_name'],
             'parent_name': i['parent_name'],
             'create_user': i['template']['create_user'],
             'id': i['template']['id']
         })
     return HttpResponse(json.dumps({'total': total, 'rows': data}))