pycloudlib.openstack.cloud module

Openstack cloud type.

class pycloudlib.openstack.cloud.Openstack(tag: str, timestamp_suffix: bool = True, config_file: Path | StringIO | None = None, *, network: str | None = None)[source]

Bases: BaseCloud

Openstack cloud class.

__init__(tag: str, timestamp_suffix: bool = True, config_file: Path | StringIO | None = None, *, network: str | None = None)[source]

Initialize the connection to openstack.

Requires valid pre-configured environment variables or clouds.yaml. See https://docs.openstack.org/python-openstackclient/pike/configuration/index.html

Parameters:
  • tag – Name of instance

  • timestamp_suffix – bool set True to append a timestamp suffix to the tag

  • config_file – path to pycloudlib configuration file

  • network – Name of the network to use (from openstack network list)

daily_image(release: str, **kwargs)[source]

Not supported for openstack.

delete_image(image_id, **kwargs)[source]

Delete an image.

Parameters:

image_id – string, id of the image to delete

get_instance(instance_id, *, username: str | None = None, **kwargs) OpenstackInstance[source]

Get an instance by id.

Parameters:

instance_id – ID of instance to get

Returns:

An instance object to use to manipulate the instance further.

image_serial(image_id)[source]

Find the image serial of the latest daily image for a particular release.

Parameters:

image_id – string, Ubuntu image id

Returns:

string, serial of latest image

launch(image_id, instance_type='m1.small', user_data='', *, username: str | None = None, **kwargs) OpenstackInstance[source]

Launch an instance.

Parameters:
  • image_id – string, image ID to use for the instance

  • instance_type – string, type (flavor) of instance to create

  • user_data – used by cloud-init to run custom scripts/configuration

  • username – username to use when connecting via SSH

  • **kwargs – dictionary of other arguments to pass to launch

Returns:

An instance object to use to manipulate the instance further.

Raises: ValueError on invalid image_id

released_image(release, **kwargs)[source]

Not supported for openstack.

snapshot(instance, clean=True, **kwargs)[source]

Snapshot an instance and generate an image from it.

Parameters:
  • instance – Instance to snapshot

  • clean – run instance clean method before taking snapshot

Returns:

An image id

use_key(public_key_path, private_key_path=None, name=None)[source]

Use an existing key.

Parameters:
  • public_key_path – path to the public key to upload

  • private_key_path – path to the private key

  • name – name to reference key by