Eutester 0.0.6 documentation

eucaops Package

Contents

eucaops Package

eucaops Package

class eucaops.Eucaops(config_file=None, password=None, keypath=None, credpath=None, aws_access_key_id=None, aws_secret_access_key=None, account='eucalyptus', user='admin', username=None, APIVersion='2010-08-31', region=None, ec2_ip=None, s3_ip=None, download_creds=True, boto_debug=0)[source]

Bases: eucaops.ec2ops.EC2ops, eucaops.s3ops.S3ops, eucaops.iamops.IAMops, eucaops.stsops.STSops

cleanup_artifacts()[source]
create_credentials(admin_cred_dir, account, user)[source]
download_creds_from_clc(admin_cred_dir)[source]
get_available_vms(type=None, zone=None)[source]

Get available VMs of a certain type or return a dictionary with all types and their available vms type VM type to get available vms

get_component_ip(component)[source]

Parse the machine list and a bm_machine object for a machine that matches the component passed in

get_component_machines(component)[source]

Parse the machine list and a list of bm_machine objects that match the component passed in

get_credentials(account='eucalyptus', user='admin')[source]

Login to the CLC and download credentials programatically for the user and account passed in Defaults to admin@eucalyptus

get_current_resources(verbose=False)[source]

Return a dictionary with all known resources the system has. Optional pass the verbose=True flag to print this info to the logs Included resources are: addresses, images, instances, key_pairs, security_groups, snapshots, volumes, zones

get_machine_by_ip(hostname)[source]
get_network_mode()[source]
modify_property(property, value)[source]

Modify a eucalyptus property through the command line euca-modify-property tool property Property to modify value Value to set it too

read_config(filepath, username='root')[source]

Parses the config file at filepath returns a dictionary with the config Config file ———- The configuration file for (2) private cloud mode has the following structure:

clc.mydomain.com CENTOS 5.7 64 REPO [CC00 CLC SC00 WS] nc1.mydomain.com VMWARE ESX-4.0 64 REPO [NC00]
IP or hostname of machine Distro installed on machine - Options are RHEL, CENTOS, UBUNTU additionally VMWARE can be used for NCs Distro version on machine - RHEL (5.x, 6.x), CentOS (5.x), UBUNTU (LUCID) Distro base architecture - 32 or 64 System built from packages (REPO) or source (BZR), packages assumes path to eucalyptus is /, bzr assumes path to eucalyptus is /opt/eucalyptus List of components installed on this machine encapsulated in brackets []

These components can be:

CLC - Cloud Controller WS - Walrus SC00 - Storage controller for cluster 00 CC00 - Cluster controller for cluster 00 NC00 - A node controller in cluster 00
send_creds_to_machine(admin_cred_dir, machine)[source]
setup_local_creds_dir(admin_cred_dir)[source]
setup_remote_creds_dir(admin_cred_dir)[source]
swap_clc()[source]
swap_component_hostname(hostname)[source]
swap_walrus()[source]
sys(cmd, verbose=True, listformat=True, timeout=120, code=None)[source]

By default will run a command on the CLC machine, the connection used can be changed by passing a different hostname into the constructor For example: instance = Eutester( hostname=instance.ip_address, keypath=”my_key.pem”) instance.sys(“mount”) # check mount points on instance and return the output as a list

ec2ops Module

class eucaops.ec2ops.EC2ops(host=None, credpath=None, endpoint=None, aws_access_key_id=None, aws_secret_access_key=None, username='root', region=None, is_secure=False, path='/', port=80, boto_debug=0, APIVersion='2012-07-20')[source]

Bases: eutester.Eutester

add_group(group_name=None, fail_if_exists=False)[source]

Add a security group to the system with name group_name, if it exists dont create it

Parameters:
  • group_name – Name of the security group to create
  • fail_if_exists – IF set, will fail if group already exists, otherwise will return the existing group
Returns:

boto group object upon success or None for failure

add_keypair(key_name=None)[source]

Add a keypair with name key_name unless it already exists

Parameters:key_name – The name of the keypair to add and download.
allocate_address()[source]

Allocate an address for the current user

Returns:boto.ec2.address object allocated
associate_address(instance, address, timeout=75)[source]

Associate an address object with an instance

Parameters:
  • instance – instance object to associate ip with
  • address – address to associate to instance
  • timeout – Time in seconds to wait for operation to complete
Raise :

Exception in case of association failure

attach_volume(instance, volume, device_path, pause=10, timeout=120)[source]

Attach a volume to an instance

Parameters:
  • instance – instance object to attach volume to
  • volume – volume object to attach
  • device_path – device name to request on guest
  • pause – Time in seconds to wait before checking volume state
  • timeout – Total time in seconds to wait for volume to reach the attached state
Returns:

Raise :

Exception of failure to reach proper state or enter previous state

authorize_group(group, port=22, protocol='tcp', cidr_ip='0.0.0.0/0')[source]

Authorize the boto.group object

Parameters:
  • group – boto.group object
  • port – Port to open, default=22
  • protocol – Protocol to authorize, default=tcp
  • cidr_ip – CIDR subnet to authorize, default=”0.0.0.0/0” everything
