2.1.2. Create Server

Verb URI Description
POST /servers Creates a new server.

Normal Response Code(s): 202

Error Response Code(s): computeFault (400, 500, …), serviceUnavailable (503), unauthorized (401), forbidden (403), badRequest (400), badMethod (405), overLimit (413), itemNotFound (404), badMediaType (415), serverCapacityUnavailable (503)

Status Transition: BUILD ACTIVE
BUILD ERROR (on error)

This operation asynchronously provisions a new server. The progress of this operation depends on several factors including location of the requested image, network i/o, host load, and the selected flavor. The progress of the request can be checked by performing a GET on /servers/id, which will return a progress attribute (0-100% completion). The full URL to the newly created server is returned via the Location header and is available as a self and bookmark link in the server representation (See Section 1.4, “Links and References”). Note that when creating a server only the server ID, its links, and the admin password are guaranteed to be returned in the request. Additional attributes may be retrieved by performing subsequent GETs on the server.

The following table describes the required and optional attributes that you can specify in the request body:

Table 2.1. Create Server Request Attributes
Name Description Required
imageRef

The image reference for the desired image for your server instance.

Specify as an ID or full URL. To get a list of available images, see Section 2.5.1, “List Images”.

Yes
flavorRef

The flavor reference for the desired flavor for your server instance.

Specify as an ID or full URL. To get a list of available flavors, see Section 2.4.1, “List Flavors”.

Yes

name

The server name. Choose any name you like.

Yes

metadata

Metadata key and value pairs. For information, see Section 2.1.2.2, “Server Metadata”. No

personality

File path and contents. For information, see Section 2.1.2.3, “Server Personality”.

No

 

Example 2.3. Server Create Request: JSON

{
    "server": {
        "flavorRef": "http://openstack.example.com/openstack/flavors/1",
        "imageRef": "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b",
        "metadata": {
            "My Server Name": "Apache1"
        },
        "name": "new-server-test",
        "personality": [
            {
                "contents": "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp
                             dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k
                             IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs
                             c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g
                             QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo
                             ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv
                             dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy
                             c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6
                             b25zLiINCg0KLVJpY2hhcmQgQmFjaA==",
                "path": "/etc/banner.txt"
            }
        ]
    }
}

 

Example 2.4. Server Create Response: JSON

{
    "server": {
        "adminPass": "MVk5HPrazHcG",
        "id": "5bbcc3c4-1da2-4437-a48a-66f15b1b13f9",
        "links": [
            {
                "href": "http://openstack.example.com/v2/openstack/servers/5bbcc3c4-1da2-4437-a48a-66f15b1b13f9",
                "rel": "self"
            },
            {
                "href": "http://openstack.example.com/openstack/servers/5bbcc3c4-1da2-4437-a48a-66f15b1b13f9",
                "rel": "bookmark"
            }
        ]
    }
}

 

Example 2.5. Server Create Request: XML

<?xml version='1.0' encoding='UTF-8'?>
<server xmlns="http://docs.openstack.org/compute/api/v1.1"
  imageRef="http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b"
  flavorRef="http://openstack.example.com/openstack/flavors/1"
  name="new-server-test">
  <metadata>
    <meta key="My Server Name">Apache1</meta>
  </metadata>
  <personality>
    <file path="/etc/banner.txt">
      ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp
      dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k
      IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs
      c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g
      QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo
      ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv
      dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy
      c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6
      b25zLiINCg0KLVJpY2hhcmQgQmFjaA== </file>
  </personality>
</server>

 

Example 2.6. Server Create Response: XML

<?xml version='1.0' encoding='UTF-8'?>
<server xmlns:atom="http://www.w3.org/2005/Atom"
  xmlns="http://docs.openstack.org/compute/api/v1.1"
  id="ea8417a1-7957-4ed5-8b3c-0befc1724308" adminPass="FoFw84XtQj3c">
  <metadata/>
  <atom:link
    href="http://openstack.example.com/v2/openstack/servers/ea8417a1-7957-4ed5-8b3c-0befc1724308"
    rel="self"/>
  <atom:link
    href="http://openstack.example.com/openstack/servers/ea8417a1-7957-4ed5-8b3c-0befc1724308"
    rel="bookmark"/>
</server>



loading table of contents...