Merge "Add microversion to allow server search option ip6 for non-admin"
This commit is contained in:
commit
a95ba57591
|
@ -22,7 +22,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"status": "CURRENT",
|
"status": "CURRENT",
|
||||||
"version": "2.4",
|
"version": "2.5",
|
||||||
"min_version": "2.1",
|
"min_version": "2.1",
|
||||||
"updated": "2013-07-23T11:33:21Z"
|
"updated": "2013-07-23T11:33:21Z"
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ REST_API_VERSION_HISTORY = """REST API Version History:
|
||||||
* 2.3 - Exposes additional os-extended-server-attributes
|
* 2.3 - Exposes additional os-extended-server-attributes
|
||||||
Exposes delete_on_termination for os-extended-volumes
|
Exposes delete_on_termination for os-extended-volumes
|
||||||
* 2.4 - Exposes reserved field in os-fixed-ips.
|
* 2.4 - Exposes reserved field in os-fixed-ips.
|
||||||
|
* 2.5 - Allow server search option ip6 for non-admin
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# The minimum and maximum versions of the API supported
|
# The minimum and maximum versions of the API supported
|
||||||
|
@ -51,7 +52,7 @@ REST_API_VERSION_HISTORY = """REST API Version History:
|
||||||
# Note(cyeoh): This only applies for the v2.1 API once microversions
|
# Note(cyeoh): This only applies for the v2.1 API once microversions
|
||||||
# support is fully merged. It does not affect the V2 API.
|
# support is fully merged. It does not affect the V2 API.
|
||||||
_MIN_API_VERSION = "2.1"
|
_MIN_API_VERSION = "2.1"
|
||||||
_MAX_API_VERSION = "2.4"
|
_MAX_API_VERSION = "2.5"
|
||||||
DEFAULT_API_VERSION = _MIN_API_VERSION
|
DEFAULT_API_VERSION = _MIN_API_VERSION
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ import stevedore
|
||||||
import webob
|
import webob
|
||||||
from webob import exc
|
from webob import exc
|
||||||
|
|
||||||
|
from nova.api.openstack import api_version_request
|
||||||
from nova.api.openstack import common
|
from nova.api.openstack import common
|
||||||
from nova.api.openstack.compute.schemas.v3 import servers as schema_servers
|
from nova.api.openstack.compute.schemas.v3 import servers as schema_servers
|
||||||
from nova.api.openstack.compute.views import servers as views_servers
|
from nova.api.openstack.compute.views import servers as views_servers
|
||||||
|
@ -273,7 +274,7 @@ class ServersController(wsgi.Controller):
|
||||||
|
|
||||||
context = req.environ['nova.context']
|
context = req.environ['nova.context']
|
||||||
remove_invalid_options(context, search_opts,
|
remove_invalid_options(context, search_opts,
|
||||||
self._get_server_search_options())
|
self._get_server_search_options(req))
|
||||||
|
|
||||||
# Verify search by 'status' contains a valid status.
|
# Verify search by 'status' contains a valid status.
|
||||||
# Convert it to filter by vm_state or task_state for compute_api.
|
# Convert it to filter by vm_state or task_state for compute_api.
|
||||||
|
@ -1077,10 +1078,14 @@ class ServersController(wsgi.Controller):
|
||||||
password = utils.generate_password()
|
password = utils.generate_password()
|
||||||
return password
|
return password
|
||||||
|
|
||||||
def _get_server_search_options(self):
|
def _get_server_search_options(self, req):
|
||||||
"""Return server search options allowed by non-admin."""
|
"""Return server search options allowed by non-admin."""
|
||||||
return ('reservation_id', 'name', 'status', 'image', 'flavor',
|
opt_list = ('reservation_id', 'name', 'status', 'image', 'flavor',
|
||||||
'ip', 'changes-since', 'all_tenants')
|
'ip', 'changes-since', 'all_tenants')
|
||||||
|
req_ver = req.api_version_request
|
||||||
|
if req_ver > api_version_request.APIVersionRequest("2.4"):
|
||||||
|
opt_list += ('ip6',)
|
||||||
|
return opt_list
|
||||||
|
|
||||||
def _get_instance(self, context, instance_uuid):
|
def _get_instance(self, context, instance_uuid):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -56,3 +56,11 @@ user documentation.
|
||||||
Show the ``reserved`` status on a ``FixedIP`` object in the ``os-fixed-ips`` API
|
Show the ``reserved`` status on a ``FixedIP`` object in the ``os-fixed-ips`` API
|
||||||
extension. The extension allows one to ``reserve`` and ``unreserve`` a fixed IP
|
extension. The extension allows one to ``reserve`` and ``unreserve`` a fixed IP
|
||||||
but the show method does not report the current status.
|
but the show method does not report the current status.
|
||||||
|
|
||||||
|
2.5
|
||||||
|
---
|
||||||
|
|
||||||
|
Before version 2.5, the command ``nova list --ip6 xxx`` returns all servers
|
||||||
|
for non-admins, as the filter option is silently discarded. There is no
|
||||||
|
reason to treat ip6 different from ip, though, so we just add this
|
||||||
|
option to the allowed list.
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"status": "CURRENT",
|
"status": "CURRENT",
|
||||||
"version": "2.4",
|
"version": "2.5",
|
||||||
"min_version": "2.1",
|
"min_version": "2.1",
|
||||||
"updated": "2013-07-23T11:33:21Z"
|
"updated": "2013-07-23T11:33:21Z"
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import six.moves.urllib.parse as urlparse
|
||||||
import testtools
|
import testtools
|
||||||
import webob
|
import webob
|
||||||
|
|
||||||
|
from nova.api.openstack import api_version_request
|
||||||
from nova.api.openstack import common
|
from nova.api.openstack import common
|
||||||
from nova.api.openstack import compute
|
from nova.api.openstack import compute
|
||||||
from nova.api.openstack.compute import plugins
|
from nova.api.openstack.compute import plugins
|
||||||
|
@ -1243,6 +1244,31 @@ class ServersControllerTest(ControllerTest):
|
||||||
self.assertEqual(len(servers), 1)
|
self.assertEqual(len(servers), 1)
|
||||||
self.assertEqual(servers[0]['id'], server_uuid)
|
self.assertEqual(servers[0]['id'], server_uuid)
|
||||||
|
|
||||||
|
def test_get_servers_allows_ip6_with_new_version(self):
|
||||||
|
"""Test getting servers by ip6 with new version requested
|
||||||
|
and no admin context
|
||||||
|
"""
|
||||||
|
server_uuid = str(uuid.uuid4())
|
||||||
|
|
||||||
|
def fake_get_all(compute_self, context, search_opts=None,
|
||||||
|
limit=None, marker=None, want_objects=False,
|
||||||
|
expected_attrs=None, sort_keys=None, sort_dirs=None):
|
||||||
|
self.assertIsNotNone(search_opts)
|
||||||
|
self.assertIn('ip6', search_opts)
|
||||||
|
self.assertEqual(search_opts['ip6'], 'ffff.*')
|
||||||
|
db_list = [fakes.stub_instance(100, uuid=server_uuid)]
|
||||||
|
return instance_obj._make_instance_list(
|
||||||
|
context, objects.InstanceList(), db_list, FIELDS)
|
||||||
|
|
||||||
|
self.stubs.Set(compute_api.API, 'get_all', fake_get_all)
|
||||||
|
|
||||||
|
req = fakes.HTTPRequestV3.blank('/servers?ip6=ffff.*')
|
||||||
|
req.api_version_request = api_version_request.APIVersionRequest('2.5')
|
||||||
|
servers = self.controller.index(req)['servers']
|
||||||
|
|
||||||
|
self.assertEqual(len(servers), 1)
|
||||||
|
self.assertEqual(servers[0]['id'], server_uuid)
|
||||||
|
|
||||||
def test_get_all_server_details(self):
|
def test_get_all_server_details(self):
|
||||||
expected_flavor = {
|
expected_flavor = {
|
||||||
"id": "1",
|
"id": "1",
|
||||||
|
|
|
@ -65,7 +65,7 @@ EXP_VERSIONS = {
|
||||||
"v2.1": {
|
"v2.1": {
|
||||||
"id": "v2.1",
|
"id": "v2.1",
|
||||||
"status": "CURRENT",
|
"status": "CURRENT",
|
||||||
"version": "2.4",
|
"version": "2.5",
|
||||||
"min_version": "2.1",
|
"min_version": "2.1",
|
||||||
"updated": "2013-07-23T11:33:21Z",
|
"updated": "2013-07-23T11:33:21Z",
|
||||||
"links": [
|
"links": [
|
||||||
|
@ -114,7 +114,7 @@ class VersionsTestV20(test.NoDBTestCase):
|
||||||
{
|
{
|
||||||
"id": "v2.1",
|
"id": "v2.1",
|
||||||
"status": "CURRENT",
|
"status": "CURRENT",
|
||||||
"version": "2.4",
|
"version": "2.5",
|
||||||
"min_version": "2.1",
|
"min_version": "2.1",
|
||||||
"updated": "2013-07-23T11:33:21Z",
|
"updated": "2013-07-23T11:33:21Z",
|
||||||
"links": [
|
"links": [
|
||||||
|
|
Loading…
Reference in New Issue