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='2013-10-15', ec2_ip=None, ec2_path=None, iam_ip=None, iam_path=None, s3_ip=None, s3_path=None, as_ip=None, as_path=None, elb_ip=None, elb_path=None, cw_ip=None, cw_path=None, cfn_ip=None, cfn_path=None, sts_ip=None, sts_path=None, port=8773, download_creds=True, boto_debug=0, debug_method=None, region=None)[source]¶
Bases: eucaops.ec2ops.EC2ops, eucaops.s3ops.S3ops, eucaops.iamops.IAMops, eucaops.stsops.STSops, eucaops.cwops.CWops, eucaops.asops.ASops, eucaops.elbops.ELBops, eucaops.cfnops.CFNops
- clean_up_test_volumes(volumes=None, min_timeout=180, timeout_per_vol=30)[source]¶
Definition: cleaup helper method intended to clean up volumes created within a test, after the test has ran.
Parameters: volumes – optional list of volumes to delete from system, otherwise will use test_resources[‘volumes’]
- cleanup_addresses(ips=None)[source]¶
Parameters: ips – optional list of ip addresses, else will attempt to delete from test_resources[]
- cleanup_artifacts(instances=True, snapshots=True, volumes=True, load_balancers=True, ip_addresses=True, auto_scaling_groups=True, launch_configurations=True, keypairs=True)[source]¶
Description: Attempts to remove artifacts created during and through this eutester’s lifespan.
- cleanup_load_balancers(lbs=None)[source]¶
Parameters: lbs – optional list of load balancers, otherwise it will attempt to delete from test_resources[]
- cleanup_test_snapshots(snaps=None, clean_images=False, add_time_per_snap=10, wait_for_valid_state=120, base_timeout=180)[source]¶
Parameters: - snaps – optional list of snapshots, else will attempt to delete from test_resources[]
- clean_images – Boolean, if set will attempt to delete registered images referencing the snapshots first. Images referencing the snapshot may prevent snapshot deletion to protect the image.
- add_time_per_snap – int number of seconds to append to base_timeout per snapshot
- wait_for_valid_state – int seconds to wait for snapshot(s) to enter a ‘deletable’ state
- base_timeout – base timeout to use before giving up, and failing operation.
- get_available_vms(type=None, zone=None)[source]¶
Get available VMs of a certain type, defaults to m1.small 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=None)[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
- classmethod get_traceback()[source]¶
Returns a string buffer with traceback, to be used for debug/info purposes.
- 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
- 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(*func_args, **func_kwargs)[source]¶
Bases: eutester.Eutester
- add_group(*func_args, **func_kwargs)[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(domain=None)[source]¶
Allocate an address for the current user
Returns: boto.ec2.address object allocated
- associate_address(instance, address, refresh_ssh=True, 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(*func_args, **func_kwargs)[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 the boto.group object
Parameters: - group – boto.group object
- port – Port to open, default=22
- end_port – End of port range to open, defaults to ‘port’ arg.
- protocol – Protocol to authorize, default=tcp
- cidr_ip – CIDR subnet to authorize, default=”0.0.0.0/0” everything
- src_security_group_name – Grant access to ‘group’ from src_security_group_name, default=None
- force_args – boolean to send arguments w/o the test method sanitizing them
Returns: True on success
Raise: Exception if operation fails
Authorize the group with group_name
Parameters: - group_name – Name of the group to authorize, default=”default”
- port – Port to open, default=22
- end_port – End of port range to open, defaults to ‘port’ arg.
- protocol – Protocol to authorize, default=tcp
- cidr_ip – CIDR subnet to authorize, default=”0.0.0.0/0” everything
- src_security_group_name – Grant access to ‘group’ from src_security_group_name, default=None
Returns:
- bundle_instance_monitor_and_register(instance, bucket_name=None, prefix=None, poll_interval_seconds=20, timeout_minutes=25)[source]¶
Attempts to start a bundle task and monitor it to completion. :param instance: boto instance to bundle :param bucket_name: Name of the bucket to upload. Default=’win+ramdom’ :param prefix: The prefix for the image file name:Default=’windows-bun + emi + random.’ :param access_key: String, Access Key ID of the owner of the bucket :param secret_key: String, Secret key used to sign the upload policy :param poll_interval_seconds: Seconds to wait between polling for bundle task status :param timeout_minutes: int, minutes to wait before timing out. :return : image
- 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’
Parameters: instances – optional list, or subset of instances to use in duplicate search.
- convert_instance_to_euisntance(instance, keypair=None, username=None, password=None, reservation=None, auto_connect=True, timeout=120)[source]¶
- convert_reservation_to_euinstance(reservation, username=None, password=None, keyname=None, private_addressing=False, 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_image(instance, name, description=None, no_reboot=False, block_device_mapping=None, dry_run=False, timeout=600)[source]¶
Parameters: - instance_id (string) – the ID of the instance to image.
- name (string) – The name of the new image
- description (string) – An optional human-readable string describing the contents and purpose of the AMI.
- no_reboot (bool) – An optional flag indicating that the bundling process should not attempt to shutdown the instance before bundling. If this flag is True, the responsibility of maintaining file system integrity is left to the owner of the instance.
- block_device_mapping (boto.ec2.blockdevicemapping.BlockDeviceMapping) – A BlockDeviceMapping data structure describing the EBS volumes associated with the Image.
- dry_run (bool) – Set to True if the operation should not actually run.
- timeout (int) – Time to allow image to get to “available” state.
Raises Exception: On not reaching the correct state or when more than one image is returned
- create_snapshot(*func_args, **func_kwargs)[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_id – (mandatory string) Volume id of the volume to create snapshot from - :param wait_on_progress:(optional integer) # of poll intervals to wait while 0 progress is made before exiting,
- overrides “poll_count” when used
Parameters: - poll_interval – (optional integer) time to sleep between polling snapshot status
- timeout – (optional integer) over all time to wait before exiting as failure
- description – (optional string) string used to describe the snapshot
Returns: EuSnapshot
- create_snapshot_from_volume(*func_args, **func_kwargs)[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_id – (mandatory string) Volume id of the volume to create snapshot from - :param wait_on_progress:(optional integer) # of poll intervals to wait while 0 progress is made before exiting,
- overrides “poll_count” when used
Parameters: - poll_interval – (optional integer) time to sleep between polling snapshot status
- timeout – (optional integer) over all time to wait before exiting as failure
- description – (optional string) string used to describe the snapshot
Returns: EuSnapshot
- create_snapshots(*func_args, **func_kwargs)[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(*func_args, **func_kwargs)[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
Parram count: (optional Integer) Specify how many snapshots to attempt to create
- :param wait_on_progress:(optional integer) # of poll intervals to wait while 0 progress is made before exiting,
- overrides “poll_count” when used
Parameters: - poll_interval – (optional integer) time to sleep between polling snapshot status
- timeout – (optional integer) over all time to wait before exiting as failure
- description – (optional string) string used to describe the snapshot
Returns: EuSnapshot list
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(*func_args, **func_kwargs)[source]¶
Create a new EBS volume then wait for it to go to available state, size or snapshot is mandatory
Parameters: - zone – 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(*func_args, **func_kwargs)[source]¶
- Definition:
- Create a multiple new EBS volumes then wait for them to go to available state, size or snapshot is mandatory
Parameters: - zone – 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
- create_web_servers(keypair, group, zone, port=80, count=2, image=None, filename='test-file', cookiename='test-cookie')[source]¶
- delete_group(group)[source]¶
Delete the security 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_image(image, timeout=60)[source]¶
Delete image by multiple deregistrations.
Parameters: - timeout – int seconds to wait before failing operation
- image – boto image object to deregister
- delete – boolean, if True will attempt to deregister until removed/deleted, default:False
- 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(*func_args, **func_kwargs)[source]¶
Delete a list of snapshots.
Parameters: - snapshots – List of snapshot IDs
- valid_states – Valid status for snapshot to enter (Default: ‘completed,failed’)
- base_timeout – Timeout for waiting for poll interval
- add_time_per_snap – Amount of time to add to base_timeout per snapshot in the list
- wait_for_valid_state – How long to wait for a valid state to be reached before attempting delete, as some states will reject a delete request.
- poll_interval – Time to wait between checking the snapshot states
- eof – Whether or not to call an Exception() when first failure is reached
Raise:
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=180)[source]¶
Delete the EBS volume then check that it no longer exists
Parameters: - poll_interval – int seconds to wait between polls to server for status
- timeout – int in seconds used for time to wait before failure
- volume – Volume object to delete
Returns: bool, success of the operation
- delete_volumes(volume_list, poll_interval=10, force_send=False, timeout=180)[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)[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_sec_group_allow(*func_args, **func_kwargs)[source]¶
Test whether a security group will allow traffic from a specific ‘src’ ip address to a specific ‘port’ using a specific ‘protocol’ :param group: Security group obj to use in lookup :param src_addr: Source address to lookup against sec group rule(s) :param src_group: Boto sec group to use in auth check :param protocol: Protocol to lookup sec group rule against :param port: Network port to lookup sec group rule against
- enable_root_user_data = '#cloud-config\ndisable_root: false'¶
- generate_default_s3_upload_policy(bucket, prefix, expiration=24, acl='ec2-bundle-read', encode=True)[source]¶
Generates s3 upload policy for bundle instance operation
Parameters: - bucket – bucket string
- prefix – prefix string
- expiration – int representing hours
- acl – acl to be used
Returns: s3 upload encoded policy
- 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(*func_args, **func_kwargs)[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=None, 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:
- get_console_output(instance)[source]¶
Retrieve console output from an instance
Parameters: instance – Instance ID or Instance object Returns: string Raise: Exception on failure to get console output
- classmethod get_datetime_from_resource_string(timestamp, time_format='%Y %m %d %H %M %S')[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(*func_args, **func_kwargs)[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
- filters – standard filters, dict.
- basic_image – boolean, avoids returning windows, load balancer and service images
- not_platform – skip if platform string matches this string. Example: not_platform=’windows’
- _args_dict – dict which can be populated by annotation to give insight into the args/kwargs this was called with
Returns: image id
Raise: Exception if image is not found
- get_images(*func_args, **func_kwargs)[source]¶
Get a list of images which match the provided criteria.
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’
- virtualization_type – example: ‘hvm’ or ‘paravirtualized’
- location – partial on location match example: ‘centos’
- state – example: ‘available’
- arch – example: ‘x86_64’
- owner_id – owners numeric id
- filters – standard filters
- basic_image – boolean, avoids returning windows, load balancer and service images
- not_platform – skip if platform string matches this string. Example: not_platform=’windows’
- max_count – return after finding ‘max_count’ number of matching images
- _args_dict – dict which can be populated by annotation to give insight into the args/kwargs this was called with
Returns: image id
Raise: Exception if image is not found
- get_instance_security_groups(instance)[source]¶
Definition: Look up and return all security groups this instance is referencing.
Parameters: instance – instance or euinstance object to Returns:
- 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(*func_args, **func_kwargs)[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
- filters – dict filters
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_manifest_string_from_bundle_task(bundle)[source]¶
Create a manifest string from a BundleInstanceTask obj :param bundle: BundleInstanceTask :return: manifest string
- get_reservation_for_instance(instance)[source]¶
Definition: Lookup and return reservation obj for this instance
Parameters: instance – boto instance or euinstance obj to use for lookup Returns: raise:
- 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(*func_args, **func_kwargs)[source]¶
Parameters: - snapid – string, snapshot id to use as filter
- volume_id – string, volume id to use as filter
- volume_size – int size of volume snap’d to use as filter
- volume_md5 – string md5 checksum of vol snap’d to use as filter
- maxcount – int max number of snaps to match before returning list
- owner_id – string owner id to use as filter
Returns: list of snapshots found
- 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(*func_args, **func_kwargs)[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(*func_args, **func_kwargs)[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
- classmethod is_address_in_network(*func_args, **func_kwargs)[source]¶
Parameters: - ip_addr – Ip address ie: 192.168.1.5
- network – Ip network in cidr notation ie: 192.168.1.0/24
Returns: boolean true if ip is found to be in network/mask, else false
- monitor_bundle_tasks(bundle_list, poll_interval_seconds=20, timeout_minutes=25, eof=True)[source]¶
Attempts to monitor the state of the bundle task id provided until completed or failed.
Parameters: - bundle_id – string bundle id to poll status for
- poll_interval_seconds – sleep period in seconds between polling for bundle task status
- timeout_minutes – timeout specified in minutes
- eof – boolean, end on first failure otherwise delay error until all bundle tasks have completed or failed
- monitor_conversion_tasks(tasks, states='completed', time_per_gig=90, base_timeout=600, interval=10, exit_on_failure=False)[source]¶
Monitors a list a task or list of tasks. Will monitor each task’s state to the provided ‘state’, or until failure, timeout. Note: timeout is calculated by size of the largest task multiplied by
‘time_per_gig’ added to the ‘base_timeout’.Parameters: - tasks – list of tasks.
- state – string representing desired state to monitor to. (pending, active, cancelled, completed, failed)
- time_per_gig – time in seconds per largest task size in GB to append to base timeout
- base_timeout – base timeout in seconds
- interval – seconds between polling tasks
- exit_on_failure – Will stop monitoring and raise an exception upon first found failure. Otherwise will continue monitoring remaining tasks in list and raise the error when all tasks are complete or timed out.
- monitor_created_euvolumes_to_state(*func_args, **func_kwargs)[source]¶
- Description:
- Monitors a list of created volumes until ‘state’ or failure. Allows for a variety of volumes, using different 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.
- poll_interval – int seconds to wait between polling for status
- size – int size in gigs to request for volume creation
- monitor_euinstances_to_state(*func_args, **func_kwargs)[source]¶
Parameters: - instance_list – list of instances to monitor
- state – state to monitor to, expected state
- min – int min count of instances that need to succeed otherwise except out
- poll_interval – int number of seconds between polls for instance status
- timeout – time to wait before this method is considered to have failed
- eof – boolean to indicate whether or not to exit on first failure
:return list of instances
- monitor_eusnaps_to_completed(*func_args, **func_kwargs)[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: - snaps – list of eusnapshots to monitor
- 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
- (optional integer) (monitor_to_progress) – will consider the monitor successful and exit when the snapshot’s progress is >= this value
- delete_failed – (optional boolean) automatically delete failed volumes
Returns: EuSnapshot list
- monitor_euvolumes_to_status(*func_args, **func_kwargs)[source]¶
- (See: monitor_created_euvolumes_to_state() if monitoring newly created volumes, otherwise this method is
- intended for monitoring attached and in-use states of volume(s). )
Definition: monitors a list of euvolumes to a given state. Some example valid states:
status = available, attached_status = None status = in-use, attached_status = attached, attaching, detachingParameters: - euvolumes – list of euvolumes to monitor
- status – state of volume expected: ie ‘in-use’, ‘available’, ‘deleted’
- attached_status – state of volume’s attached data. ie ‘attached’, ‘attaching’, ‘detaching’, ‘none’
- poll_interval – integer seconds between polling for status updates
- timeout – time to wait before failing
- eof – exit on first failure encountered, otherwise wait until other volumes pass/fail. Default=True
- validate_args – boolean, Will check args for a valid status/available_status pair. If False will monitor to a non-valid state for testing purposes
- print_bundle_task(bundle, header=True, footer=True, printout=True)[source]¶
Prints formatted output of bundle task attributes. :param bundle: BundleInstanceTask object to be printed :param header: boolean to print header containing column titles :param footer: boolean to print footer containing closing row line :param printout: boolean to print output using self.debug, else will return a buffer to be printed later. :return: string containing formatted output.
- print_euinstance_list(euinstance_list=None, state=None, instance_id=None, reservation=None, root_device_type=None, zone=None, key=None, public_ip=None, private_ip=None, ramdisk=None, kernel=None, image_id=None)[source]¶
Parameters: euinstance_list – list of euinstance objs Raise:
- register_image(*func_args, **func_kwargs)[source]¶
Register an image based on the s3 stored manifest location
Parameters: - image_location –
- root_device_name – 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_manifest(manifest, root_device_name=None, description=None, architecture=None, virtualization_type=None, platform=None, bdmdev=None, name=None, ramdisk=None, kernel=None)[source]¶
Attempts to register the provided manifest and return the image id created by it :param manifest: manifest string to register :return: : image id string
- register_snapshot(*func_args, **func_kwargs)[source]¶
Convience function for passing a snapshot instead of its id. See register_snapshot_by_id :param snapshot: Snapshot object to use as an image :param root_device_name: root device name to use when registering :param description: Description of image that will be registered :param windows: Is the image a Windows image :param bdmdev: Block device mapping :param name: Name to register the image as :param ramdisk: Ramdisk ID to use :param kernel: Kernel ID to use :param dot: Delete on terminate flag :param block_device_map: existing block device map to append snapshot block dev to
- register_snapshot_by_id(*func_args, **func_kwargs)[source]¶
Register an image snapshot
Parameters: - snap_id – snapshot id
- root_device_name – 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
- block_device_map – existing block device map to add the snapshot block dev type to
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
- revoke(group, port=22, protocol='tcp', cidr_ip='0.0.0.0/0', src_security_group_name=None, src_security_group_owner_id=None)[source]¶
- run_image(*func_args, **func_kwargs)[source]¶
Parameters: - image – image object or string image_id to create instances with
- keypair – keypair to create instances with
- group – security group to run instances in
- type – vmtype to run instances as
- zone – availability zone (aka cluster, aka parition) to run instances in
- min – minimum amount of instances to try to run
- max – max amount of instances to try to run
- user_data – user_data to run instances with
- private_addressing – boolean to run instances without public ips
- username – username for connecting ssh to instances
- password – password for connnecting ssh to instances
- auto_connect – boolean flag whether or not ssh connections should be automatically attempted
- clean_on_fail – boolean flag whether or not to attempt to delete/remove failed instances-(not implemented)
- monitor_to_running – boolean flag whether or not to monitor instances to a running state
- timeout – time allowed before failing this operation
Pararm block_device_map: block device map obj
Returns: list of euinstances
- run_instance(*func_args, **func_kwargs)[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_resource_trackers()[source]¶
Setup keys in the test_resources hash in order to track artifacts created
- show_all_addresses_verbose(display=True)[source]¶
Print table to debug output showing all addresses available to cloud admin using verbose filter
- start_bundle_instance_task(instance, bucket_name=None, prefix=None)[source]¶
REQUIRED PARAMETERS :rtype : BundleInstanceTask :param instance: boto instance to bundle :param bucket_name: Name of the bucket to upload. Default=’win+ramdom’ :param prefix: The prefix for the image file name:Default=’windows-bun + emi + random.’ :param access_key: String, Access Key ID of the owner of the bucket :param secret_key: String, Secret key used to sign the upload policy :return : bundle task object
- start_instances(reservation, timeout=480)[source]¶
Start all instances in a reservation
Parameters: reservation – boto.ec2.reservation object or list of instances 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_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(*func_args, **func_kwargs)[source]¶
Wait for instance public DNS name to clear from regex
Parameters: - instances –
- private_addressing – boolean for whether instance has private addressing enabled
- poll_interval –
- 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_group_policies(group_name, policy_name=None, delegate_account=None, doc=None, search=False)[source]¶
Returns list of policy dicts associated with a given group, and match given criteria.
Parameters: - group_name – string - group to get policies for.
- policy_name – regex - to match/filter returned policies
- delegate_account – string - used for group 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_group_policy_names(group_name, policy_name=None, delegate_account=None, search=False)[source]¶
Returns list of policy names associated with a given group, and match given criteria.
Parameters: - group_name – string - group to get policies for.
- policy_name – regex - to match/filter returned policies
- delegate_account – string - used for group lookup
- search – specify whether to use match or search when filtering the returned list
Returns: list of policy names
- 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_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
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_acl_equivalence(acl1=None, acl2=None)[source]¶
Checks if acl1 = acl2 based on comparison of the set of grants irrespective of order. One limitation is that each grant’s xml string deserialization must be the same to be considered equivalent. This has implications for the grant displayname in particular. For example, an ACL with an unknown account specified will not generally have a display-name associated with the account id, so the comparison may fail in that case even though the ids and permissions are identical.
Returns None if there is an input problem such as one or more inputs are None
acl1 An ACL object from boto.s3.acl acl2 An ACL object from boto.s3.acl
- clear_bucket(bucket_name=None)[source]¶
- Deletes the contents of the bucket specified and the bucket itself
- THIS WILL DELETE EVERYTHING!
bucket bucket name to clear
- 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.
- get_bucket_by_name(bucket_name)[source]¶
Lookup a bucket by name, if it does not exist raise an exception
- get_canned_acl(canned_acl=None, bucket_owner_id=None, bucket_owner_display_name=None)[source]¶
Returns an acl object that can be applied to a bucket or key. It is intended to be used to verify results that the service returns. To set a canned-acl you can simply set it on the bucket directly without this method.
bucket_owner_id Account id of the owner of the bucket. Required canned_acl Canned acl to implement. Required.
Options: [‘private’,’public-read’, ‘public-read-write’, ‘authenticated-read’, ‘log-delivery-write’, ‘bucket-owner-full-control’, ‘bucket-owner-full-control’]bucket_owner_display_name Required. The account display name for the bucket owner, so that the correct permission can be generated fully
- 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.
- s3_groups = {'log_delivery': 'http://acs.amazonaws.com/groups/s3/LogDelivery', 'all_users': 'http://acs.amazonaws.com/groups/global/AllUsers', 'authenticated_users': 'http://acs.amazonaws.com/groups/global/AuthenticatedUsers'}¶
- 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]¶
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)