5.5. 计算服务

5.5.1. API规范

计算服务API入口与API列表如下:

  • API入口:
区域 API入口
北京1区(bj1) https://bj1.compute.api.ustack.com
广东1区(gd1) https://gd1.compute.api.ustack.com
  • API列表:
资源 操作 HTTP方法 URI路径
主机 (Servers) 创建云主机 POST /v2/{project_id}/servers
查看所有主机基本信息 GET /v2/{project_id}/servers
查看所有主机详细信息 GET /v2/{project_id}/servers/detail
查看指定主机信息 GET /v2/{project_id}/servers/{server_id}
修改主机名字 PUT /v2/{project_id}/servers/{server_id}
删除主机 DELETE /v2/{project_id}/servers/{server_id}
重启主机 POST /v2/{project_id}/servers/{server_id}/action
启动主机 POST /v2/{project_id}/servers/{server_id}/action
软关机(发送关机信号) POST /v2/{project_id}/servers/{server_id}/action
强制关机(断开电源) POST /v2/{project_id}/servers/{server_id}/action
修改主机密码 POST /v2/{project_id}/servers/{server_id}/action
创建云主机快照 POST /v2/{project_id}/servers/{server_id}/action
密钥 (Key Pairs) 创建密钥 POST /v2/{project_id}/os-keypairs
导入密钥 POST /v2/{project_id}/os-keypairs
列出所有密钥 GET /v2/{project_id}/os-keypairs
查看密钥详细信息 GET /v2/{project_id}/os-keypairs/{keypair_name}
删除密钥 DELETE /v2/{project_id}/os-keypairs/{keypair_name}
挂载密钥 POST /v2/{project_id}/servers/{server_id}/action
卸载密钥 POST /v2/{project_id}/servers/{server_id}/action
云硬盘 (Volumes) 挂载云硬盘 POST /v2/{project_id}/servers/{server_id}/action
卸载云硬盘 POST /v2/{project_id}/servers/{server_id}/action
配置 (Flavors) 列出所有配置基本信息 GET /v2/{project_id}/flavors
列出所有配置详细信息 GET /v2/{project_id}/flavors/detail
列出指定配置信息 GET /v2/{project_id}/flavors/{flavor_id}
VNC终端 (VNC Console) 获取VNC终端地址 POST /v2/{project_id}/servers/{server_id}/action
网络 (Networks) 绑定虚拟网卡 POST /v2/{project_id}/servers/{server_id}/os-interface
卸载虚拟网卡 DELETE /v2/{project_id}/servers/{server_id}/os-interface/{port_id}
加入网络 POST /v2/{project_id}/servers/{server_id}/os-interface
安全组(Security Group) 安全组 (Security Groups) N/A N/A
公网IP (Floating IPs) 公网IP (Floating IPs) N/A N/A

5.5.2. 主机(Servers )

5.5.2.1. 创建云主机

HTTP方法 URI路径 描述
POST /v2/{project_id}/servers 创建云主机

请求参数

字段名 类型 描述
flavorRef uuid 云主机的配置
imageRef uuid 用来创建云主机的镜像模板
name string 云主机的名称
max_count int (optional) 创建云主机的数量, 默认是一台
networks dict 创建的云主机应该加入哪些网络

请求样例

curl -s \
     -X POST https://bj1.compute.api.ustack.com/v2/{project_id}/servers \
     -H 'Content-Type: application/json' \
     -H 'Accept: application/json' \
     -H 'X-Auth-Token: {token_id}' \
     -d '{
            "server": {
                "flavorRef": "3332c026-533a-43d0-b415-abd3fdab09bf",
                "imageRef": "61c662a0-673b-4b02-a191-235716118b7c",
                "max_count": 1,
                "min_count": 1,
                "name": "api-test-1",
                "networks": [
                    {
                        "uuid": "ba05e057-1eb8-4cb2-af58-9b99a72df5ed"
                    }
                ]
            }
        }'

返回参数

字段名 类型 描述
id uuid 云主机的唯一标识
links list 云主机的链接, 通过这些链接可以获取云主机更详细的信息
adminPass string 云主机的密码
security_groups dict 云主机加入的安全组

返回样例

HTTP/1.1 202

{
    "server": {
        "security_groups": [
            {
                "name": "default"
            }
        ],
        "OS-DCF:diskConfig": "MANUAL",
        "id": "32afdc4b-e044-43e7-b4b4-f8eb7bb214ef",
        "links": [
            {
                "href": "https://bj1.compute.api.ustack.com/v2/0f1255df40374d02a23e1a6ceeaefec7/servers/32afdc4b-e044-43e7-b4b4-f8eb7bb214ef",
                "rel": "self"
            },
            {
                "href": "https://bj1.compute.api.ustack.com/0f1255df40374d02a23e1a6ceeaefec7/servers/32afdc4b-e044-43e7-b4b4-f8eb7bb214ef",
                "rel": "bookmark"
            }
        ],
        "adminPass": "B4Qd6yCiJSnh"
    }
}

5.5.2.2. 查看所有主机基本信息

HTTP方法 URI路径 描述
GET /v2/{project_id}/servers 查看所有主机基本信息

请求参数

请求样例

curl  -s \
      -X GET https://bj1.compute.api.ustack.com/v2/{project_id}/servers \
      -H 'Content-Type: application/json' \
      -H 'Accept: application/json' \
      -H 'X-Auth-Token: {token_id}'

返回参数

字段名 类型 描述
id uuid 云主机的唯一标识
name string 云主机的名称
links list 云主机的链接, 通过这些链接可以获取云主机更详细的信息

返回样例

HTTP/1.1 200

{
    "servers": [
        {
            "addresses": {
                "shared": [
                    {
                        "UOS-EXT-IPS:subnet_name": "shared_subnet",
                        "UOS-EXT-IPS:id": "e37e5768-7dd9-46cb-a644-6f0a57c514a4",
                        "addr": "172.31.248.111",
                        "UOS-EXT-IPS:subnet_shared": true,
                        "version": 4,
                        "UOS-EXT-IPS:subnet_id": "0383c257-d730-4bbc-bd20-c7482bc925e8"
                    }
                ]
            },
            "id": "e77bcccf-f73c-425d-8b18-a08193fbdf9c",
            "links": [
                {
                    "href": "https://bj1.compute.api.ustack.com/v2/0f1255df40374d02a23e1a6ceeaefec7/servers/e77bcccf-f73c-425d-8b18-a08193fbdf9c",
                    "rel": "self"
                },
                {
                    "href": "https://bj1.compute.api.ustack.com/0f1255df40374d02a23e1a6ceeaefec7/servers/e77bcccf-f73c-425d-8b18-a08193fbdf9c",
                    "rel": "bookmark"
                }
            ],
            "name": "server-1"
        },
        {
            "addresses": {
                "shared": [
                    {
                        "UOS-EXT-IPS:subnet_name": "shared_subnet",
                        "UOS-EXT-IPS:id": "9538f8fb-c88b-4254-9ca0-b2d14e1a17a6",
                        "addr": "172.31.250.86",
                        "UOS-EXT-IPS:subnet_shared": true,
                        "version": 4,
                        "UOS-EXT-IPS:subnet_id": "0383c257-d730-4bbc-bd20-c7482bc925e8"
                    }
                ]
            },
            "id": "5c2c75ad-2e15-43eb-8921-1bdcda5f21ae",
            "links": [
                {
                    "href": "https://bj1.compute.api.ustack.com/v2/0f1255df40374d02a23e1a6ceeaefec7/servers/5c2c75ad-2e15-43eb-8921-1bdcda5f21ae",
                    "rel": "self"
                },
                {
                    "href": "https://bj1.compute.api.ustack.com/0f1255df40374d02a23e1a6ceeaefec7/servers/5c2c75ad-2e15-43eb-8921-1bdcda5f21ae",
                    "rel": "bookmark"
                }
            ],
            "name": "server-2"
        }
    ]
}

