Package starcluster :: Module awsutils :: Class EasyEC2
[hide private]
[frames] | no frames]

Class EasyEC2

source code


Instance Methods [hide private]
 
__init__(self, aws_access_key_id, aws_secret_access_key, aws_ec2_path='/', aws_s3_host=None, aws_s3_path='/', aws_port=None, aws_region_name=None, aws_is_secure=True, aws_region_host=None, **kwargs)
Create an EasyAWS object.
source code
 
__repr__(self)
repr(x)
source code
 
connect_to_region(self, region_name)
Connects to a given region if it exists, raises RegionDoesNotExist otherwise.
source code
 
get_region(self, region_name)
Returns boto Region object if it exists, raises RegionDoesNotExist otherwise.
source code
 
list_regions(self)
Print name/endpoint for all AWS regions
source code
 
get_registered_image(self, image_id) source code
 
create_group(self, name, description, auth_ssh=False, auth_group_traffic=False)
Create security group with name/description.
source code
 
get_all_security_groups(self, groupnames=[])
Returns all security groups
source code
 
get_group_or_none(self, name)
Returns group with name if it exists otherwise returns None
source code
 
get_or_create_group(self, name, description, auth_ssh=True, auth_group_traffic=False)
Try to return a security group by name.
source code
 
get_security_group(self, groupname) source code
 
get_security_groups(self, filters=None)
Returns all security groups on this EC2 account
source code
 
get_permission_or_none(self, group, ip_protocol, from_port, to_port, cidr_ip=None)
Returns the rule with the specified port range permission (ip_protocol, from_port, to_port, cidr_ip) defined or None if no such rule exists
source code
 
has_permission(self, group, ip_protocol, from_port, to_port, cidr_ip)
Checks whether group has the specified port range permission (ip_protocol, from_port, to_port, cidr_ip) defined
source code
 
create_placement_group(self, name)
Create a new placement group for your account.
source code
 
get_placement_groups(self, filters=None) source code
 
get_placement_group(self, groupname=None) source code
 
get_placement_group_or_none(self, name)
Returns placement group with name if it exists otherwise returns None
source code
 
get_or_create_placement_group(self, name)
Try to return a placement group by name.
source code
 
request_instances(self, image_id, price=None, instance_type='m1.small', min_count=1, max_count=1, count=1, key_name=None, security_groups=None, launch_group=None, availability_zone_group=None, placement=None, user_data=None, placement_group=None)
Convenience method for running spot or flat-rate instances
source code
 
request_spot_instances(self, price, image_id, instance_type='m1.small', count=1, launch_group=None, key_name=None, availability_zone_group=None, security_groups=None, placement=None, user_data=None) source code
 
run_instances(self, image_id, instance_type='m1.small', min_count=1, max_count=1, key_name=None, security_groups=None, placement=None, user_data=None, placement_group=None) source code
 
create_image(self, instance_id, name, description=None, no_reboot=False) source code
 
register_image(self, name, description=None, image_location=None, architecture=None, kernel_id=None, ramdisk_id=None, root_device_name=None, block_device_map=None) source code
 
delete_keypair(self, name) source code
 
create_keypair(self, name, output_file=None)
Create a new EC2 keypair and optionally save to output_file
source code
 
get_keypairs(self, filters={}) source code
 
get_keypair(self, keypair) source code
 
get_keypair_or_none(self, keypair) source code
 
__print_header(self, msg) source code
 
get_image_name(self, img) source code
 
get_instance_user_data(self, instance_id) source code
 
get_all_instances(self, instance_ids=[], filters=None) source code
 
get_instance(self, instance_id) source code
 
is_valid_conn(self) source code
 
get_all_spot_requests(self, spot_ids=[], filters=None) source code
 
list_all_spot_instances(self, show_closed=False) source code
 
show_instance(self, instance) source code
 
list_all_instances(self, show_terminated=False) source code
 
list_images(self, images, sort_key=None, reverse=False) source code
 
list_registered_images(self) source code
 
list_executable_images(self) source code
 
__list_images(self, msg, imgs) source code
 
remove_image_files(self, image_name, pretend=True) source code
 
remove_image(self, image_name, pretend=True, keep_image_data=True) source code
 
list_starcluster_public_images(self) source code
 
create_volume(self, size, zone, snapshot_id=None) source code
 
remove_volume(self, volume_id) source code
 
list_keypairs(self) source code
 
list_zones(self, region=None) source code
 
get_zones(self, filters=None) source code
 
get_zone(self, zone)
Return zone object respresenting an EC2 availability zone Raises exception.ZoneDoesNotExist if not successful
source code
 
get_zone_or_none(self, zone)
Return zone object respresenting an EC2 availability zone Returns None if unsuccessful
source code
 
create_s3_image(self, instance_id, key_location, aws_user_id, ec2_cert, ec2_private_key, bucket, image_name='image', description=None, kernel_id=None, ramdisk_id=None, remove_image_files=False, **kwargs)
Create instance-store (S3) image from running instance
source code
 
create_ebs_image(self, instance_id, key_location, name, description=None, snapshot_description=None, kernel_id=None, ramdisk_id=None, root_vol_size=15, **kwargs)
Create EBS-backed image from running instance
source code
 
get_images(self, filters=None) source code
 
get_image(self, image_id)
Return image object representing an AMI.
source code
 
get_image_or_none(self, image_id)
Return image object representing an AMI.
source code
 
get_image_files(self, image)
Returns a list of files on S3 for an EC2 instance-store (S3-backed) image.
source code
 
get_image_bucket(self, image) source code
 
get_image_manifest(self, image) source code
 
migrate_image(self, image_id, destbucket, migrate_manifest=False, kernel_id=None, ramdisk_id=None, region=None, cert=None, private_key=None)
Migrate image_id files to destbucket
source code
 
create_root_block_device_map(self, snapshot_id, root_device_name='/dev/sda1', add_ephemeral_drives=False, ephemeral_drive_0='/dev/sdb1', ephemeral_drive_1='/dev/sdc1', ephemeral_drive_2='/dev/sdd1', ephemeral_drive_3='/dev/sde1')
Utility method for building a new block_device_map for a given snapshot id.
source code
 
download_image_files(self, image_id, destdir)
Downloads the manifest.xml and all AMI parts for image_id to destdir
source code
 
list_image_files(self, image_id)
Print a list of files for image_id to the screen
source code
 
terminate_instances(self, instances=None) source code
 
get_volumes(self, filters=None)
Returns a list of all EBS volumes
source code
 
get_volume(self, volume_id)
Returns EBS volume object representing volume_id.
source code
 
get_volume_or_none(self, volume_id)
Returns EBS volume object representing volume_id.
source code
 
wait_for_snapshot(self, snapshot, refresh_interval=30) source code
 
create_snapshot(self, vol, description=None, wait_for_snapshot=False, refresh_interval=30) source code
 
get_snapshots(self, volume_ids=[], filters=None, owner='self')
Returns a list of all EBS volume snapshots
source code
 
get_snapshot(self, snapshot_id, owner='self')
Returns EBS snapshot object for snapshot_id.
source code
 
list_volumes(self, volume_id=None, status=None, attach_status=None, size=None, zone=None, snapshot_id=None, show_deleted=False, tags=None, name=None)
Print a list of volumes to the screen
source code
 
get_spot_history(self, instance_type, start=None, end=None, plot=False, plot_server_interface='localhost', plot_launch_browser=True, plot_web_browser=None, plot_shutdown_server=True) source code
 
show_console_output(self, instance_id) source code

Inherited from EasyAWS: reload

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]
  region
Returns the current EC2 region used by this EasyEC2 object
  regions
This property returns all AWS Regions, caching the results the first time a request is made to Amazon
  registered_images
  executable_images
  instances
  keypairs

Inherited from EasyAWS: conn

Inherited from object: __class__

Method Details [hide private]

__init__(self, aws_access_key_id, aws_secret_access_key, aws_ec2_path='/', aws_s3_host=None, aws_s3_path='/', aws_port=None, aws_region_name=None, aws_is_secure=True, aws_region_host=None, **kwargs)
(Constructor)

