ironic.common.swift module

class ironic.common.swift.SwiftAPI[source]

Bases: object

API for communicating with Swift.

create_object(container, obj, filename, object_headers=None)[source]

Uploads a given file to Swift.

Parameters:
  • container – The name of the container for the object.

  • obj – The name of the object in Swift

  • filename – The file to upload, as the object data

  • object_headers – the headers for the object to pass to Swift

Returns:

The Swift UUID of the object

Raises:

SwiftOperationError, if any operation with Swift fails.

create_object_from_data(obj, data, container)[source]

Uploads a given string to Swift.

Parameters:
  • obj – The name of the object in Swift

  • data – string data to put in the object

  • 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.

delete_object(container, obj)[source]

Deletes the given Swift object.

Parameters:
  • container – The name of the container in which Swift object is placed.

  • obj – The name of the object in Swift to be deleted.

Raises:

SwiftObjectNotFoundError, if object is not found in Swift.

Raises:

SwiftOperationError, if operation with Swift fails.

generate_temp_url(path, timeout, method, temp_url_key)[source]

Returns the temp url for a given path

get_object(object, container)[source]

Downloads a given object from Swift.

Parameters:
  • object – The name of the object in Swift

  • 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.

get_temp_url(container, obj, timeout)[source]

Returns the temp url for the given Swift object.

Parameters:
  • container – The name of the container in which Swift object is placed.

  • obj – The name of the Swift object.

  • timeout – The timeout in seconds after which the generated url should expire.

Returns:

The temp url for the object.

Raises:

SwiftOperationError, if any operation with Swift fails.

get_temp_url_key()[source]

Get the best temporary url key from the account headers.

ironic.common.swift.get_swift_session()[source]