Returns:

True on success

Raise :

Exception if operation fails

authorize_group_by_name(group_name='default', port=22, protocol='tcp', cidr_ip='0.0.0.0/0')[source]

Authorize the group with group_name

Parameters:
  • group_name – Name of the group to authorize, default=”default”
  • port – Port to open, default=22
  • protocol – Protocol to authorize, default=tcp
  • cidr_ip – CIDR subnet to authorize, default=”0.0.0.0/0” everything
Returns:

check_device(device_path)[source]

Used with instance connections. Checks if a device at a certain path exists

Parameters:device_path – Path to check
Returns:bool, if device was found
check_group(group_name)[source]

Check if a group with group_name exists in the system

Parameters:group_name – Group name to check for existence
Returns:bool whether operation succeeded
check_system_for_dup_ip(instances=None)[source]

Check system for instances with conflicting duplicate IPs. Will raise exception at end of iterating through all running, pending, or starting instances with info as to which instances and IPs conflict. If a list of instances is provided, all other conflicting IPS will be ignored and will only raise an exception for conflicts with the provided instance ‘inst’

convert_reservation_to_euinstance(reservation, username='root', password=None, keyname=None, timeout=60)[source]

Convert all instances in an entire reservation into eutester.euinstance.Euinstance objects.

Parameters:
  • reservation – reservation object to use in conversion
  • username – SSH user name of instance
  • password – SSH password
  • keyname – Private key file to use when connecting to the instance
  • timeout – Time in seconds to wait for successful SSH connection
Returns:

create_snapshot(volume_id, wait_on_progress=20, poll_interval=10, timeout=0, description='')[source]

Create a new single EBS snapshot from an existing volume id then wait for it to go to the created state. By default will poll for poll_count. If wait_on_progress is specified than will wait on “wait_on_progress” overrides # of poll_interval periods, using wait_on_progress # of periods of poll_interval length in seconds w/o progress before failing. If volume.id is passed, euvolume data will not be transfered to snapshot created.

Parameters:
  • volume – (mandatory string) Volume id of the volume to create snapshot from
  • wait_on_progress – (optional string) string used to describe the snapshot
  • poll_interval – (optional integer) # of poll intervals to wait while 0 progress is made before exiting, overrides “poll_count” when used
  • timeout – (optional integer) time to sleep between polling snapshot status
  • description – (optional integer) over all time to wait before exiting as failure
Returns:

EuSnapshot

create_snapshot_from_volume(volume, wait_on_progress=20, poll_interval=10, timeout=0, description='')[source]

Create a new EBS snapshot from an existing volume then wait for it to go to the created state. By default will poll for poll_count. If wait_on_progress is specified than will wait on “wait_on_progress” overrides # of poll_interval periods, using wait_on_progress # of periods of poll_interval length in seconds w/o progress before failing. If volume.id is passed, euvolume data will not be transfered to snapshot created.

Parameters:
  • volume – (mandatory Volume) Volume id of the volume to create snapshot from
  • wait_on_progress – (optional string) string used to describe the snapshot
  • poll_interval – (optional integer) # of poll intervals to wait while 0 progress is made before exiting, overrides “poll_count” when used
  • timeout – (optional integer) time to sleep between polling snapshot status
  • description – (optional integer) over all time to wait before exiting as failure
Returns:

EuSnapshot

create_snapshots(volume, count=1, mincount=None, eof=True, delay=0, wait_on_progress=20, poll_interval=10, timeout=0, monitor_to_completed=True, delete_failed=True, description='Created by eutester')[source]

Create a new EBS snapshot from an existing volume then wait for it to go to the created state. By default will poll for poll_count. If wait_on_progress is specified than will wait on “wait_on_progress” overrides # of poll_interval periods, using wait_on_progress # of periods of poll_interval length in seconds w/o progress before failing

Parameters:
  • volume – (mandatory Volume object) Volume to create snapshot from
  • mincount – (optional Integer) Specify the min success count, defaults to ‘count’
  • eof – (optional boolean) End on failure.If true will end on first failure, otherwise will continue to try and fufill mincount
  • wait_on_progress – (optional integer) # of poll intervals to wait while 0 progress is made before exiting, overrides “poll_count” when used
  • poll_interval – (optional integer) time to sleep between polling snapshot status
  • monitor_to_completed – (optional boolean) If true will monitor created snapshots to the completed state, else return a list of created snaps
  • timeout – (optional integer) over all time to wait before exiting as failure
  • delete_failed – (optional boolean) automatically delete failed volumes
  • description – (optional string) string used to describe the snapshot
Parram count:

(optional Integer) Specify how many snapshots to attempt to create

Returns:

EuSnapshot list

create_snapshots_from_vol_id(volume_id, count=1, mincount=None, eof=True, delay=0, wait_on_progress=20, poll_interval=10, timeout=0, description='')[source]

Create a new EBS snapshot from an existing volume’ string then wait for it to go to the created state. By default will poll for poll_count. If wait_on_progress is specified than will wait on “wait_on_progress” overrides # of poll_interval periods, using wait_on_progress # of periods of poll_interval length in seconds w/o progress before failing

