Merge "api: use v2.1 only in api-paste.ini"

This commit is contained in:
Jenkins 2015-09-02 04:18:31 +00:00 committed by Gerrit Code Review
commit a9090bb5f5
7 changed files with 53 additions and 33 deletions

View File

@ -15,6 +15,7 @@ paste.app_factory = nova.api.metadata.handler:MetadataRequestHandler.factory
# EC2 #
#######
# NOTE: this is now deprecated in favor of https://github.com/stackforge/ec2-api
[composite:ec2]
use = egg:Paste#urlmap
/: ec2cloud
@ -59,27 +60,41 @@ paste.app_factory = nova.api.ec2:Executor.factory
[composite:osapi_compute]
use = call:nova.api.openstack.urlmap:urlmap_factory
/: oscomputeversions
/v1.1: openstack_compute_api_v2
/v2: openstack_compute_api_v2
# starting in Liberty the v21 implementation replaces the v2
# implementation and is suggested that you use it as the default. If
# this causes issues with your clients you can rollback to the
# *frozen* v2 api by commenting out the above stanza and using the
# following instead::
# /v1.1: openstack_compute_api_legacy_v2
# /v2: openstack_compute_api_legacy_v2
# if rolling back to v2 fixes your issue please file a critical bug
# at - https://bugs.launchpad.net/nova/+bugs
#
# v21 is an exactly feature match for v2, except it has more stringent
# input validation on the wsgi surface (prevents fuzzing early on the
# API). It also provides new features via API microversions which are
# opt into for clients. Unaware clients will receive the same frozen
# v2 API feature set, but with some relaxed validation
/v1.1: openstack_compute_api_v21_legacy_v2_compatible
/v2: openstack_compute_api_v21_legacy_v2_compatible
/v2.1: openstack_compute_api_v21
/v3: openstack_compute_api_v3
[composite:openstack_compute_api_v2]
# NOTE: this is deprecated in favor of openstack_compute_api_v21_legacy_v2_compatible
[composite:openstack_compute_api_legacy_v2]
use = call:nova.api.auth:pipeline_factory
noauth2 = compute_req_id faultwrap sizelimit noauth2 ratelimit osapi_compute_app_v2
keystone = compute_req_id faultwrap sizelimit authtoken keystonecontext ratelimit osapi_compute_app_v2
keystone_nolimit = compute_req_id faultwrap sizelimit authtoken keystonecontext osapi_compute_app_v2
noauth2 = compute_req_id faultwrap sizelimit noauth2 legacy_ratelimit osapi_compute_app_legacy_v2
keystone = compute_req_id faultwrap sizelimit authtoken keystonecontext legacy_ratelimit osapi_compute_app_legacy_v2
keystone_nolimit = compute_req_id faultwrap sizelimit authtoken keystonecontext osapi_compute_app_legacy_v2
[composite:openstack_compute_api_v21]
use = call:nova.api.auth:pipeline_factory_v21
noauth2 = compute_req_id faultwrap sizelimit noauth2 osapi_compute_app_v21
keystone = compute_req_id faultwrap sizelimit authtoken keystonecontext osapi_compute_app_v21
[composite:openstack_compute_api_v3]
[composite:openstack_compute_api_v21_legacy_v2_compatible]
use = call:nova.api.auth:pipeline_factory_v21
noauth = request_id faultwrap sizelimit noauth_v3 osapi_compute_app_v3
noauth2 = request_id faultwrap sizelimit noauth_v3 osapi_compute_app_v3
keystone = request_id faultwrap sizelimit authtoken keystonecontext osapi_compute_app_v3
noauth2 = compute_req_id faultwrap sizelimit noauth2 legacy_v2_compatible osapi_compute_app_v21
keystone = compute_req_id faultwrap sizelimit authtoken keystonecontext legacy_v2_compatible osapi_compute_app_v21
[filter:request_id]
paste.filter_factory = oslo_middleware:RequestId.factory
@ -93,10 +108,7 @@ paste.filter_factory = nova.api.openstack:FaultWrapper.factory
[filter:noauth2]
paste.filter_factory = nova.api.openstack.auth:NoAuthMiddleware.factory
[filter:noauth_v3]
paste.filter_factory = nova.api.openstack.auth:NoAuthMiddlewareV3.factory
[filter:ratelimit]
[filter:legacy_ratelimit]
paste.filter_factory = nova.api.openstack.compute.limits:RateLimitingMiddleware.factory
[filter:sizelimit]
@ -105,15 +117,12 @@ paste.filter_factory = oslo_middleware:RequestBodySizeLimiter.factory
[filter:legacy_v2_compatible]
paste.filter_factory = nova.api.openstack:LegacyV2CompatibleWrapper.factory
[app:osapi_compute_app_v2]
[app:osapi_compute_app_legacy_v2]
paste.app_factory = nova.api.openstack.compute:APIRouter.factory
[app:osapi_compute_app_v21]
paste.app_factory = nova.api.openstack.compute:APIRouterV21.factory
[app:osapi_compute_app_v3]
paste.app_factory = nova.api.openstack.compute:APIRouterV3.factory
[pipeline:oscomputeversions]
pipeline = faultwrap oscomputeversionapp

View File

