1、启用专业版脚本 enable_pro.py
import json,argparse
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.cwp.v20180228 import cwp_client, models
parser = argparse.ArgumentParser(description='Test Argparse.')
parser.add_argument('-u', type=str,
help='CVM uuid , example: 2415d1da-b34e-435e-8b6c-1015e0244497 ')
parser.add_argument('-f', type=argparse.FileType('r'),
help='file includes uuids')
args = parser.parse_args()
uuids = []
if args.u:
uuid = args.u
uuids.append(uuid)
elif args.f:
with args.f as f:
for uuid in f.readlines():
uuid = uuid.strip('\n')
uuids.append(uuid)
print(uuids)
SecretId="你的id"
SecretKey="你的key"
try:
cred = credential.Credential(SecretId, SecretKey)
httpProfile = HttpProfile()
httpProfile.endpoint = "cwp.tencentcloudapi.com"
clientProfile = ClientProfile()
clientProfile.httpProfile = httpProfile
client = cwp_client.CwpClient(cred, "", clientProfile)
req = models.OpenProVersionRequest()
params = {
"MachineType": "cvm",
"MachineRegion": "0",
"Quuids": uuids
}
req.from_json_string(json.dumps(params))
resp = client.OpenProVersion(req)
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)
使用方法
- -u 参数,指定uuid
python3 enable_pro.py -u 613c8a68-12c3-4f10-b831-509109f291a3
- -f 参数,指定一个包含了很多uuid的文件
python3 enable_pro.py -f cvmfile
cvmfile 是uuid的集合,如下范例:
[root@VM-99-12-centos 004-主机安全]# cat cvmfile
2415d1da-b34e-435e-8b6c-1015e0244497
2415d1da-b34e-435e-8b6c-1015e0244498
2415d1da-b34e-435e-8b6c-1015e0244499
2、关闭专业版脚本 disable_pro.py
import json,argparse
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.cwp.v20180228 import cwp_client, models
parser = argparse.ArgumentParser(description='Test Argparse.')
parser.add_argument('-u', type=str,
help='CVM uuid , example: 2415d1da-b34e-435e-8b6c-1015e0244497 ')
parser.add_argument('-f', type=argparse.FileType('r'),
help='file includes uuids')
args = parser.parse_args()
SecretId="你的id"
SecretKey="你的key"
def disable_pro(uuid):
print("disable uuid : ",uuid)
try:
cred = credential.Credential(SecretId, SecretKey)
httpProfile = HttpProfile()
httpProfile.endpoint = "cwp.tencentcloudapi.com"
clientProfile = ClientProfile()
clientProfile.httpProfile = httpProfile
client = cwp_client.CwpClient(cred, "", clientProfile)
req = models.CloseProVersionRequest()
params = {
"Quuid": uuid
}
req.from_json_string(json.dumps(params))
resp = client.CloseProVersion(req)
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)
if args.u:
uuid = args.u
disable_pro(uuid)
elif args.f:
with args.f as f:
for uuid in f.readlines():
uuid = uuid.strip('\n')
disable_pro(uuid)
使用方法
- -u 参数,指定uuid
python3 disable_pro.py -u 613c8a68-12c3-4f10-b831-509109f291a3
- -f 参数,指定一个包含了很多uuid的文件
python3 disable_pro.py -f cvmfile
cvmfile 是uuid的集合,如下范例:
[root@VM-99-12-centos 004-主机安全]# cat cvmfile
2415d1da-b34e-435e-8b6c-1015e0244497
2415d1da-b34e-435e-8b6c-1015e0244498
2415d1da-b34e-435e-8b6c-1015e0244499
网友评论