文档首页/ 裸金属服务器 BMS/ API参考/ 应用示例/ 示例2:查询裸金属服务器
更新时间:2024-02-02 GMT+08:00
分享

示例2:查询裸金属服务器

操作场景

当您名下有多台裸金属服务器时,可以指定查询条件获取需要的裸金属服务器。

涉及接口

涉及的接口如下:

查询裸金属服务器详情列表

指定flavor查询裸金属服务器详情列表

  • 接口相关信息

    URI格式:GET /v1/{project_id}/baremetalservers/detail

    详情请参考查询裸金属服务器详情列表

  • 请求示例

    GET https://{BMS Endpoint}/v1/5233f5df59f9491ba7c14d8b5d535f6b/baremetalservers/detail?flavor=physical.comtest04.large

    {BMS Endpoint}信息请从“地区和终端节点”获取。

  • 响应示例
    {
        "count": 1,
        "servers": [
            {
                "fault": null,
                "id": "cb52b43d-8ba7-4b4d-84c4-7ef332715073",
                "name": "kd1ne4xl-c00420527-nodel-nonstop",
                "addresses": {
                    "fdbf76aa-697a-4f49-8835-36c0e6903e28": [
                        {
                            "version": "4",
                            "addr": "172.16.0.178",
                            "OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:8a:3a:50",
                            "OS-EXT-IPS:type": "fixed",
                            "OS-EXT-IPS:port_id": "0c111191-9785-49e6-8b42-66ef2802bd8f"
                        },
                        {
                            "version": "4",
                            "addr": "124.71.38.23",
                            "OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:8a:3a:50",
                            "OS-EXT-IPS:type": "floating",
                            "OS-EXT-IPS:port_id": "0c111191-9785-49e6-8b42-66ef2802bd8f"
                        }
                    ]
                },
                "flavor": {
                    "disk": "192010",
                    "vcpus": "128",
                    "ram": "524288",
                    "id": "physical.comtest04.large",
                    "name": "physical.comtest04.large"
                },
                "accessIPv4": "",
                "accessIPv6": "",
                "status": "SHUTOFF",
                "progress": null,
                "hostId": "f57b3421b5cdc214fabf127984ef779b7433acc1d6379214ed834219",
                "updated": "2020-11-07T09:28:40Z",
                "created": "2020-09-21T09:07:28Z",
                "metadata": {
                    "metering.order_id": "CS20110717284WW42",
                    "metering.image_id": "c13c91f7-038a-443e-ad76-608e255b4d85",
                    "metering.imagetype": "shared",
                    "metering.resourcespeccode": "physical.comtest04.large.linux",
                    "image_name": "euler2u8-cbg-sdi3-20200330v3",
                    "op_svc_userid": "48b5cec3f26e4bedab54cb996b124079",
                    "__bms_support_evs": "false",
                    "EcmResStatus": "",
                    "metering.product_id": "00301-103881-0--0",
                    "metering.resourcetype": "__type_baremetal",
                    "vpc_id": "fdbf76aa-697a-4f49-8835-36c0e6903e28",
                    "os_type": "Linux",
                    "os_bit": "64",
                    "chargingMode": "1"
                },
                "tags": [
                    "__type_baremetal"
                ],
                "description": "kd1ne4xl-c00420527-nodel-nonstop",
                "locked": false,
                "config_drive": "",
                "tenant_id": "5233f5df59f9491ba7c14d8b5d535f6b",
                "user_id": "fc3a5ac3fe244ca6bb079c8069f9143f",
                "key_name": null,
                "os-extended-volumes:volumes_attached": [
                    {
                        "device": "/dev/sda",
                        "bootIndex": "0",
                        "id": "405ae92b-2d59-4d61-8eb0-79946e391c33",
                        "delete_on_termination": "false"
                    }
                ],
                "OS-EXT-STS:task_state": null,
                "OS-EXT-STS:power_state": 4,
                "OS-EXT-STS:vm_state": "stopped",
                "OS-EXT-SRV-ATTR:host": "f57b3421b5cdc214fabf127984ef779b7433acc1d6379214ed834219",
                "OS-EXT-SRV-ATTR:instance_name": "instance-00567827",
                "OS-EXT-SRV-ATTR:hypervisor_hostname": "bea2f2c61b2def48c3ad001446ffada47bbd2b1cbf75d4950c9609a0",
                "OS-DCF:diskConfig": "MANUAL",
                "OS-EXT-AZ:availability_zone": "cn-south-1e",
                "os:scheduler_hints": {
                    "dec_baremetal": [
                        "share"
                    ]
                },
                "OS-EXT-SRV-ATTR:root_device_name": "/dev/vda",
                "OS-EXT-SRV-ATTR:ramdisk_id": "",
                "enterprise_project_id": "0",
                "OS-EXT-SRV-ATTR:user_data": "$USER_DATA",
                "OS-SRV-USG:launched_at": "2020-09-21T09:14:01.000000",
                "OS-EXT-SRV-ATTR:kernel_id": "",
                "OS-EXT-SRV-ATTR:launch_index": 0,
                "host_status": "UP",
                "OS-EXT-SRV-ATTR:reservation_id": "r-18mfg3us",
                "OS-EXT-SRV-ATTR:hostname": "kd1ne4xl-c00420527-nodel-nonstop",
                "OS-SRV-USG:terminated_at": null,
                "sys_tags": [
                    {
                        "key": "_sys_enterprise_project_id",
                        "value": "0"
                    }
                ],
                "security_groups": [
                    {
                        "id": "2beb2b46-2a55-4b83-b362-20698eeda10b",
                        "name": "d310-l00415626-cce-control-8xsdf"
                    }
                ],
                "image": {
                    "id": "c13c91f7-038a-443e-ad76-608e255b4d85"
                },
                "hypervisor": null
            }
        ]
    }

