Add ObjectStorageClient for cleanup
In object storage clients, there is a lot of duplicated code for setting CONF. This patch adds ObjectStorageClient for removing them. Change-Id: I07eb4af34b20ae94a09b6fa90ffeb3bc19e14762
This commit is contained in:
parent
a39d0be90d
commit
de398ac8b8
|
@ -18,17 +18,14 @@ import urllib
|
|||
from xml.etree import ElementTree as etree
|
||||
|
||||
from tempest.common import http
|
||||
from tempest.common import rest_client
|
||||
from tempest import config
|
||||
from tempest import exceptions
|
||||
from tempest.services.object_storage import base
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
|
||||
class AccountClient(rest_client.RestClient):
|
||||
def __init__(self, auth_provider):
|
||||
super(AccountClient, self).__init__(auth_provider)
|
||||
self.service = CONF.object_storage.catalog_type
|
||||
class AccountClient(base.ObjectStorageClient):
|
||||
|
||||
def create_account(self, data=None,
|
||||
params=None,
|
||||
|
@ -167,17 +164,10 @@ class AccountClient(rest_client.RestClient):
|
|||
return resp, body
|
||||
|
||||
|
||||
class AccountClientCustomizedHeader(rest_client.RestClient):
|
||||
class AccountClientCustomizedHeader(base.ObjectStorageClient):
|
||||
|
||||
# TODO(andreaf) This class is now redundant, to be removed in next patch
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(AccountClientCustomizedHeader, self).__init__(
|
||||
auth_provider)
|
||||
# Overwrites json-specific header encoding in rest_client.RestClient
|
||||
self.service = CONF.object_storage.catalog_type
|
||||
self.format = 'json'
|
||||
|
||||
def request(self, method, url, extra_headers=False, headers=None,
|
||||
body=None):
|
||||
"""A simple HTTP request interface."""
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
# Copyright 2014 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 ObjectStorageClient(rest_client.RestClient):
|
||||
"""
|
||||
Base object storage client class
|
||||
"""
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(ObjectStorageClient, self).__init__(auth_provider)
|
||||
self.service = CONF.object_storage.catalog_type
|
||||
self.format = 'json'
|
|
@ -17,20 +17,10 @@ import json
|
|||
import urllib
|
||||
from xml.etree import ElementTree as etree
|
||||
|
||||
from tempest.common import rest_client
|
||||
from tempest import config
|
||||
|
||||
CONF = config.CONF
|
||||
from tempest.services.object_storage import base
|
||||
|
||||
|
||||
class ContainerClient(rest_client.RestClient):
|
||||
def __init__(self, auth_provider):
|
||||
super(ContainerClient, self).__init__(auth_provider)
|
||||
|
||||
# Overwrites json-specific header encoding in rest_client.RestClient
|
||||
self.headers = {}
|
||||
self.service = CONF.object_storage.catalog_type
|
||||
self.format = 'json'
|
||||
class ContainerClient(base.ObjectStorageClient):
|
||||
|
||||
def create_container(
|
||||
self, container_name,
|
||||
|
|
|
@ -18,18 +18,14 @@ import urllib
|
|||
import urlparse
|
||||
|
||||
from tempest.common import http
|
||||
from tempest.common import rest_client
|
||||
from tempest import config
|
||||
from tempest import exceptions
|
||||
from tempest.services.object_storage import base
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
|
||||
class ObjectClient(rest_client.RestClient):
|
||||
def __init__(self, auth_provider):
|
||||
super(ObjectClient, self).__init__(auth_provider)
|
||||
|
||||
self.service = CONF.object_storage.catalog_type
|
||||
class ObjectClient(base.ObjectStorageClient):
|
||||
|
||||
def create_object(self, container, object_name, data,
|
||||
params=None, metadata=None):
|
||||
|
@ -182,17 +178,10 @@ class ObjectClient(rest_client.RestClient):
|
|||
return resp.status, resp.reason, resp_headers
|
||||
|
||||
|
||||
class ObjectClientCustomizedHeader(rest_client.RestClient):
|
||||
class ObjectClientCustomizedHeader(base.ObjectStorageClient):
|
||||
|
||||
# TODO(andreaf) This class is now redundant, to be removed in next patch
|
||||
|
||||
def __init__(self, auth_provider):
|
||||
super(ObjectClientCustomizedHeader, self).__init__(
|
||||
auth_provider)
|
||||
# Overwrites json-specific header encoding in rest_client.RestClient
|
||||
self.service = CONF.object_storage.catalog_type
|
||||
self.format = 'json'
|
||||
|
||||
def request(self, method, url, extra_headers=False, headers=None,
|
||||
body=None):
|
||||
"""A simple HTTP request interface."""
|
||||
|
|
Loading…
Reference in New Issue