cfme.utils.events module

Library for event testing.

class cfme.utils.events.Event(appliance, *args)[source]

Bases: object

Event represents either event received by REST API or an expected event.

Variables:TARGET_TYPES – Mapping of object types to REST API collections.
TARGET_TYPES = {'Host': 'hosts', 'Service': 'services', 'VmOrTemplate': 'vms'}
add_attrs(*attrs)[source]

Adds an EventAttr to event.

build_from_entity(event_entity)[source]

Builds Event object from event Entity

matches(evt)[source]

Compares common attributes of expected event and passed event.

process_id()[source]

Resolves target_id by target_type and target name.

class cfme.utils.events.EventAttr(attr_type=None, cmp_func=None, **attrs)[source]

Bases: object

EventAttr helps to compare event attributes with specific method.

Contains one event attribute and the method for comparing it.

match(attr)[source]

Compares current attribute with passed attribute.

class cfme.utils.events.RestEventListener(appliance)[source]

Bases: threading.Thread

EventListener accepts “expected” events, listens to db events and compares matched events with expected events. Runs callback function if expected events have it.

Variables:FILTER_ATTRS – List of filters used in REST API call
FILTER_ATTRS = ['event_type', 'target_type', 'target_id', 'source']
__call__(*args, **kwargs)[source]

it is called by register_event fixture. bad idea, to replace register_event by object later

check_expected_events()[source]

Checks that all expected events has arrived.

get_next_portion(evt)[source]

Returns list with one or more events matched with expected event.

Returns None if there is no matched events.

got_events

Returns dict with expected events and all the events matched to expected ones.

listen_to(*evts, **kwargs)[source]

Adds expected events to EventListener

May accept one or many events. Callback function will is called when expected event has arrived in event_streams. Callback will receive expected event and got event as params.

Parameters:
  • evts – list of events which EventListener should listen to
  • callback – callback function that will be called if event is received
  • first_event – EventListener will skip processing event if it has been occurred once.

By default EventListener collects and receives all matching events.

new_event(*attrs, **kwattrs)[source]

This method simplifies “expected” event creation.

Usage:

listener = appliance.event_listener()
evt = listener.new_event(target_type='VmOrTemplate',
                         target_name='my_lovely_vm',
                         event_type='vm_create')
listener.listen_to(evt)
process_events()[source]

Processes all new events and compares them with expected events.

Processed events are ignored next time.

reset_events()[source]
run()[source]

Overrides ThreadEvent run to continuously process events

set_last_record()[source]

Sets last_processed_id to the latest event.

start()[source]
started
stop()[source]