Merge "Add api-ref for container operations"

This commit is contained in:
Jenkins 2017-07-06 16:24:37 +00:00 committed by Gerrit Code Review
commit 540cb514fa
8 changed files with 437 additions and 33 deletions

View File

@ -86,3 +86,233 @@ Response Example
.. literalinclude:: samples/container-create-resp.json .. literalinclude:: samples/container-create-resp.json
:language: javascript :language: javascript
List all containers
===================
.. rest_method:: GET /v1/containers/
List all available containers in Zun.
Response Codes
--------------
.. rest_status_code:: success status.yaml
- 200
.. rest_status_code:: error status.yaml
- 401
- 403
Response
--------
.. rest_parameters:: parameters.yaml
- containers: container_list
- links: links
- addresses: addresses
- name: name
- image: image
- labels: labels
- image_driver: image_driver
- security_groups: security_groups
- command: command
- cpu: cpu
- memory: memory
- workdir: workdir
- image_pull_policy: image_pull_policy
- environment: environment
- restart_policy: restart_policy
- interactive: interactive
- uuid: uuid
- hostname: hostname
- status: status
- status_detail: status_detail
- host: host
- task_state: task_state
- status_reason: status_reason
- ports: ports
Response Example
----------------
.. literalinclude:: samples/container-get-all-resp.json
:language: javascript
Show details of a container
===========================
.. rest_method:: GET /v1/containers/{container_ident}
Get all information of a container in Zun.
Response Codes
--------------
.. rest_status_code:: success status.yaml
- 200
.. rest_status_code:: error status.yaml
- 401
- 403
- 404
Request
-------
.. rest_parameters:: parameters.yaml
- container_ident: container_ident
Response
--------
.. rest_parameters:: parameters.yaml
- links: links
- addresses: addresses
- name: name
- image: image
- labels: labels
- image_driver: image_driver
- security_groups: security_groups
- command: command
- cpu: cpu
- memory: memory
- workdir: workdir
- image_pull_policy: image_pull_policy
- environment: environment
- restart_policy: restart_policy
- interactive: interactive
- uuid: uuid
- hostname: hostname
- status: status
- status_detail: status_detail
- host: host
- task_state: task_state
- status_reason: status_reason
- ports: ports
Response Example
----------------
.. literalinclude:: samples/container-show-resp.json
:language: javascript
Delete a container
==================
.. rest_method:: DELETE /v1/containers/{container_ident}
Delete a container. To delete a container in `Creating` or `Running`
state, request to /v1/containers/{container_ident}?force=True
Response Codes
--------------
.. rest_status_code:: success status.yaml
- 204
.. rest_status_code:: error status.yaml
- 401
- 403
- 404
- 409
Request
-------
.. rest_parameters:: parameters.yaml
- container_ident: container_ident
- force: force
Response
--------
This request does not return anything in the response body.
.. rest_parameters:: parameters.yaml
- X-Openstack-Request-Id: request_id
Update information of container
===============================
.. rest_method:: PATCH /v1/containers/{container_ident}
Update information of one container attributes. Currently only `cpu` and
`memory` can be updated.
Response Codes
--------------
.. rest_status_code:: success status.yaml
- 200
.. rest_status_code:: error status.yaml
- 400
- 401
- 403
- 404
Request
-------
.. rest_parameters:: parameters.yaml
- container_ident: container_ident
- memory: memory
- cpu: cpu
Request Example
----------------
.. literalinclude:: samples/container-update-req.json
:language: javascript
Response
--------
Return new container with updated attributes.
.. rest_parameters:: parameters.yaml
- links: links
- addresses: addresses
- name: name
- image: image
- labels: labels
- image_driver: image_driver
- security_groups: security_groups
- command: command
- cpu: cpu
- memory: memory
- workdir: workdir
- image_pull_policy: image_pull_policy
- environment: environment
- restart_policy: restart_policy
- interactive: interactive
- uuid: uuid
- hostname: hostname
- status: status
- status_detail: status_detail
- host: host
- task_state: task_state
- status_reason: status_reason
- ports: ports
Response Example
----------------
.. literalinclude:: samples/container-update-resp.json
:language: javascript