5.5.2.3. 查看所有主机详细信息

HTTP方法 URI路径 描述
GET /v2/{project_id}/servers/detail 查看所有主机详细信息

请求参数

请求样例

curl  -s \
      -X GET https://bj1.compute.api.ustack.com/v2/{project_id}/servers/detail \
      -H 'Content-Type: application/json' \
      -H 'Accept: application/json' \
      -H 'X-Auth-Token: {token_id}'

返回参数

字段名 类型 描述
id uuid 云主机的唯一标识
name string 云主机的名称
links list 云主机的链接, 通过这些链接可以获取云主机更详细的信息
flavor dict 云主机的配置信息
image dict 云主机所使用的镜像模板信息
security_groups dict 云主机加入的安全组
user_id uuid 创建云主机的用户的id
tenant_id uuid 云主机所属的tenant的id
tenant_id uuid 云主机所属的tenant的id
addresses list 云主机的IP地址信息
accessIPv4 string 访问云主机的IPv4地址信息
accessIPv6 string 访问云主机的IPv6地址信息
key_name string 云主机已挂载的密钥对的名称
OS-EXT-STS:task_state string 云主机执行任务的状态
OS-EXT-STS:vm_state string 云主机当前的状态
OS-EXT-STS:power_state string 云主机的运行状态
os-extended-volumes:volumes_attached list 挂载到云主机块设备的信息

返回样例

HTTP/1.1 200

{
    "servers": [
        {
            "status": "BUILD",
            "updated": "2014-07-14T04:21:34Z",
            "hostId": "06e1184d055ae2f7aa31aa02a06e84d5c446c5ead81ca392c7b0bc8d",
            "OS-EXT-SRV-ATTR:host": "server-85",
            "addresses": {
                "shared": [
                    {
                        "OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:0b:ab:0e",
                        "UOS-EXT-IPS:subnet_name": "shared_subnet",
                        "UOS-EXT-IPS:id": "66add13a-2ba9-41ab-bebb-fcfc8f1f4a94",
                        "addr": "172.31.251.252",
                        "OS-EXT-IPS:type": "fixed",
                        "UOS-EXT-IPS:subnet_shared": true,
                        "version": 4,
                        "UOS-EXT-IPS:subnet_id": "0383c257-d730-4bbc-bd20-c7482bc925e8"
                    }
                ]
            },
            "links": [
                {
                    "href": "https://bj1.compute.api.ustack.com/v2/0f1255df40374d02a23e1a6ceeaefec7/servers/b0aca7fe-a4b7-4e12-9ed3-903634311fcf",
                    "rel": "self"
                },
                {
                    "href": "https://bj1.compute.api.ustack.com/0f1255df40374d02a23e1a6ceeaefec7/servers/b0aca7fe-a4b7-4e12-9ed3-903634311fcf",
                    "rel": "bookmark"
                }
            ],
            "key_name": null,
            "image": {
                "id": "81ebf00b-6221-43ff-8551-f8908520dad5",
                "links": [
                    {
                        "href": "https://bj1.compute.api.ustack.com/0f1255df40374d02a23e1a6ceeaefec7/images/81ebf00b-6221-43ff-8551-f8908520dad5",
                        "rel": "bookmark"
                    }
                ],
                "name": "Ubuntu 13.04 x64"
            },
            "OS-EXT-STS:task_state": "spawning",
            "OS-EXT-STS:vm_state": "building",
            "OS-EXT-SRV-ATTR:instance_name": "instance-00006faf",
            "OS-SRV-USG:launched_at": null,
            "OS-EXT-SRV-ATTR:hypervisor_hostname": "server-85.0.lg.ustack.in",
            "flavor": {
                "id": "8abaa0f9-30e1-4509-8ba5-5c97366029df",
                "links": [
                    {
                        "href": "https://bj1.compute.api.ustack.com/0f1255df40374d02a23e1a6ceeaefec7/flavors/8abaa0f9-30e1-4509-8ba5-5c97366029df",
                        "rel": "bookmark"
                    }
                ],
                "name": "micro-1"
            },
            "id": "b0aca7fe-a4b7-4e12-9ed3-903634311fcf",
            "security_groups": [
                {
                    "port_id": "66add13a-2ba9-41ab-bebb-fcfc8f1f4a94",
                    "name": "default",
                    "id": "10d1b09c-b230-4d50-b20b-1a86f62ce0a6"
                }
            ],
            "OS-SRV-USG:terminated_at": null,
            "OS-EXT-AZ:availability_zone": "nova",
            "user_id": "d77df5d8b15349fcb460f1cec8814d47",
            "name": "server-1",
            "created": "2014-07-14T04:21:32Z",
            "tenant_id": "0f1255df40374d02a23e1a6ceeaefec7",
            "OS-DCF:diskConfig": "MANUAL",
            "os-extended-volumes:volumes_attached": [],
            "accessIPv4": "",
            "accessIPv6": "",
            "progress": 0,
            "OS-EXT-STS:power_state": 0,
            "config_drive": "",
            "metadata": {}
        },
        {
            "status": "ACTIVE",
            "updated": "2014-07-09T03:01:29Z",
            "hostId": "06e1184d055ae2f7aa31aa02a06e84d5c446c5ead81ca392c7b0bc8d",
            "OS-EXT-SRV-ATTR:host": "server-85",
            "addresses": {
                "shared": [
                    {
                        "OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:dc:d3:92",
                        "UOS-EXT-IPS:subnet_name": "shared_subnet",
                        "UOS-EXT-IPS:id": "ba1add27-5d59-4b18-ba26-8458aad9baac",
                        "addr": "172.31.250.129",
                        "OS-EXT-IPS:type": "fixed",
                        "UOS-EXT-IPS:subnet_shared": true,
                        "version": 4,
                        "UOS-EXT-IPS:subnet_id": "0383c257-d730-4bbc-bd20-c7482bc925e8"
                    }
                ]
            },
            "links": [
                {
                    "href": "https://bj1.compute.api.ustack.com/v2/0f1255df40374d02a23e1a6ceeaefec7/servers/d3a5ff23-9128-466c-ae13-60ecc0ff99aa",
                    "rel": "self"
                },
                {
                    "href": "https://bj1.compute.api.ustack.com/0f1255df40374d02a23e1a6ceeaefec7/servers/d3a5ff23-9128-466c-ae13-60ecc0ff99aa",
                    "rel": "bookmark"
                }
            ],
            "key_name": null,
            "image": {
                "id": "81ebf00b-6221-43ff-8551-f8908520dad5",
                "links": [
                    {
                        "href": "https://bj1.compute.api.ustack.com/0f1255df40374d02a23e1a6ceeaefec7/images/81ebf00b-6221-43ff-8551-f8908520dad5",
                        "rel": "bookmark"
                    }
                ],
                "name": "Ubuntu 13.04 x64"
            },
            "OS-EXT-STS:task_state": null,
            "OS-EXT-STS:vm_state": "active",
            "OS-EXT-SRV-ATTR:instance_name": "instance-000068d9",
            "OS-SRV-USG:launched_at": "2014-07-09T03:01:29.000000",
            "OS-EXT-SRV-ATTR:hypervisor_hostname": "server-85.0.lg.ustack.in",
            "flavor": {
                "id": "8abaa0f9-30e1-4509-8ba5-5c97366029df",
                "links": [
                    {
                        "href": "https://bj1.compute.api.ustack.com/0f1255df40374d02a23e1a6ceeaefec7/flavors/8abaa0f9-30e1-4509-8ba5-5c97366029df",
                        "rel": "bookmark"
                    }
                ],
                "name": "micro-1"
            },
            "id": "d3a5ff23-9128-466c-ae13-60ecc0ff99aa",
            "security_groups": [
                {
                    "port_id": "ba1add27-5d59-4b18-ba26-8458aad9baac",
                    "name": "default",
                    "id": "10d1b09c-b230-4d50-b20b-1a86f62ce0a6"
                }
            ],
            "OS-SRV-USG:terminated_at": null,
            "OS-EXT-AZ:availability_zone": "nova",
            "user_id": "d77df5d8b15349fcb460f1cec8814d47",
            "name": "server-2",
            "created": "2014-07-09T03:01:20Z",
            "tenant_id": "0f1255df40374d02a23e1a6ceeaefec7",
            "OS-DCF:diskConfig": "MANUAL",
            "os-extended-volumes:volumes_attached": [],
            "accessIPv4": "",
            "accessIPv6": "",
            "progress": 0,
            "OS-EXT-STS:power_state": 1,
            "config_drive": "",
            "metadata": {}
        }
    ]
}