Parameters:
  • volume_id – (mandatory string) Volume id of the volume to create snapshot from
  • mincount – (optional Integer) Specify the min success count, defaults to ‘count’
  • eof – (optional boolean) End on failure.If true will end on first failure, otherwise will continue to try and fufill mincount
  • wait_on_progress – (optional string) string used to describe the snapshot
  • poll_interval – (optional integer) # of poll intervals to wait while 0 progress is made before exiting, overrides “poll_count” when used
  • timeout – (optional integer) time to sleep between polling snapshot status
  • description – (optional integer) over all time to wait before exiting as failure
Parram count:

(optional Integer) Specify how many snapshots to attempt to create

Returns:

EuSnapshot list

create_tags(resource_ids, tags)[source]

Add tags to the given resource

Parameters:
  • resource_ids – List of resources IDs to tag
  • tags – Dict of key value pairs to add, for just a name include a key with a ‘’ value
create_volume(azone, size=1, eof=True, snapshot=None, timeout=0, poll_interval=10, timepergig=120)[source]

Create a new EBS volume then wait for it to go to available state, size or snapshot is mandatory

Parameters:
  • azone – Availability zone to create the volume in
  • size – Size of the volume to be created
  • count – Number of volumes to be created
  • eof – Boolean, indicates whether to end on first instance of failure
  • snapshot – Snapshot to create the volume from
  • timeout – Time to wait before failing. timeout of 0 results in size of volume * timepergig seconds
  • poll_interval – How often in seconds to poll volume state
  • timepergig – Time to wait per gigabyte size of volume, used when timeout is set to 0
Returns:

create_volumes(azone, size=1, count=1, mincount=None, eof=True, monitor_to_state='available', delay=0, snapshot=None, timeout=0, poll_interval=10, timepergig=120)[source]
Definition:
Create a multiple new EBS volumes then wait for them to go to available state, size or snapshot is mandatory
Parameters:
  • azone – Availability zone to create the volume in
  • size – Size of the volume to be created
  • count – Number of volumes to be created
  • mincount – Minimum number of volumes to be created to be considered a success.Default = ‘count’
  • eof – Boolean, indicates whether to end on first instance of failure
  • monitor_to_state – String, if not ‘None’ will monitor created volumes to the provided state
  • snapshot – Snapshot to create the volume from
  • timeout – Time to wait before failing. timeout of 0 results in size of volume * timepergig seconds
  • poll_interval – How often in seconds to poll volume state
  • timepergig – Time to wait per gigabyte size of volume, used when timeout is set to 0
Returns:

list of volumes

delete_all_volumes()[source]

Deletes all volumes on the cloud

delete_group(group)[source]

Delete the group object passed in and check that it no longer shows up

Parameters:group – Group object to delete and check
Returns:bool whether operation succeeded
delete_keypair(keypair)[source]

Delete the keypair object passed in and check that it no longer shows up

Parameters:keypair – Keypair object to delete and check
Returns:boolean of whether the operation succeeded
delete_snapshot(snapshot, timeout=60)[source]

Delete the snapshot object

Parameters:
  • snapshot – boto.ec2.snapshot object to delete
  • timeout – Time in seconds to wait for deletion
delete_snapshots(snapshots, valid_states='completed, failed', base_timeout=60, add_time_per_snap=10, wait_for_valid_state=120, poll_interval=10, eof=False)[source]
delete_tags(resource_ids, tags)[source]

Add tags to the given resource

Parameters:
  • resource_ids – List of resources IDs to tag
  • tags – Dict of key value pairs to add, for just a name include a key with a ‘’ value
delete_volume(volume, poll_interval=10, timeout=120)[source]

Delete the EBS volume then check that it no longer exists

Parameters:volume – Volume object to delete
Returns:bool, success of the operation
delete_volumes(volume_list, poll_interval=10, timeout=120)[source]

Deletes a list of EBS volumes then checks for proper state transition

Parameters:
  • volume_list – List of volume objects to be deleted
  • poll_interval – integer, seconds between polls on volumes’ state
  • timeout – integer time allowed before this method fails
deregister_image(image, clear=False)[source]

Deregister an image.

Parameters:image – boto image object to deregister
detach_volume(volume, pause=10, timeout=60)[source]

Detach a volume

Parameters:
  • volume – volume to detach
  • pause – Time in seconds to wait before checking volume state
  • timeout – Total time in seconds to wait for volume to reach the attached state
Returns:

True on success

disassociate_address_from_instance(instance, timeout=75)[source]

Disassociate address from instance and ensure that it no longer holds the IP

Parameters:
  • instance – An instance that has an IP allocated
  • timeout – Time in seconds to wait for address to disassociate
Raise :
does_instance_sec_group_allow(instance, src_addr=None, protocol='tcp', port=22)[source]
does_sec_group_allow(group, src, protocol='tcp', port=22)[source]

Test whether a security group will allow traffic from a specific ‘src’ ip address to a specific ‘port’ using a specific ‘protocol’

get_all_allocated_addresses(account_id=None)[source]

