diff --git a/cyborg/api/controllers/base.py b/cyborg/api/controllers/base.py index b62077d1..659869fa 100644 --- a/cyborg/api/controllers/base.py +++ b/cyborg/api/controllers/base.py @@ -17,7 +17,6 @@ import datetime import functools import inspect -import microversion_parse import pecan from pecan import rest @@ -108,10 +107,7 @@ class Version(object): :raises: webob.HTTPNotAcceptable """ - version_str = microversion_parse.get_version( - headers, - service_type='accelerator') - + version_str = headers.get(Version.current_api_version, default_version) minimal_version = (2, 0) if version_str is None: diff --git a/cyborg/api/controllers/v2/__init__.py b/cyborg/api/controllers/v2/__init__.py index be2e3626..c8f6ea02 100644 --- a/cyborg/api/controllers/v2/__init__.py +++ b/cyborg/api/controllers/v2/__init__.py @@ -35,15 +35,13 @@ from cyborg.api.controllers.v2 import versions def min_version(): return base.Version( - {base.Version.current_api_version: ' '.join( - [versions.service_type_string(), versions.min_version_string()])}, + {base.Version.current_api_version: versions.min_version_string()}, versions.min_version_string(), versions.max_version_string()) def max_version(): return base.Version( - {base.Version.current_api_version: ' '.join( - [versions.service_type_string(), versions.max_version_string()])}, + {base.Version.current_api_version: versions.max_version_string()}, versions.min_version_string(), versions.max_version_string()) diff --git a/cyborg/tests/unit/api/controllers/v2/test_arqs.py b/cyborg/tests/unit/api/controllers/v2/test_arqs.py index a6ed7b18..c03ce79e 100644 --- a/cyborg/tests/unit/api/controllers/v2/test_arqs.py +++ b/cyborg/tests/unit/api/controllers/v2/test_arqs.py @@ -315,7 +315,7 @@ class TestARQsController(v2_test.APITestV2): self.patch_json(self.ARQ_URL, params=patch_list, headers={base.Version.current_api_version: - 'accelerator 2.1'}) + '2.1'}) mock_apply_patch.assert_called_once_with(mock.ANY, patch_list, valid_fields) mock_check_if_bound.assert_called_once_with(mock.ANY, valid_fields) diff --git a/cyborg/tests/unit/api/controllers/v2/test_device_profiles.py b/cyborg/tests/unit/api/controllers/v2/test_device_profiles.py index 8ec8fb15..5c677b1e 100644 --- a/cyborg/tests/unit/api/controllers/v2/test_device_profiles.py +++ b/cyborg/tests/unit/api/controllers/v2/test_device_profiles.py @@ -68,7 +68,7 @@ class TestDeviceProfileController(v2_test.APITestV2): mock_dp_name.return_value = dp url = self.DP_URL + '/%s' headers = self.headers - headers[base.Version.current_api_version] = 'accelerator 2.1' + headers[base.Version.current_api_version] = '2.1' self.assertRaisesRegex( webtest.app.AppError, "Request not acceptable.*", @@ -82,7 +82,7 @@ class TestDeviceProfileController(v2_test.APITestV2): mock_dp_name.return_value = dp url = self.DP_URL + '/%s' 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'], headers=headers) mock_dp_name.assert_called_once() diff --git a/cyborg/tests/unit/api/controllers/v2/test_microversion.py b/cyborg/tests/unit/api/controllers/v2/test_microversion.py index ff5eaeeb..261409d4 100644 --- a/cyborg/tests/unit/api/controllers/v2/test_microversion.py +++ b/cyborg/tests/unit/api/controllers/v2/test_microversion.py @@ -33,8 +33,7 @@ class TestMicroversions(api_base.BaseApiTest): def test_wrong_major_version(self): response = self.get_json( '/v2', - headers={'OpenStack-API-Version': ' '.join([SERVICE_TYPE, - '10'])}, + headers={'OpenStack-API-Version': '10'}, expect_errors=True, return_json=False) self.assertEqual('application/json', response.content_type) self.assertEqual(406, response.status_int) @@ -57,8 +56,7 @@ class TestMicroversions(api_base.BaseApiTest): def test_new_client_new_api(self): response = self.get_json( '/v2', - headers={'OpenStack-API-Version': ' '.join([SERVICE_TYPE, - '2.0'])}, + headers={'OpenStack-API-Version': '2.0'}, return_json=False) self.assertEqual(response.headers[H_MIN_VER], MIN_VER) self.assertEqual(response.headers[H_MAX_VER], MAX_VER) @@ -69,8 +67,7 @@ class TestMicroversions(api_base.BaseApiTest): def test_latest_microversion(self): response = self.get_json( '/v2', - headers={'OpenStack-API-Version': ' '.join([SERVICE_TYPE, - 'latest'])}, + headers={'OpenStack-API-Version': 'latest'}, return_json=False) self.assertEqual(response.headers[H_MIN_VER], MIN_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) response = self.get_json( '/v2', - headers={'OpenStack-API-Version': ' '.join( - [SERVICE_TYPE, unsupported_version])}, + headers={'OpenStack-API-Version': unsupported_version}, expect_errors=True) self.assertEqual(406, response.status_int) self.assertEqual(response.headers[H_MIN_VER], MIN_VER)