当前位置:网站首页>Tencent Cloud Lightweight Server deletes all firewall rules
Tencent Cloud Lightweight Server deletes all firewall rules
2022-07-31 05:58:00 【tcliuwenwen】
博文背景
I used to rely heavily on cloud firewalls,It is now found that it has certain drawbacks,So I decided to abandon the cloud firewall,release all rules.我使用SDKNo error was thrown when requesting to delete all firewall rules at once,But the actual execution was not successful,After debugging, it is found that the number of rules requested to be deleted at one time should not be too many.
具体操作
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)
边栏推荐
猜你喜欢
初识正则表达式
MySQL错误-this is incompatible with sql_mode=only_full_group_by完美解决方案
Powershell中UTF-8环境中文乱码解决办法
What is GameFi?
【uiautomation】微信好友列表获取(存储到txt中)
Sqlite A列数据复制到B列
[Elastic-Job source code analysis] - job listener
通信原理——纠错编码 | 汉明码(海明码)手算详解
为什么bash中的read要配合while才能读取/dev/stdin的内容
On the side of Ali, tell me what are the application scenarios of message middleware you know?
随机推荐
【uiautomation】微信好友列表获取(存储到txt中)
sqlmap注入教程 常用指令
NFT与数字藏品到底有何区别?
理解js运算符
What is the difference between NFT and digital collection?
小白学爬虫——爬虫入门
sql 添加 default 约束
什么是 GameFi?
cocos2d-x-3.2 不能混合颜色修改
podspec自动化升级脚本
sqlmap injection tutorial common commands
cocoscreator 显示刘海内容
What is an EVM Compatible Chain?
win11中利用IIS10搭建asp网站
对js的数组的理解
数字孪生将成为进入“元宇宙”一项重要的途径
Digital twins will be an important way to enter the "metaverse"
MySQL面试题大全(陆续更新)
"limit" query in Oracle database
Understanding SSRF, this article is enough