Return all allocated addresses for a given account_id as boto.ec2.address objects

Parameters:account_id – account number to filter on
Returns:list of boto.ec2.address objects
get_all_attributes(obj, verbose=True)[source]

Get a formatted list of all the key pair values pertaining to the object ‘obj’

Parameters:
  • obj – Object to extract information from
  • verbose – Print key value pairs
Returns:

Buffer of key value pairs

get_all_current_local_keys(path=None, exten='.pem')[source]

Convenience function to provide a list of all keys in the local dir at ‘path’ that exist on the server to help avoid producing additional keys in test dev.

Parameters:
  • path – Filesystem path to search in
  • exten – extension of private key file
Returns:

list of key names

get_available_addresses()[source]

Get all available addresses

Returns:a list of all available boto.ec2.address
get_connectable_euinstances(path=None, username='root', password=None, connect=True)[source]

Convenience method, returns a list of all running instances, for the current creduser for which there are local keys at ‘path’

Parameters:
  • path – Path to look for private keys
  • username – username to use if path is not pfassed
  • password – password to use if path is not passed
  • connect – bool, Whether to create an ssh connection to the instances
Returns:

classmethod get_datetime_from_resource_string(timestamp)[source]

Convert a typical resource timestamp to datetime time_struct.

Parameters:timestamp (string) – Timestamp held within specific boto resource objects.Example timestamp format: 2012-09-19T21:24:03.864Z
Return type:time_struct
Returns:The time_struct representation of the timestamp provided.
get_emi(emi=None, root_device_type=None, root_device_name=None, location=None, state='available', arch=None, owner_id=None, not_location=None)[source]

Get an emi with name emi, or just grab any emi in the system. Additional ‘optional’ match criteria can be defined.

Parameters:
  • emi – Partial ID of the emi to return, defaults to the ‘emi-” prefix to grab any
  • root_device_type – example: ‘instance-store’ or ‘ebs’
  • root_device_name – example: ‘/dev/sdb’
  • location – partial on location match example: ‘centos’
  • state – example: ‘available’
  • arch – example: ‘x86_64’
  • owner_id – owners numeric id
  • not_location – skip if location string matches this string. Example: not_location=’windows’
Returns:

image id

Raise :

Exception if image is not found

get_instance_security_groups(instance)[source]
classmethod get_instance_time_launched(instance)[source]

Get the seconds elapsed since the volume was attached.

Parameters:volume (boto volume object) – The volume used to calculate the elapsed time since attached.
Return type:integer
Returns:The number of seconds elapsed since this volume was attached.
get_instances(state=None, idstring=None, reservation=None, rootdevtype=None, zone=None, key=None, pubip=None, privip=None, ramdisk=None, kernel=None, image_id=None)[source]

Return a list of instances matching the filters provided.

Parameters:
  • state – str of desired state
  • idstring – instance-id string
  • reservation – reservation-id
  • rootdevtype – ‘instance-store’ or ‘ebs’
  • zone – Availablity zone
  • key – Keypair the instance was launched with
  • pubip – Instance public IP
  • privip – Instance private IP
  • ramdisk – Ramdisk ID string
  • kernel – Kernel ID string
  • image_id – Image ID string
Returns:

list of instances

get_keypair(name)[source]

Retrieve a boto.ec2.keypair object by its name

Parameters:name – Name of keypair on the cloud
Returns:boto.ec2.keypair object
Raise :Exception on failure to find keypair
get_reservation_for_instance(instance)[source]
get_snapshot(snapid=None)[source]
classmethod get_snapshot_time_started(snapshot)[source]

Get the seconds elapsed since the snapshot was started.

Parameters:snapshot (boto snapshot object) – The volume used to calculate the elapsed time since started.
Return type:integer
Returns:The number of seconds elapsed since this snapshot was started.
get_snapshots(snapid=None, volume_id=None, volume_size=None, volume_md5=None, maxcount=None, owner_id=None)[source]
get_traceback()[source]

Returns a string buffer with traceback, to be used for debug/info purposes.

get_volume(volume_id='vol-', status=None, attached_instance=None, attached_dev=None, snapid=None, zone=None, minsize=1, maxsize=None, eof=True)[source]

Return first volume that matches the criteria.

Parameters:
  • volume_id – string present within volume id
  • status – examples: ‘in-use’, ‘creating’, ‘available’
  • attached_instance – instance id example ‘i-1234abcd’
  • attached_dev – example ‘/dev/sdf’
  • snapid – snapshot volume was created from example ‘snap-1234abcd’
  • zone – zone of volume example ‘PARTI00’
  • minsize – minimum size of volume to be matched
  • maxsize – maximum size of volume to be matched
  • eof – exception on failure to find volume, else returns None
Returns:

List of volumes matching the filters provided

Raise :
get_volume_time_attached(volume)[source]

Get the seconds elapsed since the volume was attached.

Parameters:volume (boto volume object) – The volume used to calculate the elapsed time since attached.
Return type:integer
Returns:The number of seconds elapsed since this volume was attached.
classmethod get_volume_time_created(volume)[source]

