文档首页/ 云备份 CBR/ API参考/ API/ 可保护性/ 查询可保护资源
更新时间:2024-06-21 GMT+08:00

查询可保护资源

功能介绍

查询可保护性资源列表

调用方法

请参见如何调用API

URI

GET /v3/{project_id}/protectables/{protectable_type}/instances

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

项目ID

protectable_type

String

对象类型

表2 Query参数

参数

是否必选

参数类型

描述

id

String

根据资源id过滤

limit

Integer

每页显示的条目数量,每页最多支持50条

marker

String

上一次查询最后一条的ID

name

String

按名称过滤

offset

Integer

偏移值

server_id

String

根据该id过滤属于该服务器的所有磁盘,支持企业多项目的用户才能传入此参数

status

String

资源的状态,如available,error 等

请求参数

响应参数

状态码: 200

表3 响应Body参数

参数

参数类型

描述

instances

Array of ProtectablesResp objects

可保护性查询实例

表4 ProtectablesResp

参数

参数类型

描述

children

Array of objects

子资源

detail

Object

资源详情

id

String

id

name

String

名称

protectable

ProtectableResult object

是否可备份

size

Integer

大小,单位GB

status

String

资源状态

  • active: 可保护

  • deleted: 已删除

  • error: 异常

type

String

待备份资源的类型: OS::Nova::Server, OS::Cinder::Volume, OS::Ironic::BareMetalServer, OS::Native::Server, OS::Sfs::Turbo, OS::Workspace::DesktopV2

表5 ProtectableResult

参数

参数类型

描述

code

String

不支持备份的错误码

reason

String

不支持备份的原因

result

Boolean

是否可备份

vault

VaultGet object

绑定的存储库

message

String

资源不可备份的原因信息,当资源可保护性检验失败时才有该字段。

表6 VaultGet

参数

参数类型

描述

billing

Billing object

运营信息

description

String

存储库自定义描述信息。

最小长度:0

最大长度:255

id

String

存储库ID

name

String

存储库名称

最小长度:1

最大长度:64

project_id

String

项目ID

provider_id

String

存储库资源类型id

resources

Array of ResourceResp objects

资源

tags

Array of Tag objects

存储库标签

enterprise_project_id

String

企业项目id,默认为‘0’。

auto_bind

Boolean

是否自动绑定,默认为false,不支持。

bind_rules

VaultBindRules object

绑定规则

user_id

String

用户id

created_at

String

创建时间,例如:"2020-02-05T10:38:34.209782"

auto_expand

Boolean

是否开启存储库自动扩容能力(只支持按需存储库)。

smn_notify

Boolean

存储库smn消息通知开关

缺省值:true

threshold

Integer

存储库容量阈值,已用容量占总容量达到此百分比即发送相关通知

最小值:1

最大值:100

缺省值:80

sys_lock_source_service

String

用于标识SMB服务,您可以设置为SMB或者空

最小长度:0

最大长度:32

updated_at

String

更新时间,例如:"2020-02-05T10:38:34.209782"

version

String

版本

表7 Billing

参数

参数类型

描述

allocated

Integer

已分配容量,单位GB

charging_mode

String

创建模式,按需:post_paid,包周期:pre_paid,默认为post_paid

cloud_type

String

公有云:public ;混合云:hybrid

consistent_level

String

规格,崩溃一致性(crash_consistent)或应用一致性(app_consistent)

object_type

String

对象类型:云服务器(server),云硬盘(disk),文件系统(turbo),云桌面(workspace),VMware(vmware),关系型数据库(rds),文件(file)。

order_id

String

订单ID

product_id

String

产品ID

protect_type

String

保护类型:备份(backup)、复制(replication)。

size

Integer

容量,单位GB

最小值:1

最大值:10485760

spec_code

String

规格编码。 云服务备份存储库:vault.backup.server.normal;云硬盘备份存储库:vault.backup.volume.normal;文件备份存储库:vault.backup.turbo.normal

status

String

存储库状态

  • available: 可用

  • lock: 锁定

  • frozen: 冻结

  • deleting: 删除中

  • error: 异常