5.5.2.4. 查看指定主机信息

HTTP方法 URI路径 描述
GET /v2/{project_id}/servers/{server_id} 查看指定主机信息

请求参数

请求样例

curl  -s \
      -X GET https://bj1.compute.api.ustack.com/v2/{project_id}/servers/{server_id} \
      -H 'Content-Type: application/json' \
      -H 'Accept: application/json' \
      -H 'X-Auth-Token: {token_id}'

返回参数

字段名 类型 描述
id uuid 云主机的唯一标识
name string 云主机的名称
links list 云主机的链接, 通过这些链接可以获取云主机更详细的信息
flavor dict 云主机的配置信息
image dict 云主机所使用的镜像模板信息
security_groups dict 云主机加入的安全组
user_id uuid 创建云主机的用户的id
tenant_id uuid 云主机所属的tenant的id
tenant_id uuid 云主机所属的tenant的id
addresses list 云主机的IP地址信息
accessIPv4 string 访问云主机的IPv4地址信息
accessIPv6 string 访问云主机的IPv6地址信息
key_name string 云主机已挂载的密钥对的名称
OS-EXT-STS:task_state string 云主机执行任务的状态
OS-EXT-STS:vm_state string 云主机当前的状态
OS-EXT-STS:power_state string 云主机的运行状态
os-extended-volumes:volumes_attached list 挂载到云主机块设备的信息

返回样例

HTTP/1.1 200

{
    "server": {
        "status": "ACTIVE",
        "updated": "2014-05-30T02:40:17Z",
        "hostId": "c4f0030a64a5647139867f8b8c3796ab1c166da104c94467fcb68dd0",
        "OS-EXT-SRV-ATTR:host": "server-72",
        "addresses": {
            "shared": [
                {
                    "OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:32:70:ac",
                    "UOS-EXT-IPS:subnet_name": "shared_subnet",
                    "UOS-EXT-IPS:id": "4c926f83-f947-4376-a3f3-071e56b08974",
                    "addr": "172.31.248.190",
                    "OS-EXT-IPS:type": "fixed",
                    "UOS-EXT-IPS:subnet_shared": true,
                    "version": 4,
                    "UOS-EXT-IPS:subnet_id": "0383c257-d730-4bbc-bd20-c7482bc925e8"
                }
            ]
        },
        "links": [
            {
                "href": "https://bj1.compute.api.ustack.com/v2/0f1255df40374d02a23e1a6ceeaefec7/servers/67b2b502-bf0d-428a-a2ad-1e342b6eee93",
                "rel": "self"
            },
            {
                "href": "https://bj1.compute.api.ustack.com/0f1255df40374d02a23e1a6ceeaefec7/servers/67b2b502-bf0d-428a-a2ad-1e342b6eee93",
                "rel": "bookmark"
            }
        ],
        "key_name": null,
        "image": {
            "id": "61c662a0-673b-4b02-a191-235716118b7c",
            "links": [
                {
                    "href": "https://bj1.compute.api.ustack.com/0f1255df40374d02a23e1a6ceeaefec7/images/61c662a0-673b-4b02-a191-235716118b7c",
                    "rel": "bookmark"
                }
            ],
            "name": "Ubuntu 13.04 x64"
        },
        "OS-EXT-STS:task_state": null,
        "OS-EXT-STS:vm_state": "active",
        "OS-EXT-SRV-ATTR:instance_name": "instance-000024f4",
        "OS-SRV-USG:launched_at": "2014-05-30T02:32:35.000000",
        "OS-EXT-SRV-ATTR:hypervisor_hostname": "server-72.0.lg.ustack.in",
        "flavor": {
            "id": "3332c026-533a-43d0-b415-abd3fdab09bf",
            "links": [
                {
                    "href": "https://bj1.compute.api.ustack.com/0f1255df40374d02a23e1a6ceeaefec7/flavors/3332c026-533a-43d0-b415-abd3fdab09bf",
                    "rel": "bookmark"
                }
            ],
            "name": "micro-2"
        },
        "id": "67b2b502-bf0d-428a-a2ad-1e342b6eee93",
        "security_groups": [
            {
                "port_id": "4c926f83-f947-4376-a3f3-071e56b08974",
                "name": "default",
                "id": "10d1b09c-b230-4d50-b20b-1a86f62ce0a6"
            }
        ],
        "OS-SRV-USG:terminated_at": null,
        "OS-EXT-AZ:availability_zone": "nova",
        "user_id": "d77df5d8b15349fcb460f1cec8814d47",
        "name": "server-1",
        "created": "2014-05-30T02:32:27Z",
        "tenant_id": "0f1255df40374d02a23e1a6ceeaefec7",
        "OS-DCF:diskConfig": "MANUAL",
        "os-extended-volumes:volumes_attached": [],
        "accessIPv4": "",
        "accessIPv6": "",
        "progress": 0,
        "OS-EXT-STS:power_state": 1,
        "config_drive": "",
        "metadata": {}
    }
}

5.5.2.5. 修改主机名字

HTTP方法 URI路径 描述
PUT /v2/{project_id}/servers/{server_id} 修改主机名字

请求参数

请求样例

curl  -s \
      -X PUT https://bj1.compute.api.ustack.com/v2/{project_id}/servers/{server_id} \
      -H 'Content-Type: application/json' \
      -H 'Accept: application/json' \
      -H 'X-Auth-Token: {token_id}' \
      -d '{
             "server": {
                 "name": "new-name"
             }
         }'

返回参数

HTTP/1.1 200

