lifted package

Submodules

lifted.config module

lifted.config.configure(conf)[source]

Add lifted settings to the configuration

Parameters

conf (ComposerConfig) -- configuration object

Returns

None

This uses the composer.share_dir and composer.lib_dir as the base directories for the settings.

lifted.providers module

lifted.providers.delete_profile(ucfg, provider_name, profile)[source]

Delete a provider's profile settings file

Parameters
  • ucfg (object) -- upload config

  • provider_name (str) -- the name of the cloud provider, e.g. "azure"

  • profile (str != "") -- the name of the profile to save

Raises

ValueError when passed invalid settings or an invalid profile name

Raises

RuntimeError when the provider or profile couldn't be found

lifted.providers.list_providers(ucfg)[source]

List the names of the available upload providers

Parameters

ucfg (object) -- upload config

Returns

a list of all available provider_names

Return type

list of str

lifted.providers.load_profiles(ucfg, provider_name)[source]

Return all settings profiles associated with a provider

Parameters
  • ucfg (object) -- upload config

  • provider_name (str) -- name a provider to find profiles for

Returns

a dict of settings dicts, keyed by profile name

Return type

dict

lifted.providers.load_settings(ucfg, provider_name, profile)[source]

Load settings for a provider's profile

Parameters
  • ucfg (object) -- upload config

  • provider_name (str) -- the name of the cloud provider, e.g. "azure"

  • profile (str != "") -- the name of the profile to save

Returns

The profile settings for the selected provider

Return type

dict

Raises

ValueError when passed invalid settings or an invalid profile name

Raises

RuntimeError when the provider or profile couldn't be found

Raises

ValueError when the passed settings are invalid

This also calls validate_settings on the loaded settings, potentially raising an error if the saved settings are invalid.

lifted.providers.resolve_playbook_path(ucfg, provider_name)[source]

Given a provider's name, return the path to its playbook

Parameters
  • ucfg (object) -- upload config

  • provider_name (str) -- the name of the provider to find the playbook for

Raises

RuntimeError when the provider couldn't be found

Returns

the path to the playbook

Return type

str

lifted.providers.resolve_provider(ucfg, provider_name)[source]

Get information about the specified provider as defined in that provider's provider.toml, including the provider's display name and expected settings.

At a minimum, each setting has a display name (that likely differs from its snake_case name) and a type. Currently, there are two types of settings: string and boolean. String settings can optionally have a "placeholder" value for use on the front end and a "regex" for making sure that a value follows an expected pattern.

Parameters
  • ucfg (object) -- upload config

  • provider_name (str) -- the name of the provider to look for

Raises

RuntimeError when the provider couldn't be found

Returns

the provider

Return type

dict

lifted.providers.save_settings(ucfg, provider_name, profile, settings)[source]

Save (and overwrite) settings for a given provider

Parameters
  • ucfg (object) -- upload config

  • provider_name (str) -- the name of the cloud provider, e.g. "azure"

  • profile (str != "") -- the name of the profile to save

  • settings (dict) -- settings to save for that provider

Raises

ValueError when passed invalid settings or an invalid profile name

lifted.providers.validate_settings(ucfg, provider_name, settings, image_name=None)[source]

Raise a ValueError if any settings are invalid

Parameters
  • ucfg (object) -- upload config

  • provider_name (str) -- the name of the provider to validate the settings against

  • settings (dict) -- the settings to validate

  • image_name (str) -- optionally check whether an image_name is valid

Raises

ValueError when the passed settings are invalid

Raises

RuntimeError when provider_name can't be found

lifted.queue module

lifted.queue.cancel_upload(ucfg, uuid)[source]

Cancel an upload

Parameters
  • ucfg (ComposerConfig) -- the compose config

  • uuid (str) -- the UUID of the upload to cancel

lifted.queue.create_upload(ucfg, provider_name, image_name, settings)[source]

Creates a new upload