storage_unit

String

存储库桶名

used

Integer

已使用容量,单位MB

frozen_scene

String

冻结场景

is_multi_az

Boolean

存储库多az属性

缺省值:false

表8 ResourceResp

参数

参数类型

描述

extra_info

ResourceExtraInfo object

资源附加信息

id

String

待备份资源id

name

String

待备份资源名称

最小长度:0

最大长度:255

protect_status

String

保护状态

  • available: 可用

  • error: 异常

  • protecting: 保护中

  • restoring: 恢复中

  • removing: 删除中

size

Integer

资源已分配容量,单位为GB

type

String

待备份资源的类型: OS::Nova::Server, OS::Cinder::Volume, OS::Ironic::BareMetalServer, OS::Native::Server, OS::Sfs::Turbo, OS::Workspace::DesktopV2

backup_size

Integer

副本大小

backup_count

Integer

副本数量

表9 ResourceExtraInfo

参数

参数类型

描述

exclude_volumes

Array of strings

需要排除备份的卷id。仅在多盘备份特性中有效,排除不需要备份的磁盘。当虚拟机新绑定磁盘时,也能继续排除之前设置不用备份的卷。

表10 Tag

参数

参数类型

描述

key

String

键。

key最大长度为36个字符。

key不能为空字符串。

key前后空格会被丢弃。

key不能包含非打印字符ASCII(0-31),“=”,“*”,“<”,“>”,“\”,“,”,“|”,“/”。

key只能由中文,字母,数字,“-”,“_”组成。

value

String

值。

添加标签时value值必选,删除标签时value值可选。

value最大长度为43个字符。

value可以为空字符串。

value前后的空格会被丢弃。

value不能包含非打印字符ASCII(0-31),“=”,“*”,“<”,“>”,“\”,“,”,“|”,“/”。

value只能由中文,字母,数字,“-”,“_”,“.”组成。

表11 VaultBindRules

参数

参数类型

描述

tags

Array of BindRulesTags objects

按tags过滤自动绑定的资源

最小长度:0

最大长度:5

数组长度:0 - 5

表12 BindRulesTags

参数

参数类型

描述

key

String

key不能包含非打印字符ASCII(0-31),“=”,“*”,“<”,“>”,“\”,“,”,“|”,“/”。

key只能由中文,字母,数字,“-”,“_”组成。

value

String

value不能包含非打印字符ASCII(0-31),“=”,“*”,“<”,“>”,“\”,“,”,“|”,“/”。

value只能由中文,字母,数字,“-”,“_”,“.”组成。

请求示例

GET  https://{endpoint}/v3/{project_id}/protectables/{protectable_type}/instances

响应示例

状态码: 200

OK