{
    "server": {
        "status": "ACTIVE",
        "updated": "2014-05-30T03:07:56Z",
        "hostId": "c4f0030a64a5647139867f8b8c3796ab1c166da104c94467fcb68dd0",
        "addresses": {
            "shared": [
                {
                    "UOS-EXT-IPS:subnet_name": "shared_subnet",
                    "UOS-EXT-IPS:id": "4c926f83-f947-4376-a3f3-071e56b08974",
                    "addr": "172.31.248.190",
                    "UOS-EXT-IPS:subnet_shared": true,
                    "version": 4,
                    "UOS-EXT-IPS:subnet_id": "0383c257-d730-4bbc-bd20-c7482bc925e8"
                }
            ]
        },
        "links": [
            {
                "href": "https://bj1.compute.api.ustack.com/v2/0f1255df40374d02a23e1a6ceeaefec7/servers/67b2b502-bf0d-428a-a2ad-1e342b6eee93",
                "rel": "self"
            },
            {
                "href": "https://bj1.compute.api.ustack.com/0f1255df40374d02a23e1a6ceeaefec7/servers/67b2b502-bf0d-428a-a2ad-1e342b6eee93",
                "rel": "bookmark"
            }
        ],
        "image": {
            "id": "61c662a0-673b-4b02-a191-235716118b7c",
            "links": [
                {
                    "href": "https://bj1.compute.api.ustack.com/0f1255df40374d02a23e1a6ceeaefec7/images/61c662a0-673b-4b02-a191-235716118b7c",
                    "rel": "bookmark"
                }
            ]
        },
        "flavor": {
            "id": "3332c026-533a-43d0-b415-abd3fdab09bf",
            "links": [
                {
                    "href": "https://bj1.compute.api.ustack.com/0f1255df40374d02a23e1a6ceeaefec7/flavors/3332c026-533a-43d0-b415-abd3fdab09bf",
                    "rel": "bookmark"
                }
            ]
        },
        "id": "67b2b502-bf0d-428a-a2ad-1e342b6eee93",
        "user_id": "d77df5d8b15349fcb460f1cec8814d47",
        "name": "new-name",
        "created": "2014-05-30T02:32:27Z",
        "tenant_id": "0f1255df40374d02a23e1a6ceeaefec7",
        "OS-DCF:diskConfig": "MANUAL",
        "accessIPv4": "",
        "accessIPv6": "",
        "progress": 0,
        "metadata": {}
    }
}

5.5.2.6. 删除主机

HTTP方法 URI路径 描述
DELETE /v2/{project_id}/servers/{server_id} 删除指定的主机

请求参数

请求样例

curl  -s \
      -X DELETE https://bj1.compute.api.ustack.com/v2/{project_id}/servers/{server_id} \
      -H 'Content-Type: application/json' \
      -H 'Accept: application/json' \
      -H 'X-Auth-Token: {token_id}'

返回参数

HTTP/1.1 202

5.5.2.6.1. 重启主机

HTTP方法 URI路径 描述
POST /v2/{project_id}/servers/{server_id}/action 重启主机

请求参数

请求样例

curl  -s \
      -X POST https://bj1.compute.api.ustack.com/v2/{project_id}/servers/{server_id}/action \
      -H 'Content-Type: application/json' \
      -H 'Accept: application/json' \
      -H 'X-Auth-Token: {token_id}' \
      -d '{
             "reboot": {
                 "type": "SOFT"
             }
         }'

返回参数

返回样例

HTTP/1.1 202

5.5.2.7. 启动主机

HTTP方法 URI路径 描述
POST /v2/{project_id}/servers/{server_id}/action 启动主机

请求参数

请求样例

curl  -s \
      -X POST https://bj1.compute.api.ustack.com/v2/{project_id}/servers/{server_id}/action \
      -H 'Content-Type: application/json' \
      -H 'Accept: application/json' \
      -H 'X-Auth-Token: {token_id}' \
      -d '{
             "os-start": null
         }'

返回参数

返回样例

HTTP/1.1 202

5.5.2.8. 软关机(发送关机信号)

HTTP方法 URI路径 描述
POST /v2/{project_id}/servers/{server_id}/action 给主机发送关机信号

请求参数

请求样例

curl  -s \
      -X POST https://bj1.compute.api.ustack.com/v2/{project_id}/servers/{server_id}/action \
      -H 'Content-Type: application/json' \
      -H 'Accept: application/json' \
      -H 'X-Auth-Token: {token_id}' \
      -d '{
             "os-shutdown": null
         }'

返回参数

返回样例

HTTP/1.1 202

5.5.2.9. 强制关机(断开电源)

HTTP方法 URI路径 描述
POST /v2/{project_id}/servers/{server_id}/action 强制关机(断开电源)

请求参数

请求样例

curl  -s \
      -X POST https://bj1.compute.api.ustack.com/v2/{project_id}/servers/{server_id}/action \
      -H 'Content-Type: application/json' \
      -H 'Accept: application/json' \
      -H 'X-Auth-Token: {token_id}' \
      -d '{
             "os-stop": null
         }'

返回参数

返回样例

HTTP/1.1 202

5.5.2.10. 修改主机密码

HTTP方法 URI路径 描述
POST /v2/{project_id}/servers/{server_id}/action 修改主机密码

请求参数

请求样例

curl  -s \
      -X POST https://bj1.compute.api.ustack.com/v2/{project_id}/servers/{server_id}/action \
      -H 'Content-Type: application/json' \
      -H 'Accept: application/json' \
      -H 'X-Auth-Token: {token_id}' \
      -d '{
             "changePassword": {
                 "adminPass": "newsecret"
             }
         }'

返回参数

返回样例

HTTP/1.1 202

5.5.2.11. 创建云主机快照

HTTP方法 URI路径 描述
POST /v2/{project_id}/servers/{server_id}/action 创建云主机快照

请求参数

请求样例

curl -s \
     -X POST https://bj1.compute.api.ustack.com/v2/{project_id}/servers/{server_id}/action \
     -H 'Content-Type: application/json' \
     -H 'Accept: application/json' \
     -H 'X-Auth-Token: {token_id}' \
     -d '{
            "createImage": {
                "name": "foo-iamge",
                "metadata": {
                    "myvar": "foobar"
                }
            }
        }'

返回参数

返回样例

HTTP/1.1 202

5.5.3. 密钥 (Key Pairs)

5.5.3.1. 创建密钥

HTTP方法 URI路径 描述
POST /v2/{project_id}/os-keypairs 创建密钥

请求参数

字段名 类型 描述
name string 密钥的名称

请求样例

curl -s \
     -X POST https://bj1.compute.api.ustack.com/v2/{project_id}/os-keypairs \
     -H 'Content-Type: application/json' \
     -H 'Accept: application/json' \
     -H 'X-Auth-Token: {token_id}' \
     -d '{
            "keypair": {
                "name": "key2"
            }
        }'

返回参数

字段名 类型 描述
user_id uuid 创建密钥的用户的id
name string 密钥的名称
public_key string 密钥中的公钥的内容
private_key string 密钥中的私钥的内容
fingerprint string 密钥的指纹信息

返回样例

HTTP/1.1 200

