当前位置:网站首页>腾讯云轻量服务器删除所有防火墙规则
腾讯云轻量服务器删除所有防火墙规则
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)
边栏推荐
- (Crypto必备干货)详细分析目前NFT的几大交易市场
- 【ubuntu20.04安装MySQL以及MySQL-workbench可视化工具】
- Object,多态 1(第八天)
- Install mysqldb in mac10.14
- Error: Cannot find module ‘D:\Application\nodejs\node_modules\npm\bin\npm-cli.js‘
- Linux modify MySQL database password
- How MySQL - depots table?A look at will understand
- 小白学爬虫——爬虫入门
- The feign call fails, JSON parse error Illegal character ((CTRL-CHAR, code 31)) only regular white space (r
- 【Elastic-Job】分布式调度任务概览篇
猜你喜欢

阿里一面,说说你知道消息中间件的应用场景有哪些?

GUCCI、LV等奢侈品巨头如何布局元宇宙的,其他品牌应该跟上吗?

带你搞懂MySQL隔离级别,两个事务同时操作同一行数据会怎样?

Why is the redis single-threaded also so fast?

leetcode-829. 连续整数求和(数论)

The latest MySql installation teaching, very detailed
![[Cloud native] Ribbon is no longer used at the bottom layer of OpenFeign starting from the 2020.0.X version](/img/7e/1d27e3f1856ab8c6cbfc5221c717bb.png)
[Cloud native] Ribbon is no longer used at the bottom layer of OpenFeign starting from the 2020.0.X version

Yuan prospect and four track of the universe

gin框架学习-Gin框架和Gorm框架搭建一个简单的API微服务

Digital twins will be an important way to enter the "metaverse"
随机推荐
计网 Packet Tracer仿真 | 简单易懂集线器和交换机对比(理论+仿真)
Access数据库的查询
The feign call fails, JSON parse error Illegal character ((CTRL-CHAR, code 31)) only regular white space (r
[Cloud native] Ribbon is no longer used at the bottom layer of OpenFeign starting from the 2020.0.X version
C language tutorial (1) - preparation
初识正则表达式
leetcode-2321. 拼接数组的最大分数(差分+枚举)
利用phpstudy搭建DVWA
The MySQL database in Alibaba Cloud was attacked, and the data was finally recovered
MySQL高级SQL语句(二)
leetcode-每日一题565. 数组嵌套(标记图和并查集)
GUCCI、LV等奢侈品巨头如何布局元宇宙的,其他品牌应该跟上吗?
【云原生】SQL(及存储过程)跑得太慢怎么办?
5 methods of MySQL paging query
js中的函数
vulhub靶场学习日记hackme2
【Elastic-Job】分布式调度任务概览篇
NFTs: The Heart of Digital Ownership
什么是EVM兼容链?
2021面经-拥抱变化