{
  "instances" : [ {
    "status" : "ACTIVE",
    "children" : [ {
      "status" : "in-use",
      "name" : "no_delete_for_cbr_interface-volume-0000",
      "detail" : {
        "attachments" : [ {
          "server_id" : "55ecd8b8-1457-4a2a-a9df-53756a690082",
          "attachment_id" : "e16631fa-0522-4ac8-8f78-19db435caf68",
          "volume_id" : "13eb535f-8635-4faf-9f08-584d21e78f0a",
          "attached_at" : "2019-05-08T06:55:26.564+00:00",
          "device" : "/dev/vda",
          "id" : "13eb535f-8635-4faf-9f08-584d21e78f0a"
        } ],
        "links" : [ {
          "href" : "https://volume.region1.com/v2/3aec9116a6a5487ca14987121d2818fe/volumes/13eb535f-8635-4faf-9f08-584d21e78f0a",
          "rel" : "self"
        }, {
          "href" : "https://volume.region1.com/3aec9116a6a5487ca14987121d2818fe/volumes/13eb535f-8635-4faf-9f08-584d21e78f0a",
          "rel" : "bookmark"
        } ],
        "availability_zone" : "AZ1",
        "os-vol-host-attr:host" : "AZ1.xxxxxx#kvm_fusionstorage",
        "encrypted" : false,
        "updated_at" : "2019-05-08T08:33:07.855+00:00",
        "replication_status" : "disabled",
        "id" : "13eb535f-8635-4faf-9f08-584d21e78f0a",
        "size" : 40,
        "user_id" : "3204777a731c4ebea330350c04f41b92",
        "os-vol-tenant-attr:tenant_id" : "3aec9116a6a5487ca14987121d2818fe",
        "metadata" : {
          "policy" : "2ecbcffd-08ba-43f7-bf8d-95daba753464",
          "readonly" : "False",
          "attached_mode" : "rw"
        },
        "status" : "in-use",
        "volume_image_metadata" : {
          "container_format" : "bare",
          "min_ram" : 0,
          "__account_code" : "",
          "__os_bit" : 64,
          "size" : 2,
          "__os_version" : "CentOS 7.2 64bit",
          "__backup_id" : "",
          "__description" : "",
          "__support_diskintensive" : "true",
          "disk_format" : "vhd",
          "__isregistered" : "true",
          "__image_size" : 3295645696,
          "__platform" : "CentOS",
          "__root_origin" : "file",
          "__originalimagename" : "703eb90a-a65f-4c72-b4c1-f070a55d068b",
          "__quick_start" : "true",
          "image_name" : "CentOS7.2-cloudinit",
          "image_id" : "703eb90a-a65f-4c72-b4c1-f070a55d068b",
          "__os_type" : "Linux",
          "__image_location" : "172.100.45.130:443:pcsimsf8bd00bf6c304d2e8cf4e2beb0aed702:703eb90a-a65f-4c72-b4c1-f070a55d068b",
          "min_disk" : 40,
          "__data_origin" : "file,jingxiang:CentOS-7.2-64bit.zvhd2",
          "__support_kvm" : "true",
          "virtual_env_type" : "FusionCompute",
          "__image_source_type" : "uds",
          "__support_xen" : "true",
          "checksum" : "99914b932bd37a50b983c5e7c90ae93b",
          "__imagetype" : "gold",
          "__productcode" : ""
        },
        "multiattach" : false,
        "name" : "no_delete_for_cbr_interface-volume-0000",
        "bootable" : "true",
        "created_at" : "2019-05-08T06:54:58.478+00:00",
        "volume_type" : "SATA",
        "shareable" : false
      },
      "children" : [ ],
      "type" : "OS::Cinder::Volume",
      "id" : "13eb535f-8635-4faf-9f08-584d21e78f0a",
      "size" : 40
    }, {
      "status" : "in-use",
      "name" : "volume-f926-0001",
      "detail" : {
        "attachments" : [ {
          "server_id" : "55ecd8b8-1457-4a2a-a9df-53756a690082",
          "attachment_id" : "3b32cb75-bd96-493b-8fb2-13f063c876d5",
          "volume_id" : "8d3d519f-d409-4be3-8a1f-9f7a5ecb7a99",
          "attached_at" : "2019-05-08T06:56:25.892+00:00",
          "device" : "/dev/vdb",
          "id" : "8d3d519f-d409-4be3-8a1f-9f7a5ecb7a99"
        } ],
        "links" : [ {
          "href" : "https://volume.region1.com/v2/3aec9116a6a5487ca14987121d2818fe/volumes/8d3d519f-d409-4be3-8a1f-9f7a5ecb7a99",
          "rel" : "self"
        }, {
          "href" : "https://volume.region1.com/3aec9116a6a5487ca14987121d2818fe/volumes/8d3d519f-d409-4be3-8a1f-9f7a5ecb7a99",
          "rel" : "bookmark"
        } ],
        "availability_zone" : "AZ1",
        "os-vol-host-attr:host" : "AZ1.xxxxxx#FusionStorage",
        "encrypted" : false,
        "updated_at" : "2019-05-08T06:56:26.207+00:00",
        "replication_status" : "disabled",
        "id" : "8d3d519f-d409-4be3-8a1f-9f7a5ecb7a99",
        "size" : 10,
        "user_id" : "f3d66502790d4ddaadef5056059ed8f4",
        "os-vol-tenant-attr:tenant_id" : "3aec9116a6a5487ca14987121d2818fe",
        "metadata" : {
          "policy" : "cf3274fc-d23e-4c12-8be7-1e41b3c2faea",
          "readonly" : "False",
          "attached_mode" : "rw"
        },
        "status" : "in-use",
        "multiattach" : false,
        "name" : "volume-f926-0001",
        "bootable" : "false",
        "created_at" : "2019-03-26T09:30:46.784+00:00",
        "volume_type" : "SATA",
        "shareable" : false
      },
      "children" : [ ],
      "type" : "OS::Cinder::Volume",
      "id" : "8d3d519f-d409-4be3-8a1f-9f7a5ecb7a99",
      "size" : 10
    } ],
    "protectable" : {
      "reason" : "",
      "code" : "",
      "result" : true
    },
    "name" : "no_delete_for_cbr_interface",
    "detail" : {
      "addresses" : {
        "94b88790-c906-4450-b7c2-1c2b1ea639bf" : [ {
          "OS-EXT-IPS-MAC:mac_addr" : "fa:16:3e:9b:9d:af",
          "version" : 4,
          "OS-EXT-IPS:port_id" : "f22f531a-d38a-480b-b59e-f7e5db0dcdcc",
          "addr" : "192.168.1.44",
          "OS-EXT-IPS:type" : "fixed"
        }, {
          "OS-EXT-IPS-MAC:mac_addr" : "fa:16:3e:9b:9d:af",
          "version" : 4,
          "OS-EXT-IPS:port_id" : "f22f531a-d38a-480b-b59e-f7e5db0dcdcc",
          "addr" : "100.78.0.199",
          "OS-EXT-IPS:type" : "floating"
        } ]
      },
      "OS-EXT-SRV-ATTR:ramdisk_id" : "",
      "image" : "",
      "enterprise_project_id" : 0,
      "updated" : "2019-05-08T06:57:02.000+00:00",
      "OS-EXT-SRV-ATTR:user_data" : "IyEvYmluL2Jhc2gKZWNobyAncm9vdDokNiQ5c1FaeXIkdnk5N1pGYXg5WUpRTUpPRElGdGdjYnovTUdEZ1dad3E4VTM1dWE4MjQxTmtDTG1GRjJUUm1BdnZSQnNCLy93VER0aFVRNUt0Z1p6dUlrenp2NmQwYTAnIHwgY2hwYXNzd2QgLWU7",
      "OS-EXT-STS:vm_state" : "active",
      "OS-EXT-SRV-ATTR:instance_name" : "instance-0004456e",
      "OS-EXT-SRV-ATTR:root_device_name" : "/dev/vda",
      "OS-SRV-USG:launched_at" : "2019-05-08T06:55:38.000+00:00",
      "flavor" : {
        "vcpus" : 1,
        "disk" : 0,
        "ram" : 1024,
        "id" : "s3.small.1",
        "name" : "s3.small.1"
      },
      "id" : "55ecd8b8-1457-4a2a-a9df-53756a690082",
      "security_groups" : [ {
        "name" : "default"
      } ],
      "os-extended-volumes:volumes_attached" : [ {
        "device" : "/dev/vda",
        "id" : "13eb535f-8635-4faf-9f08-584d21e78f0a",
        "delete_on_termination" : false,
        "bootIndex" : 0
      }, {
        "device" : "/dev/vdb",
        "id" : "8d3d519f-d409-4be3-8a1f-9f7a5ecb7a99",
        "delete_on_termination" : false
      } ],
      "user_id" : "f3d66502790d4ddaadef5056059ed8f4",
      "OS-EXT-SRV-ATTR:hostname" : "no-delete-for-cbr-interface",
      "OS-DCF:diskConfig" : "MANUAL",
      "accessIPv4" : "",
      "accessIPv6" : "",
      "OS-EXT-SRV-ATTR:reservation_id" : "r-kpb5xckf",
      "progress" : 0,
      "OS-EXT-STS:power_state" : 1,
      "OS-EXT-AZ:availability_zone" : "AZ1",
      "metadata" : {
        "metering.image_id" : "703eb90a-a65f-4c72-b4c1-f070a55d068b",
        "metering.imagetype" : "gold",
        "metering.resourcespeccode" : "s3.small.1.linux",
        "metering.cloudServiceType" : "sys.service.type.ec2",
        "virtual_env_type" : "FusionCompute",
        "image_name" : "CentOS7.2-cloudinit",
        "metering.resourcetype" : 1,
        "vpc_id" : "94b88790-c906-4450-b7c2-1c2b1ea639bf",
        "os_bit" : 64,
        "cascaded.instance_extrainfo" : "",
        "os_type" : "Linux",
        "charging_mode" : 0
      },
      "status" : "ACTIVE",
      "sys_tags" : [ {
        "value" : 0,
        "key" : "_sys_enterprise_project_id"
      } ],
      "os:scheduler_hints" : { },
      "hostId" : "179f22cafe6b951921bd6deb3b13a978df620427fb37bbb7c619de98",
      "OS-EXT-SRV-ATTR:host" : "AZ1.xxxxxx",
      "description" : "",
      "tags" : [ ],
      "OS-EXT-SRV-ATTR:kernel_id" : "",
      "locked" : false,
      "OS-EXT-SRV-ATTR:hypervisor_hostname" : "nova003@36",
      "name" : "no_delete_for_cbr_interface",
      "OS-EXT-SRV-ATTR:launch_index" : 0,
      "created" : "2019-05-08T06:55:22.000+00:00",
      "tenant_id" : "3aec9116a6a5487ca14987121d2818fe",
      "host_status" : "UP",
      "config_drive" : ""
    },
    "type" : "OS::Nova::Server",
    "id" : "55ecd8b8-1457-4a2a-a9df-53756a690082",
    "size" : 50
  } ]
}