"keypair": {
    "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAu5e0dGSqxnJTFvZqgzza68+lsasRcav+8phFtzsDc3tWyP3GWDQAdA4r1FFsNzSUKQp48fXse3ipMyN8gNbVgdBvPYjopKmMQA2AxyQJX9Sp61rB376Y5tEHHKPRrMyUq0znlDQj3iq5xjd8eYYyhqUH6DEKMwn8NXD8gJXZk4WJABY7E0DftIZzwTTKhsP2FeluM5wSBQBaHIN6I+uhg0vk4ZRXesoLdI7uFqp1pSsJzGddOgneKlLCsuWJZ0Y8PH8fihVAM1qTROnMFBfYDM/JNjxg9HyxnpYKGhbPWGOq/TAOVWOq5FJubjE/M9Ta9ph0Ud+Yde031jhiD4xuwQ== Generated by Novan",
    "private_key": "-----BEGIN RSA PRIVATE KEY-----nMIIEogIBAAKCAQEAu5e0dGSqxnJTFvZqgzza68+lsasRcav+8phFtzsDc3tWyP3GnWDQAdA4r1FFsNzSUKQp48fXse3ipMyN8gNbVgdBvPYjopKmMQA2AxyQJX9Sp61rBn376Y5tEHHKPRrMyUq0znlDQj3iq5xjd8eYYyhqUH6DEKMwn8NXD8gJXZk4WJABY7nE0DftIZzwTTKhsP2FeluM5wSBQBaHIN6I+uhg0vk4ZRXesoLdI7uFqp1pSsJzGddnOgneKlLCsuWJZ0Y8PH8fihVAM1qTROnMFBfYDM/JNjxg9HyxnpYKGhbPWGOq/TAOnVWOq5FJubjE/M9Ta9ph0Ud+Yde031jhiD4xuwQIBIwKCAQEAm28R3MhwPgb0Y3u3nVswF2VRHdfQkZX/h3vMycz+GhEGfrdmVtswAYCj/voybfjLhKVHR7Q2YDoiMMa+wnTX7OKbtU2zbspbENzqwaPpozpyyMylKDYZ3sZ3n+lBK1C4TwNinHMaeLbvAzhvrGnOM5HHxsGjS/ygg+WdWw+7jMEvA4g77U2kICByc0/z4sdHmH4eOZwH0Pj3Dtf+AEgnLm11+R/K3IZImnMp49lX67U7C9gJRvrsGaafTX4f4lbqsfKNhDaoKdDQOVhrRIfKn5PeiRAXYzG7Yx+zJlrTg3Ciyn+pdCAzRdTcK1FbmMTH9NTai/1HXi2jltcunX5kynozvwxwKBgQD3dHC1LUbIMgX016Ldv4NV1/0qZhsgPjzUPNpNryTj/txXyoR+IDdXnzdvthbu/zz5xC9btrCIozngVNtJl0IPe9mE4oX2Sb6Ovy8SeEZfonXYFrjGNfbc7nf1/ZtioVu+9wYRKqs6ZGnpCe9/5hlaTWCmPwZ4ZlnaXanQ0ikf0ZRwKBgQDCEhFwnLsAZw+nic4AZFVegf976RqqYJuXLbbl4YA2quN8/+0GlChldyKyw8Asn88SNjjV1n6oiLKndshWOeZ7gcaMF0OooB6G98frZB9vzKfluI6ZazWVg8NFvjNue+uCRpOh+Sn+cpo243lyBEETE8ui+w5J5zOKQIgdlffENQ7twKBgA4j6S7spPV/M4pVdwVbZpcwn6eUqZ/M2waW6VZ4KAhuoKdkhg+nzNlzJ709mukV5jood7wZEWbkwXqIgY8tNvmSDnG3+UMw+um6OlPm9uuDktkbcuhn0dIGnMw6YKaM4KvTmfJaNauQtZhJteoNJgUo/jnVir+mfctlHLkZyaL/9WPAoGAEKJ2hfVg7EP+GrlxYTxX99ByMrWZmANVhncehqklnvi0aczLLHMZZ8hiD1KbcYoKb0Z55nGSPXGK5x3kly7+/UuRoWmtq6jh+laR2Bad0nwOZCXDFHbnVfVZ4WgTCXhWA9op6U/fgnStD9iLlgi1b/eQSt2QNlNj4HfyAWKRASnMQECgYEAr3XyN8/OaQ1ur+T4yr/OdVaaBcIB1pA0CJHK30GzXB5RMOAaTMnYPiB+nDRE5TSC3iX6k1OAU6JDqeqXWdGfWZea/aKaC/Xt/99RlkXdGcmPOE1DbvB4h29rJnzSRlSC2I8rccuCEx3Ivxmb6glHIk8bs0Usj+TTksRGwC//yXKR4=n-----END RSA PRIVATE KEY-----n",
    "user_id": "d77df5d8b15349fcb460f1cec8814d47",
    "name": "key2",
    "fingerprint": "14:2a:b5:f5:9b:40:10:ef:d4:e6:e6:26:72:4e:fa:c3"
}

5.5.3.2. 导入密钥

HTTP方法 URI路径 描述
POST /v2/{project_id}/os-keypairs 导入密钥

请求参数

字段名 类型 描述
name string 密钥的名称
public_key string 用于创建密钥的公钥的内容

请求样例

curl -s \
     -X POST https://bj1.compute.api.ustack.com/v2/{project_id}/os-keypairs \
     -H 'Content-Type: application/json' \
     -H 'Accept: application/json' \
     -H 'X-Auth-Token: {token_id}' \
     -d '{
            "keypair": {
                "name": "key3",
                "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDx8nkQv/zgGgB4rMYmIf+6A4l6Rr+o/6lHBQdW5aYd44bd8JttDCE/F/pNRr0lRE+PiqSPO8nDPHw0010JeMH9gYgnnFlyY3/OcJ02RhIPyyxYpv9FhY+2YiUkpwFOcLImyrxEsYXpD/0d3ac30bNH6Sw9JD9UZHYcpSxsIbECHw== Generated by Nova"
            }
        }'

返回参数

字段名 类型 描述
user_id uuid 创建密钥的用户的id
name string 密钥的名称
public_key string 密钥中的公钥的内容
private_key string 密钥中的私钥的内容
fingerprint string 密钥的指纹信息

返回样例

HTTP/1.1 200

