def _discover_client(self, current_client, os_api_version, os_endpoint_type, os_service_type, os_username, os_password, os_project_name, os_auth_url, client_args): if (os_api_version.get_major_version() in api_versions.DEPRECATED_VERSIONS): discovered_version = api_versions.DEPRECATED_VERSION os_service_type = 'volume' else: discovered_version = api_versions.discover_version( current_client, os_api_version) if not os_endpoint_type: os_endpoint_type = DEFAULT_CINDER_ENDPOINT_TYPE if not os_service_type: os_service_type = self._discover_service_type(discovered_version) API_MAX_VERSION = api_versions.APIVersion(api_versions.MAX_VERSION) if (discovered_version != API_MAX_VERSION or os_service_type != 'volume' or os_endpoint_type != DEFAULT_CINDER_ENDPOINT_TYPE): client_args['service_type'] = os_service_type client_args['endpoint_type'] = os_endpoint_type return (client.Client(discovered_version, os_username, os_password, os_project_name, os_auth_url, **client_args), discovered_version) else: return current_client, discovered_version
def test_microversion(self, client_min, client_max, server_min, server_max, requested_version, exp_range, end_version=None, ret_val=None): if ret_val is not None: self.fake_client.services.server_api_version.return_value = ret_val else: self._mock_returned_server_version(server_max, server_min) api_versions.MAX_VERSION = client_max api_versions.MIN_VERSION = client_min if exp_range: self.assertRaisesRegexp(exceptions.UnsupportedVersion, ".*range is '%s' to '%s'.*" % (server_min, server_max), api_versions.discover_version, self.fake_client, api_versions.APIVersion(requested_version)) else: discovered_version = api_versions.discover_version( self.fake_client, api_versions.APIVersion(requested_version)) version = requested_version if server_min is None and server_max is None: version = api_versions.DEPRECATED_VERSION elif end_version is not None: version = end_version self.assertEqual(version, discovered_version.get_string()) self.assertTrue( self.fake_client.services.server_api_version.called)
def test_microversion(self, client_min, client_max, server_min, server_max, requested_version, exp_range, end_version=None, ret_val=None): if ret_val is not None: self.fake_client.services.server_api_version.return_value = ret_val else: self._mock_returned_server_version(server_max, server_min) api_versions.MAX_VERSION = client_max api_versions.MIN_VERSION = client_min if exp_range: self.assertRaisesRegexp( exceptions.UnsupportedVersion, ".*range is '%s' to '%s'.*" % (server_min, server_max), api_versions.discover_version, self.fake_client, api_versions.APIVersion(requested_version)) else: discovered_version = api_versions.discover_version( self.fake_client, api_versions.APIVersion(requested_version)) version = requested_version if server_min is None and server_max is None: version = api_versions.DEPRECATED_VERSION elif end_version is not None: version = end_version self.assertEqual(version, discovered_version.get_string()) self.assertTrue( self.fake_client.services.server_api_version.called)