elasticluster.providers.ec2_boto¶
-
class
elasticluster.providers.ec2_boto.
BotoCloudProvider
(ec2_url, ec2_region, ec2_access_key=None, ec2_secret_key=None, vpc=None, storage_path=None, request_floating_ip=False, instance_profile=None, price=0.0, timeout=0)[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
- instance_profile (str) – Instance profile with IAM role permissions
- price (int) – Spot instance price (if 0, do not use spot instances); used as a default in start_instance:py:meth
- price – Timeout waiting for spot instances (only used if price > 0); used as a default in start_instance:py:meth
-
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
-
pause_instance
(instance_id)[source]¶ Pauses the instance - retaining disks and configuration.
Parameters: instance_id (str) – instance identifier Returns: dict - Dictionary of configuration required to restart instance.
-
resume_instance
(instance_state)[source]¶ 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, network_ids=None, price=None, timeout=None, boot_disk_device=None, boot_disk_size=None, boot_disk_type=None, boot_disk_iops=None, placement_group=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
- price (int) – Spot instance price (if 0, do not use spot instances).
- price – Timeout (in seconds) waiting for spot instances; only used if price > 0.
- boot_disk_device (str) – Root volume device path if not /dev/sda1
- boot_disk_size (str) – Target size, in GiB, for the root volume
- boot_disk_type (str) – Type of root volume (standard, gp2, io1)
- boot_disk_iops (str) – Provisioned IOPS for the root volume
- placement_group (str) – Enable low-latency networking between compute nodes.
Returns: str - instance id of the started instance