From 833635dd571e8277c3797f40c2645c423a5f3ded Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Thu, 26 Sep 2019 15:59:22 +0200 Subject: [PATCH] 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 --- ironic_inspector/common/swift.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ironic_inspector/common/swift.py b/ironic_inspector/common/swift.py index 716824004..dd59f754d 100644 --- a/ironic_inspector/common/swift.py +++ b/ironic_inspector/common/swift.py @@ -60,17 +60,18 @@ class SwiftAPI(object): raise utils.Error(_("Could not connect to the object storage " "service: %s") % exc) - def create_object(self, object, data, container=CONF.swift.container, - headers=None): + def create_object(self, object, data, container=None, headers=None): """Uploads a given string to Swift. :param object: The name of the object in Swift :param data: string data to put in 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 :returns: The Swift UUID of the object :raises: utils.Error, if any operation with Swift fails. """ + container = container or CONF.swift.container try: self.connection.create_container(container) except os_exc.SDKException as e: @@ -94,14 +95,16 @@ class SwiftAPI(object): 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. :param object: The name of the object in Swift :param container: The name of the container for the object. + Defaults to the value set in the configuration options. :returns: Swift object :raises: utils.Error, if the Swift operation fails. """ + container = container or CONF.swift.container try: obj = self.connection.download_object(object, container=container) except os_exc.SDKException as e: