当前位置:网站首页>腾讯云轻量服务器删除所有防火墙规则
腾讯云轻量服务器删除所有防火墙规则
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)
边栏推荐
- First acquaintance with Flask
- vulhub靶场学习日记hackme1
- The server time zone value ‘й‘ is unrecognized or represents more than one time zone
- Several solutions for mysql startup error The server quit without updating PID file
- Regular Expression Basics
- win11中利用IIS10搭建asp网站
- 利用phpstudy搭建DVWA
- 什么是EVM兼容链?
- 【JVM加载】---类加载机制
- DeFi 项目中的治理Token
猜你喜欢

leetcode-1833. 雪糕的最大数量(排序+贪心)

leetcode-每日一题剑指 Offer II 041. 滑动窗口的平均值(队列模拟)

什么是 GameFi?

【ubuntu20.04安装MySQL以及MySQL-workbench可视化工具】
![[Elastic-Job source code analysis] - job listener](/img/99/5e047b1aa83aad7d7f17b4eec606e6.png)
[Elastic-Job source code analysis] - job listener

DeFi Token in the project management

MySql to create data tables

MySQL compressed package installation, fool teaching

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

UiBot存在已打开的MicrosoftEdge浏览器,无法执行安装
随机推荐
计网 Packet Tracer仿真 | 简单易懂集线器和交换机对比(理论+仿真)
MySQL压缩包方式安装,傻瓜式教学
vulhub靶场学习日记hackme2
leetcode-每日一题1252. 奇数值单元格的数目(模拟优化)
win11中利用IIS10搭建asp网站
[Elastic-Job] Overview of Distributed Scheduling Tasks
sqlmap注入教程 常用指令
阿里一面,说说你知道消息中间件的应用场景有哪些?
UiBot存在已打开的MicrosoftEdge浏览器,无法执行安装
mysql password modification method in Linux (pro-test available)
元宇宙的前景及四大赛道
On the side of Ali, tell me what are the application scenarios of message middleware you know?
局部变量成员变量、引用类型、this,static(第五天)
常见JVM面试题及答案整理
[Cloud native] Open source data analysis SPL easily copes with T+0
How to distinguish big and small endian in C language
Error: Cannot find module 'D:\Application\nodejs\node_modules\npm\bin\npm-cli.js'
mac10.14中安装mysqldb
利用phpstudy搭建DVWA
[Cloud native] Ribbon is no longer used at the bottom layer of OpenFeign starting from the 2020.0.X version