> For the complete documentation index, see [llms.txt](https://pshizhsysu.gitbook.io/openstack/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pshizhsysu.gitbook.io/openstack/api/nova/chuang-jian-shi-li.md).

# 创建实例

## API

```
POST /servers
```

## Header参数

```
"X-Auth-Token" : <token>
```

## Body参数

```
{
    "server" : {
        "name" : "postman-server",
        "imageRef" : "09a155a7-0c3d-4756-9dbc-55f8b18dfbc8",
        "flavorRef" : "eeca58d6-d4c2-45f2-a664-617726ca249b",
        "networks" : [
            {
                "uuid" : "1d0f4c48-cfa0-4f1a-8572-e2092cb9fcd5"
            }
        ]
    }
}
```

上述body参数中

* `name`：是用户自定义
* `imageRef`：镜像的id，可以用`openstack image list`获取

```
$ openstack image list
+--------------------------------------+--------+--------+
| ID                                   | Name   | Status |
+--------------------------------------+--------+--------+
| 09a155a7-0c3d-4756-9dbc-55f8b18dfbc8 | cirros | active |
+--------------------------------------+--------+--------+
```

* `flavorRef`：模板的id，可以用`openstack flavor list`获取

```
$ openstack flavor list
+--------------------------------------+----------+------+------+-----------+-------+-----------+
| ID                                   | Name     |  RAM | Disk | Ephemeral | VCPUs | Is Public |
+--------------------------------------+----------+------+------+-----------+-------+-----------+
| eeca58d6-d4c2-45f2-a664-617726ca249b | 1c-1g-1g | 1024 |    1 |         0 |     1 | True      |
+--------------------------------------+----------+------+------+-----------+-------+-----------+
```

* `networks.uuid`：网络的id，可以用`openstack network list`获取

```
$ openstack network list
+--------------------------------------+------+--------------------------------------+
| ID                                   | Name | Subnets                              |
+--------------------------------------+------+--------------------------------------+
| 1d0f4c48-cfa0-4f1a-8572-e2092cb9fcd5 | net1 | fef6693a-705c-4a87-ac38-f878a5489ffc |
+--------------------------------------+------+--------------------------------------+
```

## Reference

* <https://www.sdnlab.com/20506.html>
* <https://developer.openstack.org/api-ref/compute/?expanded=create-server-detail>
