当前位置:网站首页>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)
边栏推荐
- Powershell中UTF-8环境中文乱码解决办法
- 使用ps | egrep时过滤排除掉egrep自身
- sqlite 查看表结构 android.database.sqlite.SQLiteException: table splitTable has no column named
- 年终总结——岁月静好~
- Attribute Changer的几种形态
- [Elastic-Job source code analysis] - job listener
- 什么是EVM兼容链?
- DeFi 项目中的治理Token
- flutter 混合开发 module 依赖
- GUCCI、LV等奢侈品巨头如何布局元宇宙的,其他品牌应该跟上吗?
猜你喜欢

NFT与数字藏品到底有何区别?

Error: Cannot find module ‘D:\Application\nodejs\node_modules\npm\bin\npm-cli.js‘
Getting to know regular expressions

通信原理——纠错编码 | 汉明码(海明码)手算详解

为什么bash中的read要配合while才能读取/dev/stdin的内容

【swagger关闭】生产环境关闭swagger方法

Sqlite A列数据复制到B列
![[Elastic-Job source code analysis] - job listener](/img/99/5e047b1aa83aad7d7f17b4eec606e6.png)
[Elastic-Job source code analysis] - job listener

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

局部变量成员变量、引用类型、this,static(第五天)
随机推荐
对js的数组的理解
[Elastic-Job source code analysis] - job listener
sql 外键约束【表关系绑定】
数据库 | SQL增删改查基础语法
(Crypto必备干货)详细分析目前NFT的几大交易市场
Why is the redis single-threaded also so fast?
[Cloud native] Open source data analysis SPL easily copes with T+0
理解js运算符
File operations in C language (1)
【ubuntu20.04安装MySQL以及MySQL-workbench可视化工具】
(Crypto essential dry goods) Detailed analysis of the current NFT trading markets
kotlin 插件更新到1.3.21
DeFi Token in the project management
quick-3.5 ActionTimeline的setLastFrameCallFunc调用会崩溃问题
2021面经-拥抱变化
【Elastic-Job源码分析】——作业监听器
C language tutorial (1) - preparation
Using IIS10 to build an asp website in win11
npm WARN config global `--global`, `--local` are deprecated. Use `--location解决方案
[Ubuntu20.04 installs MySQL and MySQL-workbench visualization tool]