class elasticluster.providers.openstack.OpenStackCloudProvider(username=None, password=None, project_name=None, auth_url=None, user_domain_name='default', project_domain_name='default', region_name=None, availability_zone=None, storage_path=None, compute_api_version='2', image_api_version='2', network_api_version='2.0', volume_api_version='2', identity_api_version=None, nova_api_version=None, cacert=None, use_anti_affinity_groups=False, request_floating_ip=None, build_timeout=30)[source]

This implementation of elasticluster.providers.AbstractCloudProvider uses the OpenStack native python bindings to connect to OpenStack clouds and manage instances.

  • username (str) – username of the keystone user
  • password (str) – password of the keystone user
  • project_name (str) – name of the project to use
  • user_domain_name (str) – name of the user domain to use
  • project_domain_name (str) – name of the project domain to use
  • auth_url (str) – url of keystone endpoint
  • region (str) – OpenStack region to use
  • storage_path (str) – path to store temporary data
  • request_floating_ip (bool) – Whether ip are assigned automatically True or floating ips have to be assigned manually False
  • identity_api_version – What version of the Keystone API to use. Valid values are the strings “v2” or “v3”, or None (default, meaning try v3 first and fall-back to v2).
  • cacert – Path to CA certificate bundle (for verifying HTTPS sessions) or None to use the systems’ default.
  • use_anti_affinity_groups (bool) – Place nodes of the a cluster in the same anti-affinity group.

Parameters username, password, user_domain_name, project_name, project_domain_name, and region_name will be taken from the environment if not provided. Similarly, environmental variables can be used to set values for the preferred version of identity, compute, image, network, and volume API to use.

In all these cases, any value explicitly passed to the constructor takes precedence over the corresponding environmental variable, which in turn takes precedence over the default value in the class (if any).

class AntiAffinityGroup(nova_client, prefix)[source]

Interface to OpenStack’s Anti-Affinity Groups.

A single instance of this class should manage all the AAf groups for a cluster. Use like this:

  1. Initialise class with a unique string; as the list of AAF groups used by a cluster is not persisted, the unique string is used as a marker for recovering the managed groups from OpenStack’s list.
  2. Prior to starting a node (“creating a server” in OpenStack’s language), call get() which returns the group ID and a a request handle.
  3. If node creation fails because the AAF group has no more slots available, then call full() passing the request handle and try again.

This approach is needed because we cannot probe for ‘available slots’ in a AAF group: the only way to find out if a server can be added to an AAF group is to actually try to start it.

The code is thread-safe and can be called concurrently; requests handles are the mechanism used to make sure that new groups are created only when actually needed.


Delete all anti-affinity groups with the given prefix.


Signal that the group associated to the given request cannot

If the group is still in active use, force next call to .get() to create a new group; otherwise, this is a no-op.


Return current AAF group ID and name.

OUT_OF_CAPACITY_ERRMSG = 'There are not enough hosts available.'

Fault message from OpenStack API indicating AAF group full.


Retrieves all IP addresses associated to a given instance.

Returns:tuple (IPs)

Checks if the instance is up and running.

Parameters:instance_id (str) – instance identifier
Returns:bool - True if running, False otherwise

Pauses the instance - retaining disks and configuration.

Parameters:instance_id (str) – instance identifier
Returns:dict - Dictionary of configuration required to restart instance.

Restart an instance from a dictionary of configuration.

Parameters:instance_config (dict) – Dictionary of configuration returned from pause_instance()
Returns:str - instance_id
start_instance(key_name, public_key_path, private_key_path, security_group, flavor, image_id, image_userdata, cluster_name, username=None, node_name=None, **kwargs)[source]

Starts a new instance on the cloud using the given properties. The following tasks are done to start an instance:

  • establish a connection to the cloud web service
  • check ssh keypair and upload it if it does not yet exist. This is a locked process, since this function might be called in multiple threads and we only want the key to be stored once.
  • check if the security group exists
  • run the instance with the given properties
  • key_name (str) – name of the ssh key to connect
  • public_key_path (str) – path to ssh public key
  • private_key_path (str) – path to ssh private key
  • security_group (str) – firewall rule definition to apply on the instance
  • flavor (str) – machine type to use for the instance
  • image_id (str) – image type (os) to use for the instance
  • image_userdata (str) – command to execute after startup
  • username (str) – username for the given ssh key, default None

str - instance id of the started instance


Destroy a VM.

Parameters:node (Node) – A Node instance.

Return local state which is relevant for the cluster setup process.