Reserved Instance
Updated at:2025-10-20
Tag unbinding
You can bind a tag to a specified reserved instance with the following code
Python
1from baidubce.services.bcc import bcc_model
2from baidubce.services.bcc.bcc_client import BccClient
3from sample.bcc import bcc_sample_conf
4if __name__ == "__main__":
5 import logging
6 logging.basicConfig(level=logging.DEBUG)
7 __logger = logging.getLogger(__name__)
8 bcc_client = BccClient(bcc_sample_conf.config)
9# Reserved instance IDs, maximum 100
10 reserved_instance_ids = ['r-Qyycx1SX']
11 instance_tag1 = bcc_model.TagModel(tagKey='TestKey02',
12 tagValue='TestValue02')
13 instance_tag2 = bcc_model.TagModel(tagKey='TestKey03',
14 tagValue='TestValue03')
15# List of tags to be bound
16 instance_tags = [instance_tag1, instance_tag2]
17 bcc_client.bind_reserved_instance_to_tags(reserved_instance_ids=reserved_instance_ids, tags=instance_tags)
Unbind tags
You can unbind the tag from a specified reserved instance with the following code
Python
1from baidubce.services.bcc import bcc_model
2from baidubce.services.bcc.bcc_client import BccClient
3from sample.bcc import bcc_sample_conf
4if __name__ == "__main__":
5 import logging
6 logging.basicConfig(level=logging.DEBUG)
7 __logger = logging.getLogger(__name__)
8 bcc_client = BccClient(bcc_sample_conf.config)
9# Reserved instance IDs, maximum 100
10 reserved_instance_ids = ['r-Qyycx1SX']
11 instance_tag1 = bcc_model.TagModel(tagKey='TestKey02',
12 tagValue='TestValue02')
13 instance_tag2 = bcc_model.TagModel(tagKey='TestKey03',
14 tagValue='TestValue03')
15# List of tags to be unbound
16 instance_tags = [instance_tag1, instance_tag2]
17 bcc_client.unbind_reserved_instance_from_tags(reserved_instance_ids=reserved_instance_ids, tags=instance_tags)
