Separate build_interval/timeout from RestClient
RestClient used compute build_interval/timeout values as the default, even if the other projects' clients. This implementation is not useful when RestClient is changed to a library class. Then this patch separates compute build_interval/timeout values from the class and set the same static values as the default. Change-Id: Ibc4307b406b71db258975da90a39c1f51ad27e12
This commit is contained in:
parent
bdf9bc2ad4
commit
0cd316bd60
|
@ -158,8 +158,7 @@ class Manager(manager.Manager):
|
|||
self.telemetry_client = TelemetryClientJSON(
|
||||
self.auth_provider)
|
||||
self.negative_client = rest_client.NegativeRestClient(
|
||||
self.auth_provider)
|
||||
self.negative_client.service = service
|
||||
self.auth_provider, service)
|
||||
|
||||
# TODO(andreaf) EC2 client still do their auth, v2 only
|
||||
ec2_client_args = (self.credentials.username,
|
||||
|
|
|
@ -78,16 +78,17 @@ class RestClient(object):
|
|||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
def __init__(self, auth_provider, service,
|
||||
build_interval=1, build_timeout=60):
|
||||
self.auth_provider = auth_provider
|
||||
self.service = service
|
||||
self.build_interval = build_interval
|
||||
self.build_timeout = build_timeout
|
||||
|
||||
self.endpoint_url = None
|
||||
self.service = None
|
||||
# The version of the API this client implements
|
||||
self.api_version = None
|
||||
self._skip_path = False
|
||||
self.build_interval = CONF.compute.build_interval
|
||||
self.build_timeout = CONF.compute.build_timeout
|
||||
self.general_header_lc = set(('cache-control', 'connection',
|
||||
'date', 'pragma', 'trailer',
|
||||
'transfer-encoding', 'via',
|
||||
|
|
|
@ -49,8 +49,8 @@ class BaremetalClient(rest_client.RestClient):
|
|||
"""
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(BaremetalClient, self).__init__(auth_provider)
|
||||
self.service = CONF.baremetal.catalog_type
|
||||
super(BaremetalClient, self).__init__(
|
||||
auth_provider, CONF.baremetal.catalog_type)
|
||||
self.uri_prefix = ''
|
||||
|
||||
def serialize(self, object_type, object_dict):
|
||||
|
|
|
@ -30,7 +30,7 @@ class ComputeClient(rest_client.RestClient):
|
|||
if build_timeout is None:
|
||||
build_timeout = CONF.compute.build_timeout
|
||||
|
||||
super(ComputeClient, self).__init__(auth_provider)
|
||||
self.service = CONF.compute.catalog_type
|
||||
self.build_interval = build_interval
|
||||
self.build_timeout = build_timeout
|
||||
super(ComputeClient, self).__init__(auth_provider,
|
||||
CONF.compute.catalog_type,
|
||||
build_interval=build_interval,
|
||||
build_timeout=build_timeout)
|
||||
|
|
|
@ -21,9 +21,10 @@ CONF = config.CONF
|
|||
|
||||
|
||||
class DataProcessingClient(rest_client.RestClient):
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(DataProcessingClient, self).__init__(auth_provider)
|
||||
self.service = CONF.data_processing.catalog_type
|
||||
super(DataProcessingClient, self).__init__(
|
||||
auth_provider, CONF.data_processing.catalog_type)
|
||||
|
||||
def _request_and_check_resp(self, request_func, uri, resp_status):
|
||||
"""Make a request using specified request_func and check response
|
||||
|
|
|
@ -24,8 +24,8 @@ CONF = config.CONF
|
|||
class DatabaseFlavorsClientJSON(rest_client.RestClient):
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(DatabaseFlavorsClientJSON, self).__init__(auth_provider)
|
||||
self.service = CONF.database.catalog_type
|
||||
super(DatabaseFlavorsClientJSON, self).__init__(
|
||||
auth_provider, CONF.database.catalog_type)
|
||||
|
||||
def list_db_flavors(self, params=None):
|
||||
url = 'flavors'
|
||||
|
|
|
@ -24,9 +24,9 @@ CONF = config.CONF
|
|||
class DatabaseVersionsClientJSON(rest_client.RestClient):
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(DatabaseVersionsClientJSON, self).__init__(auth_provider)
|
||||
super(DatabaseVersionsClientJSON, self).__init__(
|
||||
auth_provider, CONF.database.catalog_type)
|
||||
self.skip_path()
|
||||
self.service = CONF.database.catalog_type
|
||||
|
||||
def list_db_versions(self, params=None):
|
||||
"""List all versions."""
|
||||
|
|
|
@ -22,8 +22,8 @@ CONF = config.CONF
|
|||
class IdentityClientJSON(rest_client.RestClient):
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(IdentityClientJSON, self).__init__(auth_provider)
|
||||
self.service = CONF.identity.catalog_type
|
||||
super(IdentityClientJSON, self).__init__(auth_provider,
|
||||
CONF.identity.catalog_type)
|
||||
self.endpoint_url = 'adminURL'
|
||||
|
||||
def has_admin_extensions(self):
|
||||
|
|
|
@ -24,7 +24,7 @@ class IdentityV3Client(rest_client.RestClient):
|
|||
"""
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(IdentityV3Client, self).__init__(auth_provider)
|
||||
self.service = CONF.identity.catalog_type
|
||||
super(IdentityV3Client, self).__init__(auth_provider,
|
||||
CONF.identity.catalog_type)
|
||||
self.endpoint_url = 'adminURL'
|
||||
self.api_version = "v3"
|
||||
|
|
|
@ -523,7 +523,7 @@ class IdentityV3ClientJSON(base.IdentityV3Client):
|
|||
class V3TokenClientJSON(rest_client.RestClient):
|
||||
|
||||
def __init__(self):
|
||||
super(V3TokenClientJSON, self).__init__(None)
|
||||
super(V3TokenClientJSON, self).__init__(None, None)
|
||||
auth_url = CONF.identity.uri_v3
|
||||
if not auth_url:
|
||||
raise exceptions.InvalidConfiguration('you must specify a v3 uri '
|
||||
|
|
|
@ -35,8 +35,8 @@ LOG = logging.getLogger(__name__)
|
|||
class ImageClientJSON(rest_client.RestClient):
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(ImageClientJSON, self).__init__(auth_provider)
|
||||
self.service = CONF.image.catalog_type
|
||||
super(ImageClientJSON, self).__init__(auth_provider,
|
||||
CONF.image.catalog_type)
|
||||
self._http = None
|
||||
|
||||
def _image_meta_from_headers(self, headers):
|
||||
|
|
|
@ -29,8 +29,8 @@ CONF = config.CONF
|
|||
class ImageClientV2JSON(rest_client.RestClient):
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(ImageClientV2JSON, self).__init__(auth_provider)
|
||||
self.service = CONF.image.catalog_type
|
||||
super(ImageClientV2JSON, self).__init__(auth_provider,
|
||||
CONF.image.catalog_type)
|
||||
self._http = None
|
||||
|
||||
def _get_http(self):
|
||||
|
|
|
@ -28,8 +28,8 @@ CONF = config.CONF
|
|||
class MessagingClientJSON(rest_client.RestClient):
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(MessagingClientJSON, self).__init__(auth_provider)
|
||||
self.service = CONF.messaging.catalog_type
|
||||
super(MessagingClientJSON, self).__init__(auth_provider,
|
||||
CONF.messaging.catalog_type)
|
||||
self.version = '1'
|
||||
self.uri_prefix = 'v{0}'.format(self.version)
|
||||
|
||||
|
|
|
@ -38,10 +38,10 @@ class NetworkClientJSON(rest_client.RestClient):
|
|||
"""
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(NetworkClientJSON, self).__init__(auth_provider)
|
||||
self.service = CONF.network.catalog_type
|
||||
self.build_timeout = CONF.network.build_timeout
|
||||
self.build_interval = CONF.network.build_interval
|
||||
super(NetworkClientJSON, self).__init__(
|
||||
auth_provider, CONF.network.catalog_type,
|
||||
build_interval=CONF.network.build_interval,
|
||||
build_timeout=CONF.network.build_timeout)
|
||||
self.version = '2.0'
|
||||
self.uri_prefix = "v%s" % (self.version)
|
||||
|
||||
|
|
|
@ -24,6 +24,6 @@ class ObjectStorageClient(rest_client.RestClient):
|
|||
"""
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(ObjectStorageClient, self).__init__(auth_provider)
|
||||
self.service = CONF.object_storage.catalog_type
|
||||
super(ObjectStorageClient, self).__init__(
|
||||
auth_provider, CONF.object_storage.catalog_type)
|
||||
self.format = 'json'
|
||||
|
|
|
@ -28,10 +28,11 @@ CONF = config.CONF
|
|||
class OrchestrationClient(rest_client.RestClient):
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(OrchestrationClient, self).__init__(auth_provider)
|
||||
self.service = CONF.orchestration.catalog_type
|
||||
self.build_interval = CONF.orchestration.build_interval
|
||||
self.build_timeout = CONF.orchestration.build_timeout
|
||||
super(OrchestrationClient, self).__init__(
|
||||
auth_provider,
|
||||
CONF.orchestration.catalog_type,
|
||||
build_interval=CONF.orchestration.build_interval,
|
||||
build_timeout=CONF.orchestration.build_timeout)
|
||||
|
||||
def list_stacks(self, params=None):
|
||||
"""Lists all stacks for a user."""
|
||||
|
|
|
@ -25,8 +25,8 @@ CONF = config.CONF
|
|||
class TelemetryClientJSON(rest_client.RestClient):
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(TelemetryClientJSON, self).__init__(auth_provider)
|
||||
self.service = CONF.telemetry.catalog_type
|
||||
super(TelemetryClientJSON, self).__init__(auth_provider,
|
||||
CONF.telemetry.catalog_type)
|
||||
self.version = '2'
|
||||
self.uri_prefix = "v%s" % self.version
|
||||
|
||||
|
|
|
@ -24,7 +24,8 @@ class VolumeClient(rest_client.RestClient):
|
|||
"""
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(VolumeClient, self).__init__(auth_provider)
|
||||
self.service = CONF.volume.catalog_type
|
||||
self.build_interval = CONF.volume.build_interval
|
||||
self.build_timeout = CONF.volume.build_timeout
|
||||
super(VolumeClient, self).__init__(
|
||||
auth_provider,
|
||||
CONF.volume.catalog_type,
|
||||
build_interval=CONF.volume.build_interval,
|
||||
build_timeout=CONF.volume.build_timeout)
|
||||
|
|
|
@ -38,7 +38,7 @@ class BaseRestClientTestClass(base.TestCase):
|
|||
self.useFixture(fake_config.ConfigFixture())
|
||||
self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
|
||||
self.rest_client = rest_client.RestClient(
|
||||
fake_auth_provider.FakeAuthProvider())
|
||||
fake_auth_provider.FakeAuthProvider(), None)
|
||||
self.stubs.Set(httplib2.Http, 'request', self.fake_http.request)
|
||||
self.useFixture(mockpatch.PatchObject(self.rest_client, '_get_region',
|
||||
side_effect=self._get_region()))
|
||||
|
@ -304,7 +304,7 @@ class TestRestClientErrorCheckerJSON(base.TestCase):
|
|||
self.useFixture(fake_config.ConfigFixture())
|
||||
self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
|
||||
self.rest_client = rest_client.RestClient(
|
||||
fake_auth_provider.FakeAuthProvider())
|
||||
fake_auth_provider.FakeAuthProvider(), None)
|
||||
|
||||
def test_response_less_than_400(self):
|
||||
self.rest_client._error_checker(**self.set_data("399"))
|
||||
|
@ -434,7 +434,7 @@ class TestNegativeRestClient(BaseRestClientTestClass):
|
|||
self.fake_http = fake_http.fake_httplib2()
|
||||
super(TestNegativeRestClient, self).setUp()
|
||||
self.negative_rest_client = rest_client.NegativeRestClient(
|
||||
fake_auth_provider.FakeAuthProvider())
|
||||
fake_auth_provider.FakeAuthProvider(), None)
|
||||
self.useFixture(mockpatch.PatchObject(self.negative_rest_client,
|
||||
'_log_request'))
|
||||
|
||||
|
|
Loading…
Reference in New Issue