Merge "Show 'reserved' status in os-fixed-ips"
This commit is contained in:
commit
dac070b2b3
|
@ -22,7 +22,7 @@
|
|||
}
|
||||
],
|
||||
"status": "CURRENT",
|
||||
"version": "2.3",
|
||||
"version": "2.4",
|
||||
"min_version": "2.1",
|
||||
"updated": "2013-07-23T11:33:21Z"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"reserve": null
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"fixed_ip": {
|
||||
"address": "192.168.1.1",
|
||||
"cidr": "192.168.1.0/24",
|
||||
"host": "host",
|
||||
"hostname": "openstack",
|
||||
"reserved": false
|
||||
}
|
||||
}
|
|
@ -42,6 +42,7 @@ REST_API_VERSION_HISTORY = """REST API Version History:
|
|||
Fixes success status code for create/delete a keypair method
|
||||
* 2.3 - Exposes additional os-extended-server-attributes
|
||||
Exposes delete_on_termination for os-extended-volumes
|
||||
* 2.4 - Exposes reserved field in os-fixed-ips.
|
||||
"""
|
||||
|
||||
# The minimum and maximum versions of the API supported
|
||||
|
@ -50,7 +51,7 @@ REST_API_VERSION_HISTORY = """REST API Version History:
|
|||
# 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.3"
|
||||
_MAX_API_VERSION = "2.4"
|
||||
DEFAULT_API_VERSION = _MIN_API_VERSION
|
||||
|
||||
|
||||
|
|
|
@ -28,6 +28,17 @@ authorize = extensions.os_compute_authorizer(ALIAS)
|
|||
|
||||
|
||||
class FixedIPController(wsgi.Controller):
|
||||
|
||||
@wsgi.Controller.api_version('2.1', '2.3')
|
||||
def _fill_reserved_status(self, req, fixed_ip, fixed_ip_info):
|
||||
# NOTE(mriedem): To be backwards compatible, < 2.4 version does not
|
||||
# show anything about reserved status.
|
||||
pass
|
||||
|
||||
@wsgi.Controller.api_version('2.4') # noqa
|
||||
def _fill_reserved_status(self, req, fixed_ip, fixed_ip_info):
|
||||
fixed_ip_info['fixed_ip']['reserved'] = fixed_ip.reserved
|
||||
|
||||
@extensions.expected_errors((400, 404))
|
||||
def show(self, req, id):
|
||||
"""Return data about the given fixed ip."""
|
||||
|
@ -58,6 +69,8 @@ class FixedIPController(wsgi.Controller):
|
|||
fixed_ip_info['fixed_ip']['hostname'] = None
|
||||
fixed_ip_info['fixed_ip']['host'] = None
|
||||
|
||||
self._fill_reserved_status(req, fixed_ip, fixed_ip_info)
|
||||
|
||||
return fixed_ip_info
|
||||
|
||||
@wsgi.response(202)
|
||||
|
|
|
@ -46,3 +46,9 @@ user documentation.
|
|||
This change is required for the extraction of EC2 API into a standalone
|
||||
service. It exposes necessary properties absent in public nova APIs yet.
|
||||
Add info for Standalone EC2 API to cut access to Nova DB.
|
||||
|
||||
- **2.4**
|
||||
|
||||
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
|
||||
but the show method does not report the current status.
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
}
|
||||
],
|
||||
"status": "CURRENT",
|
||||
"version": "2.3",
|
||||
"version": "2.4",
|
||||
"min_version": "2.1",
|
||||
"updated": "2013-07-23T11:33:21Z"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"reserve": null
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"fixed_ip": {
|
||||
"cidr": "%(cidr)s",
|
||||
"hostname": "%(hostname)s",
|
||||
"host": "%(host)s",
|
||||
"address": "%(address)s",
|
||||
"reserved": %(reserved)s
|
||||
}
|
||||
}
|
|
@ -32,6 +32,8 @@ class FixedIpTest(test_servers.ServersSampleBase):
|
|||
# itself can be changed to 'v2'
|
||||
_api_version = 'v2'
|
||||
|
||||
request_api_version = None
|
||||
|
||||
def _get_flags(self):
|
||||
f = super(FixedIpTest, self)._get_flags()
|
||||
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
|
||||
|
@ -98,15 +100,29 @@ class FixedIpTest(test_servers.ServersSampleBase):
|
|||
def test_fixed_ip_reserve(self):
|
||||
# Reserve a Fixed IP.
|
||||
response = self._do_post('os-fixed-ips/192.168.1.1/action',
|
||||
'fixedip-post-req', {})
|
||||
'fixedip-post-req', {},
|
||||
api_version=self.request_api_version)
|
||||
self.assertEqual(response.status_code, 202)
|
||||
self.assertEqual(response.content, "")
|
||||
|
||||
def test_get_fixed_ip(self):
|
||||
def _test_get_fixed_ip(self, **kwargs):
|
||||
# Return data about the given fixed ip.
|
||||
response = self._do_get('os-fixed-ips/192.168.1.1')
|
||||
response = self._do_get('os-fixed-ips/192.168.1.1',
|
||||
api_version=self.request_api_version)
|
||||
project = {'cidr': '192.168.1.0/24',
|
||||
'hostname': 'openstack',
|
||||
'host': 'host',
|
||||
'address': '192.168.1.1'}
|
||||
project.update(**kwargs)
|
||||
self._verify_response('fixedips-get-resp', project, response, 200)
|
||||
|
||||
def test_get_fixed_ip(self):
|
||||
self._test_get_fixed_ip()
|
||||
|
||||
|
||||
class FixedIpV24Test(FixedIpTest):
|
||||
_api_version = 'v3'
|
||||
request_api_version = '2.4'
|
||||
|
||||
def test_get_fixed_ip(self):
|
||||
self._test_get_fixed_ip(reserved=False)
|
||||
|
|
|
@ -14,8 +14,10 @@
|
|||
|
||||
import webob
|
||||
|
||||
from nova.api.openstack import api_version_request
|
||||
from nova.api.openstack.compute.contrib import fixed_ips as fixed_ips_v2
|
||||
from nova.api.openstack.compute.plugins.v3 import fixed_ips as fixed_ips_v21
|
||||
from nova.api.openstack import wsgi as os_wsgi
|
||||
from nova import context
|
||||
from nova import db
|
||||
from nova import exception
|
||||
|
@ -119,6 +121,7 @@ class FixedIpTestV21(test.NoDBTestCase):
|
|||
|
||||
fixed_ips = fixed_ips_v21
|
||||
url = '/v2/fake/os-fixed-ips'
|
||||
wsgi_api_version = os_wsgi.DEFAULT_API_VERSION
|
||||
|
||||
def setUp(self):
|
||||
super(FixedIpTestV21, self).setUp()
|
||||
|
@ -139,14 +142,20 @@ class FixedIpTestV21(test.NoDBTestCase):
|
|||
def _get_unreserve_action(self):
|
||||
return self.controller.unreserve
|
||||
|
||||
def _get_reserved_status(self, address):
|
||||
return {}
|
||||
|
||||
def test_fixed_ips_get(self):
|
||||
req = fakes.HTTPRequest.blank('%s/192.168.1.1' % self.url)
|
||||
req.api_version_request = api_version_request.APIVersionRequest(
|
||||
self.wsgi_api_version)
|
||||
res_dict = self.controller.show(req, '192.168.1.1')
|
||||
response = {'fixed_ip': {'cidr': '192.168.1.0/24',
|
||||
'hostname': None,
|
||||
'host': None,
|
||||
'address': '192.168.1.1'}}
|
||||
self.assertEqual(response, res_dict)
|
||||
response['fixed_ip'].update(self._get_reserved_status('192.168.1.1'))
|
||||
self.assertEqual(response, res_dict, self.wsgi_api_version)
|
||||
|
||||
def test_fixed_ips_get_bad_ip_fail(self):
|
||||
req = fakes.HTTPRequest.blank('%s/10.0.0.1' % self.url)
|
||||
|
@ -242,3 +251,14 @@ class FixedIpTestV2(FixedIpTestV21):
|
|||
|
||||
def _get_unreserve_action(self):
|
||||
return self.controller.action
|
||||
|
||||
|
||||
class FixedIpTestV24(FixedIpTestV21):
|
||||
|
||||
wsgi_api_version = '2.4'
|
||||
|
||||
def _get_reserved_status(self, address):
|
||||
for fixed_ip in fake_fixed_ips:
|
||||
if address == fixed_ip['address']:
|
||||
return {'reserved': fixed_ip['reserved']}
|
||||
self.fail('Invalid address: %s' % address)
|
||||
|
|
|
@ -65,7 +65,7 @@ EXP_VERSIONS = {
|
|||
"v2.1": {
|
||||
"id": "v2.1",
|
||||
"status": "CURRENT",
|
||||
"version": "2.3",
|
||||
"version": "2.4",
|
||||
"min_version": "2.1",
|
||||
"updated": "2013-07-23T11:33:21Z",
|
||||
"links": [
|
||||
|
@ -114,7 +114,7 @@ class VersionsTestV20(test.NoDBTestCase):
|
|||
{
|
||||
"id": "v2.1",
|
||||
"status": "CURRENT",
|
||||
"version": "2.3",
|
||||
"version": "2.4",
|
||||
"min_version": "2.1",
|
||||
"updated": "2013-07-23T11:33:21Z",
|
||||
"links": [
|
||||
|
|
Loading…
Reference in New Issue