Eutester 0.0.8 documentation

eutester Package

Contents

eutester Package

eutester Package

class eutester.Eutester(credpath=None)[source]

Bases: object

clear_fail_count()[source]

The counter for keeping track of all the errors

clear_fail_log()[source]
diff(list1, list2)[source]

Return the diff of the two lists

fail(message)[source]
found(command, regex)[source]

Returns a Boolean of whether the result of the command contains the regex

get_access_key()[source]
get_account_id()[source]
get_exectuion_time()[source]

Returns the total execution time since the instantiation of the Eutester object

static get_line(length=None)[source]
get_port()[source]

Parse the eucarc for the EC2_ACCOUNT_NUMBER

get_secret_key()[source]
static get_terminal_size()[source]

Attempts to get terminal size. Currently only Linux. returns (height, width)

classmethod get_traceback()[source]

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

get_user_id()[source]
grep(string, list)[source]

Remove the strings from the list that do not match the regex string

handle_timeout(signum, frame)[source]
id_generator(size=6, chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789')[source]

Returns a string of size with random charachters from the chars array. size Size of string to return chars Array of characters to use in generation of the string

local(cmd)[source]

Run a command on the localhost :param cmd: str representing the command to be run :return: :raise: CalledProcessError on non-zero return code

parse_eucarc(field)[source]
ping(address, poll_count=10)[source]

Ping an IP and poll_count times (Default = 10) address Hostname to ping poll_count The amount of times to try to ping the hostname iwth 2 second gaps in between

classmethod printinfo(func)[source]

Decorator to print method positional and keyword args when decorated method is called usage: @printinfo def myfunction(self, arg1, arg2, kwarg1=defaultval):

stuff = dostuff(arg1, arg2, kwarg1) return stuff

When the method is run it will produce debug output showing info as to how the method was called, example:

myfunction(arg1=123, arg2=’abc’, kwarg=’words)

2013-02-07 14:46:58,928] [DEBUG]:(mydir/myfile.py:1234) - Starting method: myfunction() 2013-02-07 14:46:58,928] [DEBUG]:—> myfunction(self, arg1=123, arg2=abc, kwarg=’words’)

static render_file_template(src, dest, **kwargs)[source]
scan_port_range(ip, start, stop, timeout=1, tcp=True)[source]

Attempts to connect to ports, returns list of ports which accepted a connection

sleep(seconds=1)[source]

Convinience function for time.sleep()

test_port_status(ip, port, timeout=5, tcp=True, recv_size=0, send_buf=None, verbose=True)[source]

Attempts to connect to tcp port at ip:port within timeout seconds

wait_for_result(callback, result, timeout=60, poll_wait=10, oper=<built-in function eq>, allowed_exception_types=None, **callback_kwargs)[source]

Wait for the instance to enter the state

Parameters:
  • instance – Boto instance object to check the state on
  • result – result from the call back provided 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
  • oper – operator obj used to evaluate ‘result’ against callback’s result. ie operator.eq, operator.ne, etc..
Returns:

result upon success

Raise:

Exception when instance does not enter proper state

exception eutester.TimeoutFunctionException[source]

Bases: exceptions.Exception

Exception to raise on a timeout

euconfig Module

Created on May 11, 2012 @author: clarkmatthew

Simple utility to read a given config file and parse out the configuration. Uses python’s Config Parser but includes some utils to support legacy qa config files, and file operations on local and remote machines containing keypair values. To use this utility, the config file given must use the following format: [prefix]key=value

example: Add the following lines to a file called /tmp/config.txt Note: This example is using the legacy config with ip, distro, and component info.

>cat /tmp/config.txt

1.1.1.1 CENTOS 5.7 64 REPO [CLC WS] 1.1.1.2 CENTOS 5.7 64 REPO [NC00]

[mytest] volumes=2 image=centos.img

[joestest] image=ubuntu.img name=joe iterations=3 output=/tmp/joesoutput.txt

To retrieve config info from this file from within a test: >conf = EuConfig(filename=’/tmp/config.txt’) >myimage = conf.get_config(‘mytest’,’image’) >joesimage = conf.get(‘joestest’,’image’) > >print myimage

centos.img
>print conf.legacybuf
1.1.1.1 CENTOS 5.7 64 REPO [CLC WS] 1.1.1.2 CENTOS 5.7 64 REPO [NC00]
class eutester.euconfig.Config_Item(name, value, config_section)[source]
config_file_add_to_this_line(value_to_add)[source]
config_file_remove_this_line()[source]
config_file_set_this_line(value, quoted=True)[source]
update()[source]
class eutester.euconfig.Config_Section(name, config_manager, strip='"')[source]
add_item_to_section(config_item_name, value)[source]
config_file_add_new_line_to_section(new_line, over_write=True)[source]
config_file_add_to_existing_line(search_pattern, value_to_add)[source]
config_file_remove_line(search_pattern)[source]
config_file_swap_line(search_pattern, new_line)[source]
get_all_items(item_name=None)[source]
get_item(name)[source]
get_section_pattern()[source]
remove_all_items(item_name=None, items=None)[source]
update()[source]
update_attributes_for_section()[source]
write_new_item_to_section_in_config_file(key, value)[source]
class eutester.euconfig.EuConfig(filename='../input/2btested.lst', file_util=None, ssh=None, config_lines=None, debugmethod=None, verbose=True, default_section_name='DEFAULTS', auto_detect_memo_section=True, make_section_attrs=True, legacy_qa_config=False, preserve_option_case=True, strip_values='"')[source]
add_new_item_to_config_file_under_section(section_name, config_item_name, value)[source]
check_and_add_default_section(default_section_name=None)[source]
classmethod create_file_util_from_file(filepath, ssh=None, verbose=False)[source]

Creates either a File_Util obj, working on either a local or remote file (if ssh is provided). :param filepath: string representing the local or remote file path :param ssh: eutester ssh_connection obj if file is remote :return: File_Util obj

debug(msg)[source]
get(section, key)[source]
get_all_sections(section_name=None)[source]
get_config_buf(lines=None, default_section_name=None)[source]

Gather config lines into list. To support legacy config, will exclude all lines read prior to detecting a section header. Will ignore blank lines and lines starting with “#” representing comments

get_legacy_config(lines=None)[source]

Gather all lines from the given config until a section header is reached In order to be backwards compatible with previous configuration files will return a buffer of file read until the first section header

get_section(name)[source]
has_a_section()[source]
has_legacy_memo_section_marker(lines=None)[source]
make_sections(strip='"')[source]

Creates section objects within this euconfig instance. These are dynamic for python console dev/debugging use, the use of these in testcases should be avoided. Example: The machine classes may have a file called eucalyptus_conf and create a section ‘[eucalyptus_conf]’ This will add the section to self.config.sections, as well as create a Config_Section() object with attributes for each item which contain that item’s value. For a machine called ‘clc’ values out of this config file can be access like this...

>print clc.config.eucalyptus_conf.hypervisor > kvm

>print clc.config.eucalyptus_conf.cloud_opts >-Debs.storage.manager=SANManager -Debs.san.provider=NetappProvider –debug

populate_config_parser_from_buf(buf=None, default_section_name=None, make_section_attrs=None, strip_values=None)[source]
remove_all_sections(section_name=None, sections=None)[source]
uncomment_line(config_item)[source]
update(lines=None)[source]
class eutester.euconfig.File_Util(filepath, ssh=None, remove_blank_lines=True, verbose=False)[source]
ADD = 'ADD'
ADDTOLINE = 'ADDTOLINE'
REMOVE = 'REMOVE'
SWAP = 'SWAP'
add_new_line(new_line, after_pattern=None, over_write=False)[source]
add_to_existing_line(search_pattern, values_to_add, after_pattern=None)[source]
file_edit_line(new_line, action=None, search_pattern=None, after_pattern=None, single_action=True, tempfilepath=None)[source]
file_open(filepath, read=True, write=False, create=True, flags=None)[source]
file_replace(from_path, to_path)[source]
get_file_lines()[source]
get_md5(blocksize=65536)[source]
has_changed()[source]
match_in_lines(match_pattern, after_pattern)[source]
print_file(printmethod=None)[source]
remove_existing_line(search_pattern, after_pattern=None)[source]
sanitize(dirty_string)[source]
search_in_lines(search_pattern, after_pattern=None)[source]
stat_file()[source]
swap_existing_line(search_pattern, new_line, after_pattern=None)[source]
update(retries=3)[source]

euinstance Module

Created on Mar 7, 2012 @author: clarkmatthew extension of the boto instance class, with added convenience methods + objects Add common instance test routines to this class

Sample usage:
testinstance = EuInstance.make_euinstance_from_instance( eutester.run_instances()[0] ) print testinstance.id output = testinstance.sys(“ls /dev/xd*”) print output[0] eutester.sys(‘ping ‘+testinstance.ip_address ) testinstance.sys(‘yum install ntpd’)
class eutester.euinstance.EuInstance(connection=None)[source]

Bases: boto.ec2.instance.Instance, eutester.taggedresource.TaggedResource

assertFilePresent(filepath)[source]

Method to check for the presence of a file at ‘filepath’ on the instance filepath - mandatory - string, the filepath to verify

attach_euvolume(euvolume, dev=None, timeout=180, overwrite=False)[source]

Method used to attach a volume to an instance and track it’s use by that instance required - euvolume - the euvolume object being attached required - tester - the eucaops/eutester object/connection for this cloud optional - dev - string to specify the dev path to ‘request’ when attaching the volume to optional - timeout - integer- time allowed before failing optional - overwrite - flag to indicate whether to overwrite head data of a non-zero filled volume upon attach for md5

attach_euvolume_list(list, intervoldelay=0, timepervol=90, md5len=32)[source]

Attempts to attach a list of euvolumes. Due to limitations with KVM and detecting the location/device name of the volume as attached on the guest, MD5 sums are used... -If volumes contain an md5 will wait intervoldelay seconds before attempting to attach the next volume in the list. -If the next volume in the list does not have an MD5, the next volume will not be attached until this volume is detected and an md5sum is populated in the euvolume.

Parameters:list – List of volumes to be attached, if volumes are not of type euvolume they will be converted

:param intervoldelay : integer representing seconds between each volume attach attempt :param timepervol: time to wait for volume to attach before failing :param md5len: length from head of block device to read when calculating md5

