diff options
Diffstat (limited to 'createObject.py')
| -rw-r--r-- | createObject.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/createObject.py b/createObject.py index 9d06535..e7b0376 100644 --- a/createObject.py +++ b/createObject.py @@ -242,7 +242,7 @@ class CreateObject(): def import_object(self, obj_type, vsys_id, add_item_list, api_host, token, is_repeat): headers = {"Authorization": token} - data = {'type': obj_type, 'vsys_id': vsys_id, 'statistics_option': 'none'} + data = {'type': obj_type, 'vsys_id': vsys_id, 'statistics_option': 'none', 'is_dry_run':0} dry_data = {'type': obj_type, 'vsys_id': vsys_id, 'is_dry_run':1, 'statistics_option': 'none'} for item in add_item_list: object_file = item['keywordArray'][0] @@ -251,10 +251,17 @@ class CreateObject(): url = api_host + "/v1/policy/object/import" # dry run校验导入的文件是否合规 response = requests.post(url, data=dry_data, headers=headers, files= files, verify=False) - assert response.status_code == 200 + time1 = datetime.utcnow() # 正式导入 + for item in add_item_list: + object_file = item['keywordArray'][0] + file_name = object_file.split("/")[-1] + files = {"file":(file_name, open(object_file, 'rb'), "text/plain")} response = requests.post(url, data=data, headers=headers, files= files, verify=False) + + assert response.status_code == 200 + print(response.text) print('已经请求了1次了') print('本次请求返回的code号是'+ str(response.status_code)) time.sleep(20) |