SDK代码示例

SDK代码示例如下。

Java

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.cbr.v1.region.CbrRegion;
import com.huaweicloud.sdk.cbr.v1.*;
import com.huaweicloud.sdk.cbr.v1.model.*;


public class ListProtectableSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");

        ICredential auth = new BasicCredentials()
                .withAk(ak)
                .withSk(sk);

        CbrClient client = CbrClient.newBuilder()
                .withCredential(auth)
                .withRegion(CbrRegion.valueOf("<YOUR REGION>"))
                .build();
        ListProtectableRequest request = new ListProtectableRequest();
        request.withLimit(<limit>);
        request.withMarker("<marker>");
        request.withName("<name>");
        request.withOffset(<offset>);
        request.withStatus("<status>");
        request.withId("<id>");
        request.withServerId("<server_id>");
        try {
            ListProtectableResponse response = client.listProtectable(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}

Python

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# coding: utf-8

from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkcbr.v1.region.cbr_region import CbrRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkcbr.v1 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = __import__('os').getenv("CLOUD_SDK_AK")
    sk = __import__('os').getenv("CLOUD_SDK_SK")

    credentials = BasicCredentials(ak, sk) \

    client = CbrClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(CbrRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ListProtectableRequest()
        request.limit = <limit>
        request.marker = "<marker>"
        request.name = "<name>"
        request.offset = <offset>
        request.status = "<status>"
        request.id = "<id>"
        request.server_id = "<server_id>"
        response = client.list_protectable(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Go

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    cbr "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cbr/v1"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cbr/v1/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cbr/v1/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        Build()

    client := cbr.NewCbrClient(
        cbr.CbrClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ListProtectableRequest{}
	limitRequest:= int32(<limit>)
	request.Limit = &limitRequest
	markerRequest:= "<marker>"
	request.Marker = &markerRequest
	nameRequest:= "<name>"
	request.Name = &nameRequest
	offsetRequest:= int32(<offset>)
	request.Offset = &offsetRequest
	statusRequest:= "<status>"
	request.Status = &statusRequest
	idRequest:= "<id>"
	request.Id = &idRequest
	serverIdRequest:= "<server_id>"
	request.ServerId = &serverIdRequest
	response, err := client.ListProtectable(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

OK

错误码

请参见错误码