attach_volume(volume, dev=None, timeout=180, overwrite=False)[source]

Method used to attach a volume to an instance and track it’s use by that instance required - euvolume - the euvolume object being attached required - tester - the eucaops/eutester object/connection for this cloud optional - dev - string to specify the dev path to ‘request’ when attaching the volume to optional - timeout - integer- time allowed before failing optional - overwrite - flag to indicate whether to overwrite head data of a non-zero filled volume upon attach for md5

check_ephemeral_against_vmtype()[source]
check_instance_meta_data_for_block_device_mapping(root_dev=None, bdm=None)[source]

Checks current instances meta data against a provided block device map & root_dev, or against the current values of the instance; self.block_device_mapping & self.root_device_name

check_ram_against_vmtype(pad=32)[source]
cmd(cmd, verbose=None, enable_debug=False, try_non_root_exec=None, timeout=120, listformat=False, cb=None, cbargs=, []get_pty=True)[source]

Runs a command ‘cmd’ within an ssh connection. Upon success returns dict representing outcome of the command.

Returns dict:
[‘cmd’] - The command which was executed [‘output’] - The std out/err from the executed command [‘status’] - The exitcode of the command. Note in the case a call back fires, this exitcode is unreliable. [‘cbfired’] - Boolean to indicate whether or not the provided callback fired (ie returned False) [‘elapsed’] - Time elapsed waiting for command loop to end.

Arguments: :param cmd: - mandatory - string representing the command to be run against the remote ssh session :param verbose: - optional - will default to global setting, can be set per cmd() as well here :param timeout: - optional - integer used to timeout the overall cmd() operation in case of remote blocking :param listformat: - optional - boolean, if set returns output as list of lines, else a single buffer/string :param cb: - optional - callback, method that can be used to handle output as it’s rx’d instead of...

waiting for the cmd to finish and return buffer. Called like: cb(ssh_cmd_out_buffer, *cbargs) Must accept string buffer, and return an integer to be used as cmd status. Must return type ‘sshconnection.SshCbReturn’ If cb returns stop, recv loop will end, and channel will be closed. if cb settimer is > 0, timer timeout will be adjusted for this time if cb statuscode is != -1 cmd status will return with this value if cb nextargs is set, the next time cb is called these args will be passed instead of cbargs
Parameters:cbargs
  • optional - list of arguments to be appended to output buffer and passed to cb
cmd_expect_password(cmd, verbose=None, enable_debug=False, prompt='password', password=None, timeout=120, listformat=False, cb=None, cbargs=, []get_pty=True, retry=0)[source]
cmd_with_su(cmd, verbose=True, prompt='^Password:', username='root', password=None, listformat=False, cb=None, cbargs=, []get_pty=True, timeout=120, retry=0, enable_debug=False)[source]
cmd_with_sudo(cmd, verbose=True, enable_debug=False, prompt='^\[sudo\] password', password=None, listformat=False, cb=None, cbargs=, []get_pty=True, timeout=120, retry=0)[source]
connect_to_instance(timeout=60)[source]

Attempts to connect to an instance via ssh. timeout - optional - time in seconds to wait for connection

before failure
dd_monitor(*func_args, **func_kwargs)[source]

Executes dd command on instance, monitors and displays ongoing status, and returns stats dict for dd outcome :type ddif: str :param ddif: Interface to read data in from

Parameters:
  • ddof (str) – Interface to write data to
  • ddcount (int) – Number or count of block size (ddbs) to read/write
  • ddbs (int) – Block size used for reads/writes
  • ddbytes (int) – Number of bytes to be roughly read/write (note: used as ddbytes/ddbs = count)
  • ddcmd (str) – String representing a preformed dd comand to be executed and monitored
  • ddseek (int) – length of ddof file to seek before writing
  • timeout (int) – Number of seconds to wait before timing out on dd cmd.
  • poll_interval (int) – Number of seconds to pause between polling dd and updating status
  • tmpfile (str) – temp file used on remote instance to redirect dd’s stderr to in order to nohup dd.
Return type:

dict

Returns:

dict containing dd stats

debug(msg, traceback=1, method=None, frame=False)[source]

Used to print debug, defaults to print() but over ridden by self.debugmethod if not None msg - mandatory -string, message to be printed

detach_euvolume(euvolume, waitfordev=True, timeout=180)[source]

Method used to detach detach a volume to an instance and track it’s use by that instance required - euvolume - the euvolume object being deattached waitfordev - boolean to indicate whether or no to poll guest instance for local device to be removed optional - timeout - integer seconds to wait before timing out waiting for the volume to detach

find_blockdev_by_md5(md5=None, md5len=None, euvolume=None, add_to_attached_list=False)[source]
found(command, regex)[source]

Returns a Boolean of whether the result of the command contains the regex

get_blockdev_size_in_bytes(devpath)[source]
get_connection_debug()[source]
get_dev_dir(match=None)[source]

Attempts to return a list of devices in /dev which match the given grep criteria By default will attempt to match self.block_device_prefix if populated, otherwise will try to match sd,vd, and xd device prefixes. returns a list of matching dev names. match - optional - string used in grep search of /dev dir on instance

get_dev_md5(devpath, length, timeout=60)[source]
get_ephemeral_dev()[source]

Attempts to find the block device path on this instance

Returns:string representing path to ephemeral block device
get_free_scsi_dev(prefix=None, maxdevs=100)[source]

The volume attach command requires a cloud level device name that is not currently associated with a volume Note: This is the device name from the clouds perspective, not necessarily the guest’s This method attempts to find a free device name to use in the command optional - prefix - string, pre-pended to the the device search string optional - maxdevs - number use to specify the max device names to iterate over.

Some virt envs have a limit of 16 devs.
get_guest_dev_for_block_device_map_device(md5, md5len, map_device)[source]

Finds a device in the block device mapping and attempts to locate which guest device the volume is using based upon the provided md5 sum, and length in bytes that were read in to create the checksum. If found the volume is appended to the local list of attached volumes and the md5 checksum and len are set in the volume for later test use. returns the guest device if found.

get_guestdevs_inuse_by_vols()[source]
get_line(length)[source]
get_memtotal_in_mb()[source]
get_metadata(element_path, prefix='latest/meta-data/', timeout=10, staticmode=False)[source]

Return the lines of metadata from the element path provided

get_reservation()[source]
get_unsynced_volumes(euvol_list=None, md5length=32, timepervol=90, min_polls=2, check_md5=False)[source]

Description: Returns list of volumes which are: -in a state the cloud believes the vol is no longer attached -the attached device has changed, or is not found. If all euvols are shown as attached to this instance, and the last known local dev is present and/or a local device is found with matching md5 checksum then the list will return ‘None’ as all volumes are successfully attached and state is in sync. By default this method will iterate through all the known euvolumes attached to this euinstance. A subset can be provided in the list argument ‘euvol_list’. Returns a list of euvolumes for which a corresponding guest device could not be found, or the cloud no longer believes is attached.

Parameters:
  • euvol_list
    • optional - euvolume object list. Defaults to all self.attached_vols
  • md5length
    • optional - defaults to the length given in each euvolume. Used to calc md5 checksum of devices
  • timerpervolume – -optional - time to wait for device to appear, per volume before failing
  • min_polls
    • optional - minimum iterations to check guest devs before failing, despite timeout
  • check_md5
    • optional - find devices by md5 comparision. Default is to only perform this check when virtio_blk is in use.
get_uptime(retries=10, interval=10)[source]
get_user_group_info(username, index=3)[source]

Attempts to return a list of groups for a specific user on this instance. index is set at the grouplist by default [3], but can be adjust to include the username, password, and group id as well in the list. where the parsed string should be in format ‘name:password:groupid1:groupid2:groupid3...’

get_user_password(username)[source]

Attempts to verify whether or not a user ‘username’ has a password set or not on this instance. returns true if a password is detected, else false

get_users()[source]

Attempts to return a list of normal linux users local to this instance. Returns a list of all non-root users found within the uid_min/max range who are not marked nologin

get_volume_mounted_dir(volume)[source]

Attempts to fetch the dir/mount point for a given block-guestdev or a euvolume that contains attached guestdev information.

Parameters:
  • volume – attached euvolume
  • guestdev – local block device path
Returns:

string representing path to mounted dir, or None if not found

has_sudo()[source]
init_volume_list(reattach=False, detach=True, timeout=300)[source]

This should be used when first creating a euinstance from an instance to insure the euinstance volume state is in sync with the cloud, mainly for the case where a euinstance is made from a pre-existing and in-use instance. Method to detect volumes which the cloud believes this guest is using, and attempt to match up the cloud dev with the local guest dev. In the case the local dev can not be found the volume will be detached. If the local device is found a euvolume object is created and appended the local attached_vols list. To confirm local state with the cloud state, the options ‘reattach’, or ‘detach’ can be used.

classmethod make_euinstance_from_instance(instance, tester, debugmethod=None, keypair=None, keypath=None, password=None, username='root', auto_connect=True, verbose=True, timeout=120, private_addressing=False, reservation=None, cmdstart=None, try_non_root_exec=True, exec_password=None, retry=2)[source]

Primary constructor for this class. Note: to avoid an ssh session within this method, provide keys, username/pass later. Arguments: instance - mandatory- a Boto instance object used to build this euinstance object keypair - optional- a boto keypair object used for creating ssh connection to the instance username - optional- string used to create ssh connection as an alternative to keypair password - optional- string used to create ssh connection to this instance as an alternative to keypair exec_password -optional -string used for su or sudo where prompted for password, will default to ‘password’ auto_connect -optional -boolean, if True will attempt to automatically create an ssh session for this instance try_non_root_exec -optional -boolean, if True will attempt to use sudo if available else su -c to execute privileged commands timeout - optional- integer used for ssh connection timeout debugmethod - optional - method, used for debug output verbose - optional - boolean to determine if debug is to be printed using debug() retry - optional - integer, ssh connection attempts for non-authentication failures

md5_attached_euvolume(euvolume, timepergig=90, length=None, updatevol=True)[source]

Calculates an md5sum of the first ‘length’ bytes of the dev representing the attached euvolume. By default will use the md5len stored within the euvolume. The euvolume will be updated with the resulting checksum and length. Returns the md5 checksum euvolume - mandatory - euvolume object used to calc checksum against timepergig - optional - number of seconds used per gig in volume size used in calcuating timeout length - optional - number bytes to read from the head of the device file used in md5 calc updatevol - optional - boolean used to update the euvolume data or not

