diff options
author | Zuul <zuul@review.opendev.org> | 2023-01-06 12:00:17 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2023-01-06 12:00:17 +0000 |
commit | 7be9046021301b56c524eb7f91dd74cff0645571 (patch) | |
tree | 1d5efddaabf25efa69e2a48b9a96fa57f7034460 /ironic/common | |
parent | bed680951a55d2a0782c1e9abda6cd954045a577 (diff) | |
parent | 973d3b6ea671b15583925eaa93ea988d16734499 (diff) | |
download | ironic-7be9046021301b56c524eb7f91dd74cff0645571.tar.gz |
Merge "Enable alternative storage for inventory"
Diffstat (limited to 'ironic/common')
-rw-r--r-- | ironic/common/swift.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/ironic/common/swift.py b/ironic/common/swift.py index 8a98c32d2..dde94fb18 100644 --- a/ironic/common/swift.py +++ b/ironic/common/swift.py @@ -111,6 +111,31 @@ class SwiftAPI(object): return obj_uuid + def create_object_from_data(self, object, data, container): + """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. + :returns: The Swift UUID of the object + :raises: utils.Error, if any operation with Swift fails. + """ + try: + self.connection.put_container(container) + except swift_exceptions.ClientException as e: + operation = _("put container") + raise exception.SwiftOperationError(operation=operation, error=e) + + try: + obj_uuid = self.connection.create_object( + container, object, data=data) + except swift_exceptions.ClientException as e: + operation = _("put object") + raise exception.SwiftOperationError(operation=operation, error=e) + + return obj_uuid + def get_temp_url(self, container, obj, timeout): """Returns the temp url for the given Swift object. |