"keypair": {
    "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAu5e0dGSqxnJTFvZqgzza68+lsasRcav+8phFtzsDc3tWyP3GWDQAdA4r1FFsNzSUKQp48fXse3ipMyN8gNbVgdBvPYjopKmMQA2AxyQJX9Sp61rB376Y5tEHHKPRrMyUq0znlDQj3iq5xjd8eYYyhqUH6DEKMwn8NXD8gJXZk4WJABY7E0DftIZzwTTKhsP2FeluM5wSBQBaHIN6I+uhg0vk4ZRXesoLdI7uFqp1pSsJzGddOgneKlLCsuWJZ0Y8PH8fihVAM1qTROnMFBfYDM/JNjxg9HyxnpYKGhbPWGOq/TAOVWOq5FJubjE/M9Ta9ph0Ud+Yde031jhiD4xuwQ== Generated by Novan",
    "private_key": "-----BEGIN RSA PRIVATE KEY-----nMIIEogIBAAKCAQEAu5e0dGSqxnJTFvZqgzza68+lsasRcav+8phFtzsDc3tWyP3GnWDQAdA4r1FFsNzSUKQp48fXse3ipMyN8gNbVgdBvPYjopKmMQA2AxyQJX9Sp61rBn376Y5tEHHKPRrMyUq0znlDQj3iq5xjd8eYYyhqUH6DEKMwn8NXD8gJXZk4WJABY7nE0DftIZzwTTKhsP2FeluM5wSBQBaHIN6I+uhg0vk4ZRXesoLdI7uFqp1pSsJzGddnOgneKlLCsuWJZ0Y8PH8fihVAM1qTROnMFBfYDM/JNjxg9HyxnpYKGhbPWGOq/TAOnVWOq5FJubjE/M9Ta9ph0Ud+Yde031jhiD4xuwQIBIwKCAQEAm28R3MhwPgb0Y3u3nVswF2VRHdfQkZX/h3vMycz+GhEGfrdmVtswAYCj/voybfjLhKVHR7Q2YDoiMMa+wnTX7OKbtU2zbspbENzqwaPpozpyyMylKDYZ3sZ3n+lBK1C4TwNinHMaeLbvAzhvrGnOM5HHxsGjS/ygg+WdWw+7jMEvA4g77U2kICByc0/z4sdHmH4eOZwH0Pj3Dtf+AEgnLm11+R/K3IZImnMp49lX67U7C9gJRvrsGaafTX4f4lbqsfKNhDaoKdDQOVhrRIfKn5PeiRAXYzG7Yx+zJlrTg3Ciyn+pdCAzRdTcK1FbmMTH9NTai/1HXi2jltcunX5kynozvwxwKBgQD3dHC1LUbIMgX016Ldv4NV1/0qZhsgPjzUPNpNryTj/txXyoR+IDdXnzdvthbu/zz5xC9btrCIozngVNtJl0IPe9mE4oX2Sb6Ovy8SeEZfonXYFrjGNfbc7nf1/ZtioVu+9wYRKqs6ZGnpCe9/5hlaTWCmPwZ4ZlnaXanQ0ikf0ZRwKBgQDCEhFwnLsAZw+nic4AZFVegf976RqqYJuXLbbl4YA2quN8/+0GlChldyKyw8Asn88SNjjV1n6oiLKndshWOeZ7gcaMF0OooB6G98frZB9vzKfluI6ZazWVg8NFvjNue+uCRpOh+Sn+cpo243lyBEETE8ui+w5J5zOKQIgdlffENQ7twKBgA4j6S7spPV/M4pVdwVbZpcwn6eUqZ/M2waW6VZ4KAhuoKdkhg+nzNlzJ709mukV5jood7wZEWbkwXqIgY8tNvmSDnG3+UMw+um6OlPm9uuDktkbcuhn0dIGnMw6YKaM4KvTmfJaNauQtZhJteoNJgUo/jnVir+mfctlHLkZyaL/9WPAoGAEKJ2hfVg7EP+GrlxYTxX99ByMrWZmANVhncehqklnvi0aczLLHMZZ8hiD1KbcYoKb0Z55nGSPXGK5x3kly7+/UuRoWmtq6jh+laR2Bad0nwOZCXDFHbnVfVZ4WgTCXhWA9op6U/fgnStD9iLlgi1b/eQSt2QNlNj4HfyAWKRASnMQECgYEAr3XyN8/OaQ1ur+T4yr/OdVaaBcIB1pA0CJHK30GzXB5RMOAaTMnYPiB+nDRE5TSC3iX6k1OAU6JDqeqXWdGfWZea/aKaC/Xt/99RlkXdGcmPOE1DbvB4h29rJnzSRlSC2I8rccuCEx3Ivxmb6glHIk8bs0Usj+TTksRGwC//yXKR4=n-----END RSA PRIVATE KEY-----n",
    "user_id": "d77df5d8b15349fcb460f1cec8814d47",
    "name": "key2",
    "fingerprint": "14:2a:b5:f5:9b:40:10:ef:d4:e6:e6:26:72:4e:fa:c3"
}

5.5.3.3. 列出所有密钥

HTTP方法 URI路径 描述
GET /v2/{project_id}/os-keypairs 列出所有密钥

请求参数

请求样例

curl -s \
     -X GET https://bj1.compute.api.ustack.com/v2/{project_id}/os-keypairs \
     -H 'Content-Type: application/json' \
     -H 'Accept: application/json' \
     -H 'X-Auth-Token: {token_id}'

返回参数

字段名 类型 描述
name string 密钥的名称
public_key string 密钥中的公钥的内容
fingerprint string 密钥的指纹信息

返回样例

HTTP/1.1 200

{
    "keypairs": [
        {
            "keypair": {
                "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAz6V2RZUYWIomYLTHQKDk2fJDnAPovZiWkiR+YW5GeamFkMTVDpuzuHXxYef0WP+SUHHbLhucL/pZgpwJQfbGSCRhkZEzxNTX9Zuh0GOUGaF7a4JveUxDkVvamf9YHxNmWEsxXt2tME1e9/ndl6Y5gkuqvu0VkTD9qWDx7hS583KajoRAfBxrmm2Q8sktUY8ifFWoKXeHAhMyHeq0mV36kHX7fCF5ISfUx5dB4v/FQms4qibeGLuNN8K0vr3eIwtXSaR8ucDYynCxCle158JzURZJaCGBY4ZqJ3RlPdDtRG+Bi8cJID7hJp5jZ7W7j0otGssO1H07i91LZS7ssEL/PQ== Generated by Novan",
                "name": "key1",
                "fingerprint": "40:b8:1d:71:66:3a:28:7a:0e:c1:ec:a5:c3:2c:c8:df"
            }
        },
        {
            "keypair": {
                "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAu5e0dGSqxnJTFvZqgzza68+lsasRcav+8phFtzsDc3tWyP3GWDQAdA4r1FFsNzSUKQp48fXse3ipMyN8gNbVgdBvPYjopKmMQA2AxyQJX9Sp61rB376Y5tEHHKPRrMyUq0znlDQj3iq5xjd8eYYyhqUH6DEKMwn8NXD8gJXZk4WJABY7E0DftIZzwTTKhsP2FeluM5wSBQBaHIN6I+uhg0vk4ZRXesoLdI7uFqp1pSsJzGddOgneKlLCsuWJZ0Y8PH8fihVAM1qTROnMFBfYDM/JNjxg9HyxnpYKGhbPWGOq/TAOVWOq5FJubjE/M9Ta9ph0Ud+Yde031jhiD4xuwQ== Generated by Novan",
                "name": "key2",
                "fingerprint": "14:2a:b5:f5:9b:40:10:ef:d4:e6:e6:26:72:4e:fa:c3"
            }
        },
        {
            "keypair": {
                "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDx8nkQv/zgGgB4rMYmIf+6A4l6Rr+o/6lHBQdW5aYd44bd8JttDCE/F/pNRr0lRE+PiqSPO8nDPHw0010JeMH9gYgnnFlyY3/OcJ02RhIPyyxYpv9FhY+2YiUkpwFOcLImyrxEsYXpD/0d3ac30bNH6Sw9JD9UZHYcpSxsIbECHw== Generated by Nova",
                "name": "key3",
                "fingerprint": "1e:2c:9b:56:79:4b:45:77:f9:ca:7a:98:2c:b0:d5:3c"
            }
        }
    ]
}

5.5.3.4. 查看密钥详细信息

HTTP方法 URI路径 描述
GET /v2/{project_id}/os-keypairs/{key_name} 查看密钥详细信息

请求参数

请求样例

curl -s \
     -X GET https://bj1.compute.api.ustack.com/v2/{project_id}/os-keypairs/{key_name} \
     -H 'Content-Type: application/json' \
     -H 'Accept: application/json' \
     -H 'X-Auth-Token: {token_id}'

返回参数

字段名 类型 描述
id int 密钥的id
user_id uuid 创建密钥的用户的id
name string 密钥的名称
public_key string 密钥中的公钥的内容
private_key string 密钥中的私钥的内容
fingerprint string 密钥的指纹信息
created_at datetime 密钥的创建时间
deleted bool 密钥是否被用户删除了

返回样例

HTTP/1.1 200

