From 163745ffa8340467412d478e442b203e83487524 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E6=98=8E=E6=98=8E?= Date: Sat, 12 Sep 2020 15:38:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E9=80=A0=E6=89=B9=E9=87=8FIP?= =?UTF-8?q?=E4=BD=9C=E4=B8=BAItem=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 04-CustomLibrary/Custometest/cmd_cer.py | 39 ++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) 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'],