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']¶
-
get_next_portion
(evt, max_id=None)[source]¶ Returns list with one or more events matched with expected event.
Returns None if there is no matched events.
-
property
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.
-
start
()[source]¶ Start the thread’s activity.
It must be called at most once per thread object. It arranges for the object’s run() method to be invoked in a separate thread of control.
This method will raise a RuntimeError if called more than once on the same thread object.
-
property
started
¶