Add api-ref for instance create

Change-Id: Iba3caa608a0d5b7a000039c783752597f94397b9
This commit is contained in:
Zhenguo Niu 2016-09-30 00:54:57 +08:00
parent fcde6bd102
commit 25169af553
5 changed files with 214 additions and 2 deletions

View File

@ -7,4 +7,5 @@
.. rest_expand_all::
.. include:: urls.inc
.. include:: types.inc
.. include:: instances.inc
.. include:: types.inc

View File

@ -0,0 +1,70 @@
.. -*- rst -*-
===========
Instances
===========
Lists, creates, shows details for, updates, and deletes instances.
Create Instance
===============
.. rest_method:: POST /instances
Creates a instance.
The progress of this operation depends on the location of the
requested image, network I/O, selected type, and other factors.
The ``Location`` header returns the full URL to the newly created
instance and is available as a ``self`` and ``bookmark`` link in the
instance representation.
Normal response codes: 201
Error response codes: badRequest(400), unauthorized(401),
forbidden(403), conflict(409)
Request
-------
.. rest_parameters:: parameters.yaml
- name: instance_name
- description: instance_description
- instance_type_uuid: typeRef
- image_uuid: imageRef
- availability_zone: availability-zone
- networks: networks
- networks.uuid: network_uuid
- networks.port_type: network_port_type
**Example Create Instance: JSON request**
.. literalinclude:: ../../doc/api_samples/instances/instance-create-req.json
:language: javascript
Response
--------
.. rest_parameters:: parameters.yaml
- name: instance_name
- description: instance_description
- instance_type_uuid: typeRef
- image_uuid: imageRef
- availability_zone: availability-zone
- network_info: network_info
- links: links
- uuid: instance_uuid
- status: instance_status
- power_state: instance_power_state
- project_id: project_id_body
- user_id: user_id_body
- updated_at: updated_at
- created_at: created_at
**Example Create Instance: JSON response**
.. literalinclude:: ../../doc/api_samples/instances/instance-create-resp.json
:language: javascript

View File

@ -38,6 +38,21 @@ user_id:
# variables in body
availability_zone:
description: |
The availability zone from which to launch the instance. When you provision resources,
you specify from which availability zone you want your instance to be built. Typically,
you use availability zones to arrange bare metal nodes into logical groups.
An availability zone provides a form of physical isolation and redundancy from
other availability zones. For instance, if some racks in your data center are
on a separate power source, you can put servers in those racks in their own availability
zone. Availability zones can also help separate different classes of hardware. By
segregating resources into availability zones, you can ensure that your application
resources are spread across disparate machines to achieve high availability in
the event of hardware or other failure.
in: body
required: false
type: string
created_at:
description: |
The date and time when the resource was created. The date and time
@ -53,12 +68,86 @@ created_at:
in: body
required: true
type: string
imageRef:
description: |
The UUID of the image to use for your instance.
in: body
required: true
type: string
instance_description:
description: |
A free form description of the instance. Limited to 255 characters
in length.
in: body
required: false
type: string
instance_name:
description: |
The instance name.
in: body
required: true
type: string
instance_power_state:
description: |
The current power state of this instance. Usually, “power on” or “power off”, but may be “None”
if Nimble is unable to determine the power state (eg, due to hardware failure)
in: body
required: true
type: string
instance_status:
description: |
The status of this instance. Usually, "building", "active", "error", or "None".
in: body
required: true
type: string
instance_uuid:
description: |
The UUID of the server instance
in: body
required: true
type: string
links:
description: |
Links to the resources in question.
A list of relative links. Includes the self and bookmark links.
in: body
required: true
type: array
network_info:
description: |
The port info in the requested network for the instance, with fixed_ip, mac_address, and
network uuid
in: body
required: true
type: dict
network_port_type:
description: |
To provision the server instance with a specified type of NIC(like 1GE or 10 GE) for a
network, specify the type of the NIC in the ``port_type`` key in a dict in ``networks`` list.
in: body
required: false
type: string
network_uuid:
description: |
To provision the server instance with a NIC for a network, specify the UUID of
the network in the ``uuid`` key in a dict in ``networks`` list.
in: body
required: true
type: string
networks:
description: |
A list of networks of the tenant. Optionally, you can create one or more NICs on the instance.
To provision the server instance with a NIC for a network, specify the UUID of the network
in the ``uuid`` key in a dict in ``networks`` list. To provision the server instance with a
specified type of NIC, specify the port-type key in a dict in a ``networks`` list.
in: body
required: true
type: array
project_id_body:
description: |
The UUID of the project in a multi-tenancy cloud.
in: body
required: true
type: string
type_description:
description: |
The description of the type.
@ -142,3 +231,9 @@ updated_at:
in: body
required: true
type: string
user_id_body:
description: |
The user ID of the user who owns the instance.
in: body
required: true
type: string

View File

@ -0,0 +1,15 @@
{
"name": "test_instance",
"description": "this is a test instance",
"instance_type_uuid": "0607b5f3-6111-424d-ba46-f5de39a6fa69",
"image_uuid": "efe0a06f-ca95-4808-b41e-9f55b9c5eb98",
"networks": [
{
"uuid": "c1940655-8b8e-4370-b8f9-03ba1daeca31"
},
{
"uuid": "8e8ceb07-4641-4188-9b22-840755e92ee2",
"port_type": "10GE"
}
]
}

View File

@ -0,0 +1,31 @@
{
"name": "test_instance",
"description": "this is a test instance",
"instance_type_uuid": "0607b5f3-6111-424d-ba46-f5de39a6fa69",
"image_uuid": "efe0a06f-ca95-4808-b41e-9f55b9c5eb98",
"availability_zone" : "Beijing-01",
"status": "active",
"power_state": "on",
"links": [
{
"href": "http://10.3.150.17:6688/v1/instances/7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
"rel": "self"
},
{
"href": "http://10.3.150.17:6688/instances/7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
"rel": "bookmark"
}
],
"uuid": "7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
"created_at": "2016-09-27T02:37:21.966342+00:00",
"updated_at": null,
"project_id": "2f15c3524826465a9afbd150478b3b76",
"user_id": "a6205fcab03d4a289251f420456b1289",
"network_info": {
"3c5b24d1-21b7-4036-8bd1-b0aefe65533d": {
"network": "42a01505-855d-4f3b-9b8b-0abd413b3036",
"mac_address": "aa:bb:cc:dd:ee:ff"
"fixed_ip": "10.1.0.100"
},
},
}