当前位置:网站首页>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统计文件夹大小
- 【swagger关闭】生产环境关闭swagger方法
- cocos2d-x-3.2 不能混合颜色修改
- UiBot存在已打开的MicrosoftEdge浏览器,无法执行安装
- 正则表达式基础知识
- SQLite 查询表中每天插入的数量
- 著名网站msdn.itellyou.cn原理分析
- sqlite 查看表结构 android.database.sqlite.SQLiteException: table splitTable has no column named
- [Elastic-Job source code analysis] - job listener
- 碎片化NFT(Fractional NFT)
猜你喜欢
Error: Cannot find module ‘D:\Application\nodejs\node_modules\npm\bin\npm-cli.js‘
js中的this指向与原型对象
(Crypto essential dry goods) Detailed analysis of the current NFT trading markets
小米手机短信定位服务激活失败
2021美赛C题M奖思路
MySQL-如何分库分表?一看就懂
【云原生】微服务Nacos的简单介绍与使用
【windows】--- SQL Server 2008 超详细安装教程
数字孪生将成为进入“元宇宙”一项重要的途径
年终总结——岁月静好~
随机推荐
2021美赛C题M奖思路
【uiautomation】微信好友列表获取(存储到txt中)
CMOS管原理,及其在推挽电路中的应用
什么是 GameFi?
The feign call fails, JSON parse error Illegal character ((CTRL-CHAR, code 31)) only regular white space (r
Oracle数据库中的“limit”查询
quick-3.5 无法正常显示有混合纹理的csb文件
js中的对象与函数的理解
Digital twins will be an important way to enter the "metaverse"
使用ps | egrep时过滤排除掉egrep自身
[Ubuntu20.04 installs MySQL and MySQL-workbench visualization tool]
UiBot存在已打开的MicrosoftEdge浏览器,无法执行安装
[Elastic-Job] Overview of Distributed Scheduling Tasks
win11中利用IIS10搭建asp网站
理解js运算符
场效应管 | N-mos内部结构详解
flutter arr 依赖
NFT与数字藏品到底有何区别?
2021年京东数据分析工程师秋招笔试编程题
mysql启动报错The server quit without updating PID file几种解决办法