指定enterprise_project_id查询裸金属服务器详情列表

  • 接口相关信息

    URI格式:GET /v1/{project_id}/baremetalservers/detail

    详情请参考查询裸金属服务器详情列表

  • 请求示例

    GET https://{BMS Endpoint}/v1/5233f5df59f9491ba7c14d8b5d535f6b/baremetalservers/detail?enterprise_project_id=98135c62-f0c1-4003-9c9f-7f5523d7f3a2

    {BMS Endpoint}信息请从“地区和终端节点”获取。{enterprise_project_id}信息请在管理控制台右上角单击“企业 > 项目管理”,进入企业项目管理页面获取。

  • 响应示例
    {
        "count": 1,
        "servers": [
            {
                "fault": null,
                "id": "cb52b43d-8ba7-4b4d-84c4-7ef332715073",
                "name": "kd1ne4xl-c00420527-nodel-nonstop",
                "addresses": {
                    "fdbf76aa-697a-4f49-8835-36c0e6903e28": [
                        {
                            "version": "4",
                            "addr": "172.16.0.178",
                            "OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:8a:3a:50",
                            "OS-EXT-IPS:type": "fixed",
                            "OS-EXT-IPS:port_id": "0c111191-9785-49e6-8b42-66ef2802bd8f"
                        },
                        {
                            "version": "4",
                            "addr": "124.71.38.23",
                            "OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:8a:3a:50",
                            "OS-EXT-IPS:type": "floating",
                            "OS-EXT-IPS:port_id": "0c111191-9785-49e6-8b42-66ef2802bd8f"
                        }
                    ]
                },
                "flavor": {
                    "disk": "192010",
                    "vcpus": "128",
                    "ram": "524288",
                    "id": "physical.comtest04.large",
                    "name": "physical.comtest04.large"
                },
                "accessIPv4": "",
                "accessIPv6": "",
                "status": "SHUTOFF",
                "progress": null,
                "hostId": "f57b3421b5cdc214fabf127984ef779b7433acc1d6379214ed834219",
                "updated": "2020-11-07T09:28:40Z",
                "created": "2020-09-21T09:07:28Z",
                "metadata": {
                    "metering.order_id": "CS20110717284WW42",
                    "metering.image_id": "c13c91f7-038a-443e-ad76-608e255b4d85",
                    "metering.imagetype": "shared",
                    "metering.resourcespeccode": "physical.comtest04.large.linux",
                    "image_name": "euler2u8-cbg-sdi3-20200330v3",
                    "op_svc_userid": "48b5cec3f26e4bedab54cb996b124079",
                    "__bms_support_evs": "false",
                    "EcmResStatus": "",
                    "metering.product_id": "00301-103881-0--0",
                    "metering.resourcetype": "__type_baremetal",
                    "vpc_id": "fdbf76aa-697a-4f49-8835-36c0e6903e28",
                    "os_type": "Linux",
                    "os_bit": "64",
                    "chargingMode": "1"
                },
                "tags": [
                    "__type_baremetal"
                ],
                "description": "kd1ne4xl-c00420527-nodel-nonstop",
                "locked": false,
                "config_drive": "",
                "tenant_id": "5233f5df59f9491ba7c14d8b5d535f6b",
                "user_id": "fc3a5ac3fe244ca6bb079c8069f9143f",
                "key_name": null,
                "os-extended-volumes:volumes_attached": [
                    {
                        "device": "/dev/sda",
                        "bootIndex": "0",
                        "id": "405ae92b-2d59-4d61-8eb0-79946e391c33",
                        "delete_on_termination": "false"
                    }
                ],
                "OS-EXT-STS:task_state": null,
                "OS-EXT-STS:power_state": 4,
                "OS-EXT-STS:vm_state": "stopped",
                "OS-EXT-SRV-ATTR:host": "f57b3421b5cdc214fabf127984ef779b7433acc1d6379214ed834219",
                "OS-EXT-SRV-ATTR:instance_name": "instance-00567827",
                "OS-EXT-SRV-ATTR:hypervisor_hostname": "bea2f2c61b2def48c3ad001446ffada47bbd2b1cbf75d4950c9609a0",
                "OS-DCF:diskConfig": "MANUAL",
                "OS-EXT-AZ:availability_zone": "cn-south-1e",
                "os:scheduler_hints": {
                    "dec_baremetal": [
                        "share"
                    ]
                },
                "OS-EXT-SRV-ATTR:root_device_name": "/dev/vda",
                "OS-EXT-SRV-ATTR:ramdisk_id": "",
                "enterprise_project_id": "98135c62-f0c1-4003-9c9f-7f5523d7f3a2",
                "OS-EXT-SRV-ATTR:user_data": "$USER_DATA",
                "OS-SRV-USG:launched_at": "2020-09-21T09:14:01.000000",
                "OS-EXT-SRV-ATTR:kernel_id": "",
                "OS-EXT-SRV-ATTR:launch_index": 0,
                "host_status": "UP",
                "OS-EXT-SRV-ATTR:reservation_id": "r-18mfg3us",
                "OS-EXT-SRV-ATTR:hostname": "kd1ne4xl-c00420527-nodel-nonstop",
                "OS-SRV-USG:terminated_at": null,
                "sys_tags": [
                    {
                        "key": "_sys_enterprise_project_id",
                        "value": "0"
                    }
                ],
                "security_groups": [
                    {
                        "id": "2beb2b46-2a55-4b83-b362-20698eeda10b",
                        "name": "d310-l00415626-cce-control-8xsdf"
                    }
                ],
                "image": {
                    "id": "c13c91f7-038a-443e-ad76-608e255b4d85"
                },
                "hypervisor": null
            }
        ]
    }

相关文档