Skip to content

Commit 09239fc

Browse files
committed
Allow unshelve to a specific host (REST API part)
This adds support to the REST API, in a new microversion, for specifying a destination host to unshelve server action when the server is shelved offloaded. This patch also supports the ability to unpin the availability_zone of an instance that is bound to it. Note that the functional test changes are due to those tests using the "latest" microversion 2.91. Implements: blueprint unshelve-to-host Change-Id: I9e95428c208582741e6cd99bd3260d6742fcc6b7
1 parent a263fa4 commit 09239fc

30 files changed

+1316
-55
lines changed

api-ref/source/parameters.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,8 +1858,11 @@ availability_zone_state:
18581858
availability_zone_unshelve:
18591859
description: |
18601860
The availability zone name. Specifying an availability zone is only
1861-
allowed when the server status is ``SHELVED_OFFLOADED`` otherwise a
1862-
409 HTTPConflict response is returned.
1861+
allowed when the server status is ``SHELVED_OFFLOADED`` otherwise
1862+
HTTP 409 conflict response is returned.
1863+
1864+
Since microversion 2.91 ``"availability_zone":null`` allows unpinning the
1865+
instance from any availability_zone it is pinned to.
18631866
in: body
18641867
required: false
18651868
type: string
@@ -3690,6 +3693,15 @@ host_status_update_rebuild:
36903693
required: false
36913694
type: string
36923695
min_version: 2.75
3696+
host_unshelve:
3697+
description: |
3698+
The destination host name. Specifying a destination host is by default only
3699+
allowed to project_admin, if it not the case HTTP 403 forbidden response
3700+
is returned.
3701+
in: body
3702+
required: false
3703+
type: string
3704+
min_version: 2.91
36933705
host_zone:
36943706
description: |
36953707
The available zone of the host.

api-ref/source/servers-action-shelve.inc

Lines changed: 91 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,65 @@ Policy defaults enable only users with the administrative role or the owner of t
121121

122122
**Preconditions**
123123

124-
The server status must be ``SHELVED`` or ``SHELVED_OFFLOADED``.
124+
Unshelving a server without parameters requires its status to be ``SHELVED`` or ``SHELVED_OFFLOADED``.
125+
126+
Unshelving a server with availability_zone and/or host parameters requires its status to be only ``SHELVED_OFFLOADED`` otherwise HTTP 409 conflict response is returned.
127+
128+
If a server is locked, you must have administrator privileges to unshelve the server.
129+
130+
As of ``microversion 2.91``, you can unshelve to a specific compute node if you have PROJECT_ADMIN privileges.
131+
This microversion also gives the ability to pin a server to an availability_zone and to unpin a server
132+
from any availability_zone.
133+
134+
When a server is pinned to an availability_zone, the server move operations will keep the server in that
135+
availability_zone. However, when the server is not pinned to any availability_zone, the move operations can
136+
move the server to nodes in different availability_zones.
137+
138+
The behavior according to unshelve parameters will follow the below table.
139+
140+
+----------+---------------------------+----------+--------------------------------+
141+
| Boot | AZ (1) | Host (1) | Result |
142+
+==========+===========================+==========+================================+
143+
| No AZ | No AZ or AZ=null | No | Free scheduling (2) |
144+
+----------+---------------------------+----------+--------------------------------+
145+
| No AZ | No AZ or AZ=null | Host1 | Schedule to Host1. |
146+
| | | | Server remains unpinned. |
147+
+----------+---------------------------+----------+--------------------------------+
148+
| No AZ | AZ="AZ1" | No | Schedule to any host in "AZ1". |
149+
| | | | Server is pined to "AZ1". |
150+
+----------+---------------------------+----------+--------------------------------+
151+
| No AZ | AZ="AZ1" | Host1 | Verify Host1 is in "AZ1", |
152+
| | | | then schedule to Host1, |
153+
| | | | otherwise reject the request. |
154+
| | | | Server is pined to "AZ1". |
155+
+----------+---------------------------+----------+--------------------------------+
156+
| AZ1 | No AZ | No | Schedule to any host in "AZ1". |
157+
| | | | Server remains pined to "AZ1". |
158+
+----------+---------------------------+----------+--------------------------------+
159+
| AZ1 | AZ=null | No | Free scheduling (2). |
160+
| | | | Server is unpinned. |
161+
+----------+---------------------------+----------+--------------------------------+
162+
| AZ1 | No AZ | Host1 | Verify Host1 is in "AZ1", |
163+
| | | | then schedule to Host1, |
164+
| | | | otherwise reject the request. |
165+
| | | | Server remains pined to "AZ1". |
166+
+----------+---------------------------+----------+--------------------------------+
167+
| AZ1 | AZ=null | Host1 | Schedule to Host1. |
168+
| | | | Server is unpinned. |
169+
+----------+---------------------------+----------+--------------------------------+
170+
| AZ1 | AZ="AZ2" | No | Schedule to any host in "AZ2". |
171+
| | | | Server is pined to "AZ2". |
172+
+----------+---------------------------+----------+--------------------------------+
173+
| AZ1 | AZ="AZ2" | Host1 | Verify Host1 is in "AZ2" then |
174+
| | | | schedule to Host1, |
175+
| | | | otherwise reject the request. |
176+
| | | | Server is pined to "AZ2". |
177+
+----------+---------------------------+----------+--------------------------------+
178+
179+
(1) Unshelve body parameters
180+
(2) Schedule to any host available.
181+
125182

126-
If the server is locked, you must have administrator privileges to unshelve the server.
127183

128184
**Asynchronous Postconditions**
129185

@@ -147,11 +203,30 @@ Request
147203
{"unshelve": null} or {"unshelve": {"availability_zone": <string>}}.
148204
A request body of {"unshelve": {}} is not allowed.
149205

206+
.. note:: Since microversion 2.91, allowed request body schema are
207+
208+
- {"unshelve": null} (Keep compatibility with previous microversions)
209+
210+
or
211+
212+
- {"unshelve": {"availability_zone": <string>}} (Unshelve and pin server to availability_zone)
213+
- {"unshelve": {"availability_zone": null}} (Unshelve and unpin server from any availability zone)
214+
- {"unshelve": {"host": <fqdn>}}
215+
- {"unshelve": {"availability_zone": <string>, "host": <fqdn>}}
216+
- {"unshelve": {"availability_zone": null, "host": <fqdn>}}
217+
218+
Everything else is not allowed, examples:
219+
220+
- {"unshelve": {}}
221+
- {"unshelve": {"host": <fqdn>, "host": <fqdn>}}
222+
- {"unshelve": {"foo": <string>}}
223+
150224
.. rest_parameters:: parameters.yaml
151225

152226
- server_id: server_id_path
153227
- unshelve: unshelve
154228
- availability_zone: availability_zone_unshelve
229+
- host: host_unshelve
155230

156231
|
157232
@@ -162,9 +237,22 @@ Request
162237

163238
**Example Unshelve server (unshelve Action) (v2.77)**
164239

165-
.. literalinclude:: ../../doc/api_samples/os-shelve/v2.77/os-unshelve.json
240+
.. literalinclude:: ../../doc/api_samples/os-shelve/v2.77/os-unshelve-az.json
166241
:language: javascript
167242

243+
**Examples Unshelve server (unshelve Action) (v2.91)**
244+
245+
.. literalinclude:: ../../doc/api_samples/os-shelve/v2.91/os-unshelve-host.json
246+
:language: javascript
247+
248+
.. literalinclude:: ../../doc/api_samples/os-shelve/v2.91/os-unshelve-az-host.json
249+
:language: javascript
250+
251+
.. literalinclude:: ../../doc/api_samples/os-shelve/v2.91/os-unshelve-host-and-unpin-az.json
252+
:language: javascript
253+
254+
.. literalinclude:: ../../doc/api_samples/os-shelve/v2.91/os-unshelve-unpin-az.json
255+
:language: javascript
168256

169257
Response
170258
--------
File renamed without changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"unshelve": {
3+
"availability_zone": "nova",
4+
"host": "host01"
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"unshelve": {
3+
"availability_zone": null,
4+
"host": "host01"
5+
}
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"unshelve": {
3+
"host": "host01"
4+
}
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"unshelve": {
3+
"availability_zone": null
4+
}
5+
}

doc/api_samples/versions/v21-version-get-resp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
}
2020
],
2121
"status": "CURRENT",
22-
"version": "2.90",
22+
"version": "2.91",
2323
"min_version": "2.1",
2424
"updated": "2013-07-23T11:33:21Z"
2525
}

doc/api_samples/versions/versions-get-resp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
}
2323
],
2424
"status": "CURRENT",
25-
"version": "2.90",
25+
"version": "2.91",
2626
"min_version": "2.1",
2727
"updated": "2013-07-23T11:33:21Z"
2828
}

nova/api/openstack/api_version_request.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@
247247
updating or rebuilding an instance. The
248248
``OS-EXT-SRV-ATTR:hostname`` attribute is now returned in various
249249
server responses regardless of policy configuration.
250+
* 2.91 - Add support to unshelve instance to a specific host and
251+
to pin/unpin AZ.
250252
"""
251253

252254
# The minimum and maximum versions of the API supported
@@ -255,7 +257,7 @@
255257
# Note(cyeoh): This only applies for the v2.1 API once microversions
256258
# support is fully merged. It does not affect the V2 API.
257259
_MIN_API_VERSION = '2.1'
258-
_MAX_API_VERSION = '2.90'
260+
_MAX_API_VERSION = '2.91'
259261
DEFAULT_API_VERSION = _MIN_API_VERSION
260262

261263
# Almost all proxy APIs which are related to network, images and baremetal

0 commit comments

Comments
 (0)