Remove accelerator in microversion header
Closes-Bug: 2049489 Change-Id: I0e392e63da354682da0ce7f347ab6e24d3d2432d
This commit is contained in:
parent
751bc6ae55
commit
279a260bb2
@ -17,7 +17,6 @@ import datetime
|
|||||||
import functools
|
import functools
|
||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
import microversion_parse
|
|
||||||
|
|
||||||
import pecan
|
import pecan
|
||||||
from pecan import rest
|
from pecan import rest
|
||||||
@ -108,10 +107,7 @@ class Version(object):
|
|||||||
:raises: webob.HTTPNotAcceptable
|
:raises: webob.HTTPNotAcceptable
|
||||||
|
|
||||||
"""
|
"""
|
||||||
version_str = microversion_parse.get_version(
|
version_str = headers.get(Version.current_api_version, default_version)
|
||||||
headers,
|
|
||||||
service_type='accelerator')
|
|
||||||
|
|
||||||
minimal_version = (2, 0)
|
minimal_version = (2, 0)
|
||||||
|
|
||||||
if version_str is None:
|
if version_str is None:
|
||||||
|
@ -35,15 +35,13 @@ from cyborg.api.controllers.v2 import versions
|
|||||||
|
|
||||||
def min_version():
|
def min_version():
|
||||||
return base.Version(
|
return base.Version(
|
||||||
{base.Version.current_api_version: ' '.join(
|
{base.Version.current_api_version: versions.min_version_string()},
|
||||||
[versions.service_type_string(), versions.min_version_string()])},
|
|
||||||
versions.min_version_string(), versions.max_version_string())
|
versions.min_version_string(), versions.max_version_string())
|
||||||
|
|
||||||
|
|
||||||
def max_version():
|
def max_version():
|
||||||
return base.Version(
|
return base.Version(
|
||||||
{base.Version.current_api_version: ' '.join(
|
{base.Version.current_api_version: versions.max_version_string()},
|
||||||
[versions.service_type_string(), versions.max_version_string()])},
|
|
||||||
versions.min_version_string(), versions.max_version_string())
|
versions.min_version_string(), versions.max_version_string())
|
||||||
|
|
||||||
|
|
||||||
|
@ -315,7 +315,7 @@ class TestARQsController(v2_test.APITestV2):
|
|||||||
|
|
||||||
self.patch_json(self.ARQ_URL, params=patch_list,
|
self.patch_json(self.ARQ_URL, params=patch_list,
|
||||||
headers={base.Version.current_api_version:
|
headers={base.Version.current_api_version:
|
||||||
'accelerator 2.1'})
|
'2.1'})
|
||||||
mock_apply_patch.assert_called_once_with(mock.ANY, patch_list,
|
mock_apply_patch.assert_called_once_with(mock.ANY, patch_list,
|
||||||
valid_fields)
|
valid_fields)
|
||||||
mock_check_if_bound.assert_called_once_with(mock.ANY, valid_fields)
|
mock_check_if_bound.assert_called_once_with(mock.ANY, valid_fields)
|
||||||
|
@ -68,7 +68,7 @@ class TestDeviceProfileController(v2_test.APITestV2):
|
|||||||
mock_dp_name.return_value = dp
|
mock_dp_name.return_value = dp
|
||||||
url = self.DP_URL + '/%s'
|
url = self.DP_URL + '/%s'
|
||||||
headers = self.headers
|
headers = self.headers
|
||||||
headers[base.Version.current_api_version] = 'accelerator 2.1'
|
headers[base.Version.current_api_version] = '2.1'
|
||||||
self.assertRaisesRegex(
|
self.assertRaisesRegex(
|
||||||
webtest.app.AppError,
|
webtest.app.AppError,
|
||||||
"Request not acceptable.*",
|
"Request not acceptable.*",
|
||||||
@ -82,7 +82,7 @@ class TestDeviceProfileController(v2_test.APITestV2):
|
|||||||
mock_dp_name.return_value = dp
|
mock_dp_name.return_value = dp
|
||||||
url = self.DP_URL + '/%s'
|
url = self.DP_URL + '/%s'
|
||||||
headers = self.headers
|
headers = self.headers
|
||||||
headers[base.Version.current_api_version] = 'accelerator 2.2'
|
headers[base.Version.current_api_version] = '2.2'
|
||||||
data = self.get_json(url % dp['name'],
|
data = self.get_json(url % dp['name'],
|
||||||
headers=headers)
|
headers=headers)
|
||||||
mock_dp_name.assert_called_once()
|
mock_dp_name.assert_called_once()
|
||||||
|
@ -33,8 +33,7 @@ class TestMicroversions(api_base.BaseApiTest):
|
|||||||
def test_wrong_major_version(self):
|
def test_wrong_major_version(self):
|
||||||
response = self.get_json(
|
response = self.get_json(
|
||||||
'/v2',
|
'/v2',
|
||||||
headers={'OpenStack-API-Version': ' '.join([SERVICE_TYPE,
|
headers={'OpenStack-API-Version': '10'},
|
||||||
'10'])},
|
|
||||||
expect_errors=True, return_json=False)
|
expect_errors=True, return_json=False)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(406, response.status_int)
|
self.assertEqual(406, response.status_int)
|
||||||
@ -57,8 +56,7 @@ class TestMicroversions(api_base.BaseApiTest):
|
|||||||
def test_new_client_new_api(self):
|
def test_new_client_new_api(self):
|
||||||
response = self.get_json(
|
response = self.get_json(
|
||||||
'/v2',
|
'/v2',
|
||||||
headers={'OpenStack-API-Version': ' '.join([SERVICE_TYPE,
|
headers={'OpenStack-API-Version': '2.0'},
|
||||||
'2.0'])},
|
|
||||||
return_json=False)
|
return_json=False)
|
||||||
self.assertEqual(response.headers[H_MIN_VER], MIN_VER)
|
self.assertEqual(response.headers[H_MIN_VER], MIN_VER)
|
||||||
self.assertEqual(response.headers[H_MAX_VER], MAX_VER)
|
self.assertEqual(response.headers[H_MAX_VER], MAX_VER)
|
||||||
@ -69,8 +67,7 @@ class TestMicroversions(api_base.BaseApiTest):
|
|||||||
def test_latest_microversion(self):
|
def test_latest_microversion(self):
|
||||||
response = self.get_json(
|
response = self.get_json(
|
||||||
'/v2',
|
'/v2',
|
||||||
headers={'OpenStack-API-Version': ' '.join([SERVICE_TYPE,
|
headers={'OpenStack-API-Version': 'latest'},
|
||||||
'latest'])},
|
|
||||||
return_json=False)
|
return_json=False)
|
||||||
self.assertEqual(response.headers[H_MIN_VER], MIN_VER)
|
self.assertEqual(response.headers[H_MIN_VER], MIN_VER)
|
||||||
self.assertEqual(response.headers[H_MAX_VER], MAX_VER)
|
self.assertEqual(response.headers[H_MAX_VER], MAX_VER)
|
||||||
@ -82,8 +79,7 @@ class TestMicroversions(api_base.BaseApiTest):
|
|||||||
unsupported_version = str(float(MAX_VER) + 0.1)
|
unsupported_version = str(float(MAX_VER) + 0.1)
|
||||||
response = self.get_json(
|
response = self.get_json(
|
||||||
'/v2',
|
'/v2',
|
||||||
headers={'OpenStack-API-Version': ' '.join(
|
headers={'OpenStack-API-Version': unsupported_version},
|
||||||
[SERVICE_TYPE, unsupported_version])},
|
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(406, response.status_int)
|
self.assertEqual(406, response.status_int)
|
||||||
self.assertEqual(response.headers[H_MIN_VER], MIN_VER)
|
self.assertEqual(response.headers[H_MIN_VER], MIN_VER)
|
||||||
|
Loading…
Reference in New Issue
Block a user