-
Notifications
You must be signed in to change notification settings - Fork 35
Event application examples
This information contains event application examples, including verification.
-
opx-alm-service
contains an example of a Python application that registers for events (see opx-alm-service). -
cps_api_events_unittest.cpp
contains an example of a C++ application that registers for events (see cps_api_events_unittest.cpp). -
cps_send_event.py
contains an example of publishing events in Python (see cps_send_event.py). -
cps_api_events_unittest.cpp
contains an example of publishing events in C++ (see cps_api_events_unittest.cpp).
1. Import the CPS object Python library.
import cps
2. Create a handle to connect to the event service.
handle = cps.event_connect()
3. Register a key with the event service to receive notification when an event is published.
cps.event_register(handle, cps.key_from_name('observed','dell-base-if-cmn/if/interfaces/interface'))
while True:
# wait for the event
obj = cps.event_wait(handle)
print obj
See register_for_events.py to view the Python application example, or see register_for_events.c to view the C application example.
NOTE: The CPS Python API does not support a function to register a callback for published events.
1. Import the CPS and CPS object Python library.
import cps
import cps_utils
2. Create a handle to connect to the event service.
handle = cps.event_connect()
3. Create a CPS object.
obj = cps_utils.CPSObject('dell-base-if-cmn/if/interfaces/interface',qual='observed', data= {"ifindex":23})
4. Publish the CPS object.
cps.event_send(handle, obj.get())
See publish_events.py to view the Python application example, or see publish_events.c to view the C application example.
© 2019 OpenSwitch project. All information is contributed to and made available by OPX under the Creative Commons Attribution 4.0 International License (available at http://creativecommons.org/licenses/by/4.0/).
- Home
- System overview
- Software releases
- Hardware support
- FAQs
- Install
- Build
- Configure
- Develop
- Administer
- Troubleshoot
- Software compatibility
- Contribute
- DevOps
- Join