Get the seconds elapsed since the volume was created.

Parameters:volume (boto volume object) – The volume used to calculate the elapsed time since created.
Return type:integer
Returns:The number of seconds elapsed since this volume was created.
get_volumes(volume_id='vol-', status=None, attached_instance=None, attached_dev=None, snapid=None, zone=None, minsize=1, maxsize=None, md5=None, eof=False)[source]

Return list of volumes that matches the criteria. Criteria options to be matched:

Parameters:
  • volume_id – string present within volume id
  • status – examples: ‘in-use’, ‘creating’, ‘available’
  • attached_instance – instance id example ‘i-1234abcd’
  • attached_dev – example ‘/dev/sdf’
  • snapid – snapshot volume was created from example ‘snap-1234abcd’
  • zone – zone of volume example ‘PARTI00’
  • minsize – minimum size of volume to be matched
  • maxsize – maximum size of volume to be matched
  • eof – exception on failure to find volume, else returns empty list
Returns:

List of volumes matching the filters provided

Raise :
get_windows_instance_password(instance, private_key_path=None, key=None, dir=None, exten='.pem', encoded=True)[source]

Get password for a windows instance.

Parameters:
  • instance – euinstance object
  • private_key_path – private key file used to decrypt password
  • key – name of private key
  • dir – Path to private key
  • exten – extension of private key
  • encoded – boolean of whether string returned from server is Base64 encoded
Returns:

decrypted password

Raise :

Exception when private key cannot be found on filesystem

get_zones()[source]

Return a list of availability zone names.

Returns:list of zone names
classmethod is_address_in_network(ip_addr, network)[source]
monitor_created_euvolumes_to_state(volumes, eof=True, mincount=None, state='available', poll_interval=10, deletefailed=True, size=1, timepergig=120)[source]
Description:
Monitors a list of created volumes until ‘state’ or failure. Allows for a variety of volumes, using differnt
types and creation methods to be monitored by a central method.
Parameters:
  • volumes – list of created volumes
  • eof – boolean, if True will end on first failure
  • mincount – minimum number of successful volumes, else fail
  • state – string indicating the expected state to monitor to
  • deletefailed – delete all failed volumes, in eof case deletes ‘volumes’ list. In non-eof, if mincount is met, will delete any failed volumes.
  • timepergig – integer, time allowed per gig before failing.
monitor_euinstances_to_running(instances, poll_interval=10, timeout=480)[source]
monitor_euinstances_to_state(instance_list, state='running', min=None, poll_interval=10, timeout=120, eof=True)[source]
monitor_eusnaps_to_completed(snaps, mincount=None, eof=True, wait_on_progress=20, poll_interval=10, timeout=0, monitor_to_completed=True, delete_failed=True)[source]

Monitor an EBS snapshot list for snapshots to enter the to the completed state. By default will poll for poll_count. If wait_on_progress is specified than will wait on “wait_on_progress” overrides # of poll_interval periods, using wait_on_progress # of periods of poll_interval length in seconds w/o progress before failing

Parameters:
  • mincount – (optional Integer) Specify the min success count, defaults to length of list provided
  • eof – (optional boolean) End on failure.If true will end on first failure, otherwise will continue to try and fufill mincount
  • wait_on_progress – (optional integer) # of poll intervals to wait while 0 progress is made before exiting, overrides “poll_count” when used
  • poll_interval – (optional integer) time to sleep between polling snapshot status
  • timeout – (optional integer) over all time to wait before exiting as failure
  • delete_failed – (optional boolean) automatically delete failed volumes
Returns:

EuSnapshot list

print_euinstance_list(list)[source]
print_eusnapshot_list(eusnapshots)[source]
print_euvolume_list(euvolumelist)[source]
register_image(image_location, rdn=None, description=None, bdmdev=None, name=None, ramdisk=None, kernel=None)[source]

Register an image based on the s3 stored manifest location

Parameters:
  • image_location
  • rdn – root-device-name for image
  • description – description of image to be registered
  • bdmdev – block-device-mapping object for image
  • name – name of image to be registered
  • ramdisk – ramdisk id
  • kernel – kernel id (note for windows this name should be “windows”)
Returns:

image id string

register_snapshot(snapshot, rdn='/dev/sda1', description='bfebs', windows=False, bdmdev=None, name=None, ramdisk=None, kernel=None, dot=True)[source]

Convience function for passing a snapshot instead of its id. See register_snapshot_by_id

register_snapshot_by_id(snap_id, rdn='/dev/sda1', description='bfebs', windows=False, bdmdev=None, name=None, ramdisk=None, kernel=None, dot=True)[source]

Register an image snapshot

Parameters:
  • snap_id – snapshot id
  • rdn – root-device-name for image
  • description – description of image to be registered
  • windows – Is windows image boolean
  • bdmdev – block-device-mapping device for image
  • name – name of image to be registered
  • ramdisk – ramdisk id
  • kernel – kernel id (note for windows this name should be “windows”)
  • dot – Delete On Terminate boolean
Returns:

emi id of registered image

release_address(address)[source]

Release all addresses or a particular IP