@ -74,6 +74,7 @@ class NoAuthMiddleware(NoAuthMiddlewareBase):
return self.base_call(req, True, always_admin=False)
# TODO(johnthetubaguy) this should be removed in the M release
class NoAuthMiddlewareV3(NoAuthMiddlewareBase):
"""Return a fake token if one isn't specified."""

View File

@ -23,15 +23,16 @@ from nova import paths
CONF = cfg.CONF
class ApiPasteFixture(fixtures.Fixture):
class ApiPasteV21Fixture(fixtures.Fixture):
def _replace_line(self, target_file, line):
# TODO(johnthetubaguy) should really point the tests at /v2.1
target_file.write(line.replace(
"/v2: openstack_compute_api_v2",
"/v2: openstack_compute_api_v21_legacy_v2_compatible",
"/v2: openstack_compute_api_v21"))
def setUp(self):
super(ApiPasteFixture, self).setUp()
super(ApiPasteV21Fixture, self).setUp()
CONF.set_default('api_paste_config',
paths.state_path_def('etc/nova/api-paste.ini'))
tmp_api_paste_dir = self.useFixture(fixtures.TempDir())
@ -44,12 +45,12 @@ class ApiPasteFixture(fixtures.Fixture):
CONF.set_override('api_paste_config', tmp_api_paste_file_name)
class ApiPasteV2CompatibleFixture(ApiPasteFixture):
class ApiPasteLegacyV2Fixture(ApiPasteV21Fixture):
def _replace_line(self, target_file, line):
line = line.replace("noauth2 osapi_compute_app_v21",
"noauth2 legacy_v2_compatible osapi_compute_app_v21")
# NOTE(johnthetubaguy) this is hack so we test the legacy_v2 code
# even though its disable by default in api-paste.ini
line = line.replace(
"/v2: openstack_compute_api_v2",
"/v2: openstack_compute_api_v21")
"/v2: openstack_compute_api_v21_legacy_v2_compatible",
"/v2: openstack_compute_api_legacy_v2")
target_file.write(line)

View File

@ -57,13 +57,19 @@ class ApiSampleTestBaseV3(testscenarios.WithScenarios,
'osapi_v21')
expected_middleware = []
if (not hasattr(self, '_test') or (self._test == 'v2.1')):
# NOTE(gmann)For v2.1 API testing, override /v2 endpoint with v2.1
self.useFixture(api_paste_fixture.ApiPasteFixture())
# NOTE(gmann): we should run v21 tests on /v2.1 but then we need
# two sets of sample files as api version (v2 or v2.1) is being
# added in response's link/namespace etc
# override /v2 in compatibility mode with v2.1
self.useFixture(api_paste_fixture.ApiPasteV21Fixture())
expected_middleware = [compute.APIRouterV21]
elif self._test == 'v2.1_compatible':
self.useFixture(api_paste_fixture.ApiPasteV2CompatibleFixture())
expected_middleware = [openstack.LegacyV2CompatibleWrapper,
compute.APIRouterV21]
elif (self._test == 'v2' and self._api_version == 'v2'):
# override /v2 in compatibility mode with v2 legacy
self.useFixture(api_paste_fixture.ApiPasteLegacyV2Fixture())
super(ApiSampleTestBaseV3, self).setUp()
self.useFixture(test.SampleNetworks(host=self.network.host))
fake_network.stub_compute_with_ips(self.stubs)

View File

@ -17,6 +17,7 @@ from oslo_config import cfg
from oslo_log import log as logging
# Import extensions to pull in osapi_compute_extension CONF option used below.
from nova.tests.functional import api_paste_fixture
from nova.tests.functional import integrated_helpers
CONF = cfg.CONF
@ -26,6 +27,10 @@ LOG = logging.getLogger(__name__)
class ExtensionsTest(integrated_helpers._IntegratedTestBase):
_api_version = 'v2'
def setUp(self):
self.useFixture(api_paste_fixture.ApiPasteLegacyV2Fixture())
super(ExtensionsTest, self).setUp()
def _get_flags(self):
f = super(ExtensionsTest, self)._get_flags()
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]

View File

@ -17,7 +17,6 @@ from nova.api import openstack
from nova.api.openstack import compute
from nova.api.openstack import wsgi
from nova.tests.functional.api import client
from nova.tests.functional import api_paste_fixture
from nova.tests.functional import test_servers
from nova.tests.unit import fake_network
@ -26,7 +25,6 @@ class LegacyV2CompatibleTestBase(test_servers.ServersTestBase):
_api_version = 'v2'
def setUp(self):
self.useFixture(api_paste_fixture.ApiPasteV2CompatibleFixture())
super(LegacyV2CompatibleTestBase, self).setUp()
self._check_api_endpoint('/v2', [compute.APIRouterV21,
openstack.LegacyV2CompatibleWrapper])

View File

@ -48,7 +48,7 @@ class SecgroupsFullstack(testscenarios.WithScenarios, test.TestCase):
super(SecgroupsFullstack, self).setUp()
self.useFixture(policy_fixture.RealPolicyFixture())
if self._test == 'v2.1':
self.useFixture(api_paste_fixture.ApiPasteFixture())
self.useFixture(api_paste_fixture.ApiPasteV21Fixture())
api_fixture = self.useFixture(nova_fixtures.OSAPIFixture())
self.api = api_fixture.api