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'}¶
-
-
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.
-
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
-
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.
-
started
¶
-