Launch Module

Handle the instance: * Launch new instance with spot request * Terminate instance * Check instance connectivity

launch.check_spot_price(client, config)[source]
Check the current spot price on the selected amazon region of the instance type choosen
and compare with the one provided by the user
Parameters:
  • client – the ec2 client
  • config – the configuration dictionary of the user
Returns:

Exit if the spot price of the user is too low (< current price + 20%)

launch.launch(client, num_instance, config)[source]

Launch num_instance on Amazon EC2 with spot request

Parameters:
  • client – the ec2 client
  • num_instance – number of instance to launch
  • config – the configuration dictionary of the user
Returns:

the list of spot request’s ids

launch.ping(host, port)[source]

Ping the port of the host

Parameters:
  • host – the host to ping
  • port – the port of the host to ping
Returns:

the port if the port is open or False if there is a connection error

launch.query_yes_no(question, default='yes')[source]

Ask a yes/no question via raw_input() and return their answer.

Parameters:
  • question – is a string that is presented to the user.
  • default – is the presumed answer if the user just hits <Enter>. It must be “yes” (the default), “no” or None (meaning an answer is required of the user).
Returns:

The “answer” return value is True for “yes” or False for “no”.

launch.terminate(client, spot_request_ids, instance_ids)[source]

Delete all the spot_request_ids and terminate al the instance_ids

Parameters:
  • client – the ec2 client
  • spot_request_ids – id of all the spot instance request to delete
  • instance_ids – id of all the instance to terminate
Returns:

launch.wait_for_fulfillment(client, request_ids, pending_request_ids)[source]

Wait that all the spot instance request are fulfilled

Parameters:
  • client – the ec2 client
  • request_ids – id of all the spot instance request to fulfill
  • pending_request_ids – id of the remaining spot instance request to fulfill
Returns:

Exit when all the spot request are fulfilled

launch.wait_for_running(client, instance_ids, pending_instance_ids)[source]

Wait that all the instance are in running state

Parameters:
  • client – the ec2 client
  • instance_ids – id of all the instance to check running
  • pending_instance_ids – id of the remaining instance to check running
Returns:

Exit when all the instance are running

launch.wait_ping(client, instance_ids, pending_instance_ids)[source]

Wait that all the instance have open the ssh port (22)

Parameters:
  • client – the ec2 client
  • instance_ids – id of all the instance to ping
  • pending_instance_ids – id of the remaining instance to ping
Returns:

Exit when all the instance are reachable on port 22