自动快照策略

创建自动快照策略

创建自动快照策略,参考如下代码:

public static void createAsp(BccClient bccClient, String aspName, List<String> time, List<String> week, String days) {

    CreateAspRequest createAspRequest = new CreateAspRequest();

    // 设置快照名

    createAspRequest.setName(aspName);    

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

    // 例如设置做快照的时间点为下午两点:

    // createAspRequest.setTimePoints(14)

    createAspRequest.setTimePoints(time);

    // 设置一周中做快照的时间,取值为0~6,0代表周日,1~6代表周一到周六

    // 例如设置做快照的时间为礼拜五:

    // createAspRequest.setRepeatWeekdays(5)

    createAspRequest.setRepeatWeekdays(week);

    // 设置自动快照保留天数,取-1则永久保留

    createAspRequest.setRetentionDays(days);

    bccClient.createAsp(createAspRequest);

}

绑定自动快照策略

绑定自动快照策略,参考如下代码:

public static void attachAsp(BccClient bccClient, String aspId, List<String> volumeIds) {

    AttachAspRequest attachAspRequest = new AttachAspRequest();

    // 设置需要绑定的自动快照策略ID

    attachAspRequest.setAspId(aspId);    

    // 设置需要绑定的磁盘ID

    attachAspRequest.setVolumeIds(volumeIds);

    bccClient.attachAsp(attachAspRequest);

}

解绑自动快照策略

解绑自动快照策略,参考如下代码:

public static void detachAsp(BccClient bccClient, String aspId, List<String> volumeIds) {

    DetachAspRequest detachAspRequest = new DetachAspRequest();

    // 设置需要解绑的自动快照策略ID

    detachAspRequest.setAspId(aspId);    

    // 设置需要解绑的磁盘ID

    detachAspRequest.setVolumeIds(volumeIds);

    bccClient.detachAsp(detachAspRequest);

}

删除自动快照策略

删除自动快照策略,参考如下代码:

public static void deleteAsp(BccClient bccClient, String aspId) {

    DeleteAspRequest deleteAspRequest = new DeleteAspRequest();

    // 设置需要删除的自动快照策略ID

    deleteAspRequest.setAspId(aspId);    

    bccClient.deleteAsp(deleteAspRequest);

}

查询自动快照策略列表

查询自动快照策略列表,参考如下代码:

public static void listAsps(BccClient bccClient, String aspName, String aspId, int maxKeys, String volumeName) {

    ListAspsRequest listAspsRequest = new ListAspsRequest();

    // 设置被查找自动快照策略名称

    listAspsRequest.setName(aspName);

    // 设置起始点

    listAspsRequest.setMarker(aspId);    

    // 设置返回数据大小

    listAspsRequest.setMaxKeys(maxKeys); 

    ListAspsResponse listAspsResponse = bccClient.listAsps(listAspsRequest);

}

查询自动快照策略详情

查询自动快照策略详情,参考如下代码:

public static void getAsp(BccClient bccClient, String aspId) {

    GetAspRequest getAspRequest = new GetAspRequest();

    // 设置自动快照策略ID

    getAspRequest.setAspId(aspId); 

    GetAspResponse getAspResponse = bccClient.getAsp(getAspRequest);

}