{
    "keypair": {
        "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDx8nkQv/zgGgB4rMYmIf+6A4l6Rr+o/6lHBQdW5aYd44bd8JttDCE/F/pNRr0lRE+PiqSPO8nDPHw0010JeMH9gYgnnFlyY3/OcJ02RhIPyyxYpv9FhY+2YiUkpwFOcLImyrxEsYXpD/0d3ac30bNH6Sw9JD9UZHYcpSxsIbECHw== Generated by Nova",
        "user_id": "d77df5d8b15349fcb460f1cec8814d47",
        "name": "key3",
        "deleted": false,
        "created_at": "2014-06-04T08:11:11.000000",
        "updated_at": null,
        "fingerprint": "1e:2c:9b:56:79:4b:45:77:f9:ca:7a:98:2c:b0:d5:3c",
        "deleted_at": null,
        "id": 1862
    }
}

5.5.3.5. 删除密钥

HTTP方法 URI路径 描述
DELETE /v2/{project_id}/os-keypairs/{key_name} 删除密钥

请求参数

请求样例

curl -s \
     -X DELETE https://bj1.compute.api.ustack.com/v2/{project_id}/os-keypairs/{key_name} \
     -H 'Content-Type: application/json' \
     -H 'Accept: application/json' \
     -H 'X-Auth-Token: {token_id}'

返回参数

返回样例

HTTP/1.1 200

5.5.3.6. 挂载密钥

HTTP方法 URI路径 描述
POST /v2/{project_id}/servers/{server_id}/action 挂载密钥

请求参数

字段名 类型 描述
key_names list 要挂载的密钥的名称

请求样例

curl -s \
     -X POST https://bj1.compute.api.ustack.com/v2/{project_id}/servers/{server_id}/action \
     -H 'Content-Type: application/json' \
     -H 'Accept: application/json' \
     -H 'X-Auth-Token: {token_id}' \
     -d '{
            "attachKeypairs": {
                "key_names": ["key1", "key2"]
            }
        }'

返回参数

返回样例

HTTP/1.1 202

5.5.3.7. 卸载密钥

HTTP方法 URI路径 描述
POST /v2/{project_id}/servers/{server_id}/action 卸载密钥

请求参数

字段名 类型 描述
key_names list 要卸载的密钥的名称

请求样例

curl -s \
     -X POST https://bj1.compute.api.ustack.com/v2/{project_id}/servers/{server_id}/action \
     -H 'Content-Type: application/json' \
     -H 'Accept: application/json' \
     -H 'X-Auth-Token: {token_id}' \
     -d '{
            "detachKeypairs": {
                "key_names": [
                    "key1",
                    "key2"
                ]
            }
        }'

返回参数

返回样例

HTTP/1.1 202

5.5.4. 云硬盘 (Volumes)

5.5.4.1. 挂载云硬盘

HTTP方法 URI路径 描述
POST /v2/{project_id}/servers/{server_id}/os-volume_attachments 挂载云硬盘

请求参数

字段名 类型 描述
volumeId uuid 要挂载的云硬盘的UUID

请求样例

curl -s \
     -X POST https://bj1.compute.api.ustack.com/v2/{project_id}/servers/{server_id}/os-volume_attachments \
     -H 'Content-Type: application/json' \
     -H 'Accept: application/json' \
     -H 'X-Auth-Token: {token_id}' \
     -d '{
            "volumeAttachment": {
                "volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
            }
        }'

返回参数

字段名 类型 描述
id uuid 云硬盘挂载信息的UUID
volumeId uuid 要挂载的云硬盘的UUID
serverId uuid 挂载云硬盘的主机的UUID
device string 云硬盘挂载到主机设备路径

返回样例

HTTP/1.1 202

{
    "volumeAttachment": {
        "device": "/dev/vdd",
        "id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
        "serverId": "0c92f3f6-c253-4c9b-bd43-e880a8d2eb0a",
        "volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
    }
}

5.5.4.2. 卸载云硬盘

HTTP方法 URI路径 描述
DELETE /v2/{project_id}/servers/{server_id}/os-volume_attachments/{volume_id} 卸载云硬盘

请求参数

请求样例

curl -s \
     -X DELETE https://bj1.compute.api.ustack.com/v2/{project_id}/servers/{server_id}/os-volume_attachments/{volume_id} \
     -H 'Content-Type: application/json' \
     -H 'Accept: application/json' \
     -H 'X-Auth-Token: {token_id}'

返回参数

返回样例

HTTP/1.1 202

5.5.5. 配置 (Flavors)

5.5.5.1. 列出所有配置基本信息

HTTP方法 URI路径 描述
GET /v2/{project_id}/flavors 列出所有配置基本信息

请求参数

请求样例

curl -s \
     -X GET https://bj1.compute.api.ustack.com/v2/{project_id}/flavors \
     -H 'Content-Type: application/json' \
     -H 'Accept: application/json' \
     -H 'X-Auth-Token: {token_id}'

返回参数

字段名 类型 描述
id uuid 配置信息的唯一标识
links dict 配置信息的链接, 通过这些链接可以获取更详细的信息
name string 配置信息的名称

返回样例

HTTP/1.1 200

{
    "flavors": [
        {
            "id": "215ea357-2d56-4387-9991-0c083806e3f8",
            "links": [
                {
                    "href": "https://bj1.compute.api.ustack.com/v2/0f1255df40374d02a23e1a6ceeaefec7/flavors/215ea357-2d56-4387-9991-0c083806e3f8",
                    "rel": "self"
                },
                {
                    "href": "https://bj1.compute.api.ustack.com/0f1255df40374d02a23e1a6ceeaefec7/flavors/215ea357-2d56-4387-9991-0c083806e3f8",
                    "rel": "bookmark"
                }
            ],
            "name": "micro-1"
        },
        {
            "id": "3332c026-533a-43d0-b415-abd3fdab09bf",
            "links": [
                {
                    "href": "https://bj1.compute.api.ustack.com/v2/0f1255df40374d02a23e1a6ceeaefec7/flavors/3332c026-533a-43d0-b415-abd3fdab09bf",
                    "rel": "self"
                },
                {
                    "href": "https://bj1.compute.api.ustack.com/0f1255df40374d02a23e1a6ceeaefec7/flavors/3332c026-533a-43d0-b415-abd3fdab09bf",
                    "rel": "bookmark"
                }
            ],
            "name": "micro-2"
        },
        {
            "id": "7f05780f-caf6-43bd-af55-b183cec6a758",
            "links": [
                {
                    "href": "https://bj1.compute.api.ustack.com/v2/0f1255df40374d02a23e1a6ceeaefec7/flavors/7f05780f-caf6-43bd-af55-b183cec6a758",
                    "rel": "self"
                },
                {
                    "href": "https://bj1.compute.api.ustack.com/0f1255df40374d02a23e1a6ceeaefec7/flavors/7f05780f-caf6-43bd-af55-b183cec6a758",
                    "rel": "bookmark"
                }
            ],
            "name": "standard-1"
        }
    ]
}

5.5.5.2. 列出所有配置详细信息

HTTP方法 URI路径 描述
GET /v2/{project_id}/flavors/detail 列出所有配置详细信息

请求参数

请求样例

curl -s \
     -X GET https://bj1.compute.api.ustack.com/v2/{project_id}/flavors/detail \
     -H 'Content-Type: application/json' \
     -H 'Accept: application/json' \
     -H 'X-Auth-Token: {token_id}'

返回参数

返回样例

HTTP/1.1 200

{
    "flavors": [
        {
            "name": "micro-1",
            "links": [
                {
                    "href": "https://bj1.compute.api.ustack.com/v2/0f1255df40374d02a23e1a6ceeaefec7/flavors/215ea357-2d56-4387-9991-0c083806e3f8",
                    "rel": "self"
                },
                {
                    "href": "https://bj1.compute.api.ustack.com/0f1255df40374d02a23e1a6ceeaefec7/flavors/215ea357-2d56-4387-9991-0c083806e3f8",
                    "rel": "bookmark"
                }
            ],
            "ram": 12288,
            "OS-FLV-DISABLED:disabled": false,
            "vcpus": 12,
            "swap": "",
            "os-flavor-access:is_public": true,
            "rxtx_factor": 1,
            "OS-FLV-EXT-DATA:ephemeral": 0,
            "disk": 20,
            "id": "215ea357-2d56-4387-9991-0c083806e3f8"
        },
        {
            "name": "micro-2",
            "links": [
                {
                    "href": "https://bj1.compute.api.ustack.com/v2/0f1255df40374d02a23e1a6ceeaefec7/flavors/21c0cf18-d0dc-43ab-8fdb-40ba8b0935d9",
                    "rel": "self"
                },
                {
                    "href": "https://bj1.compute.api.ustack.com/0f1255df40374d02a23e1a6ceeaefec7/flavors/21c0cf18-d0dc-43ab-8fdb-40ba8b0935d9",
                    "rel": "bookmark"
                }
            ],
            "ram": 8192,
            "OS-FLV-DISABLED:disabled": false,
            "vcpus": 2,
            "swap": "",
            "os-flavor-access:is_public": true,
            "rxtx_factor": 1,
            "OS-FLV-EXT-DATA:ephemeral": 0,
            "disk": 20,
            "id": "21c0cf18-d0dc-43ab-8fdb-40ba8b0935d9"
        },
        {
            "name": "standard-1",
            "links": [
                {
                    "href": "https://bj1.compute.api.ustack.com/v2/0f1255df40374d02a23e1a6ceeaefec7/flavors/e15253c2-c340-4402-89ae-cfd794774560",
                    "rel": "self"
                },
                {
                    "href": "https://bj1.compute.api.ustack.com/0f1255df40374d02a23e1a6ceeaefec7/flavors/e15253c2-c340-4402-89ae-cfd794774560",
                    "rel": "bookmark"
                }
            ],
            "ram": 16384,
            "OS-FLV-DISABLED:disabled": false,
            "vcpus": 8,
            "swap": "",
            "os-flavor-access:is_public": true,
            "rxtx_factor": 1,
            "OS-FLV-EXT-DATA:ephemeral": 0,
            "disk": 20,
            "id": "e15253c2-c340-4402-89ae-cfd794774560"
        }
    ]
}

5.5.5.3. 列出指定配置信息

HTTP方法 URI路径 描述
GET /v2/{project_id}/flavors/{flavor_id} 列出指定配置信息

请求参数

请求样例

curl -s \
     -X GET https://bj1.compute.api.ustack.com/v2/{project_id}/flavors/{flavor_id} \
     -H 'Content-Type: application/json' \
     -H 'Accept: application/json' \
     -H 'X-Auth-Token: {token_id}'

返回参数

字段名 类型 描述
id uuid 配置信息的唯一标识
links dict 配置信息的链接, 通过这些链接可以获取更详细的信息
name string 配置信息的名称
ram int 内存的大小, 以MB为单位
vcpus int 有多少个云主机的CPU
disk int 根分区的大小, 以 GB 为单位
swap int 交换分区的大小, 以 GB 为单位
os-flavor-access:is_public bool 本配置信息是否公开的, 如果是, 则所有的人都可以看见和使用

返回样例

HTTP/1.1 200

{
    "flavor": {
        "name": "compute-12",
        "links": [
            {
                "href": "https://bj1.compute.api.ustack.com/v2/0f1255df40374d02a23e1a6ceeaefec7/flavors/215ea357-2d56-4387-9991-0c083806e3f8",
                "rel": "self"
            },
            {
                "href": "https://bj1.compute.api.ustack.com/0f1255df40374d02a23e1a6ceeaefec7/flavors/215ea357-2d56-4387-9991-0c083806e3f8",
                "rel": "bookmark"
            }
        ],
        "ram": 12288,
        "OS-FLV-DISABLED:disabled": false,
        "vcpus": 12,
        "swap": "",
        "os-flavor-access:is_public": true,
        "rxtx_factor": 1,
        "OS-FLV-EXT-DATA:ephemeral": 0,
        "disk": 20,
        "id": "215ea357-2d56-4387-9991-0c083806e3f8"
    }
}

5.5.6. 网络 (Networks)

5.5.6.1. 绑定虚拟网卡

HTTP方法 URI路径 描述
POST /v2/{project_id}/servers/{server_id}/os-interface 绑定虚拟网卡

请求参数

字段名 类型 描述
port_id uuid 指定云主机要绑定的虚拟网卡

请求样例

curl -s \
     -X POST https://bj1.compute.api.ustack.com/v2/{project_id}/servers/{server_id}/os-interface \
     -H 'Content-Type: application/json' \
     -H 'Accept: application/json' \
     -H 'X-Auth-Token: {token_id}' \
     -d '{
            "interfaceAttachment": {
                "port_id": "{port_id}"
            }
        }'

返回参数

返回样例

HTTP/1.1 200

5.5.6.2. 卸载虚拟网卡

HTTP方法 URI路径 描述
DELETE /v2/{project_id}/servers/{server_id}/os-interface/{port_id} 卸载虚拟网卡

请求参数

请求样例

curl -s \
     -X DELETE https://bj1.compute.api.ustack.com/v2/{project_id}/servers/{server_id}/os-interface/{port_id} \
     -H 'Content-Type: application/json' \
     -H 'Accept: application/json' \
     -H 'X-Auth-Token: {token_id}'

返回参数

返回样例

HTTP/1.1 202

5.5.6.3. 加入网络

HTTP方法 URI路径 描述
POST /v2/{project_id}/servers/{server_id}/os-interface 加入网络

请求参数

字段名 类型 描述
sbunet_id uuid 指定要加入到那个子网
net_id uuid 指定云主机要加入的网络

请求样例

curl -s \
     -X POST https://bj1.compute.api.ustack.com/v2/{project_id}/servers/{server_id}/os-interface \
     -H 'Content-Type: application/json' \
     -H 'Accept: application/json' \
     -H 'X-Auth-Token: {token_id}' \
     -d '{
            "interfaceAttachment": {
                "fixed_ips": [
                    {
                        "subnet_id": "{subnet_id}"
                     }
                ]
                "net_id": "{net_id}"
            }
        }'

返回参数

返回样例

HTTP/1.1 200

5.5.7. VNC终端 (VNC Console)

5.5.7.1. 获取VNC终端地址

HTTP方法 URI路径 描述
POST /v2/{project_id}/servers/{server_id}/action 获取VNC终端地址

请求参数

字段名 类型 描述
type string VNC终端的类型

请求样例

curl -s \
     -X POST https://bj1.compute.api.ustack.com/v2/{project_id}/servers/{server_id}/action \
     -H 'Content-Type: application/json' \
     -H 'Accept: application/json' \
     -H 'X-Auth-Token: {token_id}' \
     -d '{
            "os-getVNCConsole": {
                "type": "novnc"
            }
        }'

返回参数

字段名 类型 描述
type string VNC终端的类型
url string VNC终端的链接

返回样例

HTTP/1.1 202

{
    "console": {
        "type": "novnc",
        "url": "https://bj1.compute.api.ustack.com/vnc/vnc_auto.html?token=36f6426d-1366-4734-af15-c81560becd77"
    }
}