Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GET servers API sorting REST API updates
Updates the v2 and v3 /servers and /servers/detail APIs to support the multiple sort keys and sort directions (using the 'sort_key' and 'sort_dir' parameters); these parameters can be specified multiple times to create a list of sort keys and directions. These parameters are passed from the API layer to the compute layer, then to the instance layer (with updated version), then to the database layers, and then to the common paginate_query function; the paginate_query function already supports multiple sort keys and directions. The function signatures in these various layers are updated with new 'sort_keys' and 'sort_dirs' parameters that represent the sort keys and directions information as lists. This support is enabled on the v2 API by the existence of a new 'os-server-sort-keys' API extension and is always enabled in the v3 API. The extension API sample issues 2 server creates and then ensures that both servers are listed (name is unique) in the list reply. DocImpact: The existing v2 and v3 servers API documentation needs to reflect these new parameters. The nova client will also be updated to use these parameters. Change-Id: I02baf6c3cc7d29abab132ef1726140c57e17d9b6 Partially implements: blueprint nova-pagination
- Loading branch information
Showing
32 changed files
with
454 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"server" : { | ||
"name" : "new-server-test", | ||
"imageRef" : "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b", | ||
"flavorRef" : "http://openstack.example.com/openstack/flavors/1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<server xmlns="http://docs.openstack.org/compute/api/v1.1" imageRef="http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b" flavorRef="http://openstack.example.com/openstack/flavors/1" name="new-server-test"> | ||
</server> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"server": { | ||
"adminPass": "jDje6SdBHGfQ", | ||
"id": "e08e6d34-fcc1-480e-b11e-24a675b479f8", | ||
"links": [ | ||
{ | ||
"href": "http://openstack.example.com/v2/openstack/servers/e08e6d34-fcc1-480e-b11e-24a675b479f8", | ||
"rel": "self" | ||
}, | ||
{ | ||
"href": "http://openstack.example.com/openstack/servers/e08e6d34-fcc1-480e-b11e-24a675b479f8", | ||
"rel": "bookmark" | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<server xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" id="e08e6d34-fcc1-480e-b11e-24a675b479f8" adminPass="jDje6SdBHGfQ"> | ||
<metadata/> | ||
<atom:link href="http://openstack.example.com/v2/openstack/servers/e08e6d34-fcc1-480e-b11e-24a675b479f8" rel="self"/> | ||
<atom:link href="http://openstack.example.com/openstack/servers/e08e6d34-fcc1-480e-b11e-24a675b479f8" rel="bookmark"/> | ||
</server> |
18 changes: 18 additions & 0 deletions
18
doc/api_samples/os-server-sort-keys/server-sort-keys-list-resp.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"servers": [ | ||
{ | ||
"id": "e08e6d34-fcc1-480e-b11e-24a675b479f8", | ||
"links": [ | ||
{ | ||
"href": "http://openstack.example.com/v2/openstack/servers/e08e6d34-fcc1-480e-b11e-24a675b479f8", | ||
"rel": "self" | ||
}, | ||
{ | ||
"href": "http://openstack.example.com/openstack/servers/e08e6d34-fcc1-480e-b11e-24a675b479f8", | ||
"rel": "bookmark" | ||
} | ||
], | ||
"name": "new-server-test" | ||
} | ||
] | ||
} |
7 changes: 7 additions & 0 deletions
7
doc/api_samples/os-server-sort-keys/server-sort-keys-list-resp.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<servers xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1"> | ||
<server name="new-server-test" id="e08e6d34-fcc1-480e-b11e-24a675b479f8"> | ||
<atom:link href="http://openstack.example.com/v2/openstack/servers/e08e6d34-fcc1-480e-b11e-24a675b479f8" rel="self"/> | ||
<atom:link href="http://openstack.example.com/openstack/servers/e08e6d34-fcc1-480e-b11e-24a675b479f8" rel="bookmark"/> | ||
</server> | ||
</servers> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"server" : { | ||
"name" : "new-server-test", | ||
"imageRef" : "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b", | ||
"flavorRef" : "http://openstack.example.com/openstack/flavors/1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"server": { | ||
"adminPass": "jDje6SdBHGfQ", | ||
"id": "e08e6d34-fcc1-480e-b11e-24a675b479f8", | ||
"links": [ | ||
{ | ||
"href": "http://openstack.example.com/v3/servers/e08e6d34-fcc1-480e-b11e-24a675b479f8", | ||
"rel": "self" | ||
}, | ||
{ | ||
"href": "http://openstack.example.com/servers/e08e6d34-fcc1-480e-b11e-24a675b479f8", | ||
"rel": "bookmark" | ||
} | ||
] | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
doc/v3/api_samples/servers-sort/server-sort-keys-list-resp.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"servers": [ | ||
{ | ||
"id": "e08e6d34-fcc1-480e-b11e-24a675b479f8", | ||
"links": [ | ||
{ | ||
"href": "http://openstack.example.com/v3/servers/e08e6d34-fcc1-480e-b11e-24a675b479f8", | ||
"rel": "self" | ||
}, | ||
{ | ||
"href": "http://openstack.example.com/servers/e08e6d34-fcc1-480e-b11e-24a675b479f8", | ||
"rel": "bookmark" | ||
} | ||
], | ||
"name": "new-server-test" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright 2014 IBM Corp. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
from nova.api.openstack import extensions | ||
|
||
|
||
class Server_sort_keys(extensions.ExtensionDescriptor): | ||
"""Add sort keys and directions to the Server GET v2 API.""" | ||
|
||
name = "ServerSortKeys" | ||
alias = "os-server-sort-keys" | ||
namespace = ("http://docs.openstack.org/compute/ext/" | ||
"server_sort_keys/api/v2") | ||
updated = "2014-05-22T00:00:00Z" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
nova/tests/functional/api_samples/os-server-sort-keys/server-post-req.json.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"server" : { | ||
"name" : "new-server-test", | ||
"imageRef" : "%(host)s/openstack/images/%(image_id)s", | ||
"flavorRef" : "%(host)s/openstack/flavors/1" | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
nova/tests/functional/api_samples/os-server-sort-keys/server-post-req.xml.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<server xmlns="http://docs.openstack.org/compute/api/v1.1" imageRef="%(host)s/openstack/images/%(image_id)s" flavorRef="%(host)s/openstack/flavors/1" name="new-server-test"> | ||
</server> |
16 changes: 16 additions & 0 deletions
16
nova/tests/functional/api_samples/os-server-sort-keys/server-post-resp.json.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"server": { | ||
"adminPass": "%(password)s", | ||
"id": "%(id)s", | ||
"links": [ | ||
{ | ||
"href": "%(host)s/v2/openstack/servers/%(uuid)s", | ||
"rel": "self" | ||
}, | ||
{ | ||
"href": "%(host)s/openstack/servers/%(uuid)s", | ||
"rel": "bookmark" | ||
} | ||
] | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
nova/tests/functional/api_samples/os-server-sort-keys/server-post-resp.xml.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<server xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" id="%(id)s" adminPass="%(password)s"> | ||
<metadata/> | ||
<atom:link href="%(host)s/v2/openstack/servers/%(uuid)s" rel="self"/> | ||
<atom:link href="%(host)s/openstack/servers/%(uuid)s" rel="bookmark"/> | ||
</server> |
18 changes: 18 additions & 0 deletions
18
nova/tests/functional/api_samples/os-server-sort-keys/server-sort-keys-list-resp.json.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"servers": [ | ||
{ | ||
"id": "%(id)s", | ||
"links": [ | ||
{ | ||
"href": "%(host)s/v2/openstack/servers/%(id)s", | ||
"rel": "self" | ||
}, | ||
{ | ||
"href": "%(host)s/openstack/servers/%(id)s", | ||
"rel": "bookmark" | ||
} | ||
], | ||
"name": "new-server-test" | ||
} | ||
] | ||
} |
7 changes: 7 additions & 0 deletions
7
nova/tests/functional/api_samples/os-server-sort-keys/server-sort-keys-list-resp.xml.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<servers xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1"> | ||
<server name="new-server-test" id="%(id)s"> | ||
<atom:link href="%(host)s/v2/openstack/servers/%(id)s" rel="self"/> | ||
<atom:link href="%(host)s/openstack/servers/%(id)s" rel="bookmark"/> | ||
</server> | ||
</servers> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
nova/tests/functional/v3/api_samples/servers-sort/server-post-req.json.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"server" : { | ||
"name" : "new-server-test", | ||
"imageRef" : "%(host)s/openstack/images/%(image_id)s", | ||
"flavorRef" : "%(host)s/openstack/flavors/1" | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
nova/tests/functional/v3/api_samples/servers-sort/server-post-resp.json.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"server": { | ||
"adminPass": "%(password)s", | ||
"id": "%(id)s", | ||
"links": [ | ||
{ | ||
"href": "%(host)s/v3/servers/%(uuid)s", | ||
"rel": "self" | ||
}, | ||
{ | ||
"href": "%(host)s/servers/%(uuid)s", | ||
"rel": "bookmark" | ||
} | ||
] | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
nova/tests/functional/v3/api_samples/servers-sort/server-sort-keys-list-resp.json.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"servers": [ | ||
{ | ||
"id": "%(id)s", | ||
"links": [ | ||
{ | ||
"href": "%(host)s/v3/servers/%(id)s", | ||
"rel": "self" | ||
}, | ||
{ | ||
"href": "%(host)s/servers/%(id)s", | ||
"rel": "bookmark" | ||
} | ||
], | ||
"name": "new-server-test" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.