View File

@ -5,6 +5,18 @@ request_id:
description: | description: |
A unique ID for tracking service request. The request ID associated A unique ID for tracking service request. The request ID associated
with the request by default appears in the service logs. with the request by default appears in the service logs.
container_ident:
description: |
The UUID or name of container in Zun.
in: path
required: true
type: string
force:
description: |
Specify to delete container forcefully.
in: query
required: true
type: string
addresses: addresses:
type: string type: string
description: | description: |
@ -22,6 +34,12 @@ command:
Send command to the container. Send command to the container.
in: body in: body
type: string type: string
container_list:
type: array
in: body
required: true
description: |
The list of all containers in Zun.
cpu: cpu:
description: | description: |
The number of virtual cpus. The number of virtual cpus.

View File

@ -1,16 +1,21 @@
{ {
"environment":{ "environment":{
"foo": "bar"
}, },
"labels":{ "labels":{
"app": "hello"
}, },
"image": "cirros", "image": "ubuntu",
"command": "ping -c 4 8.8.8.8", "command": "/bin/sh -c 'echo hello'",
"name": "test", "name": "test",
"cpu": 2, "cpu": 2,
"memory": 500, "memory": 500,
"workdir": null, "workdir": "/home/ubuntu",
"image_pull_policy": null, "image_pull_policy": "always",
"restart_policy": null, "restart_policy":{
"Name": "no",
"MaximumRetryCount": 0
},
"interactive": "False", "interactive": "False",
"image_driver": "docker", "image_driver": "docker",
"security_groups": null "security_groups": null

View File

@ -1,33 +1,37 @@
{ {
"addresses": null, "addresses": null,
"links":[{ "links": [{
"href": "http://10.223.197.220:9517/v1/containers/2a278cd8-5d89-462e-8453-0ced64564714", "href": "http://openstack.example.com/v1/containers/b0694d40-70af-4488-b104-10f66b593347",
"rel": "self" "rel": "self"
}, },
{"href": "http://10.223.197.220:9517/containers/2a278cd8-5d89-462e-8453-0ced64564714", "rel": "bookmark"} {"href": "http://openstack.example.com/containers/b0694d40-70af-4488-b104-10f66b593347", "rel": "bookmark"}
], ],
"image": "cirros", "image": "ubuntu",
"labels":{ "labels": {
}, "app": "hello"
"security_groups": null, },
"image_pull_policy": null, "security_groups": null,
"uuid": "2a278cd8-5d89-462e-8453-0ced64564714", "image_pull_policy": "always",
"hostname": null, "uuid": "b0694d40-70af-4488-b104-10f66b593347",
"environment": { "hostname": null,
}, "environment": {
"memory": "500M", "foo": "bar"
"status": "Creating", },
"workdir": null, "memory": "500M",
"status_detail": null, "status": "Creating",
"host": "ubuntu", "workdir": "/home/ubuntu",
"image_driver": "docker", "status_detail": null,
"task_state": null, "host": null,
"status_reason": null, "image_driver": "docker",
"name": "test", "task_state": null,
"restart_policy": null, "status_reason": null,
"ports": null, "name": "test",
"command": "ping -c 4 8.8.8.8", "restart_policy": {
"cpu": 2.0, "MaximumRetryCount": "0",
"interactive": false "Name": "no"
},
"ports": null,
"command": "/bin/sh -c 'echo hello'",
"cpu": 2.0,
"interactive": false
} }

View File

@ -0,0 +1,49 @@
{
"addresses": {
"public": [{
"version": 4,
"addr": "172.24.4.3",
"port": "4b077255-9b4d-4068-b24f-b89594f870c2"
}, {
"version": 6,
"addr": "2001:db8::9",
"port": "4b077255-9b4d-4068-b24f-b89594f870c2"
}]
},
"links": [{
"href": "http://openstack.example.com/v1/containers/b0694d40-70af-4488-b104-10f66b593347",
"rel": "self"
},
{"href": "http://openstack.example.com/containers/b0694d40-70af-4488-b104-10f66b593347", "rel": "bookmark"}
],
"image": "ubuntu",
"labels": {
"app": "hello"
},
"security_groups": [],
"image_pull_policy": "always",
"uuid": "b0694d40-70af-4488-b104-10f66b593347",
"hostname": "zun-sandbox-5812822d-6794-4839-85c0-1c01665c0d48",
"environment": {
"foo": "bar"
},
"memory": "500M",
"status": "Stopped",
"workdir": "/home/ubuntu",
"status_detail": "Exited(0) 10 mins ago ",
"host": "ubuntu",
"image_driver": "docker",
"task_state": null,
"status_reason": null,
"name": "test",
"restart_policy": {
"MaximumRetryCount": "0",
"Name": "no"
},
"ports": [],
"command": "/bin/sh -c 'echo hello'",
"cpu": 2.0,
"interactive": false
}],
"next": null
}

