Deprecate Baremetal and fping API

This patch deprecates Baremetal and fping API. All of those APIs
will return 404 after new Microversion.

The deprecated API endpoints are
'/os-fping'
'/os-baremetal-nodes'

This patch doesn't bump the max api version, due to the patch separation.
The max api version will bump in the last patch.

Partially implements blueprint deprecate-api-proxies

Change-Id: I92064cbcb5f6414da0c9d294f912a860428af698
This commit is contained in:
He Jie Xu 2016-06-24 15:55:12 +08:00
parent 83bd45bbcf
commit b6f2d8310d
4 changed files with 51 additions and 7 deletions

View File

@ -19,6 +19,8 @@
from oslo_utils import importutils
import webob
from nova.api.openstack.api_version_request \
import MAX_PROXY_API_SUPPORT_VERSION
from nova.api.openstack import common
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
@ -80,6 +82,7 @@ class BareMetalNodeController(wsgi.Controller):
d[f] = node_ref.get(f)
return d
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
@extensions.expected_errors((404, 501))
def index(self, req):
context = req.environ['nova.context']
@ -100,6 +103,7 @@ class BareMetalNodeController(wsgi.Controller):
nodes.append(node)
return {'nodes': nodes}
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
@extensions.expected_errors((404, 501))
def show(self, req, id):
context = req.environ['nova.context']
@ -125,19 +129,23 @@ class BareMetalNodeController(wsgi.Controller):
node['interfaces'].append({'address': port.address})
return {'node': node}
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
@extensions.expected_errors(400)
def create(self, req, body):
_no_ironic_proxy("node-create")
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
@extensions.expected_errors(400)
def delete(self, req, id):
_no_ironic_proxy("node-delete")
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
@wsgi.action('add_interface')
@extensions.expected_errors(400)
def _add_interface(self, req, id, body):
_no_ironic_proxy("port-create")
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
@wsgi.action('remove_interface')
@extensions.expected_errors(400)
def _remove_interface(self, req, id, body):

View File

@ -20,6 +20,8 @@ import os
import six
from webob import exc
from nova.api.openstack.api_version_request \
import MAX_PROXY_API_SUPPORT_VERSION
from nova.api.openstack import common
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
@ -67,6 +69,7 @@ class FpingController(wsgi.Controller):
ret += [ip["address"] for ip in all_ips]
return ret
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
@extensions.expected_errors(503)
def index(self, req):
context = req.environ["nova.context"]
@ -117,6 +120,7 @@ class FpingController(wsgi.Controller):
})
return {"servers": res}
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
@extensions.expected_errors((404, 503))
def show(self, req, id):
context = req.environ["nova.context"]

View File

@ -22,16 +22,12 @@ from webob import exc
from nova.api.openstack.compute import baremetal_nodes \
as b_nodes_v21
from nova import context
from nova import exception
from nova import test
from nova.tests.unit.api.openstack import fakes
from nova.tests.unit.virt.ironic import utils as ironic_utils
class FakeRequest(object):
def __init__(self, context):
self.environ = {"nova.context": context}
def fake_node(**updates):
node = {
'id': 1,
@ -74,7 +70,7 @@ class BareMetalNodesTestV21(test.NoDBTestCase):
self._setup()
self.context = context.get_admin_context()
self.request = FakeRequest(self.context)
self.request = fakes.HTTPRequest.blank('', use_admin_context=True)
def _setup(self):
self.controller = b_nodes_v21.BareMetalNodeController()
@ -213,3 +209,25 @@ class BareMetalNodesTestV21(test.NoDBTestCase):
self.assertRaises(exc.HTTPBadRequest,
self.controller._remove_interface,
self.request, 'fake-id', 'fake-body')
class BareMetalNodesTestDeprecation(test.NoDBTestCase):
def setUp(self):
super(BareMetalNodesTestDeprecation, self).setUp()
self.controller = b_nodes_v21.BareMetalNodeController()
self.req = fakes.HTTPRequest.blank('', version='2.36')
def test_all_apis_return_not_found(self):
self.assertRaises(exception.VersionNotFoundForAPIMethod,
self.controller.show, self.req, fakes.FAKE_UUID)
self.assertRaises(exception.VersionNotFoundForAPIMethod,
self.controller.index, self.req)
self.assertRaises(exception.VersionNotFoundForAPIMethod,
self.controller.create, self.req, {})
self.assertRaises(exception.VersionNotFoundForAPIMethod,
self.controller.delete, self.req, fakes.FAKE_UUID)
self.assertRaises(exception.VersionNotFoundForAPIMethod,
self.controller._add_interface, self.req, fakes.FAKE_UUID, {})
self.assertRaises(exception.VersionNotFoundForAPIMethod,
self.controller._remove_interface, self.req, fakes.FAKE_UUID, {})

View File

@ -138,3 +138,17 @@ class FpingPolicyEnforcementV21(test.NoDBTestCase):
rule = {"os_compute_api:os-fping": "project:non_fake"}
self.common_policy_check(
rule, self.controller.show, self.req, FAKE_UUID)
class FpingTestDeprecation(test.NoDBTestCase):
def setUp(self):
super(FpingTestDeprecation, self).setUp()
self.controller = fping_v21.FpingController()
self.req = fakes.HTTPRequest.blank('', version='2.36')
def test_all_apis_return_not_found(self):
self.assertRaises(exception.VersionNotFoundForAPIMethod,
self.controller.show, self.req, fakes.FAKE_UUID)
self.assertRaises(exception.VersionNotFoundForAPIMethod,
self.controller.index, self.req)