ServerCreate
(Difference between revisions)
Line 1: | Line 1: | ||
+ | <pre style="color:red">Needs production update</pre> | ||
+ | |||
This operation will create a new server. The server creation is asynchronous, the progress can be checked with the URL in the response Location header or the self link in the body. | This operation will create a new server. The server creation is asynchronous, the progress can be checked with the URL in the response Location header or the self link in the body. | ||
Line 5: | Line 7: | ||
== Parameters == | == Parameters == | ||
=== JSON === | === JSON === | ||
− | |||
<big><source lang="javascript"> | <big><source lang="javascript"> | ||
{ | { | ||
"server":{ | "server":{ | ||
− | "name":" | + | "name":"{display_server_name}", |
− | "imageRef":"http:// | + | "imageRef":"http://{server_name}/images/{image_id}/", |
− | "flavorRef":"http:// | + | "flavorRef":"http://{server_name}/flavors/{flavor_id}/" |
+ | } | ||
} | } | ||
</source></big> | </source></big> | ||
− | |||
; name - ''string'' | ; name - ''string'' | ||
Line 27: | Line 28: | ||
== Result == | == Result == | ||
=== JSON === | === JSON === | ||
− | |||
<big><source lang="javascript"> | <big><source lang="javascript"> | ||
{ | { | ||
"server":{ | "server":{ | ||
− | "status":" | + | "status":"BUILD", |
"updated":null, | "updated":null, | ||
− | "hostId":" | + | "hostId":"", |
"addresses":{ | "addresses":{ | ||
"public":[ | "public":[ | ||
{ | { | ||
"version":4, | "version":4, | ||
− | "addr":" | + | "addr":"{ip_address}" |
} | } | ||
], | ], | ||
Line 44: | Line 44: | ||
{ | { | ||
"version":4, | "version":4, | ||
− | "addr":" | + | "addr":"{ip_address}" |
} | } | ||
] | ] | ||
Line 50: | Line 50: | ||
"links":[ | "links":[ | ||
{ | { | ||
− | "href":"http:// | + | "href":"http://{server_name}/servers/{server_id}/", |
"rel":"self" | "rel":"self" | ||
} | } | ||
Line 58: | Line 58: | ||
"links":[ | "links":[ | ||
{ | { | ||
− | "href":"http:// | + | "href":"http://{server_name}/images/20GB_Ubuntu%2010.10%20x64%20R1soft/", |
"rel":"self" | "rel":"self" | ||
} | } | ||
Line 64: | Line 64: | ||
"id":"20GB_Ubuntu 10.10 x64 R1soft" | "id":"20GB_Ubuntu 10.10 x64 R1soft" | ||
}, | }, | ||
− | "userId":" | + | "userId":"{user_account_id}", |
"flavor":{ | "flavor":{ | ||
"name":"1024MB Server3", | "name":"1024MB Server3", | ||
"links":[ | "links":[ | ||
{ | { | ||
− | "href":" | + | "href":"{server_name}/flavors/3/", |
"rel":"self" | "rel":"self" | ||
} | } | ||
Line 75: | Line 75: | ||
"id":3 | "id":3 | ||
}, | }, | ||
− | "id":" | + | "id":"{server_id}", |
− | "name":" | + | "name":"{display_server_name}", |
− | "created":" | + | "created":"", |
"tenantId":null, | "tenantId":null, | ||
− | "accessIPv4":" | + | "accessIPv4":"{ip_address}", |
"accessIPv6":null, | "accessIPv6":null, | ||
− | "progress": | + | "progress":0, |
"metadata":{ | "metadata":{ | ||
Line 90: | Line 90: | ||
+ | * When a server is still pending (has not completed the provisioning process), the creation timestamp and hostId that are returned will be empty string. | ||
==== server ==== | ==== server ==== | ||
; id - ''string'' | ; id - ''string'' | ||
Line 107: | Line 108: | ||
; name - ''string'' | ; name - ''string'' | ||
− | : | + | : Display name for this server. |
; created - ''string'' | ; created - ''string'' | ||
Line 162: | Line 163: | ||
; flavor.id - ''string'' | ; flavor.id - ''string'' | ||
: Unique identifier for flavor this server is based on. | : Unique identifier for flavor this server is based on. | ||
+ | |||
+ | == Response Codes == | ||
+ | ; Success: | ||
+ | :''HTTP/1.1 202 Accepted'' | ||
+ | ::Request is accepted. | ||
+ | |||
+ | ; Failure: | ||
+ | :''HTTP/1.1 400 Bad Request'' | ||
+ | ::The resource used for creating server is not found. | ||
+ | |||
+ | == Examples == | ||
+ | '''Create a new server''' | ||
+ | :'''POST''' <nowiki>http://{api_url}/servers</nowiki> | ||
+ | |||
+ | ''Request Headers:'' | ||
+ | Content-Type:application/json | ||
+ | Charset=UTF-8 | ||
+ | Authorization:Base64-encoded username & password string | ||
+ | |||
+ | ''Request Body:'' | ||
+ | {"server" : { "flavorRef" : "<nowiki>http://{server_name}//flavors/{flavor_id}</nowiki>", "name" : "{display_server_name}", | ||
+ | "imageRef" : "<nowiki>http://{server_name}//images/{image_id}</nowiki>" } } | ||
+ | |||
+ | ''Response Code:'' | ||
+ | <pre>HTTP/1.1 202 Accepted</pre> | ||
+ | |||
+ | ''Response Body:'' | ||
+ | {"server": {"status": "BUILD", "updated": null, "hostId": "", | ||
+ | "addresses": {"public": [{"version": 4, "addr": "{ip_address}"}], "private": [{"version": 4, "addr": "{ip_address}"}]}, | ||
+ | "links": [{"href": "<nowiki>http://{server_name}/servers/{server_id}/</nowiki>", "rel": "self"}], "image": {"name": "CentOS 5 Plesk", | ||
+ | "links": [{"href": "<nowiki>http://{server_name}/images/Centos%205%20x86%20Plesk/</nowiki>", "rel": "self"}], "id": "Centos 5 x86 Plesk"}, | ||
+ | "userId": "{user_account_id}", "flavor": {"name": "", "links": [], "id": ""}, "id": "{server_id}", "name": "{display_server_name}", | ||
+ | "created": "", "tenantId": null, "accessIPv4": "{ip_address}", "accessIPv6": null, "progress": 0, "metadata": {}}} | ||
+ | |||
+ | * When a server is still pending (has not completed the provisioning process), the creation timestamp and hostId that are returned will be empty string. | ||
+ | |||
+ | |||
+ | '''Create a server with bad request body''' | ||
+ | :'''POST''' <nowiki>http://{api_url}/servers</nowiki> | ||
+ | |||
+ | ''Request Headers:'' | ||
+ | Content-Type:application/json | ||
+ | Charset=UTF-8 | ||
+ | Authorization:Base64-encoded username & password string | ||
+ | |||
+ | ''Request Body:'' | ||
+ | {"server" : { "flavorRef" : "<nowiki>http://{server_name}//flavors/{flavor_id}</nowiki>", "name" : "{display_server_name}", | ||
+ | "imageRef" : "<nowiki>http://{server_name}//images/{image_id}</nowiki>" } } | ||
+ | |||
+ | ''Response Code:'' | ||
+ | <pre>HTTP/1.1 400 Bad Request</pre> | ||
+ | |||
+ | ''Response Body:'' | ||
+ | {"computeFault": {"message": "Bad imageRef", "code": 400, "details": ""}} | ||
+ | |||
<!-- THIS CODE ENABLES DISQUS COMMENTS ON THE PAGE - DELETE TO DISABLE COMMENTING--> | <!-- THIS CODE ENABLES DISQUS COMMENTS ON THE PAGE - DELETE TO DISABLE COMMENTING--> |
Revision as of 18:57, 12 April 2012
Needs production update
This operation will create a new server. The server creation is asynchronous, the progress can be checked with the URL in the response Location header or the self link in the body.
POST /servers
Contents |
Parameters
JSON
{ "server":{ "name":"{display_server_name}", "imageRef":"http://{server_name}/images/{image_id}/", "flavorRef":"http://{server_name}/flavors/{flavor_id}/" } }
- name - string
- Display name for this server
- imageRef - string
- Absolute URL of the Image to use
- flavorRef - string
- Absolute URL of the Flavor to use
Result
JSON
{ "server":{ "status":"BUILD", "updated":null, "hostId":"", "addresses":{ "public":[ { "version":4, "addr":"{ip_address}" } ], "private":[ { "version":4, "addr":"{ip_address}" } ] }, "links":[ { "href":"http://{server_name}/servers/{server_id}/", "rel":"self" } ], "image":{ "name":"Ubuntu 10.10 x64", "links":[ { "href":"http://{server_name}/images/20GB_Ubuntu%2010.10%20x64%20R1soft/", "rel":"self" } ], "id":"20GB_Ubuntu 10.10 x64 R1soft" }, "userId":"{user_account_id}", "flavor":{ "name":"1024MB Server3", "links":[ { "href":"{server_name}/flavors/3/", "rel":"self" } ], "id":3 }, "id":"{server_id}", "name":"{display_server_name}", "created":"", "tenantId":null, "accessIPv4":"{ip_address}", "accessIPv6":null, "progress":0, "metadata":{ } } }
- When a server is still pending (has not completed the provisioning process), the creation timestamp and hostId that are returned will be empty string.
server
- id - string
- Unique identifier for this server.
- links - list
- Hypermedia for this resource.
- status - string
- Current state of the server. Values: BUILD, ACTIVE, SUSPENDED, DELETED, UNKNOWN
- hostId - string
- Id of the physical host this virtual machine is running on.
- userId - string
- Unique identifier for the owner of this server.
- name - string
- Display name for this server.
- created - string
- The date and time this server was created. ISO 8601 format, YYYY-MM-DDTHH:MM:SS.
- accessIPv4 - string
- The default included public IPv4 address.
- progress - number
- The progress of the current this server while in the BUILD status. The value is in the range of 0 - 100, but currently will only even be 0, 50, 100.
- metadata - object
- Unused always an empty object.
- tenantId
- Unused always always null.
- accessIPv6
- Unused always null.
- updated
- Unused always null.
addresses
- addresses.public.version - number
- IP version of this address. Values: 4
- addresses.public.addr = string
- Public IP address of this server
- addresses.private.version - number
- IP version of this address. Values: 4
- addresses.private.addr - string
- Private IP address of this server
image
- image.name - string
- The display name of the image this server is based on.
- image.links - list
- Hypermedia for the image.
- image.id - string
- Unique identifier for image this server is based on.
flavor
- flavor.name - string
- The display name of the flavor this server is based on.
- flavor.links - list
- Hypermedia for the flavor.
- flavor.id - string
- Unique identifier for flavor this server is based on.
Response Codes
- Success
- HTTP/1.1 202 Accepted
- Request is accepted.
- Failure
- HTTP/1.1 400 Bad Request
- The resource used for creating server is not found.
Examples
Create a new server
- POST http://{api_url}/servers
Request Headers:
Content-Type:application/json Charset=UTF-8 Authorization:Base64-encoded username & password string
Request Body:
{"server" : { "flavorRef" : "http://{server_name}//flavors/{flavor_id}", "name" : "{display_server_name}", "imageRef" : "http://{server_name}//images/{image_id}" } }
Response Code:
HTTP/1.1 202 Accepted
Response Body:
{"server": {"status": "BUILD", "updated": null, "hostId": "", "addresses": {"public": [{"version": 4, "addr": "{ip_address}"}], "private": [{"version": 4, "addr": "{ip_address}"}]}, "links": [{"href": "http://{server_name}/servers/{server_id}/", "rel": "self"}], "image": {"name": "CentOS 5 Plesk", "links": [{"href": "http://{server_name}/images/Centos%205%20x86%20Plesk/", "rel": "self"}], "id": "Centos 5 x86 Plesk"}, "userId": "{user_account_id}", "flavor": {"name": "", "links": [], "id": ""}, "id": "{server_id}", "name": "{display_server_name}", "created": "", "tenantId": null, "accessIPv4": "{ip_address}", "accessIPv6": null, "progress": 0, "metadata": {}}}
- When a server is still pending (has not completed the provisioning process), the creation timestamp and hostId that are returned will be empty string.
Create a server with bad request body
- POST http://{api_url}/servers
Request Headers:
Content-Type:application/json Charset=UTF-8 Authorization:Base64-encoded username & password string
Request Body:
{"server" : { "flavorRef" : "http://{server_name}//flavors/{flavor_id}", "name" : "{display_server_name}", "imageRef" : "http://{server_name}//images/{image_id}" } }
Response Code:
HTTP/1.1 400 Bad Request
Response Body:
{"computeFault": {"message": "Bad imageRef", "code": 400, "details": ""}}