(request)
return HttpResponse(json.dumps({"status": 403, "result": u"参数不正确"}, ensure_ascii=False, indent=4, ))
sn编号查询，返回记录IP
sn编号查询，返回记录IP
sn编号查询，返回记录IP
def CmdbUpdate(request):
    """
    sn编号查询，返回记录IP
    """
    import requests
    url = "http://192.168.8.80:8000/cmdb/"
    s = requests.get(url)
    rst = s.json()
    data = rst.get("result")
    idc = IDC.objects.get(pk="9b70bec5660441c2ae10908da1db38d3")
    for i in data:
        result = i.get("fields")
        try:
            host_data = Host.objects.get(eth1=result.get("eth1"))
            host_data.cpu = result.get("cpu", "")
            host_data.memory = result.get("memory", "")
            host_data.hard_disk = result.get("hard_disk", "")
            host_data.brand = result.get("brand", "Dell R410")
            host_data.editor = result.get("editor", "")
            host_data.number = result.get("number", "")
            host_data.eth2 = result.get("eth2", "")
            host_data.save()
        except:
            cmdb = Host(node_name=result.get("node_name"),
                        eth1=result.get("eth1"),
                        mac=result.get("mac"),
                        internal_ip=result.get("internal_ip"),
                        brand=result.get("brand"),
                        cpu=result.get("cpu"),
                        idc=idc,
                        system="CentOS",
                        system_cpuarch="X86_64",
                        cabinet=result.get("cabinet"),
                        server_cabinet_id=result.get("server_cabinet_id"),
                        number=result.get("number"),
                        editor=result.get("editor"),
                        status=result.get("status", 1),
                        room_number=result.get("room_number"),
                        hard_disk=result.get("hard_disk"),
                        eth2=result.get("eth2", ""),
                        memory=result.get("memory", ""),
                        server_sn=result.get("server_sn", ""))
            cmdb.save()
    return HttpResponse(json.dumps({"status": 403, "result": u"参数不正确"}, ensure_ascii=False, indent=4, ))
def CmdbUpdate ( request ) : import requests url = "http://192.168.8.80:8000/cmdb/" s = requests . get ( url ) rst = s . json ( ) data = rst . get ( "result" ) idc = IDC . objects . get ( pk = "9b70bec5660441c2ae10908da1db38d3" ) for i in data : result = i . get ( "fields" ) try : host_data = Host . objects . get ( eth1 = result . get ( "eth1" ) ) host_data . cpu = result . get ( "cpu" , "" ) host_data . memory = result . get ( "memory" , "" ) host_data . hard_disk = result . get ( "hard_disk" , "" ) host_data . brand = result . get ( "brand" , "Dell R410" ) host_data . editor = result . get ( "editor" , "" ) host_data . number = result . get ( "number" , "" ) host_data . eth2 = result . get ( "eth2" , "" ) host_data . save ( ) except : cmdb = Host ( node_name = result . get ( "node_name" ) , eth1 = result . get ( "eth1" ) , mac = result . get ( "mac" ) , internal_ip = result . get ( "internal_ip" ) , brand = result . get ( "brand" ) , cpu = result . get ( "cpu" ) , idc = idc , system = "CentOS" , system_cpuarch = "X86_64" , cabinet = result . get ( "cabinet" ) , server_cabinet_id = result . get ( "server_cabinet_id" ) , number = result . get ( "number" ) , editor = result . get ( "editor" ) , status = result . get ( "status" , 1 ) , room_number = result . get ( "room_number" ) , hard_disk = result . get ( "hard_disk" ) , eth2 = result . get ( "eth2" , "" ) , memory = result . get ( "memory" , "" ) , server_sn = result . get ( "server_sn" , "" ) ) cmdb . save ( ) return HttpResponse ( json . dumps ( { "status" : 403 , "result" : u"参数不正确"}, ensure_ a s ii=False, in d ent=4 , ))