当前位置:网站首页>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)
边栏推荐
猜你喜欢

Install mysqldb in mac10.14

feign调用不通问题,JSON parse error Illegal character ((CTRL-CHAR, code 31)) only regular white space (r

【云原生】微服务Nacos的简单介绍与使用
![[JVM Loading]---Class Loading Mechanism](/img/b6/d1754cb6699d18602ca9a463571c0c.png)
[JVM Loading]---Class Loading Mechanism

MySQL错误-this is incompatible with sql_mode=only_full_group_by完美解决方案

(Crypto essential dry goods) Detailed analysis of the current NFT trading markets

MySql创建数据表

Common JVM interview questions and answers

数字孪生将成为进入“元宇宙”一项重要的途径

js中的对象与函数的理解
随机推荐
mysql password modification method in Linux (pro-test available)
feign调用不通问题,JSON parse error Illegal character ((CTRL-CHAR, code 31)) only regular white space (r
On the side of Ali, tell me what are the application scenarios of message middleware you know?
Several solutions for mysql startup error The server quit without updating PID file
Markdown 帮助文档
一个简单的bash转powershell案例
[Cloud native] Open source data analysis SPL easily copes with T+0
Oracle数据库中的“limit”查询
为什么redis是单线程还那么快?
MySql to create data tables
What is the difference between NFT and digital collection?
数字孪生将成为进入“元宇宙”一项重要的途径
[JVM Loading]---Class Loading Mechanism
GUCCI、LV等奢侈品巨头如何布局元宇宙的,其他品牌应该跟上吗?
(Crypto必备干货)详细分析目前NFT的几大交易市场
cocos2d-x 实现跨平台的目录遍历
js中的函数
NFT与数字藏品到底有何区别?
Hyper-V新建虚拟机注意事项
MySQL分页查询的5种方法