Remove all CONF values from RestClient
To moving RestClient to tempest-lib, this patch moves all CONF values from RestClient to service clients. This patch adds TempestRestClient which passes common CONF values for Tempest own values. Change-Id: I3434061fd19de741e36b13bd3c458cf49fdfe783
This commit is contained in:
parent
ed8aff5987
commit
0e83665d98
|
@ -25,12 +25,9 @@ import six
|
|||
|
||||
from tempest.common import http
|
||||
from tempest.common.utils import misc as misc_utils
|
||||
from tempest import config
|
||||
from tempest import exceptions
|
||||
from tempest.openstack.common import log as logging
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
# redrive rate limited calls at most twice
|
||||
MAX_RECURSION_DEPTH = 2
|
||||
|
||||
|
@ -80,13 +77,16 @@ class RestClient(object):
|
|||
|
||||
def __init__(self, auth_provider, service, region,
|
||||
endpoint_type='publicURL',
|
||||
build_interval=1, build_timeout=60):
|
||||
build_interval=1, build_timeout=60,
|
||||
disable_ssl_certificate_validation=False, ca_certs=None,
|
||||
trace_requests=''):
|
||||
self.auth_provider = auth_provider
|
||||
self.service = service
|
||||
self.region = region
|
||||
self.endpoint_type = endpoint_type
|
||||
self.build_interval = build_interval
|
||||
self.build_timeout = build_timeout
|
||||
self.trace_requests = trace_requests
|
||||
|
||||
# The version of the API this client implements
|
||||
self.api_version = None
|
||||
|
@ -99,8 +99,7 @@ class RestClient(object):
|
|||
'location', 'proxy-authenticate',
|
||||
'retry-after', 'server',
|
||||
'vary', 'www-authenticate'))
|
||||
dscv = CONF.identity.disable_ssl_certificate_validation
|
||||
ca_certs = CONF.identity.ca_certificates_file
|
||||
dscv = disable_ssl_certificate_validation
|
||||
self.http_obj = http.ClosingHttp(
|
||||
disable_ssl_certificate_validation=dscv, ca_certs=ca_certs)
|
||||
|
||||
|
@ -117,10 +116,10 @@ class RestClient(object):
|
|||
|
||||
def __str__(self):
|
||||
STRING_LIMIT = 80
|
||||
str_format = ("config:%s, service:%s, base_url:%s, "
|
||||
str_format = ("service:%s, base_url:%s, "
|
||||
"filters: %s, build_interval:%s, build_timeout:%s"
|
||||
"\ntoken:%s..., \nheaders:%s...")
|
||||
return str_format % (CONF, self.service, self.base_url,
|
||||
return str_format % (self.service, self.base_url,
|
||||
self.filters, self.build_interval,
|
||||
self.build_timeout,
|
||||
str(self.token)[0:STRING_LIMIT],
|
||||
|
@ -253,8 +252,7 @@ class RestClient(object):
|
|||
if req_headers is None:
|
||||
req_headers = {}
|
||||
caller_name = misc_utils.find_test_caller()
|
||||
trace_regex = CONF.debug.trace_requests
|
||||
if trace_regex and re.search(trace_regex, caller_name):
|
||||
if self.trace_requests and re.search(self.trace_requests, caller_name):
|
||||
self.LOG.debug('Starting Request (%s): %s %s' %
|
||||
(caller_name, method, req_url))
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
# Copyright 2015 NEC Corporation. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest.common import rest_client
|
||||
from tempest import config
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
|
||||
class ServiceClient(rest_client.RestClient):
|
||||
|
||||
def __init__(self, auth_provider, service, region,
|
||||
endpoint_type=None, build_interval=None, build_timeout=None):
|
||||
params = {
|
||||
'disable_ssl_certificate_validation':
|
||||
CONF.identity.disable_ssl_certificate_validation,
|
||||
'ca_certs': CONF.identity.ca_certificates_file,
|
||||
'trace_requests': CONF.debug.trace_requests
|
||||
}
|
||||
if endpoint_type is not None:
|
||||
params.update({'endpoint_type': endpoint_type})
|
||||
if build_interval is not None:
|
||||
params.update({'build_interval': build_interval})
|
||||
if build_timeout is not None:
|
||||
params.update({'build_timeout': build_timeout})
|
||||
super(ServiceClient, self).__init__(auth_provider, service, region,
|
||||
**params)
|
|
@ -16,7 +16,7 @@ import urllib
|
|||
|
||||
import six
|
||||
|
||||
from tempest.common import rest_client
|
||||
from tempest.common import service_client
|
||||
from tempest import config
|
||||
|
||||
CONF = config.CONF
|
||||
|
@ -42,7 +42,7 @@ def handle_errors(f):
|
|||
return wrapper
|
||||
|
||||
|
||||
class BaremetalClient(rest_client.RestClient):
|
||||
class BaremetalClient(service_client.ServiceClient):
|
||||
"""
|
||||
Base Tempest REST client for Ironic API.
|
||||
|
||||
|
|
|
@ -12,13 +12,13 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest.common import rest_client
|
||||
from tempest.common import service_client
|
||||
from tempest import config
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
|
||||
class ComputeClient(rest_client.RestClient):
|
||||
class ComputeClient(service_client.ServiceClient):
|
||||
"""
|
||||
Base compute client class
|
||||
"""
|
||||
|
|
|
@ -14,13 +14,13 @@
|
|||
|
||||
import json
|
||||
|
||||
from tempest.common import rest_client
|
||||
from tempest.common import service_client
|
||||
from tempest import config
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
|
||||
class DataProcessingClient(rest_client.RestClient):
|
||||
class DataProcessingClient(service_client.ServiceClient):
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(DataProcessingClient, self).__init__(
|
||||
|
|
|
@ -15,13 +15,13 @@
|
|||
|
||||
import urllib
|
||||
|
||||
from tempest.common import rest_client
|
||||
from tempest.common import service_client
|
||||
from tempest import config
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
|
||||
class DatabaseFlavorsClientJSON(rest_client.RestClient):
|
||||
class DatabaseFlavorsClientJSON(service_client.ServiceClient):
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(DatabaseFlavorsClientJSON, self).__init__(
|
||||
|
|
|
@ -15,13 +15,13 @@
|
|||
|
||||
import urllib
|
||||
|
||||
from tempest.common import rest_client
|
||||
from tempest.common import service_client
|
||||
from tempest import config
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
|
||||
class DatabaseVersionsClientJSON(rest_client.RestClient):
|
||||
class DatabaseVersionsClientJSON(service_client.ServiceClient):
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(DatabaseVersionsClientJSON, self).__init__(
|
||||
|
|
|
@ -13,13 +13,14 @@
|
|||
import json
|
||||
|
||||
from tempest.common import rest_client
|
||||
from tempest.common import service_client
|
||||
from tempest import config
|
||||
from tempest import exceptions
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
|
||||
class IdentityClientJSON(rest_client.RestClient):
|
||||
class IdentityClientJSON(service_client.ServiceClient):
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(IdentityClientJSON, self).__init__(
|
||||
|
|
|
@ -12,13 +12,13 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest.common import rest_client
|
||||
from tempest.common import service_client
|
||||
from tempest import config
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
|
||||
class IdentityV3Client(rest_client.RestClient):
|
||||
class IdentityV3Client(service_client.ServiceClient):
|
||||
"""
|
||||
Base identity v3 client class
|
||||
"""
|
||||
|
|
|
@ -17,6 +17,7 @@ import json
|
|||
import urllib
|
||||
|
||||
from tempest.common import rest_client
|
||||
from tempest.common import service_client
|
||||
from tempest import config
|
||||
from tempest import exceptions
|
||||
from tempest.services.identity.v3.json import base
|
||||
|
@ -520,7 +521,7 @@ class IdentityV3ClientJSON(base.IdentityV3Client):
|
|||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
|
||||
class V3TokenClientJSON(rest_client.RestClient):
|
||||
class V3TokenClientJSON(service_client.ServiceClient):
|
||||
|
||||
def __init__(self):
|
||||
super(V3TokenClientJSON, self).__init__(None, None, None)
|
||||
|
|
|
@ -22,6 +22,7 @@ import urllib
|
|||
|
||||
from tempest.common import glance_http
|
||||
from tempest.common import rest_client
|
||||
from tempest.common import service_client
|
||||
from tempest.common.utils import misc as misc_utils
|
||||
from tempest import config
|
||||
from tempest import exceptions
|
||||
|
@ -32,7 +33,7 @@ CONF = config.CONF
|
|||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ImageClientJSON(rest_client.RestClient):
|
||||
class ImageClientJSON(service_client.ServiceClient):
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(ImageClientJSON, self).__init__(
|
||||
|
|
|
@ -20,13 +20,14 @@ import jsonschema
|
|||
|
||||
from tempest.common import glance_http
|
||||
from tempest.common import rest_client
|
||||
from tempest.common import service_client
|
||||
from tempest import config
|
||||
from tempest import exceptions
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
|
||||
class ImageClientV2JSON(rest_client.RestClient):
|
||||
class ImageClientV2JSON(service_client.ServiceClient):
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(ImageClientV2JSON, self).__init__(
|
||||
|
|
|
@ -17,7 +17,7 @@ import json
|
|||
import urllib
|
||||
|
||||
from tempest.api_schema.response.messaging.v1 import queues as queues_schema
|
||||
from tempest.common import rest_client
|
||||
from tempest.common import service_client
|
||||
from tempest.common.utils import data_utils
|
||||
from tempest import config
|
||||
|
||||
|
@ -25,7 +25,7 @@ from tempest import config
|
|||
CONF = config.CONF
|
||||
|
||||
|
||||
class MessagingClientJSON(rest_client.RestClient):
|
||||
class MessagingClientJSON(service_client.ServiceClient):
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(MessagingClientJSON, self).__init__(
|
||||
|
|
|
@ -15,6 +15,7 @@ import time
|
|||
import urllib
|
||||
|
||||
from tempest.common import rest_client
|
||||
from tempest.common import service_client
|
||||
from tempest.common.utils import misc
|
||||
from tempest import config
|
||||
from tempest import exceptions
|
||||
|
@ -22,7 +23,7 @@ from tempest import exceptions
|
|||
CONF = config.CONF
|
||||
|
||||
|
||||
class NetworkClientJSON(rest_client.RestClient):
|
||||
class NetworkClientJSON(service_client.ServiceClient):
|
||||
|
||||
"""
|
||||
Tempest REST client for Neutron. Uses v2 of the Neutron API, since the
|
||||
|
|
|
@ -12,13 +12,13 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest.common import rest_client
|
||||
from tempest.common import service_client
|
||||
from tempest import config
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
|
||||
class ObjectStorageClient(rest_client.RestClient):
|
||||
class ObjectStorageClient(service_client.ServiceClient):
|
||||
"""
|
||||
Base object storage client class
|
||||
"""
|
||||
|
|
|
@ -18,14 +18,14 @@ import re
|
|||
import time
|
||||
import urllib
|
||||
|
||||
from tempest.common import rest_client
|
||||
from tempest.common import service_client
|
||||
from tempest import config
|
||||
from tempest import exceptions
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
|
||||
class OrchestrationClient(rest_client.RestClient):
|
||||
class OrchestrationClient(service_client.ServiceClient):
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(OrchestrationClient, self).__init__(
|
||||
|
|
|
@ -15,14 +15,14 @@
|
|||
|
||||
import urllib
|
||||
|
||||
from tempest.common import rest_client
|
||||
from tempest.common import service_client
|
||||
from tempest import config
|
||||
from tempest.openstack.common import jsonutils as json
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
|
||||
class TelemetryClientJSON(rest_client.RestClient):
|
||||
class TelemetryClientJSON(service_client.ServiceClient):
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(TelemetryClientJSON, self).__init__(
|
||||
|
|
|
@ -12,13 +12,13 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest.common import rest_client
|
||||
from tempest.common import service_client
|
||||
from tempest import config
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
|
||||
class VolumeClient(rest_client.RestClient):
|
||||
class VolumeClient(service_client.ServiceClient):
|
||||
"""
|
||||
Base volume client class
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue