Don't use configuration options in function signatures
This causes the values to be evaluated at import time, which makes it harder to import such modules in functional tests. Change-Id: I1fc69058f737ef3ab9e703968d05a2d77fc57fdb
This commit is contained in:
parent
40f1dff1e5
commit
833635dd57
@ -60,17 +60,18 @@ class SwiftAPI(object):
|
|||||||
raise utils.Error(_("Could not connect to the object storage "
|
raise utils.Error(_("Could not connect to the object storage "
|
||||||
"service: %s") % exc)
|
"service: %s") % exc)
|
||||||
|
|
||||||
def create_object(self, object, data, container=CONF.swift.container,
|
def create_object(self, object, data, container=None, headers=None):
|
||||||
headers=None):
|
|
||||||
"""Uploads a given string to Swift.
|
"""Uploads a given string to Swift.
|
||||||
|
|
||||||
:param object: The name of the object in Swift
|
:param object: The name of the object in Swift
|
||||||
:param data: string data to put in the object
|
:param data: string data to put in the object
|
||||||
:param container: The name of the container for the object.
|
:param container: The name of the container for the object.
|
||||||
|
Defaults to the value set in the configuration options.
|
||||||
:param headers: the headers for the object to pass to Swift
|
:param headers: the headers for the object to pass to Swift
|
||||||
:returns: The Swift UUID of the object
|
:returns: The Swift UUID of the object
|
||||||
:raises: utils.Error, if any operation with Swift fails.
|
:raises: utils.Error, if any operation with Swift fails.
|
||||||
"""
|
"""
|
||||||
|
container = container or CONF.swift.container
|
||||||
try:
|
try:
|
||||||
self.connection.create_container(container)
|
self.connection.create_container(container)
|
||||||
except os_exc.SDKException as e:
|
except os_exc.SDKException as e:
|
||||||
@ -94,14 +95,16 @@ class SwiftAPI(object):
|
|||||||
|
|
||||||
return obj_uuid
|
return obj_uuid
|
||||||
|
|
||||||
def get_object(self, object, container=CONF.swift.container):
|
def get_object(self, object, container=None):
|
||||||
"""Downloads a given object from Swift.
|
"""Downloads a given object from Swift.
|
||||||
|
|
||||||
:param object: The name of the object in Swift
|
:param object: The name of the object in Swift
|
||||||
:param container: The name of the container for the object.
|
:param container: The name of the container for the object.
|
||||||
|
Defaults to the value set in the configuration options.
|
||||||
:returns: Swift object
|
:returns: Swift object
|
||||||
:raises: utils.Error, if the Swift operation fails.
|
:raises: utils.Error, if the Swift operation fails.
|
||||||
"""
|
"""
|
||||||
|
container = container or CONF.swift.container
|
||||||
try:
|
try:
|
||||||
obj = self.connection.download_object(object, container=container)
|
obj = self.connection.download_object(object, container=container)
|
||||||
except os_exc.SDKException as e:
|
except os_exc.SDKException as e:
|
||||||
|
Loading…
Reference in New Issue
Block a user