elasticluster.providers.ec2_boto

class elasticluster.providers.ec2_boto.BotoCloudProvider(ec2_url, ec2_region, ec2_access_key, ec2_secret_key, storage_path=None, request_floating_ip=False)[source]

This implementation of elasticluster.providers.AbstractCloudProvider uses the boto ec2 interface to connect to ec2 compliant clouds and manage instances.

Please check https://github.com/boto/boto for further information about the supported cloud platforms.

Parameters:
  • ec2_url (str) – url to connect to cloud web service
  • ec2_region (str) – region identifier
  • ec2_access_key (str) – access key of the user account
  • ec2_secret_key (str) – secret key of the user account
  • 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
get_ips(instance_id)[source]

Retrieves the private and public ip addresses for a given instance.

Returns:list (ips)
is_instance_running(instance_id)[source]

Checks if the instance is up and running.

Parameters:instance_id (str) – instance identifier
Returns:bool - True if running, False otherwise
start_instance(key_name, public_key_path, private_key_path, security_group, flavor, image_id, image_userdata, 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
Parameters:
  • 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
Returns:

str - instance id of the started instance

stop_instance(instance_id)[source]

Stops the instance gracefully.

Parameters:instance_id (str) – instance identifier