示例#1
0
def vm_op_ajax(req):
    vmid = req.POST.get('vmid')
    op = req.POST.get('op')
    res = api_vm_op({'req_user': req.user, 'uuid': vmid, 'op': op})
    if not res['res'] and res['err'] in ERROR_CN:
        res['error'] = ERROR_CN[res['err']]
    return HttpResponse(json.dumps(res), content_type='application/json')
示例#2
0
def vm_op_ajax(req):
    vmid = req.POST.get('vmid')
    op = req.POST.get('op')
    res = api_vm_op({
        'req_user': req.user,
        'uuid': vmid,
        'op': op})
    if not res['res'] and res['err'] in ERROR_CN:
        res['error'] = ERROR_CN[res['err']]
    return HttpResponse(json.dumps(res), content_type='application/json')
示例#3
0
def vm_batch_op_ajax(req):
    vmid_list = req.POST.getlist('vmid_list[]')
    op = req.POST.get('op')
    res_list = []
    for vmid in vmid_list:
        res = api_vm_op({'req_user': req.user, 'uuid': vmid, 'op': op})
        if not res['res'] and res['err'] in ERROR_CN:
            res['error'] = ERROR_CN[res['err']]
        res['vmid'] = vmid
        res_list.append(res)
    return HttpResponse(json.dumps(res_list), content_type='application/json')