Owners Manual

if(cps_api_action(&tran,obj) != cps_api_ret_code_OK ){
cps_api_object_delete(obj);
return false;
}
// Commit the transaction
if(cps_api_commit(&tran) != cps_api_ret_code_OK ) {
cps_api_transaction_close(&tran);
return false;
}
// Cleanup the Transaction
cps_api_transaction_close(&tran);
return true;
}
Event application examples
Register events
1 Import the CPS object Python library.
import cps
2 Create a handle to connect to event service.
handle = cps.event_connect()
3 Register a key with the event service to receive notication when an event for the key is published.
cps.event_register(handle, cps.key_from_name('observed','base-port/interface'))
while True:
# wait for the event
o = cps.event_wait(handle)
print o
register-for-events.py
#Python block code to register for events
import cps
#Create handle to connect to event service
handle = cps.event_connect()
#Register key with event service
cps.event_register(handle, cps.key_from_name('observed','base-port/interface'))
while True:
o = cps.event_wait(handle)
print o
register-for-events.c
// C application example to register for events
#include "cps_api_events.h"
#include "cps_api_object.h"
#include "dell-base-phy-interface.h"
#include "cps_class_map.h"
#include "cps_api_object_key.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
// Callback for the interface event handling
static bool cps_if_event_cb(cps_api_object_t obj, void *param){
42
Application examples