Remove CONF values from images clients
To move image clients to tempest-lib, this patch moves
CONF values from image clients to the client setting and classes
instantiate image clients.
Change-Id: I83b9466fc43bfcefd8d78c43f2c6e9dce4596d18
diff --git a/tempest/clients.py b/tempest/clients.py
index 7a41f32..d6eefbc 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -194,8 +194,22 @@
endpoint_type=CONF.telemetry.endpoint_type,
**self.default_params_with_timeout_values)
if CONF.service_available.glance:
- self.image_client = ImageClientJSON(self.auth_provider)
- self.image_client_v2 = ImageClientV2JSON(self.auth_provider)
+ self.image_client = ImageClientJSON(
+ self.auth_provider,
+ CONF.image.catalog_type,
+ CONF.image.region or CONF.identity.region,
+ endpoint_type=CONF.image.endpoint_type,
+ build_interval=CONF.image.build_interval,
+ build_timeout=CONF.image.build_timeout,
+ **self.default_params)
+ self.image_client_v2 = ImageClientV2JSON(
+ self.auth_provider,
+ CONF.image.catalog_type,
+ CONF.image.region or CONF.identity.region,
+ endpoint_type=CONF.image.endpoint_type,
+ build_interval=CONF.image.build_interval,
+ build_timeout=CONF.image.build_timeout,
+ **self.default_params)
self.orchestration_client = OrchestrationClient(
self.auth_provider,
CONF.orchestration.catalog_type,
diff --git a/tempest/cmd/javelin.py b/tempest/cmd/javelin.py
index aff4087..f871a73 100755
--- a/tempest/cmd/javelin.py
+++ b/tempest/cmd/javelin.py
@@ -200,7 +200,14 @@
**object_storage_params)
self.containers = container_client.ContainerClient(
_auth, **object_storage_params)
- self.images = image_client.ImageClientV2JSON(_auth)
+ self.images = image_client.ImageClientV2JSON(
+ _auth,
+ CONF.image.catalog_type,
+ CONF.image.region or CONF.identity.region,
+ endpoint_type=CONF.image.endpoint_type,
+ build_interval=CONF.image.build_interval,
+ build_timeout=CONF.image.build_timeout,
+ **default_params)
self.telemetry = telemetry_client.TelemetryClientJSON(
_auth,
CONF.telemetry.catalog_type,
diff --git a/tempest/services/image/v1/json/image_client.py b/tempest/services/image/v1/json/image_client.py
index 4ea710f..50f75b3 100644
--- a/tempest/services/image/v1/json/image_client.py
+++ b/tempest/services/image/v1/json/image_client.py
@@ -25,26 +25,32 @@
from tempest.common import glance_http
from tempest.common import service_client
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
-
LOG = logging.getLogger(__name__)
class ImageClientJSON(service_client.ServiceClient):
- def __init__(self, auth_provider):
+ def __init__(self, auth_provider, catalog_type, region, endpoint_type=None,
+ build_interval=None, build_timeout=None,
+ disable_ssl_certificate_validation=None,
+ ca_certs=None, **kwargs):
super(ImageClientJSON, self).__init__(
auth_provider,
- CONF.image.catalog_type,
- CONF.image.region or CONF.identity.region,
- endpoint_type=CONF.image.endpoint_type,
- build_interval=CONF.image.build_interval,
- build_timeout=CONF.image.build_timeout)
+ catalog_type,
+ region,
+ endpoint_type=endpoint_type,
+ build_interval=build_interval,
+ build_timeout=build_timeout,
+ disable_ssl_certificate_validation=(
+ disable_ssl_certificate_validation),
+ ca_certs=ca_certs,
+ **kwargs)
self._http = None
+ self.dscv = disable_ssl_certificate_validation
+ self.ca_certs = ca_certs
def _image_meta_from_headers(self, headers):
meta = {'properties': {}}
@@ -112,11 +118,10 @@
return None
def _get_http(self):
- dscv = CONF.identity.disable_ssl_certificate_validation
- ca_certs = CONF.identity.ca_certificates_file
return glance_http.HTTPClient(auth_provider=self.auth_provider,
filters=self.filters,
- insecure=dscv, ca_certs=ca_certs)
+ insecure=self.dscv,
+ ca_certs=self.ca_certs)
def _create_with_data(self, headers, data):
resp, body_iter = self.http.raw_request('POST', '/v1/images',
@@ -138,8 +143,7 @@
@property
def http(self):
if self._http is None:
- if CONF.service_available.glance:
- self._http = self._get_http()
+ self._http = self._get_http()
return self._http
def create_image(self, name, container_format, disk_format, **kwargs):
diff --git a/tempest/services/image/v2/json/image_client.py b/tempest/services/image/v2/json/image_client.py
index 50f273c..e55a824 100644
--- a/tempest/services/image/v2/json/image_client.py
+++ b/tempest/services/image/v2/json/image_client.py
@@ -21,29 +21,34 @@
from tempest.common import glance_http
from tempest.common import service_client
-from tempest import config
-
-CONF = config.CONF
class ImageClientV2JSON(service_client.ServiceClient):
- def __init__(self, auth_provider):
+ def __init__(self, auth_provider, catalog_type, region, endpoint_type=None,
+ build_interval=None, build_timeout=None,
+ disable_ssl_certificate_validation=None, ca_certs=None,
+ **kwargs):
super(ImageClientV2JSON, self).__init__(
auth_provider,
- CONF.image.catalog_type,
- CONF.image.region or CONF.identity.region,
- endpoint_type=CONF.image.endpoint_type,
- build_interval=CONF.image.build_interval,
- build_timeout=CONF.image.build_timeout)
+ catalog_type,
+ region,
+ endpoint_type=endpoint_type,
+ build_interval=build_interval,
+ build_timeout=build_timeout,
+ disable_ssl_certificate_validation=(
+ disable_ssl_certificate_validation),
+ ca_certs=ca_certs,
+ **kwargs)
self._http = None
+ self.dscv = disable_ssl_certificate_validation
+ self.ca_certs = ca_certs
def _get_http(self):
- dscv = CONF.identity.disable_ssl_certificate_validation
- ca_certs = CONF.identity.ca_certificates_file
return glance_http.HTTPClient(auth_provider=self.auth_provider,
filters=self.filters,
- insecure=dscv, ca_certs=ca_certs)
+ insecure=self.dscv,
+ ca_certs=self.ca_certs)
def _validate_schema(self, body, type='image'):
if type in ['image', 'images']:
@@ -56,8 +61,7 @@
@property
def http(self):
if self._http is None:
- if CONF.service_available.glance:
- self._http = self._get_http()
+ self._http = self._get_http()
return self._http
def update_image(self, image_id, patch):
diff --git a/tempest/tests/common/test_service_clients.py b/tempest/tests/common/test_service_clients.py
index afe4abc..59d506c 100644
--- a/tempest/tests/common/test_service_clients.py
+++ b/tempest/tests/common/test_service_clients.py
@@ -55,6 +55,8 @@
from tempest.services.identity.v3.json import policy_client
from tempest.services.identity.v3.json import region_client
from tempest.services.identity.v3.json import service_client
+from tempest.services.image.v1.json import image_client
+from tempest.services.image.v2.json import image_client as image_v2_client
from tempest.services.messaging.json import messaging_client
from tempest.services.network.json import network_client
from tempest.services.object_storage import account_client
@@ -163,7 +165,9 @@
identity_v3_identity_client.IdentityV3ClientJSON,
policy_client.PolicyClientJSON,
region_client.RegionClientJSON,
- service_client.ServiceClientJSON
+ service_client.ServiceClientJSON,
+ image_client.ImageClientJSON,
+ image_v2_client.ImageClientV2JSON
]
for client in test_clients: