Automatic Snapshot Policy
Last Updated:2020-07-20
Create an automatic snapshot policy
The following codes are used to create an automatic snapshot policy:
def create_asp(self):
# Set a snapshot id name
asp_name = 'your-asp-name'
#Set Time points for snapshot in a day, the value is 0-23, where 0 is Sunday
time_points = [0, 22]
#Set Time points for snapshot in a week, the value is 0-6, where 0 is Sunday
repeat_week_days = [0, 5]
# Set automatic snapshot retention days, take -1 for permanent retention
retention_days = '-1'
self.assertEqual(
type(self.client.create_asp(asp_name=asp_name,
time_points=time_points,
repeat_week_days=repeat_week_days,
retention_days=retention_days)),
baidubce.bce_response.BceResponse)
Bind an automatic snapshot policy
The following codes are used to bind an automatic snapshot policy:
def attach_asp(self):
# Set a snapshot id
asp_id = 'your-choose-asp-id'
# Set the disk id to be bound. You can select multiple options
volume_ids = ['you-choose-volume-id1', 'you-choose-volume-id2']
self.assertEqual(
type(self.client.attach_asp(asp_id=asp_id,volume_ids=volume_ids)),
baidubce.bce_response.BceResponse)
Unbind automatic snapshot policies
The following codes are used to unbind an automatic snapshot policy:
def attach_asp(self):
# Set a snapshot id
asp_id = 'your-choose-asp-id'
# Set the disk id to be unbound. You can select multiple options.
volume_ids = ['you-choose-volume-id1', 'you-choose-volume-id2']
self.assertEqual(
type(self.client.detach_asp(asp_id=asp_id,volume_ids=volume_ids)),
baidubce.bce_response.BceResponse)
Delete an Automatic Snapshot Policy
The following codes are used to delete an automatic snapshot policy:
def attach_asp(self):
# Set a deleted automatic snapshot id
asp_id = 'your-choose-asp-id'
self.assertEqual(
type(self.client.delete_asp(asp_id=asp_id)),
baidubce.bce_response.BceResponse)
Query the automatic snapshot policy list
The following codes are used to query the automatic snapshot policy list:
def list_asp(self):
self.assertEqual(
type(self.client.list_asps()),
baidubce.bce_response.BceResponse)
Query the automatic snapshot policy details
The following codes are used to query the automatic snapshot policy details:
# Set a automatic snapshot id is queried
asp_id = 'your-choose-asp-id'
def list_asp(self):
self.assertEqual(
type(self.client.get_asp(asp_id=asp_id)),
baidubce.bce_response.BceResponse)