View File

@ -0,0 +1,47 @@
{
"addresses": {
"public": [{
"version": 4,
"addr": "172.24.4.3",
"port": "4b077255-9b4d-4068-b24f-b89594f870c2"
}, {
"version": 6,
"addr": "2001:db8::9",
"port": "4b077255-9b4d-4068-b24f-b89594f870c2"
}]
},
"links": [{
"href": "http://openstack.example.com/v1/containers/b0694d40-70af-4488-b104-10f66b593347",
"rel": "self"
},
{"href": "http://openstack.example.com/containers/b0694d40-70af-4488-b104-10f66b593347", "rel": "bookmark"}
],
"image": "ubuntu",
"labels": {
"app": "hello"
},
"security_groups": [],
"image_pull_policy": "always",
"uuid": "b0694d40-70af-4488-b104-10f66b593347",
"hostname": "zun-sandbox-5812822d-6794-4839-85c0-1c01665c0d48",
"environment": {
"foo": "bar"
},
"memory": "500M",
"status": "Stopped",
"workdir": "/home/ubuntu",
"status_detail": "Exited(0) 8 mins ago ",
"host": "ubuntu",
"image_driver": "docker",
"task_state": null,
"status_reason": null,
"name": "test",
"restart_policy": {
"MaximumRetryCount": "0",
"Name": "no"
},
"ports": [],
"command": "/bin/sh -c 'echo hello'",
"cpu": 2.0,
"interactive": false
}

View File

@ -0,0 +1,4 @@
{
"memory": "200",
"cpu": "3"
}

View File

@ -0,0 +1,47 @@
{
"addresses": {
"public": [{
"version": 4,
"addr": "172.24.4.3",
"port": "4b077255-9b4d-4068-b24f-b89594f870c2"
}, {
"version": 6,
"addr": "2001:db8::9",
"port": "4b077255-9b4d-4068-b24f-b89594f870c2"
}]
},
"links": [{
"href": "http://openstack.example.com/v1/containers/b0694d40-70af-4488-b104-10f66b593347",
"rel": "self"
},
{"href": "http://openstack.example.com/containers/b0694d40-70af-4488-b104-10f66b593347", "rel": "bookmark"}
],
"image": "ubuntu",
"labels": {
"app": "hello"
},
"security_groups": [],
"image_pull_policy": "always",
"uuid": "b0694d40-70af-4488-b104-10f66b593347",
"hostname": "zun-sandbox-5812822d-6794-4839-85c0-1c01665c0d48",
"environment": {
"foo": "bar"
},
"memory": "200M",
"status": "Stopped",
"workdir": "/home/ubuntu",
"status_detail": "Exited(0) 18 mins ago ",
"host": "ubuntu",
"image_driver": "docker",
"task_state": null,
"status_reason": null,
"name": "test",
"restart_policy": {
"MaximumRetryCount": "0",
"Name": "no"
},
"ports": [],
"command": "/bin/sh -c 'echo hello'",
"cpu": 3.0,
"interactive": false
}