Parameters
  • ucfg (object) -- upload config

  • provider_name (str) -- the name of the cloud provider to upload to, e.g. "azure"

  • image_name (str) -- what to name the image in the cloud

  • settings (dict) -- settings to pass to the upload, specific to the cloud provider

Returns

the created upload object

Return type

Upload

lifted.queue.delete_upload(ucfg, uuid)[source]

Delete an upload

Parameters
  • ucfg (ComposerConfig) -- the compose config

  • uuid (str) -- the UUID of the upload to delete

lifted.queue.get_all_uploads(ucfg)[source]

Get a list of all stored Upload objects

Parameters

ucfg (object) -- upload config

Returns

a list of all stored upload objects

Return type

list of Upload

lifted.queue.get_upload(ucfg, uuid, ignore_missing=False, ignore_corrupt=False)[source]

Get an Upload object by UUID

Parameters
  • ucfg (object) -- upload config

  • uuid (str) -- UUID of the upload to get

  • ignore_missing (bool) -- if True, don't raise a RuntimeError when the specified upload is missing, instead just return None

  • ignore_corrupt (bool) -- if True, don't raise a RuntimeError when the specified upload could not be deserialized, instead just return None

Returns

the upload object or None

Return type

Upload or None

Raises

RuntimeError

lifted.queue.get_uploads(ucfg, uuids)[source]

Gets a list of Upload objects from a list of upload UUIDs, ignoring missing or corrupt uploads

Parameters
  • ucfg (object) -- upload config

  • uuids (list of str) -- list of upload UUIDs to get

Returns

a list of the uploads that were successfully deserialized

Return type

list of Upload

lifted.queue.ready_upload(ucfg, uuid, image_path)[source]

Pass an image_path to an upload and mark it ready to execute

Parameters
  • ucfg (object) -- upload config

  • uuid (str) -- the UUID of the upload to mark ready

  • image_path (str) -- the path of the image to pass to the upload

lifted.queue.reset_upload(ucfg, uuid, new_image_name=None, new_settings=None)[source]

Reset an upload so it can be attempted again

Parameters
  • ucfg (object) -- upload config

  • uuid (str) -- the UUID of the upload to reset

  • new_image_name (str) -- optionally update the upload's image_name

  • new_settings (dict) -- optionally update the upload's settings

lifted.queue.start_upload_monitor(ucfg)[source]

Start a thread that manages the upload queue

Parameters

ucfg (ComposerConfig) -- the compose config

lifted.upload module

class lifted.upload.Upload(uuid=None, provider_name=None, playbook_path=None, image_name=None, settings=None, creation_time=None, upload_log=None, upload_pid=None, image_path=None, status_callback=None, status=None)[source]

Bases: object

Represents an upload of an image to a cloud provider. Instances of this class are serialized as TOML and stored in the upload queue directory, which is /var/lib/lorax/upload/queue/ by default

cancel(status_callback=None)[source]

Cancel the upload. Sends a SIGINT to self.upload_pid.

Parameters

status_callback (function) -- a function of the form callback(self)

execute(status_callback=None)[source]

Execute the upload. Meant to be called from a dedicated process so that the upload can be cancelled by sending a SIGINT to self.upload_pid.

Parameters

status_callback (function) -- a function of the form callback(self)

is_cancellable()[source]

Is the upload in a cancellable state?

Returns

whether the upload is cancellable

Return type

bool

ready(image_path, status_callback)[source]

Provide an image_path and mark the upload as ready to execute

Parameters
  • image_path (str) -- path of the image to upload

  • status_callback (function) -- a function of the form callback(self)

reset(status_callback)[source]

Reset the upload so it can be attempted again

Parameters

status_callback (function) -- a function of the form callback(self)

serializable()[source]

Returns a representation of the object as a dict for serialization

Returns

the object's __dict__

Return type

dict

set_status(status, status_callback=None)[source]

Sets the status of the upload with an optional callback

Parameters
  • status (str) -- the new status

  • status_callback (function) -- a function of the form callback(self)

summary()[source]

Return a dict with useful information about the upload

Returns

upload information

Return type

dict

Module contents