mount_attached_volume(volume, mkfs_cmd='mkfs.ext3', force_mkfs=False, mountdir='/mnt', name=None)[source]

Attempts to mount a block device associated with an attached volume. Attempts to mkfs, and mkdir for mount if needed.

Parameters:
  • volume – euvolume obj
  • mkfs_cmd – string representing mkfs cmd, defaults to ‘mkfs.ext3’
  • mountdir – dir to mount, defaults to ‘/mnt’
  • name – name of dir create within mountdir to mount volume, defaults to volume’s id
Returns:

string representing path to volume’s mounted dir

printself(title=True, footer=True, printmethod=None)[source]
random_fill_volume(*func_args, **func_kwargs)[source]

Attempts to fill the entire given euvolume with unique non-zero data. The srcdev is read from in a set size, and then used to write to the euvolume to populate it. The file helps with both speed up the copy in the urandom case, and adds both some level of randomness another src device as well as allows smaller src devs to be used to fill larger euvolumes by repeatedly reading into the copy. :param euvolume: the attached euvolume object to write data to :param srcdev: the source device to copy data from :param length: the number of bytes to copy into the euvolume :returns dd’s data/time stat

reboot_instance_and_verify(waitconnect=30, timeout=360, connect=True, checkvolstatus=False, pad=5)[source]

Attempts to reboot an instance and verify it’s state post reboot. waitconnect-optional-integer representing seconds to wait before attempting to connect to instance after reboot timeout-optional-integer, seconds. If a connection has failed, this timer is used to determine a retry onnect- optional - boolean to indicate whether an ssh session should be established once the expected state has been reached checkvolstatus - optional -boolean to be used to check volume status post start up

reset_ssh_connection(timeout=None)[source]
set_block_device_prefix()[source]
set_last_status(status=None)[source]
set_rootfs_device()[source]
start_instance_and_verify(timeout=300, state='running', failstates=['terminated'], failfasttime=30, connect=True, checkvolstatus=True)[source]

Attempts to start instance and verify state, and reconnects ssh session timeout -optional-time to wait on instance to go to state ‘state’ before failing state -optional-the expected state to signify success, default is running failstate -optional-a state transition that indicates failure, default is terminated connect- optional - boolean to indicate whether an ssh session should be established once the expected state has been reached checkvolstatus - optional -boolean to be used to check volume status post start up

start_interactive_ssh(timeout=180)[source]
stop_instance_and_verify(timeout=200, state='stopped', failstate='terminated', check_vols=True)[source]

Attempts to stop instance and verify the state has gone to stopped state timeout -optional-time to wait on instance to go to state ‘state’ before failing state -optional-the expected state to signify success, default is stopped failstate -optional-a state transition that indicates failure, default is terminated

sys(cmd, verbose=True, code=None, try_non_root_exec=None, enable_debug=False, timeout=120)[source]

Issues a command against the ssh connection to this instance Returns a list of the lines from stdout+stderr as a result of the command cmd - mandatory - string, the command to be executed verbose - optional - boolean flag to enable debug timeout - optional - command timeout in seconds

sys_with_su(cmd, verbose=True, enable_debug=False, code=None, prompt='^Password:', username='root', password=None, retry=0, timeout=120)[source]
sys_with_sudo(cmd, verbose=True, enable_debug=False, prompt='^\[sudo\] password', code=None, password=None, retry=0, timeout=120)[source]
terminate_and_verify(verify_vols=True, volto=180, timeout=300, poll_interval=10)[source]

Attempts to terminate the instance and verify delete on terminate state of an ebs root block dev if any. If flagged will attempt to verify the correct state of any volumes attached during the terminate operation.

Parameters:
  • verify_vols (boolean) – boolean used to flag whether or not to check for correct volume state after terminate
  • volto (integer) – timeout used for time in seconds to wait for volumes to detach and become available after terminating the instnace
  • timeout (integer) – timeout in seconds when waiting for an instance to go to terminated state.
time_dd(ddcmd, timeout=90, poll_interval=1, tmpfile=None)[source]

(Added for legacy support, use dd_monitor instead) Executes dd command on instance, parses and returns stats on dd outcome

update(validate=False, dry_run=False, err_state='terminated', err_code=-1)[source]
update_vm_type_info()[source]
verify_attached_vol_cloud_status(euvolume)[source]

Confirm that the cloud is showing the state for this euvolume as attached to this instance

vol_write_random_data_get_md5(euvolume, srcdev=None, length=32, timepergig=90, overwrite=False)[source]

Attempts to copy some amount of data into an attached volume, and return the md5sum of that volume A brief check of the first 32 bytes is performed to see if this volume has pre-existing non-zero filled data. If pre-existing data is found, and the overwrite flag is not set then the write is not performed. Returns string with MD5 checksum calculated on ‘length’ bytes from the head of the device. volume - mandatory - boto volume object of the attached volume srcdev - optional - string, the file to copy into the volume timepergig - optional - the time in seconds per gig, used to estimate an adequate timeout period overwrite - optional - boolean. write to volume regardless of whether existing data is found

zero_fill_volume(euvolume)[source]

zero fills the given euvolume with,returns dd’s data/time stat

eulogger Module

Example: import eulogger self.logger = eulogger.Eulogger(name=’euca’) self.log = self.logger.log

self.log.debug(“This is a debug message”) self.log.critical(“this is a critical message”)

class eutester.eulogger.Allow_Logger_By_Name(name='')[source]

Bases: logging.Filter

Only messages from this logger are allow through to prevent duplicates from other loggers of same level, etc..

filter(record)[source]
class eutester.eulogger.Eulogger(parent_logger_name='eutester', identifier='eulogger', stdout_level='debug', stdout_format=None, logfile='', logfile_level='debug', make_log_file_global=True, use_global_log_files=True, file_format=None, clear_file=False)[source]

Bases: object

add_muted_file_handler_to_parent_logger(filepath, level)[source]
getChild(logger, suffix)[source]

## Add this for 2.6 support, this was implemented in 2.7...###

get_parent_logger_files()[source]
class eutester.eulogger.File_Handler_Info(filepath, level)[source]
class eutester.eulogger.Mute_Filter(name='')[source]

Bases: logging.Filter

filter(record)[source]

eupopulator Module

Created on Apr 25, 2012 @author: vic.iglesias@eucalyptus.com

class eutester.eupopulator.EuPopulator(eucaops, config_file=None)[source]

Bases: object

This class is intended to read in a config file using ConfigParser, then create resources based on the config file It is also able to serialize the current resources in a cloud into a file, read in that file and verify that the resources still exist in the same way. Serialization is done with Pickle.

addresses()[source]
buckets()[source]
depopulate()[source]
keypairs()[source]
populate()[source]

Takes the config and creates each of the resources based on their parameters

prefix_generator(size=6, chars='abcdefghijklmnopqrstuvwxyz0123456789')[source]
security_groups()[source]
serialize_resources(output_file='cloud_objects.dat')[source]
Takes a snapshot of the current resources in the system and puts them into a data structure, then pickles this struct into a file.
output_file Filename to use when outputing the serialized data, if this is None then the byte stream will be returned
snapshots()[source]
volumes()[source]

euproperties Module

Created on Mar 7, 2012 @author: clarkmatthew Place holder class to provide convenience for testing, modifying, and retrieving Eucalyptus cloud property information Intention is to reduce the time in looking up property names, and values outside of the eutester test lib, etc Note: Debug output for the tester.sys command are controled by the eutester/eucaops object

Sample: cat my_cloud.conf > 192.168.1.76 CENTOS 6.3 64 REPO [CLC WS] > 192.168.1.77 CENTOS 6.3 64 REPO [SC00 CC00] > 192.168.1.78 CENTOS 6.3 64 REPO [NC00]

from eucaops import Eucaops from eutester import euproperties Eucaops(config_file=’my_cloud.conf’, password=’mypassword’)

ep_mgr = euproperties.Euproperty_Manager(tester,
verbose=True, debugmethod=tester.debug)

#get some storage service properties, and some property values...

