Skip to content

Commit

Permalink
Show 'locked' information in server details
Browse files Browse the repository at this point in the history
Adds a new microversion to show server 'locked' information in
server details.

DocImpact - See nova/api/openstack/rest_api_version_history.rst
for details

APIImpact

Implements blueprint add-locking-information-in-server-get-response

Depends-on: I5be664c3e99adc37738f8b074f1891dad97497b1

Change-Id: I3e5dc6e37f130f70e3a861a9906bb062c6110742
  • Loading branch information
gmannos committed Jul 30, 2015
1 parent 14d0029 commit 49a572a
Show file tree
Hide file tree
Showing 18 changed files with 523 additions and 69 deletions.
2 changes: 1 addition & 1 deletion doc/api_samples/versions/versions-get-resp.json
Expand Up @@ -22,7 +22,7 @@
}
],
"status": "CURRENT",
"version": "2.8",
"version": "2.9",
"min_version": "2.1",
"updated": "2013-07-23T11:33:21Z"
}
Expand Down
58 changes: 58 additions & 0 deletions doc/v3/api_samples/servers/v2.9/server-get-resp.json
@@ -0,0 +1,58 @@
{
"server": {
"accessIPv4": "1.2.3.4",
"accessIPv6": "80fe::",
"addresses": {
"private": [
{
"addr": "192.168.0.3",
"OS-EXT-IPS-MAC:mac_addr": "aa:bb:cc:dd:ee:ff",
"OS-EXT-IPS:type": "fixed",
"version": 4
}
]
},
"created": "2013-09-03T04:01:32Z",
"flavor": {
"id": "1",
"links": [
{
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
]
},
"hostId": "92154fab69d5883ba2c8622b7e65f745dd33257221c07af363c51b29",
"id": "0e44cc9c-e052-415d-afbf-469b0d384170",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]
},
"key_name": null,
"links": [
{
"href": "http://openstack.example.com/v2/openstack/servers/0e44cc9c-e052-415d-afbf-469b0d384170",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/servers/0e44cc9c-e052-415d-afbf-469b0d384170",
"rel": "bookmark"
}
],
"metadata": {
"My Server Name": "Apache1"
},
"name": "new-server-test",
"progress": 0,
"status": "ACTIVE",
"tenant_id": "openstack",
"updated": "2013-09-03T04:01:33Z",
"user_id": "fake",
"locked": false
}
}
12 changes: 12 additions & 0 deletions doc/v3/api_samples/servers/v2.9/server-post-req.json
@@ -0,0 +1,12 @@
{
"server" : {
"accessIPv4": "1.2.3.4",
"accessIPv6": "80fe::",
"name" : "new-server-test",
"imageRef" : "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"flavorRef" : "http://openstack.example.com/flavors/1",
"metadata" : {
"My Server Name" : "Apache1"
}
}
}
16 changes: 16 additions & 0 deletions doc/v3/api_samples/servers/v2.9/server-post-resp.json
@@ -0,0 +1,16 @@
{
"server": {
"adminPass": "6NpUwoz2QDRN",
"id": "f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/servers/f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/servers/f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"rel": "bookmark"
}
]
}
}
60 changes: 60 additions & 0 deletions doc/v3/api_samples/servers/v2.9/servers-details-resp.json
@@ -0,0 +1,60 @@
{
"servers": [
{
"accessIPv4": "1.2.3.4",
"accessIPv6": "80fe::",
"addresses": {
"private": [
{
"addr": "192.168.0.3",
"OS-EXT-IPS-MAC:mac_addr": "aa:bb:cc:dd:ee:ff",
"OS-EXT-IPS:type": "fixed",
"version": 4
}
]
},
"created": "2013-09-03T04:01:32Z",
"flavor": {
"id": "1",
"links": [
{
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
]
},
"hostId": "bcf92836fc9ed4203a75cb0337afc7f917d2be504164b995c2334b25",
"id": "f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]
},
"key_name": null,
"links": [
{
"href": "http://openstack.example.com/v2/openstack/servers/f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/servers/f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"rel": "bookmark"
}
],
"metadata": {
"My Server Name": "Apache1"
},
"name": "new-server-test",
"progress": 0,
"status": "ACTIVE",
"tenant_id": "openstack",
"updated": "2013-09-03T04:01:32Z",
"user_id": "fake",
"locked": false
}
]
}
18 changes: 18 additions & 0 deletions doc/v3/api_samples/servers/v2.9/servers-list-resp.json
@@ -0,0 +1,18 @@
{
"servers": [
{
"id": "22c91117-08de-4894-9aa9-6ef382400985",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/servers/22c91117-08de-4894-9aa9-6ef382400985",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/servers/22c91117-08de-4894-9aa9-6ef382400985",
"rel": "bookmark"
}
],
"name": "new-server-test"
}
]
}
3 changes: 2 additions & 1 deletion nova/api/openstack/api_version_request.py
Expand Up @@ -47,6 +47,7 @@
* 2.6 - Consolidate the APIs for getting remote consoles
* 2.7 - Check flavor type before add tenant access.
* 2.8 - Add new protocol for VM console (mks)
* 2.9 - Exposes lock information in server details.
"""

# The minimum and maximum versions of the API supported
Expand All @@ -55,7 +56,7 @@
# Note(cyeoh): This only applies for the v2.1 API once microversions
# support is fully merged. It does not affect the V2 API.
_MIN_API_VERSION = "2.1"
_MAX_API_VERSION = "2.8"
_MAX_API_VERSION = "2.9"
DEFAULT_API_VERSION = _MIN_API_VERSION


Expand Down
6 changes: 6 additions & 0 deletions nova/api/openstack/compute/views/servers.py
Expand Up @@ -19,6 +19,7 @@
from oslo_log import log as logging
from oslo_utils import timeutils

from nova.api.openstack import api_version_request
from nova.api.openstack import common
from nova.api.openstack.compute.views import addresses as views_addresses
from nova.api.openstack.compute.views import flavors as views_flavors
Expand Down Expand Up @@ -280,4 +281,9 @@ def show(self, request, instance, extend_address=True):
if server["server"]["status"] in self._progress_statuses:
server["server"]["progress"] = instance.get("progress", 0)

if (request.api_version_request >=
api_version_request.APIVersionRequest("2.9")):
server["server"]["locked"] = (True if instance["locked_by"]
else False)

return server
6 changes: 6 additions & 0 deletions nova/api/openstack/rest_api_version_history.rst
Expand Up @@ -100,3 +100,9 @@ user documentation.
2.8
---
Add 'mks' protocol and 'webmks' type for remote consoles.

2.9
---

Show instance lock information in new response attribute 'locked'
in server details. Returned value will be True or False.
Expand Up @@ -22,7 +22,7 @@
}
],
"status": "CURRENT",
"version": "2.8",
"version": "2.9",
"min_version": "2.1",
"updated": "2013-07-23T11:33:21Z"
}
Expand Down
@@ -0,0 +1,58 @@
{
"server": {
"accessIPv4": "%(access_ip_v4)s",
"accessIPv6": "%(access_ip_v6)s",
"addresses": {
"private": [
{
"addr": "%(ip)s",
"OS-EXT-IPS-MAC:mac_addr": "aa:bb:cc:dd:ee:ff",
"OS-EXT-IPS:type": "fixed",
"version": 4
}
]
},
"created": "%(isotime)s",
"flavor": {
"id": "1",
"links": [
{
"href": "%(host)s/openstack/flavors/1",
"rel": "bookmark"
}
]
},
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(host)s/openstack/images/%(uuid)s",
"rel": "bookmark"
}
]
},
"key_name": null,
"links": [
{
"href": "%(host)s/v2/openstack/servers/%(uuid)s",
"rel": "self"
},
{
"href": "%(host)s/openstack/servers/%(uuid)s",
"rel": "bookmark"
}
],
"metadata": {
"My Server Name": "Apache1"
},
"name": "new-server-test",
"progress": 0,
"status": "ACTIVE",
"tenant_id": "openstack",
"updated": "%(isotime)s",
"user_id": "fake",
"locked": false
}
}
@@ -0,0 +1,12 @@
{
"server" : {
"accessIPv4": "%(access_ip_v4)s",
"accessIPv6": "%(access_ip_v6)s",
"name" : "new-server-test",
"imageRef" : "%(glance_host)s/images/%(image_id)s",
"flavorRef" : "%(host)s/flavors/1",
"metadata" : {
"My Server Name" : "Apache1"
}
}
}
@@ -0,0 +1,16 @@
{
"server": {
"adminPass": "%(password)s",
"id": "%(id)s",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/servers/%(uuid)s",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/servers/%(uuid)s",
"rel": "bookmark"
}
]
}
}
@@ -0,0 +1,60 @@
{
"servers": [
{
"accessIPv4": "%(access_ip_v4)s",
"accessIPv6": "%(access_ip_v6)s",
"addresses": {
"private": [
{
"addr": "%(ip)s",
"OS-EXT-IPS-MAC:mac_addr": "aa:bb:cc:dd:ee:ff",
"OS-EXT-IPS:type": "fixed",
"version": 4
}
]
},
"created": "%(isotime)s",
"flavor": {
"id": "1",
"links": [
{
"href": "%(host)s/openstack/flavors/1",
"rel": "bookmark"
}
]
},
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(host)s/openstack/images/%(uuid)s",
"rel": "bookmark"
}
]
},
"key_name": null,
"links": [
{
"href": "%(host)s/v2/openstack/servers/%(uuid)s",
"rel": "self"
},
{
"href": "%(host)s/openstack/servers/%(id)s",
"rel": "bookmark"
}
],
"metadata": {
"My Server Name": "Apache1"
},
"name": "new-server-test",
"progress": 0,
"status": "ACTIVE",
"tenant_id": "openstack",
"updated": "%(isotime)s",
"user_id": "fake",
"locked": false
}
]
}

0 comments on commit 49a572a

Please sign in to comment.