Parameters:address – Address object to release
Raise :Exception when the address does not release
run_image(image=None, keypair=None, group='default', type=None, zone=None, min=1, max=1, user_data=None, private_addressing=False, username='root', password=None, auto_connect=True, clean_on_fail=True, monitor_to_running=True, timeout=480)[source]
run_instance(image=None, keypair=None, group='default', type=None, zone=None, min=1, max=1, user_data=None, private_addressing=False, username='root', password=None, is_reachable=True, timeout=480)[source]

Run instance/s and wait for them to go to the running state

Parameters:
  • image – Image object to use, default is pick the first emi found in the system
  • keypair – Keypair name to use for the instances, defaults to none
  • group – Security group name to apply to this set of instnaces, defaults to none
  • type – VM type to use for these instances, defaults to m1.small
  • zone – Availability zone to run these instances
  • min – Minimum instnaces to launch, default 1
  • max – Maxiumum instances to launch, default 1
  • user_data – User-data string to pass to instance
  • private_addressing – Runs an instance with only private IP address
  • username – username to use when connecting via ssh
  • password – password to use when connecting via ssh
  • is_reachable – Instance can be reached on its public IP (Default=True)
  • timeout – Time in seconds for instance to enter running state
Returns:

Reservation object

Raise :
setup_ec2_connection(endpoint=None, aws_access_key_id=None, aws_secret_access_key=None, is_secure=True, host=None, region=None, path='/', port=443, APIVersion='2012-07-20', boto_debug=0)[source]
setup_ec2_resource_trackers()[source]

Setup keys in the test_resources hash in order to track artifacts created

start_instances(reservation, timeout=480)[source]

Start all instances in a reservation

Parameters:reservation – boto.ec2.reservation object
Raise :Exception when instance does not reach running state
stop_instances(reservation, timeout=480)[source]

Stop all instances in a reservation

Parameters:reservation – boto.ec2.reservation object
Raise :Exception when instance does not reach stopped state
terminate_instances(reservation=None, timeout=480)[source]

Terminate instances in the system

Parameters:reservation – Reservation object to terminate all instances in, default is to terminate all instances
Raise :Exception when instance does not reach terminated state
terminate_single_instance(instance, timeout=300)[source]

Terminate an instance

Parameters:
  • instance – boto.instance object to terminate
  • timeout – Time in seconds to wait for terminated state
Returns:

True on success

verify_local_keypath(keyname, path=None, exten='.pem')[source]

Convenience function to verify if a given ssh key ‘keyname’ exists on the local server at ‘path’

Returns:the keypath if the key is found.
>>> instance= self.get_instances(state='running')[0]
>>> keypath = self.get_local_keypath(instance.key_name)
wait_for_instance(instance, state='running', poll_count=None, timeout=480)[source]

Wait for the instance to enter the state

Parameters:
  • instance – Boto instance object to check the state on
  • state – state that we are looking for
  • poll_count – Number of 10 second poll intervals to wait before failure (for legacy test script support)
  • timeout – Time in seconds to wait before failure
Returns:

True on success

Raise :

Exception when instance does not enter proper state

wait_for_instances_block_dev_mapping(instances, poll_interval=1, timeout=60)[source]
wait_for_reservation(reservation, state='running', timeout=480)[source]

Wait for an entire reservation to enter the state

Parameters:
  • reservation – Boto reservation object to check the state on
  • state – state that we are looking for
  • timeout – How long in seconds to wait for state
Returns:

True on success

wait_for_valid_ip(instances, poll_interval=10, timeout=60)[source]

Wait for instance public DNS name to clear from 0.0.0.0

Parameters:
  • instance – instance object to check
  • timeout – Time in seconds to wait for IP to change
Returns:

True on success

Raise :

Exception if IP stays at 0.0.0.0

iamops Module

class eucaops.iamops.IAMops(credpath=None, endpoint='iam.amazonaws.com', aws_access_key_id=None, aws_secret_access_key=None, is_secure=True, port=443, path='/', boto_debug=0)[source]

Bases: eutester.Eutester

add_user_to_group(group_name, user_name, delegate_account=None)[source]

Add a user to a group.

Parameters:
  • group_name – name of group to add user to
  • user_name – name of user to add to group
  • delegate_account – str can be used by Cloud admin in Eucalyptus to choose an account to operate on
attach_policy_group(group_name, policy_name, policy_json, delegate_account=None)[source]

Attach a policy to a group.

Parameters:
  • group_name – name of group to remove user from
  • policy_name – Name to upload policy as
  • policy_json – Policy text
  • delegate_account – str can be used by Cloud admin in Eucalyptus to choose an account to operate on
attach_policy_user(user_name, policy_name, policy_json, delegate_account=None)[source]

Attach a policy string to a user

Parameters:
  • user_name – string - user to apply policy to
  • policy_name – Name to upload policy as
  • policy_json – Policy text
  • delegate_account – str can be used by Cloud admin in Eucalyptus to choose an account to operate on
create_access_key(user_name=None, delegate_account=None)[source]

Create a new access key for the user.