#Get/Set value from dynamic method created in Euproperty_Manager...
san_host_prop_value = ep_mgr.get_storage_sanhost_value() ep_mgr.set_storage_sanhost_value(‘192.168.1.200’)
#Get/set value from euproperty directly...
san_host_prop = ep_mgr.get_property(‘san_host’, ‘storage’, ‘PARTI00’) san_host_prop_value = san_host_prop.get() san_host_prop_set(‘192.168.1.200’
#Get multiple properties at once based on certain filters...
storage_properties = ep_mgr.get_properties(service_type=’storage’) partition1_properties = ep_mgr.get_properties(partition=’partition1’)
exception eutester.euproperties.EupropertiesException(value)[source]

Bases: exceptions.Exception

class eutester.euproperties.Euproperty(prop_mgr, property_string, service_type, partition, name, value, mandatory=False, description='')[source]
get()[source]
print_self(include_header=True, show_description=True, print_method=None, printout=True)[source]
reset_to_default()[source]
set(value)[source]
update()[source]
exception eutester.euproperties.EupropertyNotFoundException(value)[source]

Bases: exceptions.Exception

class eutester.euproperties.Euproperty_Manager(tester, verbose=False, machine=None, service_url=None, debugmethod=None)[source]
create_dynamic_property_map_from_property(euproperty)[source]
debug(msg)[source]

simple method for printing debug. msg - mandatory - string to be printed method - optional - callback to over ride default printing method

debugmethod = None
get_all_properties_by_search_string(search_string, list=None)[source]
get_all_properties_for_partition(partition, list=None, verbose=False)[source]
get_all_properties_for_service(service, list=None)[source]
get_clc()[source]
get_euproperty_by_name(name, list=None)[source]
get_properties(partition=None, service_type=None, value=None, search_string=None, force_update=False)[source]
get_property(name, service_type, partition, force_update=False)[source]
get_property_by_string(property_string)[source]
get_property_default_value(prop, ireadthewarning=False)[source]

Note: This hack method is intrusive! It will briefly reset the property This is a temporary method to get a properties default method prop - mandatory - string, eucalyptus property ireadthewarning - mandatory - boolean, to warn user this method is intrusive

get_property_value_by_string(property_string)[source]
parse_euproperty_description(propstring)[source]

Example string to parse: “DESCRIPTION www.http_port Listen to HTTP on this port.”

parse_euproperty_from_string(propstring)[source]

Intended to convert a line of ouptut from euca-describe-properties into a euproperty. :param str: line of output, example: “PROPERTY walrus.storagemaxbucketsizeinmb 5120” :returns euproperty

parse_property_value_from_string(propstring)[source]
reset_property_to_default(prop)[source]

Sets a property ‘prop’ at eucaops/eutester object ‘eucaops’ to it’s default value Returns new value prop - mandatory - string representing the property to set ucaops - optional - the eucaops/eutester object to set the property at

set_property(property, value, reset_to_default=False)[source]

Sets the property ‘prop’ at eucaops/eutester object ‘tester’ to ‘value’ Returns new value prop - mandatory - str representing the property to set value - mandatory - str representing the value to set the property to eucaops - optional - the eucaops/eutester object to set the property at

set_property_value_by_string(property_string, value)[source]
show_all_authentication_properties(partition=None, debug_method=None, descriptions=True)[source]
show_all_autoscaling_properties(partition=None, debug_method=None, descriptions=True)[source]
show_all_bootstrap_properties(partition=None, debug_method=None, descriptions=True)[source]
show_all_cloud_properties(partition=None, debug_method=None, descriptions=True)[source]
show_all_cluster_properties(partition=None, debug_method=None, descriptions=True)[source]
show_all_imaging_properties(partition=None, debug_method=None)[source]
show_all_loadbalancing_properties(partition=None, debug_method=None)[source]
show_all_objectstorage_properties(partition=None, debug_method=None, descriptions=True)[source]
show_all_properties(partition=None, service_type=None, value=None, search_string=None, list=None, debug_method=None, descriptions=True)[source]
show_all_reporting_properties(partition=None, debug_method=None, descriptions=True)[source]
show_all_storage_properties(partition=None, debug_method=None, descriptions=True)[source]
show_all_system_properties(partition=None, debug_method=None, descriptions=True)[source]
show_all_tagging_properties(partition=None, debug_method=None)[source]
show_all_vmwarebroker_properties(partition=None, debug_method=None, descriptions=True)[source]
show_all_walrus_properties(partition=None, debug_method=None, descriptions=True)[source]
show_all_www_properties(partition=None, debug_method=None, descriptions=True)[source]
tester = None
update_property_list(property_name='')[source]
verbose = False
class eutester.euproperties.Euproperty_Type[source]
authentication = 'authentication'
autoscaling = 'autoscaling'
bootstrap = 'bootstrap'
cloud = 'cloud'
cloudwatch = 'cloudwatch'
cluster = 'cluster'
dns = 'dns'
classmethod get_type_by_string(typestring)[source]
imaging = 'imaging'
loadbalancing = 'loadbalancing'
objectstorage = 'objectstorage'
reporting = 'reporting'
storage = 'storage'
system = 'system'
tagging = 'tagging'
tokens = 'tokens'
vmwarebroker = 'vmwarebroker'
walrus = 'walrus'
www = 'www'
class eutester.euproperties.Property_Map(**kwargs)[source]

euservice Module

class eutester.euservice.DnsService(service_string)[source]

Bases: eutester.euservice.Euservice

resolve(name, timeout=360, poll_count=20)[source]

Resolve hostnames against the Eucalyptus DNS service

class eutester.euservice.Eunode(tester, hostname, partition, name=None, instance_ids=None, instances=None, state=None, machine=None, debugmethod=None)[source]
debug(msg)[source]

Simple method to print debug messsage ‘msg’ :param msg: message to be printed

get_hypervisor_from_euca_conf()[source]

Attempts to find HYPERVISOR value in <eucalytpus home>/etc/eucalyptus.conf

Returns:string representing hypervisor type if found
get_instance_block_disk_dev_on_node(instance, block_dev)[source]
get_instance_block_disk_source_paths(instance, target_dev=None)[source]

Returns dict mapping target dev to source path dev/file on NC Example return dict: {‘vdb’:’/NodeDiskPath/dev/sde’}

get_instance_block_disk_xml_dom_list(instance_id)[source]
get_instance_console_path(instance_id)[source]
get_instance_device_xml_dom(instance_id)[source]
get_instance_multipath_dev_for_instance_block_dev(instance, ebs_block_dev, verbose=False)[source]
get_instance_multipath_dev_for_instance_ebs_volume(instance, volume)[source]
get_instance_multipath_dev_info_for_instance_block_dev(instance, ebs_block_dev, verbose=False)[source]
get_instance_multipath_dev_info_for_instance_ebs_volume(instance, volume)[source]
get_instance_xml_dom(instance_id)[source]
get_instance_xml_text(instance_id)[source]
get_service_state()[source]
get_virsh_list()[source]

Return a dict of virsh list domains. dict should have dict[‘id’], dict[‘name’], dict[‘state’]

remote_tail_monitor_cb(buf, instance_id, max_lines, lines_read, start_time, timeout, print_method, prefix, idle_timeout)[source]
start()[source]
stop()[source]
sys(cmd, code=None)[source]

Command to be executed via ssh on remote eunode machine :param cmd: string - command to be executed :param code: int - optional exit code used to determine pass fail of remote command. :return: list of lines from remote cmd’s output

tail_instance_console(instance, max_lines=None, timeout=30, idle_timeout=30, print_method=None)[source]
class eutester.euservice.Euservice(service_string, tester=None)[source]

Bases: object

activeactive_service_types = ['objectstorage']
static create_service(service_string, tester=None)[source]
disable()[source]
enable()[source]
get_service_string()[source]
isActiveActive()[source]
isDisabled()[source]
isEnabled()[source]
print_self(header=True, footer=True, printmethod=None)[source]
start()[source]
stop()[source]
class eutester.euservice.EuserviceManager(tester)[source]

Bases: object

all_services_operational()[source]
clc_type_string = 'eucalyptus'
cluster_type_string = 'cluster'
compare_versions(version1, version2)[source]
Parameters:
  • version1
  • version2
Returns:

1 - if version1 is newer than version2

Returns:

0 - if versions are equal

Returns:

-1 - if version1 is older than version2

disable(euservice)[source]
enable(euservice)[source]
get(*func_args, **func_kwargs)[source]

Method attempts to ‘get’ euservices by parsing euca-describe-services on the CLC(s). The method will do some basic service state checks as well as wait for a reasonable amount of time ‘allow_clc_start_time’ in seconds to allow the eucalyptus service(s) to initialize/sync and be ready to service requests.

Parameters:
  • type – service type string to filter returned services list by
  • partition – partition, aka zone, aka cluster to filter by.
  • attempt_both – When set, query the alternate CLC if the first errors
  • allow_clc_start_time – In the case both CLCs are not responding, this is used as the timeout. This time represents the amount of time allowed from the time the clc process(s) were started. If a valid response is not detected, this method will error out.
Returns:

list of euservices

get_all_cloud_controllers(partition=None, state=None, name=None, hostname=None, running=None, use_cached_list=True)[source]

Returns a list of services of CLC services that match the provided filter criteria.

Parameters:
  • partition – partition to fileter returned service list with
  • state – state to filter returned service list with
  • name – name to filter returned service list with
  • hostname – hostname/ip to filter returned service list with
  • running – running boolean to filter returned service list with
  • service_list – list of euservices to filter from
  • use_cached_list – use current list and state of self.all_services, else get_all_services()
Returns:

list of matching cc euservice objects

get_all_cluster_controllers(partition=None, state=None, name=None, hostname=None, running=None, use_cached_list=True)[source]

Returns a list of services of cluster services that match the provided filter criteria.

Parameters:
  • partition – partition to filter returned service list with
  • state – state to filter returned service list with
  • name – name to filter returned service list with
  • hostname – hostname/ip to filter returned service list with
  • running – running boolean to filter returned service list with
  • service_list – list of euservices to filter from
  • use_cached_list – use current list and state of self.all_services, else get_all_services()
Returns:

list of matching cc euservice objects

get_all_node_controllers(hostname=None, partition=None, part_name=None, instance_id=None, has_instances=None, service_state=None, use_cached_list=True)[source]

Returns a list of services of node controllers that match the provided filter criteria.

Parameters:
  • part_name – name of partition to filter list with
  • instance_id – filter list for specific instance id
  • has_instances – filter list by nodes which have instance ids associated with them
  • partition – partition obj to filter returned service list with
  • name – name to filter returned service list with
  • hostname – hostname/ip to filter returned service list with
  • running – running boolean to filter returned service list with
  • use_cached_list – use current list and state of self.all_services, else get_all_services()
Returns:

list of matching cc euservice objects

get_all_osgs(partition=None, state=None, name=None, hostname=None, running=None, use_cached_list=True)[source]

Returns a list of Object Storage Gateways that match the provided filter criteria.

Parameters:
  • partition – partition to filter returned service list with
  • state – state to filter returned service list with
  • name – name to filter returned service list with
  • hostname – hostname/ip to filter returned service list with
  • running – running boolean to filter returned service list with
  • service_list – list of euservices to filter from
  • use_cached_list – use current list and state of self.all_services, else get_all_services()
Returns:

list of matching cc euservice objects

get_all_partitions()[source]
get_all_services()[source]
get_all_services_by_filter(*func_args, **func_kwargs)[source]

Returns a list of services of service that match the provided filter criteria.

Parameters:
  • type – type of service to look for (cluster, eucalyptus, storage, walrus)
  • partition – partition to filter returned service list with
  • state – state to filter returned service list with
  • name – name to filter returned service list with
  • hostname – hostname/ip to filter returned service list with
  • running – running boolean to filter returned service list with
  • use_cached_list – use current list and state of self.all_services, else get_all_services()
Returns:

list of matching cc euservice objects

Examples:
  • Get all the services running on a specific machine “XYZ”:

    get_all_services_by_filter(hostname=”XYZ”)

  • Get all services in ENABLED state:

    get_all_services_by_filter(state=”ENABLED”)

  • Get all Storage controllers in zone/partition “MYZONE”:

    get_all_services_by_filter(type=self.storage_type_string, partition=”MYZONE”)

get_all_storage_controllers(partition=None, state=None, name=None, hostname=None, running=None, use_cached_list=True)[source]

Returns a list of services of storage controller services that match the provided filter criteria.

Parameters:
  • partition – partition to fileter returned service list with
  • state – state to filter returned service list with
  • name – name to filter returned service list with
  • hostname – hostname/ip to filter returned service list with
  • running – running boolean to filter returned service list with
  • service_list – list of euservices to filter from
  • use_cached_list – use current list and state of self.all_services, else get_all_services()
Returns:

list of matching cc euservice objects

get_all_walrus(partition=None, state=None, name=None, hostname=None, running=None, use_cached_list=True)[source]

Returns a list of services of walrus services that match the provided filter criteria.

Parameters:
  • partition – partition to fileter returned service list with
  • state – state to filter returned service list with
  • name – name to filter returned service list with
  • hostname – hostname/ip to filter returned service list with
  • running – running boolean to filter returned service list with
  • service_list – list of euservices to filter from
  • use_cached_list – use current list and state of self.all_services, else get_all_services()
Returns:

list of matching cc euservice objects

get_conclusive_enabled_clc()[source]
get_disabled(list_of_services)[source]

Returns a list of the services of the requested type that are in DISABLED state

get_disabled_clc()[source]
get_disabled_walrus()[source]
get_enabled(list_of_services)[source]

Returns a list of the services of the requested type that are in ENABLED state

get_enabled_clc()[source]
get_enabled_dns()[source]
get_enabled_osg()[source]
get_enabled_osgs()[source]

Returns list of enabled osgs

get_enabled_walrus()[source]
isReachable(address)[source]
modify_process(euservice, command)[source]
modify_service(euservice, state)[source]
node_type_string = 'node'
osg_type_string = 'objectstorage'
populate_nodes(enabled_clc=None)[source]

Sort output of ‘list nodes cmd’ on clc, create/update eunode objects. Returned list is used to update:’service_manager.node_list’

Parameters:enabled_clc – To avoid an update() or update() loop the current enabled clc can be provided. This can also be used to test nc lookup on disabled CLC by providing this component obj instead.
Returns:list of eunode objects
populate_nodes_3_3(enabled_clc=None)[source]

Sort output of ‘list nodes cmd’ on clc, create/update eunode objects. Returned list is used to update:’service_manager.node_list’

Parameters:enabled_clc – To avoid an update() or update() loop the current enabled clc can be provided. This can also be used to test nc lookup on disabled CLC by providing this component obj instead.
Returns:list of eunode objects

version >= 3.3.0 output (note state and instances on lines to follow node(s) [type] [partition] [node hostname] [state] NODE PARTI00 192.168.51.15 ENABLED NODE PARTI00 192.168.51.13 ENABLED [type] [instances per line] INSTANCE i-A1BE4281

populate_nodes_pre_3_3(enabled_clc=None)[source]

Sort output of ‘list nodes cmd’ on clc, create/update eunode objects. Returned list is used to update:’service_manager.node_list’

Parameters:enabled_clc – To avoid an update() or update() loop the current enabled clc can be provided. This can also be used to test nc lookup on disabled CLC by providing this component obj instead.
Returns:list of eunode objects

output for <= 3.2.2 [type] [node hostname] [cc_name] [instances....] NODE 192.168.51.72 CC_71 i-9A293E9B

print_services_list(services=None)[source]
reset()[source]
start(euservice)[source]
start_all()[source]
stop(euservice)[source]
storage_type_string = 'storage'
sync_credentials()[source]
update(name=None)[source]
update_node_list(enabled_clc=None)[source]
update_service_list()[source]
wait_for_all_services_operational(timeout=600)[source]

Attempts to wait for a core set of eutester monitored services on the cloud and/or specified in the config file to transition to ENABLED. In the HA case will look for both an ENABLED and DISABLED service.

wait_for_service(euservice, state='ENABLED', states=None, attempt_both=True, timeout=600)[source]
walrus_type_string = 'walrus'
class eutester.euservice.Partition(name, service_manager)[source]
get_disabled(list)[source]
get_disabled_cc()[source]
get_disabled_sc()[source]
get_disabled_vb()[source]
get_enabled(list)[source]
get_enabled_cc()[source]
get_enabled_sc()[source]
get_enabled_vb()[source]
class eutester.euservice.log_marker(tester, components, start_marker=None, log_files=None)[source]
add_start_marker(components=None, log_files=None, marker=None)[source]

Attempts to add a unique ‘marker’ in the ‘log_files’ provided in all the ‘components’ provided.

Parameters:
  • components
  • log_files
  • marker

eutestcase Module

class eutester.eutestcase.EutesterTestCase(name=None, debugmethod=None, log_level='debug', logfile=None, logfile_level='debug')[source]

Bases: unittest.case.TestCase

add_arg(arg, value)[source]

Description: Adds an arg ‘arg’ within the local testcase args namespace and assigns it ‘value’. If arg exists already in testcase.args, then an exception will be raised.

Parameters:
  • arg (string) – string name of arg to set.
  • value (value) – value to set arg to
clean_method()[source]
color = <eutester.eutestcase.TestColor instance at 0x7f6a21802cf8>
compile_all_args()[source]
create_testunit_by_name(name, obj=None, eof=True, autoarg=True, *args, **kwargs)[source]

Description: Attempts to match a method name contained with object ‘obj’, and create a EutesterTestUnit object from that method and the provided positional as well as keyword arguments provided.

Parameters:
  • name (string) – Name of method to look for within instance of object ‘obj’
  • obj (class instance) – Instance type, defaults to self testcase object
  • args (positional arguements) – None or more positional arguments to be passed to method to be run
  • kwargs (keyword arguments) – None or more keyword arguements to be passed to method to be run
create_testunit_from_method(method, *args, **kwargs)[source]
Description: Convenience method calling EutesterTestUnit.
Creates a EutesterTestUnit object from a method and set of arguments to be fed to that method
Parameters:
  • method (method) – The underlying method for this object to wrap, run and provide information on
  • eof (boolean) – Boolean to indicate whether this testunit should cause a test list to end of failure
  • autoarg (boolean) – Boolean to indicate whether to autopopulate this testunit with values from global testcase.args
  • args (list of positional arguments) – the positional arguments to be fed to the given testunit ‘method’
  • kwargs (list of keyword arguements) – list of keyword
Return type:

EutesterTestUnit

Returns:

EutesterTestUnit object

debug(msg, traceback=1, color=None, linebyline=True)[source]

Description: Method for printing debug

type msg: string param msg: Mandatory string buffer to be printed in debug message

type traceback: integer param traceback: integer value for what frame to inspect to derive the originating method and method line number

type color: TestColor color param color: Optional ascii text color scheme. See TestColor for more info.

disable_color()[source]
do_with_args(meth, *args, **kwargs)[source]

Description: Convenience method used to wrap the provided instance_method, function, or object type ‘meth’ and populate meth’s positional and keyword arguments with the local testcase.args created from the CLI and/or config file, as well as the *args and **kwargs variable length arguments passed into this method.

Parameters:
  • meth (method) – A method or class initiator to wrapped/populated with this testcase objects namespace args
  • args (positional arguments) – None or more values representing positional arguments to be passed to ‘meth’ when executed. These will take precedence over local testcase obj namespace args
  • kwargs (keyword arguments) – None or more values reprsenting keyword arguments to be passed to ‘meth’ when executed. These will take precedence over local testcase obj namespace args and positional args
enable_color()[source]
endfailure(msg='')[source]
endsuccess(msg='')[source]
errormsg(msg='')[source]
format_line_for_color(msg, color)[source]
get_arg(arg)[source]

Description: Fetchs the value of an arg within the local testcase args namespace. If the arg does not exist, None will be returned.

Parameters:arg (string) – string name of arg to get.
Return type:value
Returns:Value of arguement given, or None if not found
get_args(use_cli=True, file_sections=[])[source]

Description: Method will attempt to retrieve all command line arguments presented through local testcase’s ‘argparse’ methods, as well as retrieve all EuConfig file arguments. All arguments will be combined into a single namespace object held locally at ‘testcase.args’. Note: cli arg ‘config’ must be provided for config file valus to be store in self.args.

Parameters:
  • use_cli (boolean) – Boolean to indicate whether or not to create and read from a cli argparsing object
  • use_default_files – Boolean to indicate whether or not to read default config file at $HOME/.eutester/eutester.conf (not indicated by cli)
  • sections (list) – list of EuConfig sections to read configuration values from, and store in self.args.
Return type:

arparse.namespace obj

Returns:

namespace object with values from cli and config file arguements

get_default_userhome_config(fname='eutester.conf')[source]

Description: Attempts to fetch the file ‘fname’ from the current user’s home dir. Returns path to the user’s home dir default eutester config file.

Parameters:fname (string) – the eutester default config file name
Return type:string
Returns:string representing the path to ‘fname’, the default eutester conf file.
classmethod get_meth_arg_names(meth)[source]

Description: Return varnames within argcount :type:meth: method :param: meth: method to fetch arg names for

Return type:list
Returns:list of strings representing the varnames within argcount for this method
classmethod get_method_fcode(meth)[source]
get_pretty_args(testunit)[source]

Description: Returns a string buf containing formated arg:value for printing later

Type:testunit: Eutestcase.eutestertestunit object
Param:testunit: A testunit object for which the namespace args will be used
Return type:string
Returns:formated string containing args and their values.
classmethod get_testunit_method_arg_dict(testunit)[source]
getline(len)[source]
has_arg(arg)[source]

Description: If arg is present in local testcase args namespace, will return True, else False

Parameters:arg (string) – string name of arg to check for.
Return type:boolean
Returns:True if arg is present, false if not
populate_testunit_with_args(testunit, namespace=None)[source]
Description: Checks a given test unit’s available positional and key word args lists for matching
values contained with the given namespace, by default will use local testcase.args. If testunit’s underlying method has arguments matching the namespace provided, then those args will be applied to the testunits args referenced when running the testunit. Namespace values will not be applied/overwrite testunits, if the testunit already has conflicting values in it’s args(positional) list or kwargs(keyword args) dict.
Type:testunit: Eutestcase.eutestertestunit object
Param:testunit: A testunit object for which the namespace values will be applied
Type:namespace: namespace obj
Param:namespace: namespace obj containing args/values to be applied to testunit. None by default will use local testunit args.
print_test_list_results(list=None, printout=True, printmethod=None)[source]

Description: Prints a formated list of results for a list of EutesterTestUnits

Parameters:
  • list (list) – list of EutesterTestUnits
  • printout (boolean) – boolean to flag whether to print using printmethod or self.debug, or to return a string buffer representing the results output
  • printmethod (method) – method to use for printing test result output. Default is self.debug
print_test_list_short_stats(list, printmethod=None)[source]
print_test_unit_startmsg(test)[source]
classmethod print_testunit_method_arg_values(testunit)[source]
resultdefault(msg, printout=True, color='blueongrey')[source]
resulterr(msg, printout=True, color='failred')[source]
resultfail(msg, printout=True, color='redongrey')[source]
run_method_by_name(name, obj=None, *args, **kwargs)[source]

Description: Find a method within an instance of obj and run that method with either args/kwargs provided or any self.args which match the methods varname.

Parameters:
  • name (string) – Name of method to look for within instance of object ‘obj’
  • obj (class instance) – Instance type, defaults to self testcase object
  • args (positional arguements) – None or more positional arguments to be passed to method to be run
  • kwargs (keyword arguments) – None or more keyword arguements to be passed to method to be run
run_test_case_list(list, eof=False, clean_on_exit=True, printresults=True)[source]

Desscription: wrapper to execute a list of ebsTestCase objects

Parameters:
  • list (list) – list of EutesterTestUnit objects to be run
  • eof (boolean) – Flag to indicate whether run_test_case_list should exit on any failures. If this is set to False it will exit only when a given EutesterTestUnit fails and has it’s eof flag set to True.
  • clean_on_exit (boolean) – Flag to indicate if clean_on_exit should be ran at end of test list execution.
  • printresults (boolean) – Flag to indicate whether or not to print a summary of results upon run_test_case_list completion.
Return type:

integer

Returns:

integer exit code to represent pass/fail of the list executed.

run_test_list_by_name(list, eof=None)[source]
set_arg(arg, value)[source]

Description: Sets an arg ‘arg’ within the local testcase args namespace to ‘value’. If arg does not exist in testcase.args, then it will be created.

Parameters:
  • arg (string) – string name of arg to set.
  • value (value) – value to set arg to
setup_debugmethod(testcasename=None, log_level=None, logfile=None, logfile_level=None)[source]
setup_parser(testname=None, description=None, emi=True, zone=True, vmtype=True, keypair=True, credpath=True, password=True, config=True, configblocks=True, ignoreblocks=True, color=True, testlist=True, userdata=True, instance_user=True, stdout_log_level=True, logfile_level=True, logfile=True, instance_password=True, region=True)[source]

Description: Convenience method to setup argparse parser and some canned default arguments, based upon the boolean values provided. For each item marked as ‘True’ this method will add pre-defined command line arguments, help strings and default values. This will then be available by the end script as an alternative to recreating these items on a per script bassis.

Parameters:
  • testname (string) – Name used for argparse (help menu, etc.)
  • description (string) – Description used for argparse (help menu, etc.)
  • emi (boolean) – Flag to present the emi command line argument/option for providing an image emi id via the cli
  • zone (boolean) – Flag to present the zone command line argument/option for providing a zone via the cli
  • vmtype (boolean) – Flag to present the vmtype command line argument/option for providing a vmtype via the cli
  • kepair – Flag to present the keypair command line argument/option for providing a keypair via the cli
  • credpath (boolean) – Flag to present the credpath command line argument/option for providing a local path to creds via the cli
  • password (boolean) – Flag to present the password command line argument/option for providing password

used in establishing machine ssh sessions

Parameters:
  • config (boolean) – Flag to present the config file command line argument/option for providing path to config file
  • configblocks (string list) – Flag to present the configblocks command line arg/option used to provide list of configuration blocks to read from Note: By default if a config file is provided the script will only look for blocks; ‘globals’, and the filename of the script being run.
  • ignoreblocks (string list) – Flag to present the configblocks command line arg/option used to provide list of configuration blocks to ignore if present in configfile Note: By default if a config file is provided the script will look for blocks; ‘globals’, and the filename of the script being run
  • testlist (string list) – Flag to present the testlist command line argument/option for providing a list of testnames to run
  • userdata (boolean) – Flag to present the userdata command line argument/option for providing userdata to instance(s) within test
  • instance_user (boolean) – Flag to present the instance_user command line argument/option for providing an ssh username for instance login via the cli
  • instance_password (boolean) – Flag to present the instance_password command line argument/option for providing a ssh password for instance login via the cli
  • use_color (flag) – Flag to enable/disable use of ascci color codes in debug output.
  • stdout_log_level – boolean flag to present the –log_leveel command line option to set stdout log level
  • logfile_level – boolean flag to present the –logfile_level command line option to set the log file log level
  • logfile – boolean flag to present the –logfile command line option to set the log file path to log to
  • region – boolean flag to present the –region command line option to set the region for the test to use
setuptestcase(name=None, debugmethod=None, use_default_file=False, default_config='eutester.conf', log_level='debug', logfile=None, logfile_level='debug')[source]
show_args(args=None)[source]
Description: Prints args names and values for debug purposes.
By default will use the local testcase.args, else args can be provided.
Parameters:args (namespace object) – namespace object to be printed,by default None will print local testcase’s args.
show_self()[source]
startmsg(msg='')[source]
status(msg, traceback=2, b=1, a=0, testcolor=None)[source]

Description: Convenience method to format debug output

Parameters:
  • msg (string) – The string to be formated and printed via self.debug
  • traceback (integer) – integer value for what frame to inspect to derive the originating method and method line number

:param b:number of blank lines to print before msg

:param a:number of blank lines to print after msg

Parameters:testcolor (TestColor color) – Optional TestColor ascii color scheme
class eutester.eutestcase.EutesterTestResult[source]

standardized test results

failed = 'failed'
not_run = 'not_run'
passed = 'passed'
class eutester.eutestcase.EutesterTestUnit(method, *args, **kwargs)[source]

Description: Convenience class to run wrap individual methods, and run and store and access results.

type method: method param method: The underlying method for this object to wrap, run and provide information on

type args: list of arguments param args: the arguments to be fed to the given ‘method’

type eof: boolean param eof: boolean to indicate whether a failure while running the given ‘method’ should end the test case exectution.

classmethod create_testcase_from_method(method, eof=False, *args, **kwargs)[source]

Description: Creates a EutesterTestUnit object from a method and set of arguments to be fed to that method

type method: method param method: The underlying method for this object to wrap, run and provide information on

type args: list of arguments param args: the arguments to be fed to the given ‘method’

get_test_method_description()[source]

Description: Attempts to derive test unit description for the registered test method. Keys off the string “Description:” preceded by any amount of white space and ending with either a blank line or the string “EndDescription”. This is used in debug output when providing info to the user as to the method being run as a testunit’s intention/description.

run(eof=None)[source]

Description: Wrapper which attempts to run self.method and handle failures, record time.

set_kwarg(kwarg, val)[source]
exception eutester.eutestcase.SkipTestException(value)[source]

Bases: exceptions.Exception

class eutester.eutestcase.TestColor[source]
backgrounds = {'blue': 44, 'setasdefault': 49, 'black': 40, 'yellow': 43, 'cyan': 46, 'green': 42, 'magenta': 45, 'white': 47, 'red': 41}
canned_colors = {'reset': '\x1b[0m', 'blinkwhiteonred': '\x1b[1;5;37;41m', 'whiteongreen': '\x1b[1;37;42m', 'failred': '\x1b[101m', 'whiteonblue': '\x1b[1;37;44m', 'blueongrey': '\x1b[1;34;47m', 'redongrey': '\x1b[1;31;47m', 'red': '\x1b[31m'}
foregrounds = {'blue': 34, 'setasdefault': 39, 'black': 30, 'yellow': 33, 'cyan': 36, 'green': 32, 'magenta': 35, 'white': 37, 'red': 31}
formats = {'reset': '0', 'dim': '2', 'reverse': '7', 'blink': '5', 'uline': '4', 'hidden': '8', 'bold': '1'}
classmethod get_bg_from_string(bg)[source]
classmethod get_canned_color(color)[source]
classmethod get_color(fmt=0, fg='', bg='')[source]

Description: Method to return ascii color codes to format terminal output. Examples:

blinking_red_on_black = get_color(‘blink’, ‘red’, ‘blue’) bold_white_fg = get_color(‘bold’, ‘white, ‘’) green_fg = get_color(‘’,’green’,’‘)

print bold_white_fg+”This text is bold white”+TestColor.reset

Parameters:
  • fmt (color attribute) – An integer or string that represents an ascii color attribute. see TestColor.formats
  • fg (ascii foreground attribute) – An integer or string that represents an ascii foreground color attribute. see TestColor.foregrounds
  • bg (ascii background attribute) – An integer or string that represents an ascii background color attribute. see TestColor.backgrounds
classmethod get_fg_from_string(fg)[source]
classmethod get_format_from_string(format)[source]
reset = '\x1b[0m'

euvolume Module

Created on Mar 7, 2012 @author: clarkmatthew Place holder for volume test specific convenience methods+objects to extend boto’s volume class

class eutester.euvolume.EuVolume(connection=None)[source]

Bases: boto.ec2.volume.Volume, eutester.taggedresource.TaggedResource

classmethod make_euvol_from_vol(volume, tester=None, cmdstart=None)[source]
printself(title=True, footer=True, printmethod=None)[source]
set_attached_status()[source]
set_last_status(status=None)[source]
set_volume_detached_tags()[source]
tag_guestdev_key = 'guestdev'

Note: Different hypervisors will honor the requested cloud dev differently, so the requested device can not be relied up as the device it attached to on the guest ‘guestdev’

tag_instance_id_key = 'instance_id'
tag_md5_key = 'md5'
tag_md5len_key = 'md5len'
update()[source]
update_volume_attach_info_tags(md5=None, md5len=None, instance_id=None, guestdev=None)[source]

machine Module

class eutester.machine.Distro[source]
centos_5 = <eutester.machine.DistroRelease instance at 0x7f6a23078fc8>
centos_6 = <eutester.machine.DistroRelease instance at 0x7f6a23078f38>
debian_squeeze = <eutester.machine.DistroRelease instance at 0x7f6a23078e18>
debian_wheezy = <eutester.machine.DistroRelease instance at 0x7f6a23078e60>
fedora_18 = <eutester.machine.DistroRelease instance at 0x7f6a23084050>
classmethod get_distros(Distro)[source]
rhel_5 = <eutester.machine.DistroRelease instance at 0x7f6a23078f80>
rhel_6 = <eutester.machine.DistroRelease instance at 0x7f6a23078ea8>
ubuntu_lucid = <eutester.machine.DistroRelease instance at 0x7f6a23078d40>
ubuntu_precise = <eutester.machine.DistroRelease instance at 0x7f6a23078dd0>
vmware_4 = <eutester.machine.DistroRelease instance at 0x7f6a230840e0>
vmware_5 = <eutester.machine.DistroRelease instance at 0x7f6a23084098>
class eutester.machine.DistroName[source]
centos = 'centos'
debian = 'debian'
fedora = 'fedora'
rhel = 'rhel'
ubuntu = 'ubuntu'
vmware = 'vmware'
class eutester.machine.DistroRelease(distro_name, distro_number, distro_release='', package_manager=None)[source]
class eutester.machine.Machine(hostname, distro='', distro_ver='', arch='', source='', components='', connect=True, password=None, keypath=None, username='root', timeout=120, retry=2, debugmethod=None, verbose=True)[source]
add_repo(url, name='test-repo')[source]
chown(user, path)[source]
cmd(cmd, verbose=True, timeout=120, listformat=False, cb=None, cbargs=[])[source]

Issues a command against the ssh connection to this instance returns dict containing:

[‘cmd’] - The command which was executed [‘output’] - The std out/err from the executed command [‘status’] - The exit (exitcode) of the command, in the case a call back fires, this status code is unreliable. [‘cbfired’] - Boolean to indicate whether or not the provided callback fired (ie returned False) [‘elapsed’] - Time elapsed waiting for command loop to end.

cmd - mandatory - string, the command to be executed verbose - optional - boolean flag to enable debug timeout - optional - command timeout in seconds listformat -optional - specifies returned output in list of lines, or single string buffer cb - optional - call back function, accepting string buffer, returning true false see sshconnection for more info

config[source]
debug(msg)[source]

Used to print debug, defaults to print() but over ridden by self.debugmethod if not None msg - mandatory -string, message to be printed

distro[source]
dump_netfail_info(ip=None, mac=None, pass1=None, pass2=None, showpass=True, taillength=50)[source]

Debug method to provide potentially helpful info from current machine when debugging connectivity issues.

eucalyptus_conf[source]
found(command, regex, verbose=True)[source]

Returns a Boolean of whether the result of the command contains the regex

get_available(path, unit=1)[source]

Return df output’s available field. By default this is KB. path - optional -string. unit - optional -integer used to divide return value. Can be used to convert KB to MB, GB, TB, etc..

get_df_info(path=None, verbose=True)[source]

Return df’s output in dict format for a given path. If path is not given will give the df info for the current working dir used in the ssh session this command is executed in (ie: /home/user or /root). path - optional -string, used to specifiy path to use in df command. Default is PWD of ssh shelled command verbose - optional -boolean, used to specify whether or debug is printed during this command. Example:

dirpath = ‘/disk1/storage’ dfout = self.get_df_info(path=dirpath) available_space = dfout[‘available’] mounted_on = dfout[‘mounted’] filesystem = dfout[‘filesystem’]
get_distro_info_from_machine()[source]
get_elapsed_seconds_since_pid_started(pid)[source]

Attempts to parse ps time elapsed since process/pid has been running and return the presented time in elapsed number of seconds. :param pid: Process id to get elapsed time from :return: Elapsed time in seconds that pid has been running

get_eucalyptus_cc_is_running_status()[source]

Checks eucalyptus-cc service status :return: boolean, True if running False if not.

get_eucalyptus_cc_pid()[source]
Returns:Returns the process id for eucalyptus-cc running on this machine, or None if not found.
get_eucalyptus_cc_process_uptime()[source]

Attempts to look up the elapsed running time of the PID associated with the eucalyptus-cc process/service. :return: (int) elapsed time in seconds this PID has been running

get_eucalyptus_cloud_is_running_status()[source]

Checks eucalyptus-cloud service status :return: boolean, True if running False if not.

get_eucalyptus_cloud_pid()[source]
Returns:Returns the process id for eucalyptus-cloud running on this machine, or None if not found.
get_eucalyptus_cloud_process_uptime()[source]

Attempts to look up the elapsed running time of the PID associated with the eucalyptus-cloud process/service. :return: (int) elapsed time in seconds this PID has been running

get_eucalyptus_conf(eof=False, verbose=False)[source]
get_eucalyptus_nc_is_running_status()[source]

Checks eucalyptus-nc service status :return: boolean, True if running False if not.

get_eucalyptus_nc_pid()[source]
Returns:Returns the process id for eucalyptus-nc running on this machine, or None if not found.
get_eucalyptus_nc_process_uptime()[source]

Attempts to look up the elapsed running time of the PID associated with the eucalyptus-nc process/service. :return: (int) elapsed time in seconds this PID has been running

get_eucalyptus_service_pid(eucalyptus_service)[source]

Returns the process id or pid of the eucalyptus service running on this machine. Will return None if not found, which may indicate the process is not running or not intended to run on this machine.

Parameters:eucalyptus_service – eucalyptus-cloud, eucalyptus-cc, eucalyptus-nc
Returns:string representing pid
get_eucalyptus_version(versionpath='/etc/eucalyptus/eucalyptus-version')[source]
Parameters:versionpath – path to version file
Returns:eucalyptus version string
get_file_groupid(path)[source]
get_file_perms_flag(path)[source]
get_file_size(path)[source]
get_file_stat(path)[source]
get_file_userid(path)[source]
get_installed_packages()[source]
get_masked_pass(pwd, firstlast=True, charcount=True, show=False)[source]

format password for printing options: pwd - string- the text password to format firstlast -boolean - show the first and last characters in pwd charcount -boolean - print a “*” for each char in pwd, otherwise return fixed string ‘hidden‘ show - boolean - convert pwd to str() and return it in plain text

get_package_info()[source]
get_service_is_running_status(service, code=0)[source]

Checks status of service ‘service’ on the machine obj. :param service: string representing service name :return: boolean.

get_uptime()[source]
install(package, nogpg=False, timeout=300)[source]
interrupt_network(time=120, interface='eth0')[source]
is_file_present(filepath)[source]
mkfs(partition, type='ext3')[source]
mount(device, path)[source]
package_manager[source]
ping_check(host)[source]
ping_cmd(host, count=2, pingtimeout=10, commandtimeout=120, listformat=False, verbose=True)[source]
poll_log(log_file='/var/log/messages')[source]
put_templated_file(local_src, remote_dest, **kwargs)[source]
reboot(force=True)[source]
refresh_connection()[source]
refresh_ssh()[source]
repo_utils[source]
save_all_logs(path='logs')[source]

Save log buffers to a file

save_log(log_file, path='logs')[source]

Save log buffer for log_file to the path to a file

sftp[source]
ssh[source]
start_log(log_file='/var/log/messages')[source]

Start thread to poll logs

stop_log(log_file='/var/log/messages')[source]

Terminate thread that is polling logs

str_found(buf, regex, search=True)[source]

Return True if given regex matches against given string

str_found_cb(buf, regex, verbose, search=True)[source]

Return sshcbreturn type setting stop to True if given regex matches against given string buf

sys(cmd, verbose=True, timeout=120, listformat=True, code=None)[source]

Issues a command against the ssh connection to this instance Returns a list of the lines from stdout+stderr as a result of the command

sys_until_found(cmd, regex, verbose=True, timeout=120, listformat=True)[source]

Run a command until output of command satisfies/finds regex or EOF is found. returns dict containing:

[‘cmd’] - The command which was executed [‘output’] - The std out/err from the executed command [‘status’] - The exit (exitcode) of the command, in the case a call back fires, this status code is unreliable. [‘cbfired’] - Boolean to indicate whether or not the provided callback fired (ie returned False) [‘elapsed’] - Time elapsed waiting for command loop to end.

cmd - mandatory - string, the command to be executed regex - mandatory - regex to look for verbose - optional - boolean flag to enable debug timeout - optional - command timeout in seconds listformat -optional - specifies returned output in list of lines, or single string buffer

update_repos()[source]
upgrade(package=None, nogpg=False)[source]
wget_remote_image(url, path=None, dest_file_name=None, user=None, password=None, retryconn=True, timeout=300)[source]
wget_status_cb(buf)[source]

repoutils Module

class eutester.repoutils.Apt(machine)[source]

Bases: eutester.repoutils.PackageManager

add_repo(url, name=None)[source]
install(package, timeout=300)[source]
update_repos()[source]
upgrade(package=None)[source]
class eutester.repoutils.Package[source]
name = None
version = None
class eutester.repoutils.PackageManager[source]
add_repo(url, name=None)[source]
get_installed_packages()[source]
get_package_info()[source]
install(package)[source]
machine = None
name = None
update_repos()[source]
upgrade(package=None)[source]
class eutester.repoutils.RepoUtils(machine, package_manager='yum')[source]
class eutester.repoutils.Yum(machine)[source]

Bases: eutester.repoutils.PackageManager

add_repo(url, name=None)[source]
install(package, nogpg=False)[source]
update_repos()[source]
upgrade(package=None, nogpg=False)[source]

sshconnection Module

Created on Mar 7, 2012 @author: clarkmatthew

simple class to establish an ssh session example usage:

import sshconnection ssh = SshConnection( ‘192.168.1.1’, keypath=’/home/testuser/keyfile.pem’)

#use sys() to get either a list of output lines or a single string buffer depending on listformat flag output = ssh.sys(‘ls /dev/sd*’,timeout=10) print output[0] print ssh.lastcmd+” exited with code: “+str(ssh.lastexitcode)

#...or use cmd to get a dict of output, exitstatus, and elapsed time to execute... out = ssh.cmd(‘ping 192.168.1.2 -c 1 -W 5’)

print out[‘cmd’]+” exited with status:”+out[‘status’]+”, elapsed time:”+out[‘elapsed’] print out[‘output’]
example with proxy:

import sshconnection

instance_private_ip = ‘10.1.1.5’ instance_user = ‘root’ instance_keypath = ‘/tmp/instancekey.pem’

proxy_ip = ‘192.168.1.2’ proxy_username = ‘testuser’ #proxy_password = ‘foo’ proxy_keypath = ‘/home/testuser/keyfile.pem’

example output from ipython:

In[4]: instance_ssh = SshConnection( instance_private_ip, username=instance_user, keypath=instance_keypath,
proxy=proxy_ip, proxy_username = proxy_username, proxy_keypath = proxy_keypath, debug_connect = True)

ssh_connect args: hostname:10.1.1.5 username:root password:None keypath:/tmp/instancekey.pem timeout:60 retry:1 IPV6 DNS lookup disabled, do IPV4 resolution and pass IP to connect() 10.1.1.5, is already an ip, dont do host lookup... 192.168.1.2, is already an ip, dont do host lookup... SSH connection attempt(1 of 2), host:’root@10.1.1.5’, using ipv4:10.1.1.5, thru proxy:‘192.168.1.2’ Using Keypath:/tmp/instancekey.pem SSH - Connected to 10.1.1.5 via proxy host:192.168.1.2:22

In [5]: instance_ssh.sys(‘hostname’) Out[5]: [‘euca_10_1_1_5.eucalyptus_cloud.com’]

exception eutester.sshconnection.CommandExitCodeException(value)[source]

Bases: exceptions.Exception

exception eutester.sshconnection.CommandExpectPasswordException(value)[source]

Bases: exceptions.Exception

exception eutester.sshconnection.CommandTimeoutException(value)[source]

Bases: exceptions.Exception

class eutester.sshconnection.SshCbReturn(stop=False, statuscode=-1, settimer=0, buf=None, sendstring=None, nextargs=None, nextcb=None, removecb=False)[source]
class eutester.sshconnection.SshConnection(host, username='root', password=None, keypair=None, keypath=None, proxy=None, proxy_username='root', proxy_password=None, proxy_keyname=None, proxy_keypath=None, key_files=None, find_keys=True, enable_ipv6_dns=False, timeout=60, retry=1, debugmethod=None, verbose=False, debug_connect=False)[source]
close()[source]
close_sftp()[source]
cmd(cmd, verbose=None, timeout=120, listformat=False, enable_debug=False, cb=None, cbargs=, []invoke_shell=False, get_pty=True, shell_delay=2, shell_return='r')[source]

Runs a command ‘cmd’ within an ssh connection. Upon success returns dict representing outcome of the command.

Returns dict:
[‘cmd’] - The command which was executed [‘output’] - The std out/err from the executed command [‘status’] - The exitcode of the command. Note in the case a call back fires, this exitcode is unreliable. [‘cbfired’] - Boolean to indicate whether or not the provided callback fired (ie returned False) [‘elapsed’] - Time elapsed waiting for command loop to end.

Arguments: :param cmd: - mandatory - string representing the command to be run against the remote ssh session :param verbose: - optional - will default to global setting, can be set per cmd() as well here :param timeout: - optional - integer used to timeout the overall cmd() operation in case of remote blocking :param listformat: - optional - boolean, if set returns output as list of lines, else a single buffer/string :param cb: - optional - callback, method that can be used to handle output as it’s rx’d instead of...

waiting for the cmd to finish and return buffer. Called like: cb(ssh_cmd_out_buffer, *cbargs) Must accept string buffer, and return an integer to be used as cmd status. Must return type ‘sshconnection.SshCbReturn’ If cb returns stop, recv loop will end, and channel will be closed. if cb settimer is > 0, timer timeout will be adjusted for this time if cb statuscode is != -1 cmd status will return with this value if cb nextargs is set, the next time cb is called these args will be passed instead of cbargs
Parameters:
  • cbargs
    • optional - list of arguments to be appended to output buffer and passed to cb
  • enable_debug
    • optional - boolean, if set will use self.debug() to print additional messages during cmd()
cmd_not_executed_code = -99
cmd_timeout_err_code = -100
debug(msg, verbose=None)[source]

simple method for printing debug. :param msg: - mandatory - string to be printed :param verbose: boolean to override global verbose flag

expect_password_cb(buf, password, prompt='^Password', nextcb=None, cbargs=, []retry=0, password_attempts=0, verbose=False)[source]

Sample callback to handle password prompts to be provided to ssh.cmd() :param buf: output from cmd() :param password: string password to be supplied to a detected ‘password’ prompt :param nextcb: function/method callback to be returned, this cmd() will use to handle it’s future output. :param prompt: regex string used to match prompt. case insensitive match used :

expect_prompt_cb(buf, command=None, prompt_match='^\w+(>|#|\$)', verbose=None)[source]
get_ipv4_lookup(hostname, port=22, verbose=False)[source]

Do an ipv4 lookup of ‘hostname’ and return list of any resolved ip addresses

Parameters:
  • hostname – hostname to resolve
  • port – port to include in lookup, default is ssh port 22
  • verbose – boolean to print addditional debug
Returns:

list of ip addresses (strings in a.b.c.d format)

get_proxy_transport(proxy_host=None, dest_host=None, port=22, proxy_username='root', proxy_password=None, proxy_keypath=None, key_files=None, verbose=True)[source]
Parameters:
  • key_files – pubkey file. If ‘None’ will check global self.key_files default:’~/.ssh/authorized_keys’
  • verbose – print debug
  • proxy_host – hostname of ssh proxy
  • port – ssh proxy port
  • dest_host – end host to connect to
  • proxy_username – proxy username for ssh authentication
  • proxy_password – proxy password for ssh authentication
  • proxy_keypath – local path to key used for ssh authentication
Returns:

paramiko transport

get_ssh_connection(hostname, username='root', password=None, keypath=None, proxy=None, proxy_username=None, proxy_password=None, proxy_keypath=None, key_files=None, enable_ipv6_dns=None, port=22, timeout=60, retry=1, verbose=False)[source]

Create a paramiko ssh session to hostname. Will attempt to authenticate first with a keypath if provided, if the sshkey file path is not provided. username and password will be used to authenticate. This leaves out the case where a password is passed as the password needed to unlock the key file. This 3rd case may need to be added but may mask failures in tests for key insertion when using tests who’s images have baked in passwords for login access(tbd). Upon success returns a paramiko sshclient with an established connection.

Parameters:
  • hostname
    • mandatory - hostname or ip to establish ssh connection with
  • username
    • optional - username used to authenticate ssh session
  • password
    • optional - password used to authenticate ssh session
  • keypath
    • optional - full path to sshkey file used to authenticate ssh session
  • proxy
    • optional - host to proxy ssh connection through
  • proxy_username
    • optional ssh username of proxy host for authentication
  • proxy_password
    • optional ssh password of proxy host for authentication
  • proxy_keypath
    • optional path to ssh key to use for proxy authentication
  • timeout
    • optional - tcp timeout
  • enable_ipv6_dns
    • optional - boolean to avoid ipv6 dns ‘AAAA’ lookups
  • retry
    • optional - Number of attempts to establish ssh connection for errors outside of authentication
  • port
    • optional - port to connect to, default 22
  • verbose
    • optional - enable verbose debug output
mask_password(pass_string)[source]

Replace all but first and last chars with ‘*’ of provided password string.

Parameters:pass_string – string representing a password to hide/format
Returns:Formatted hidden password
open_sftp(transport=None)[source]
refresh_connection()[source]

Attempts to establish a new ssh connection to replace the old ‘connection’ of this ssh obj.

sftp_get(localfilepath, remotefilepath)[source]

sftp transfer file from remotefilepath to remote system at localfilepath :param localfilepath: path where remote file ‘get’ will place file on local system :param remotefilepath: destination path for file to ‘get’ on remote system

sftp_put(localfilepath, remotefilepath)[source]

sftp transfer file from localfilepath to remote system at remotefilepath :param localfilepath: path to file on local system :param remotefilepath: destination path for put on remote system

ssh_sys_timeout(chan, start, cmd)[source]

callback to be scheduled during ssh cmds which have timed out. :param chan: - paramiko channel to be closed :param start - time.time() used to calc elapsed time when this fired for debug :param cmd - the command ran

start_interactive(timeout=180)[source]

Example method to invoke an interactive shell :pararm timeout: inactive session timeout, a value of 0 will wait for input/output forever

sys(cmd, verbose=False, timeout=120, listformat=True, enable_debug=False, code=None)[source]

Issue a command cmd and return output in list format

Parameters:
  • cmd
    • mandatory - string representing the command to be run against the remote ssh session
  • verbose
    • optional - will default to global setting, can be set per cmd() as well here
  • timeout
    • optional - integer used to timeout the overall cmd() operation in case of remote blockingd
  • listformat
    • optional - format output into single buffer or list of lines
  • code
    • optional - expected exitcode, will except if cmd’s exitcode does not match this value

xmlrunner Module

XML Test Runner for PyUnit

class eutester.xmlrunner.XMLTestRunner(stream=None)[source]

Bases: object

A test runner that stores results in XML format compatible with JUnit.

XMLTestRunner(stream=None) -> XML test runner

The XML file is written to the supplied stream. If stream is None, the results are stored in a file called TEST-<module>.<class>.xml in the current working directory (if not overridden with the path property), where <module> and <class> are the module and class name of the test class.

path

The path where the XML files are stored.

This property is ignored when the XML file is written to a file stream.

run(test)[source]

Run the given test case or test suite.

class eutester.xmlrunner.XMLTestRunnerTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

class NullStream[source]

Bases: object

A file-like object that discards everything written to it.

write(buffer)[source]
XMLTestRunnerTest.setUp()[source]
XMLTestRunnerTest.test_error()[source]

Regression test: Check whether a test run with a erroneous test matches a previous run.

XMLTestRunnerTest.test_failure()[source]

Regression test: Check whether a test run with a failing test matches a previous run.

XMLTestRunnerTest.test_no_tests()[source]

Regression test: Check whether a test run without any tests matches a previous run.

XMLTestRunnerTest.test_stderr_capture()[source]

Regression test: Check whether a test run with output to stderr matches a previous run.

XMLTestRunnerTest.test_stdout_capture()[source]

Regression test: Check whether a test run with output to stdout matches a previous run.

XMLTestRunnerTest.test_success()[source]

Regression test: Check whether a test run with a successful test matches a previous run.

XMLTestRunnerTest.test_unittests_changing_stderr()[source]

Check whether the XMLTestRunner recovers gracefully from unit tests that change stderr, but don’t change it back properly.

XMLTestRunnerTest.test_unittests_changing_stdout()[source]

Check whether the XMLTestRunner recovers gracefully from unit tests that change stdout, but don’t change it back properly.

Contents