更新时间:2024-06-21 GMT+08:00
查询备份元数据
功能介绍
查询备份时资源的元数据
调用方法
请参见如何调用API。
URI
GET /v3/{project_id}/backups/{backup_id}/metadata
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
backup_id |
是 |
String |
备份ID |
project_id |
是 |
String |
项目ID |
请求参数
无
响应参数
状态码: 200
参数 |
参数类型 |
描述 |
---|---|---|
backup_id |
String |
备份ID |
backups |
String |
云服务器备份信息 |
flavor |
String |
云服务器规格信息 |
floatingips |
Array of strings |
云服务器浮动IP信息 |
interface |
String |
云服务器接口信息 |
ports |
Array of strings |
云服务器端口信息 |
server |
String |
云服务器信息 |
volumes |
Array of strings |
云服务器卷信息 |
请求示例
GET https://{endpoint}/v3/f841e01fd2b14e7fa41b6ae7aa6b0594/backups/ca994f11-9f96-4c6c-891f-13c5cdd2507d/metadata
响应示例
状态码: 200
OK
{ "backup_id" : "6df2b54c-dd62-4059-a07c-1b8f24f2725d", "backups" : "{\"provider_id\": \"0daac4c5-6707-4851-97ba-169e36266b66\", \"checkpoint_id\": \"8b0851a8-adf3-4f4c-a914-dead08bf9664\", \"updated_at\": null, \"vault_id\": \"3b5816b5-f29c-4172-9d9a-76c719a659ce\", \"id\": \"6df2b54c-dd62-4059-a07c-1b8f24f2725d\", \"resource_az\": \"az1.dc1\", \"image_type\": \"backup\", \"resource_id\": \"94eba8b2-acc9-4d82-badc-127144cc5526\", \"resource_size\": 40, \"children\": [], \"parent_id\": null, \"extend_info\": {\"auto_trigger\": true, \"supported_restore_mode\": \"backup\", \"os_images_data\": null, \"contain_system_disk\": true, \"snapshot_id\": null, \"bootable\": null, \"progress\": null, \"support_lld\": true, \"app_consistency\": {\"app_consistency_error_code\": \"0\", \"app_consistency_status\": \"0\", \"app_consistency_error_message\": \"\", \"app_consistency\": \"0\"}}, \"project_id\": \"4229d7a45436489f8c3dc2b1d35d4987\", \"status\": \"available\", \"resource_name\": \"ecs-1f0f-0002\", \"description\": \"backup_description\", \"expired_at\": null, \"replication_records\": [], \"name\": \"backup_name\", \"created_at\": \"2019-05-10T07:59:12.084695\", \"protected_at\": null, \"resource_type\": \"OS::Nova::Server\"}", "server" : "{\"server\":{\"tags\":[\"key_01\",\"key_02\"],\"progress\":0,\"links\":[{\"rel\":\"self\",\"href\":\"https://compute.region.dc1.domainname.com/v2.1/4229d7a45436489f8c3dc2b1d35d4987/servers/94eba8b2-acc9-4d82-badc-127144cc5526\"},{\"rel\":\"bookmark\",\"href\":\"https://compute.region.dc1.domainname.com/4229d7a45436489f8c3dc2b1d35d4987/servers/94eba8b2-acc9-4d82-badc-127144cc5526\"}],\"id\":\"94eba8b2-acc9-4d82-badc-127144cc5526\",\"name\":\"ecs-1f0f-0002\",\"status\":\"ACTIVE\",\"OS-EXT-STS:vm_state\":\"active\",\"OS-EXT-STS:power_state\":1,\"OS-EXT-STS:task_state\":null,\"flavor\":{\"links\":[{\"rel\":\"bookmark\",\"href\":\"https://compute.region.dc1.domainname.com/4229d7a45436489f8c3dc2b1d35d4987/flavors/s2.small.1\"}],\"id\":\"s2.small.1\"},\"accessIPv4\":\"\",\"accessIPv6\":\"\",\"image\":\"\",\"OS-EXT-SRV-ATTR:hostname\":\"ecs-1f0f-0002\",\"OS-EXT-SRV-ATTR:host\":\"az1.dc1\",\"tenant_id\":\"4229d7a45436489f8c3dc2b1d35d4987\",\"user_id\":\"38d65be2ecd840d19046e239e841a734\",\"OS-EXT-AZ:availability_zone\":\"az1.dc1\",\"OS-EXT-SRV-ATTR:hypervisor_hostname\":\"nova001@248\",\"OS-EXT-SRV-ATTR:launch_index\":0,\"OS-EXT-SRV-ATTR:user_data\":\"IyEvYmluL2Jhc2gKZWNobyAncm9vdDokNiQ2OUNsYVckUFNka1pZa2RicGFsTFJGRnNLejhJVGp4eUlLSjNya1M3UURaMlRmT0J3Nk9ndUVhRm8xdGhMRS43aWpvc3RFZTlzVkYuQjBGNm1UQURxZEhWbTkxTDEnIHwgY2hwYXNzd2QgLWU7\",\"OS-SRV-USG:launched_at\":\"2019-05-08T08:53:07.000000\",\"OS-SRV-USG:terminated_at\":null,\"config_drive\":\"\",\"created\":\"2019-05-08T08:52:22Z\",\"description\":\"\",\"key_name\":null,\"locked\":false,\"updated\":\"2019-05-08T08:53:12Z\",\"metadata\":{\"charging_mode\":\"0\",\"image_name\":\"Public CentOS 7.6 64bit for Test\",\"metering.cloudServiceType\":\"hws.service.type.ec2\",\"metering.image_id\":\"79bee4ee-0025-4645-b004-23d2a66f6eec\",\"metering.imagetype\":\"gold\",\"metering.resourcespeccode\":\"s2.small.1.linux\",\"metering.resourcetype\":\"1\",\"os_bit\":\"64\",\"os_type\":\"Linux\",\"vpc_id\":\"df963ec6-561c-4c69-9787-0456a55f8fd0\"},\"hostId\":\"bfced2732a5c5f974a1882616828d31d32c0d79964d26b1f3d8694e3\",\"OS-EXT-SRV-ATTR:kernel_id\":\"\",\"OS-EXT-SRV-ATTR:ramdisk_id\":\"\",\"OS-EXT-SRV-ATTR:root_device_name\":\"/dev/vda\",\"os-extended-volumes:volumes_attached\":[{\"id\":\"eccbcfdd-f843-4bbb-b2c0-a5ce861f9376\",\"delete_on_termination\":true}],\"OS-DCF:diskConfig\":\"MANUAL\",\"security_groups\":[{\"name\":\"sg-a924\"}],\"OS-EXT-SRV-ATTR:reservation_id\":\"r-y43be5p0\",\"addresses\":{\"df963ec6-561c-4c69-9787-0456a55f8fd0\":[{\"OS-EXT-IPS-MAC:mac_addr\":\"fa:16:3e:ef:d5:fb\",\"version\":4,\"addr\":\"192.168.1.128\",\"OS-EXT-IPS:type\":\"fixed\"},{\"OS-EXT-IPS-MAC:mac_addr\":\"fa:16:3e:ef:d5:fb\",\"version\":4,\"addr\":\"100.64.1.29\",\"OS-EXT-IPS:type\":\"floating\"}]},\"host_status\":\"UP\",\"OS-EXT-SRV-ATTR:instance_name\":\"instance-00260179\"}}", "volumes" : [ "{\"volume\":{\"attachments\":[{\"attached_at\":\"2019-05-08T08:52:48.810938\",\"attachment_id\":\"8cbc141a-9403-48e2-9323-6c05683e7e50\",\"device\":\"/dev/vda\",\"host_name\":null,\"id\":\"eccbcfdd-f843-4bbb-b2c0-a5ce861f9376\",\"server_id\":\"94eba8b2-acc9-4d82-badc-127144cc5526\",\"volume_id\":\"eccbcfdd-f843-4bbb-b2c0-a5ce861f9376\"}],\"availability_zone\":\"az1.dc1\",\"backup_id\":null,\"bootable\":\"true\",\"consistencygroup_id\":null,\"created_at\":\"2019-05-08T08:52:26.824375\",\"dedicated_storage_id\":null,\"dedicated_storage_name\":null,\"description\":\"\",\"encrypted\":false,\"enterprise_project_id\":\"0\",\"id\":\"eccbcfdd-f843-4bbb-b2c0-a5ce861f9376\",\"lifecycle\":0,\"links\":[{\"href\":\"https://evs.cn-north-1.myhuaweicloud.com/v2/4229d7a45436489f8c3dc2b1d35d4987/os-vendor-volumes/eccbcfdd-f843-4bbb-b2c0-a5ce861f9376\",\"rel\":\"self\"},{\"href\":\"https://evs.cn-north-1.myhuaweicloud.com/4229d7a45436489f8c3dc2b1d35d4987/os-vendor-volumes/eccbcfdd-f843-4bbb-b2c0-a5ce861f9376\",\"rel\":\"bookmark\"}],\"metadata\":{\"__openstack_region_name\":\"az1.dc1\",\"__system__volume_name\":\"ecs-1f0f-0002\",\"attached_mode\":\"rw\",\"readonly\":\"False\"},\"migration_status\":null,\"multiattach\":false,\"name\":\"ecs-1f0f-0002\",\"os-vol-host-attr:host\":\"az1.dc1#2\",\"os-vol-mig-status-attr:migstat\":null,\"os-vol-mig-status-attr:name_id\":null,\"os-vol-tenant-attr:tenant_id\":\"4229d7a45436489f8c3dc2b1d35d4987\",\"os-volume-replication:extended_status\":null,\"plan_delete_at\":null,\"pre_deleted_at\":null,\"provider_location\":\"{\"storage_type\": \"FC_DSWARE\", \"vol_name\": \"eccbcfddf8434bbbb2c0a5ce861f9376\", \"offset\": 4, \"ip\": \"192.144.44.120\", \"urn\": \"urn:sites:4D760908:volumes:3975388\", \"uri\": \"/service/sites/4D760908/volumes/3975388\", \"pool\": \"2\"}\",\"replication_status\":\"disabled\",\"restored_from_recycle_bin_at\":null,\"service_type\":\"EVS\",\"shareable\":false,\"size\":40,\"snapshot_id\":null,\"source_volid\":null,\"status\":\"in-use\",\"storage_cluster_id\":\"0\",\"sys_tags\":{\"_sys_enterprise_project_id\":\"0\"},\"tags\":{},\"updated_at\":\"2019-05-10T03:52:41.053912\",\"user_id\":\"38d65be2ecd840d19046e239e841a734\",\"volume_image_metadata\":{\"__account_code\":\"\",\"__backup_id\":\"\",\"__data_origin\":\"\",\"__description\":\"\",\"__image_location\":\"192.149.48.66:443:pcsimssouthchina:79bee4ee-0025-4645-b004-23d2a66f6eec\",\"__image_size\":\"647303168\",\"__image_source_type\":\"uds\",\"__imagetype\":\"gold\",\"__isregistered\":\"true\",\"__lazyloading\":\"true\",\"__originalimagename\":\"79bee4ee-0025-4645-b004-23d2a66f6eec\",\"__os_bit\":\"64\",\"__os_type\":\"Linux\",\"__os_version\":\"CentOS 7.6 64bit\",\"__platform\":\"CentOS\",\"__productcode\":\"\",\"__support_kvm\":\"true\",\"__support_xen\":\"true\",\"checksum\":\"99914b932bd37a50b983c5e7c90ae93b\",\"container_format\":\"bare\",\"disk_format\":\"zvhd2\",\"image_id\":\"79bee4ee-0025-4645-b004-23d2a66f6eec\",\"image_name\":\"Public CentOS 7.6 64bit for Test\",\"min_disk\":\"40\",\"min_ram\":\"0\",\"size\":\"2\",\"virtual_env_type\":\"FusionCompute\"},\"volume_qos_specs\":null,\"volume_type\":\"SATA\"}}" ], "interface" : "{\"interfaceAttachments\": [{\"port_state\": \"ACTIVE\", \"fixed_ips\": [{\"subnet_id\": \"63b881a8-daf0-45b1-90d8-e0c01a9e5275\", \"ip_address\": \"192.168.1.128\"}], \"port_id\": \"76a45e6e-8f02-4de2-9358-0110280ed000\", \"net_id\": \"0756f84d-03b3-44a0-95d8-c1ac70058f9d\", \"mac_addr\": \"fa:16:3e:ef:d5:fb\"}]}", "flavor" : "{\"flavor\": {\"name\": \"s2.small.1\", \"links\": [{\"href\": \"https://compute.Region.dc1.domainname.com/v2/4229d7a45436489f8c3dc2b1d35d4987/flavors/s2.small.1\", \"rel\": \"self\"}, {\"href\": \"https://compute.Region.dc1.domainname.com/4229d7a45436489f8c3dc2b1d35d4987/flavors/s2.small.1\", \"rel\": \"bookmark\"}], \"ram\": 1024, \"OS-FLV-DISABLED:disabled\": false, \"vcpus\": 1, \"swap\": \"\", \"os-flavor-access:is_public\": true, \"rxtx_factor\": 1.0, \"OS-FLV-EXT-DATA:ephemeral\": 0, \"disk\": 0, \"id\": \"s2.small.1\"}}", "ports" : [ "{\"port\":{\"id\":\"76a45e6e-8f02-4de2-9358-0110280ed000\",\"name\":\"\",\"admin_state_up\":true,\"status\":\"ACTIVE\",\"network_id\":\"0756f84d-03b3-44a0-95d8-c1ac70058f9d\",\"tenant_id\":\"4229d7a45436489f8c3dc2b1d35d4987\",\"project_id\":\"4229d7a45436489f8c3dc2b1d35d4987\",\"device_id\":\"94eba8b2-acc9-4d82-badc-127144cc5526\",\"mac_address\":\"fa:16:3e:ef:d5:fb\",\"device_owner\":\"compute:az1.dc1\",\"description\":\"\",\"created_at\":\"2019-05-08T08:52:25\",\"updated_at\":\"2019-05-08T08:52:25\",\"port_security_enabled\":true,\"tags\":[],\"security_groups\":[\"a27d2564-b40c-41ec-9eb6-6eca3ff5aeee\"],\"allowed_address_pairs\":[],\"extra_dhcp_opts\":[],\"fixed_ips\":[{\"subnet_id\":\"63b881a8-daf0-45b1-90d8-e0c01a9e5275\",\"ip_address\":\"192.168.1.128\"}],\"dns_assignment\":[{\"ip_address\":\"192.168.1.128\",\"hostname\":\"ip-192-168-1-128\",\"fqdn\":\"ip-192-168-1-128.southchina.compute.internal.\"}],\"qos_policy_id\":null,\"dns_name\":\"ip-192-168-1-128\",\"dns_domain\":\"southchina.compute.internal.\",\"instance_id\":\"\",\"instance_type\":\"\",\"ecs_flavor\":\"\",\"binding:host_id\":\"az1.dc1\",\"binding:vif_type\":\"cascading\",\"binding:vnic_type\":\"normal\",\"binding:vif_details\":{\"primary_interface\":true},\"binding:profile\":{}}}" ], "floatingips" : [ "{\"floatingips\":null}" ] }
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 |
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 ShowMetadataSolution { 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(); ShowMetadataRequest request = new ShowMetadataRequest(); try { ShowMetadataResponse response = client.showMetadata(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 |
# 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 = ShowMetadataRequest() response = client.show_metadata(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 |
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.ShowMetadataRequest{} response, err := client.ShowMetadata(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
OK |
错误码
请参见错误码。
父主题: 备份