当前位置:网站首页>腾讯云轻量服务器删除所有防火墙规则
腾讯云轻量服务器删除所有防火墙规则
2022-07-31 05:12:00 【tcliuwenwen】
博文背景
我以前重度依赖于云防火墙,现在发现它有一定的弊端,所以决定弃用云防火墙,放行所有规则。我使用SDK请求一次性删除所有防火墙规则时并没有抛出错误,但是实际执行并没有成功,经过调试发现一次性请求删除的规则数不宜过多。
具体操作
import os
import json
from tencentcloud.common import credential
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.lighthouse.v20200324 import lighthouse_client, models
try:
cloud_secret_id = "AXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXE"
cloud_secret_key = "AXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXE"
cloud_token = "AXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXE"
cred = credential.Credential(cloud_secret_id, cloud_secret_key, cloud_token)
httpProfile = HttpProfile()
httpProfile.endpoint = "lighthouse.tencentcloudapi.com"
clientProfile = ClientProfile()
clientProfile.httpProfile = httpProfile
client = lighthouse_client.LighthouseClient(cred, "ap-hongkong", clientProfile)
query_req = models.DescribeFirewallRulesRequest()
query_params = {
"InstanceId": "lhins-jjbknicj",
"Offset": 0,
"Limit": 20
}
query_req.from_json_string(json.dumps(query_params))
query_resp = client.DescribeFirewallRules(query_req)
# print(query_resp.to_json_string())
FirewallRules = json.loads(query_resp.to_json_string()).get("FirewallRuleSet")
if FirewallRules == list():
raise Exception("FirewallRules is empty")
req = models.DeleteFirewallRulesRequest()
def deleteAppType(item):
del item["AppType"]
return item
params = {
"InstanceId": "lhins-jjbknicj",
"FirewallRules": list(map(deleteAppType, FirewallRules))
}
print(params)
req.from_json_string(json.dumps(params))
resp = client.DeleteFirewallRules(req)
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)
边栏推荐
猜你喜欢
随机推荐
js中的break与continue退出
MySQL compressed package installation, fool teaching
【云原生】开源数据分析 SPL 轻松应对 T+0
Understanding SSRF, this article is enough
Several solutions for mysql startup error The server quit without updating PID file
C language tutorial (3) - if and loop
2021 Mianjing - Embrace Change
feign调用不通问题,JSON parse error Illegal character ((CTRL-CHAR, code 31)) only regular white space (r
leetcode-每日一题558. 四叉树交集(分治递归)
一文速学-玩转MySQL获取时间、格式转换各类操作方法详解
On the side of Ali, tell me what are the application scenarios of message middleware you know?
gin框架学习-Casbin入门指南(ACL、RBAC、域内RBAC模型)
[windows]--- SQL Server 2008 super detailed installation tutorial
Access database query
win11中利用IIS10搭建asp网站
gin框架学习-JWT认证
vulhub靶场学习日记hackme1
vulhub靶场学习日记SickOs1.2
MySQL分页查询的5种方法
"limit" query in Oracle database