当前位置:网站首页>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)
边栏推荐
- 一个简单的bash转powershell案例
- Understanding SSRF, this article is enough
- Using IIS10 to build an asp website in win11
- 数据库 | SQL增删改查基础语法
- Build vulhub vulnerability shooting range on kali
- cocos2d-x-3.2 Physics
- 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
- 腾讯云轻量服务器删除所有防火墙规则
- 使用ps | egrep时过滤排除掉egrep自身
猜你喜欢
[windows]--- SQL Server 2008 super detailed installation tutorial
Access数据库的查询
Eternal blue bug reappears
著名网站msdn.itellyou.cn原理分析
Android软件安全与逆向分析阅读笔记
永恒之蓝漏洞复现
Artifact SSMwar exploded Error deploying artifact.See server log for details
元宇宙的前景及四大赛道
(Crypto essential dry goods) Detailed analysis of the current NFT trading markets
【Elastic-Job源码分析】——作业监听器
随机推荐
在kali上搭建vulhub漏洞靶场
Regular Expression Basics
MySQL高级SQL语句(二)
quick-3.5 无法正常显示有混合纹理的csb文件
Hyper-V新建虚拟机注意事项
纯shell实现文本替换
Eternal blue bug reappears
阿里云中mysql数据库被攻击了,最终数据找回来了
Fragmented NFT (Fractional NFT)
Why is the redis single-threaded also so fast?
Linux修改MySQL数据库密码
CMOS管原理,及其在推挽电路中的应用
使用ps | egrep时过滤排除掉egrep自身
数据库 | SQL查询进阶语法
NFT:数字所有权的核心
What is an EVM Compatible Chain?
Linux modify MySQL database password
mysql password modification method in Linux (pro-test available)
Digital twins will be an important way to enter the "metaverse"
js中的break与continue退出