Parameters:
  • user_name – Name of user to create access key for to
  • delegate_account – str can be used by Cloud admin in Eucalyptus to choose an account to operate on
Returns:

A tuple of access key and and secret key with keys: ‘access_key_id’ and ‘secret_access_key’

create_account(account_name)[source]

Create an account with the given name

Parameters:account_name – str name of account to create
create_group(group_name, path='/', delegate_account=None)[source]

Create group.

:param :param path: path for group :param delegate_account: str can be used by Cloud admin in Eucalyptus to choose an account to operate on

create_user(user_name, path='/', delegate_account=None)[source]

Create a user

Parameters:
  • user_name – str name of user
  • path – str user path
  • delegate_account – str can be used by Cloud admin in Eucalyptus to choose an account to operate on
delete_account(account_name, recursive=False)[source]

Delete an account with the given name

Parameters:
  • account_name – str name of account to delete
  • recursive
delete_group(group_name, delegate_account=None)[source]

Delete group.

Parameters:
  • group_name – name of group to delete
  • delegate_account
delete_user(user_name, delegate_account=None)[source]

Delete a user

Parameters:
  • user_name – str name of user
  • delegate_account – str can be used by Cloud admin in Eucalyptus to choose an account to operate on
detach_policy_group(group_name, policy_name, delegate_account=None)[source]

Remove a policy from a group.

Parameters:
  • group_name – name of group to remove user from
  • policy_name – Name to upload policy as
  • delegate_account – str can be used by Cloud admin in Eucalyptus to choose an account to operate on
detach_policy_user(user_name, policy_name, delegate_account=None)[source]

Detach a policy from user

Parameters:
  • user_name – string - user to apply policy to
  • policy_name – Name to upload policy as
  • delegate_account – str can be used by Cloud admin in Eucalyptus to choose an account to operate on
get_all_accounts(account_id=None, account_name=None, search=False)[source]

Request all accounts, return account dicts that match given criteria

Parameters:
  • account_id – regex string - to use for account_name
  • account_name – regex - to use for account ID
  • search – boolean - specify whether to use match or search when filtering the returned list
Returns:

list of account names

get_all_groups(account_name=None, account_id=None, path=None, group_name=None, group_id=None, search=False)[source]

Queries all accounts matching given account criteria, returns all groups found within these accounts which then match the given user criteria. Account info is added to the group dicts

Parameters:
  • account_name – regex - to use for account_name
  • account_id – regex - to use for
  • path – regex - to match for path
  • group_name – regex - to match for group_name
  • group_id – regex - to match for group_id
  • search – boolean - specify whether to use match or search when filtering the returned list
Returns:

get_all_users(account_name=None, account_id=None, path=None, user_name=None, user_id=None, search=False)[source]

Queries all accounts matching given account criteria, returns all users found within these accounts which then match the given user criteria. Account info is added to the user dicts

Parameters:
  • account_name – regex - to use for account name
  • account_id – regex - to use for account id
  • path – regex - to match for path
  • user_name – regex - to match for user name
  • user_id – regex - to match for user id
  • search – boolean - specify whether to use match or search when filtering the returned list
Returns:

List of users with account name tuples

get_euare_accountname()[source]

Get account name of current user

get_euare_username()[source]

Get all users in the current users account

get_groups_from_account(path=None, group_name=None, group_id=None, delegate_account=None, search=False)[source]

Returns groups that match given criteria. By default will return groups from current account.

Parameters:
  • path – regex - to match for path
  • group_name – regex - to match for group_name
  • group_id – regex - to match for group_id
  • delegate_account – string - to use for delegating account lookup
  • search – specify whether to use match or search when filtering the returned list
Returns:

get_user_policies(user_name, policy_name=None, delegate_account=None, doc=None, search=False)[source]

Returns list of policy dicts associated with a given user, and match given criteria.

Parameters:
  • user_name – string - user to get policies for.
  • policy_name – regex - to match/filter returned policies
  • delegate_account – string - used for user lookup
  • doc – policy document to use as a filter
  • search – boolean - specify whether to use match or search when filtering the returned list
Returns:

get_user_policy_names(user_name, policy_name=None, delegate_account=None, search=False)[source]

Returns list of policy names associated with a given user, and match given criteria.

Parameters:
  • user_name – string - user to get policies for.
  • policy_name – regex - to match/filter returned policies
  • delegate_account – string - used for user lookup
  • search – specify whether to use match or search when filtering the returned list
Returns:

list of policy names

get_users_from_account(path=None, user_name=None, user_id=None, delegate_account=None, search=False)[source]

Returns users that match given criteria. By default will return current account.

Parameters:
  • path – regex - to match for path
  • user_name – str name of user
  • user_id – regex - to match for user_id
  • delegate_account – str can be used by Cloud admin in Eucalyptus to choose an account to operate on
  • search – use regex search (any occurrence) rather than match (exact same strings must occur)
Returns:

remove_user_from_group(group_name, user_name, delegate_account=None)[source]

Remove a user from a group.

Parameters:
  • group_name – name of group to remove user from
  • user_name – name of user to remove from group
  • delegate_account – str can be used by Cloud admin in Eucalyptus to choose an account to operate on
