diff --git a/04-CustomLibrary/Custometest/cmd_cer.py b/04-CustomLibrary/Custometest/cmd_cer.py index 300b8c8..13b84ea 100644 --- a/04-CustomLibrary/Custometest/cmd_cer.py +++ b/04-CustomLibrary/Custometest/cmd_cer.py @@ -232,7 +232,44 @@ class Order: n+=1 else: return n - + def Interface_data(ipstart,ipend): + list1 = [] + while ipstart<=ipend: + url = "http://192.168.44.17/v1/policy/object" + false = False + true = True + ip = "192.168.2."+str(ipstart) + data = {"opAction":"add","returnData":1,"objectList":{"objectType":"ip","objectSubType":"endpoint","isValid":1,"isInitialize":0,"isExclusion":0,"objectName":str(ip),"objectDesc":"","subObjectIds":[],"addItemList":[{"ip":ip,"ipIf":false,"portIf":false,"port":"0-65535","itemId":"","clientIp1":ip,"clientIp2":ip,"clientPort1":"0","clientPort2":"65535","clientIpFormat":"range","clientPortFormat":"range","addrType":4,"direction":0,"temporaryItemId":1599893528}],"updateItemList":[],"deleteItemIds":[],"iconColor":"#31739C"}} + headers = { + 'Content-Type': "application/json", + 'Authorization': "1520b640-fa0f-4ed4-b972-7e0b75ecec40&103&" + } + # r = requests.post(url,data1,headers=headers) + result = requests.post(url=url, data=json.dumps(data), headers=headers).json() + res = json.dumps(result, ensure_ascii=False, sort_keys=True, indent=2) + a = result["data"]["objectList"][0]["objectId"] + list1.append(a) + # sleep(1) + # print(res) + # print("**************") + # print(result["data"]["objectList"][0]["objectId"]) + + # print(ip) + ipstart+=1 + url = "http://192.168.44.17/v1/policy/object" + false = False + true = True + data = {"opAction":"add","returnData":1,"objectList":{"objectType":"ip","objectSubType":"endpoint","isValid":1,"isInitialize":0,"isExclusion":0,"objectName":"192.168.2."+str(ipstart)+"~"+str(ipend)+"集合","objectDesc":"","subObjectIds":list1,"addItemList":[],"updateItemList":[],"deleteItemIds":[],"iconColor":"#31739C"}} + headers = { + 'Content-Type': "application/json", + 'Authorization': "1520b640-fa0f-4ed4-b972-7e0b75ecec40&103&" + } + # r = requests.post(url,data1,headers=headers) + result1 = requests.post(url=url, data=json.dumps(data), headers=headers).json() + res = json.dumps(result1, ensure_ascii=False, sort_keys=True, indent=2) + # a = result["data"]["objectList"][0]["objectId"] + + return result1 if __name__ == '__main__': # datas = {"url":['https://www.baidu.com'],