source code 

Create an EasyAWS object.

Requires aws_access_key_id/aws_secret_access_key from an Amazon Web Services (AWS) account and a connection_authenticator function that returns an authenticated AWS connection object

Providing only the keys will default to using Amazon EC2

kwargs are passed to the connection_authenticator's constructor

Overrides: object.__init__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

connect_to_region(self, region_name)

source code 

Connects to a given region if it exists, raises RegionDoesNotExist otherwise. Once connected, this object will return only data from the given region.

create_group(self, name, description, auth_ssh=False, auth_group_traffic=False)

source code 

Create security group with name/description. auth_ssh=True will open port 22 to world (0.0.0.0/0). auth_group_traffic will allow all traffic between instances in the same security group

get_all_security_groups(self, groupnames=[])

source code 

Returns all security groups

groupnames - optional list of group names to retrieve

get_or_create_group(self, name, description, auth_ssh=True, auth_group_traffic=False)

source code 

Try to return a security group by name. If the group is not found,
attempt to create it.  Description only applies to creation.

auth_ssh - authorize ssh traffic from world
auth_group_traffic - authorizes all traffic between members of the
                     group

create_placement_group(self, name)

source code 

Create a new placement group for your account. This will create the placement group within the region you are currently connected to.

get_or_create_placement_group(self, name)

source code 

Try to return a placement group by name. If the group is not found, attempt to create it.

create_keypair(self, name, output_file=None)

source code 

Create a new EC2 keypair and optionally save to output_file

Returns boto.ec2.keypair.KeyPair

remove_image(self, image_name, pretend=True, keep_image_data=True)

source code 
Decorators:
  • @print_timing("Removing image")

get_image(self, image_id)

source code 

Return image object representing an AMI. Raises exception.AMIDoesNotExist if unsuccessful

get_image_or_none(self, image_id)

source code 

Return image object representing an AMI. Returns None if unsuccessful

get_image_files(self, image)

source code 

Returns a list of files on S3 for an EC2 instance-store (S3-backed) image. This includes the image's manifest and part files.

migrate_image(self, image_id, destbucket, migrate_manifest=False, kernel_id=None, ramdisk_id=None, region=None, cert=None, private_key=None)

source code 

Migrate image_id files to destbucket

Decorators:
  • @print_timing("Migrating image")

create_root_block_device_map(self, snapshot_id, root_device_name='/dev/sda1', add_ephemeral_drives=False, ephemeral_drive_0='/dev/sdb1', ephemeral_drive_1='/dev/sdc1', ephemeral_drive_2='/dev/sdd1', ephemeral_drive_3='/dev/sde1')

source code 

Utility method for building a new block_device_map for a given snapshot id. This is useful when creating a new image from a volume snapshot. The returned block device map can be used with self.register_image

download_image_files(self, image_id, destdir)

source code 

Downloads the manifest.xml and all AMI parts for image_id to destdir

Decorators:
  • @print_timing("Downloading image")

get_volume(self, volume_id)

source code 

Returns EBS volume object representing volume_id. Raises exception.VolumeDoesNotExist if unsuccessful

get_volume_or_none(self, volume_id)

source code 

Returns EBS volume object representing volume_id. Returns None if unsuccessful

get_snapshot(self, snapshot_id, owner='self')

source code 

Returns EBS snapshot object for snapshot_id.

Raises exception.SnapshotDoesNotExist if unsuccessful


Property Details [hide private]

region

Returns the current EC2 region used by this EasyEC2 object

Get Method:
unreachable.region(self) - Returns the current EC2 region used by this EasyEC2 object

regions

This property returns all AWS Regions, caching the results the first time a request is made to Amazon

Get Method:
unreachable.regions(self) - This property returns all AWS Regions, caching the results the first time a request is made to Amazon

registered_images

Get Method:
unreachable.registered_images(self)

executable_images

Get Method:
unreachable.executable_images(self)

instances

Get Method:
unreachable.instances(self)

keypairs

Get Method:
unreachable.keypairs(self)