def DeployResult(request, jid):
    if request.method == 'GET':
        minions_list = request.GET.get('minion')
        savelogid = request.GET.get('savelogid')

        saltm = Minions.objects.get(minion=minions_list.split(',')[0])

        url = saltm.saltserver.url
        username = saltm.saltserver.username
        password = saltm.saltserver.password

        salt = SaltApi(url, username, password)
        resultdata = salt.salt_runner(jid)
        resultdata = JobResultFromat(resultdata)

        #print savelogid
        #logs = CmdRunLog.objects.get(id=savelogid)
        #logs.runresult=resultdata
        #logs.runsuccess=len(resultdata)
        #logs.save()
        #print yaml.load_all(resultdata)

        ret = {'minion': minions_list, 'resultdata': resultdata}

        return HttpResponse(json.dumps(ret))
def jobdetail(request):
    if request.method == 'GET':
        jid = request.GET.get('jid')
        print jid
        jiddata = SaltJobs.objects.get(jid=jid)
        masterdata = SaltServer.objects.get(url=jiddata.saltserver)
        url = masterdata.url
        username = masterdata.username
        password = masterdata.password

        salt = SaltApi(url, username, password)
        resultdata = salt.salt_runner(jid)
        return HttpResponse(json.dumps(resultdata))