自动快照策略

创建自动快照策略

以下代码用于创建自动快照策略:

def create_asp(self):

      #设置快照名称

      asp_name = 'your-asp-name'

      #设置一天中做快照的时间点,取值为0~23,0为午夜12点

      time_points = [0, 22]

      #设置一周中做快照的时间点,取值为0~6,0为周日

      repeat_week_days = [0, 5]

      #设置自动快照保留天数,-1为永久保留

      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)

绑定自动快照策略

以下代码用于绑定自动快照策略:

def attach_asp(self):

      #设置快照id

      asp_id = 'your-choose-asp-id'

      #设置需要绑定的磁盘id,可多选

      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)

解绑自动快照策略

以下代码用于解绑自动快照策略:

def attach_asp(self):

      #设置快照id

      asp_id = 'your-choose-asp-id'

      #设置需要解绑的磁盘id,可多选

      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)

删除自动快照策略

以下代码用于删除自动快照策略:

def attach_asp(self):

      #设置被删除自动快照id

      asp_id = 'your-choose-asp-id'

      self.assertEqual(

            type(self.client.delete_asp(asp_id=asp_id)), 

            baidubce.bce_response.BceResponse)

查询自动快照策略列表

以下代码用于查询自动快照策略列表:

def list_asp(self):

      self.assertEqual(

            type(self.client.list_asps()), 

            baidubce.bce_response.BceResponse)

查询自动快照策略详情

以下代码用于查询自动快照策略详情:

#设置被查询自动快照id

      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)