预留实例券
更新时间:2024-04-26
绑定标签
使用以下代码给指定预留实例券绑定标签
Python
1from baidubce.services.bcc import bcc_model
2from baidubce.services.bcc.bcc_client import BccClient
3from sample.bcc import bcc_sample_conf
4
5if __name__ == "__main__":
6 import logging
7
8 logging.basicConfig(level=logging.DEBUG)
9 __logger = logging.getLogger(__name__)
10 bcc_client = BccClient(bcc_sample_conf.config)
11
12 # 预留实例券ID,最多支持100个
13 reserved_instance_ids = ['r-Qyycx1SX']
14 instance_tag1 = bcc_model.TagModel(tagKey='TestKey02',
15 tagValue='TestValue02')
16 instance_tag2 = bcc_model.TagModel(tagKey='TestKey03',
17 tagValue='TestValue03')
18 # 待绑定tag列表
19 instance_tags = [instance_tag1, instance_tag2]
20 bcc_client.bind_reserved_instance_to_tags(reserved_instance_ids=reserved_instance_ids, tags=instance_tags)
解绑标签
使用以下代码从指定预留实例券中解绑标签
Python
1from baidubce.services.bcc import bcc_model
2from baidubce.services.bcc.bcc_client import BccClient
3from sample.bcc import bcc_sample_conf
4
5if __name__ == "__main__":
6 import logging
7
8 logging.basicConfig(level=logging.DEBUG)
9 __logger = logging.getLogger(__name__)
10
11 bcc_client = BccClient(bcc_sample_conf.config)
12
13 # 预留实例券ID,最多支持100个
14 reserved_instance_ids = ['r-Qyycx1SX']
15 instance_tag1 = bcc_model.TagModel(tagKey='TestKey02',
16 tagValue='TestValue02')
17 instance_tag2 = bcc_model.TagModel(tagKey='TestKey03',
18 tagValue='TestValue03')
19 # 待解绑tag列表
20 instance_tags = [instance_tag1, instance_tag2]
21 bcc_client.unbind_reserved_instance_from_tags(reserved_instance_ids=reserved_instance_ids, tags=instance_tags)