setup_iam_connection(endpoint='iam.amazonaws.com', aws_access_key_id=None, aws_secret_access_key=None, is_secure=True, port=443, path='/', boto_debug=0)[source]
show_all_accounts(account_name=None, account_id=None, search=False)[source]

Debug Method to print an account list based on given filter criteria

Parameters:
  • account_name – regex - to use for account_name
  • account_id – regex - to use for account_id
  • search – boolean - specify whether to use match or search when filtering the returned list
show_all_groups(account_name=None, account_id=None, path=None, group_name=None, group_id=None, search=False)[source]

Print all groups in an account

Parameters:
  • account_name – regex - to use for account_name
  • account_id – regex - to use for
  • path – regex - to match for path
  • group_name – regex - to match for user_name
  • group_id – regex - to match for user_id
  • search – boolean - specify whether to use match or search when filtering the returned list
show_all_users(account_name=None, account_id=None, path=None, user_name=None, user_id=None, search=False)[source]

Debug Method to print a user list based on given filter criteria

Parameters:
  • account_name – regex - to use for account_name
  • account_id – regex - to use for
  • path – regex - to match for path
  • user_name – regex - to match for user_name
  • user_id – regex - to match for user_id
  • search – boolean - specify whether to use match or search when filtering the returned list
show_euare_whoami()[source]

Debug method used to display the who am I info related to iam/euare.

show_user_policy_summary(user_name, policy_name=None, delegate_account=None, doc=None, search=False)[source]

Debug method to display policy summary applied to a given user

Parameters:
  • user_name – string - user to get policies for.
  • policy_name – regex - to match/filter returned policies
  • delegate_account – string - used for user lookup
  • doc – policy document to use as a filter
  • search – boolean - specify whether to use match or search when filtering the returned list
show_user_summary(user_name, delegate_account=None, account_id=None)[source]

Debug method for to display euare/iam info for a specific user.

Parameters:
  • user_name – string - user to get policies for.
  • delegate_account – string - used for user lookup
  • account_id – regex - to use for account id

s3ops Module

class eucaops.s3ops.S3ops(endpoint=None, credpath=None, aws_access_key_id=None, aws_secret_access_key=None, is_secure=False, path='/', port=80, boto_debug=0)[source]

Bases: eutester.Eutester

check_md5(eTag=None, data=None)[source]
clear_bucket(bucket)[source]

Deletes the contents of the bucket specified and the bucket itself bucket boto.bucket to delete recursively

clear_keys_with_prefix(bucket, prefix)[source]
create_bucket(bucket_name)[source]

Create a bucket. If the bucket already exists and you have access to it, no error will be returned by AWS. Note that bucket names are global to S3 so you need to choose a unique name.

delete_bucket(bucket)[source]

Delete a bucket. bucket_name The name of the Walrus Bucket

delete_object(object)[source]
get_bucket_by_name(bucket_name)[source]

Lookup a bucket by name, if it does not exist raise an exception

get_canned_acl(owner_id=None, canned_acl=None, bucket_owner_id=None)[source]

Returns an acl object that can be applied to a bucket or key owner_id Account id of the owner of the bucket. Required canned_acl Canned acl to implement. Required.

Options: [‘public-read’, ‘public-read-write’, ‘authenticated-read’, ‘log-delivery-write’, ‘bucket-owner-full-control’, ‘bucket-owner-full-control’]

bucket_owner_id Required for bucket-owner-full-control and bucket-owner-full-control acls to be created

get_objects_by_prefix(bucket_name, prefix)[source]

Get keys in the specified bucket that match the prefix if no prefix is passed all objects are returned as a result set. If only 1 key matches it will be returned as a Key object.

setup_s3_connection(endpoint=None, aws_access_key_id=None, aws_secret_access_key=None, is_secure=False, path='/', port=80, boto_debug=0)[source]
setup_s3_resource_trackers()[source]

Setup keys in the test_resources hash in order to track artifacts created

upload_object(bucket_name, key_name, path_to_file=None, contents=None)[source]

Write the contents of a local file to walrus bucket_name The name of the walrus Bucket. key_name The name of the object containing the data in walrus. path_to_file Fully qualified path to local file.

exception eucaops.s3ops.S3opsException(msg)[source]

Bases: exceptions.Exception

Exception raised for errors that occur when running S3 operations.

Attributes:
msg – explanation of the error

stsops Module

class eucaops.stsops.STSops(endpoint=None, region=None, credpath=None, aws_access_key_id=None, aws_secret_access_key=None)[source]

Bases: eutester.Eutester

get_session_token(duration=None)[source]

Get a possibly cached session token, if getting a new token request the given duration Options:

duration - The desired duration for the token in seconds (if issued, None for default duration)
issue_session_token(duration=None)[source]

Get a newly issued session token with the given (or default) duration Options:

duration - The desired duration for the token in seconds (None for default duration)
setup_sts_connection(endpoint=None, region=None, aws_access_key_id=None, aws_secret_access_key=None, path='/', port=443, is_secure=True, boto_debug=0)[source]

Contents