def sytem_fault_notify(): handle = cps.event_connect() pas_fault_obj = cps_object.CPSObject(module='base-pas/platform-fault', data={ 'fault-type': 8 }) cps.event_send(handle,pas_fault_obj.get())
def publish_events(self, mod, event_data, op): """ This function publishes/raises CPS Events with the information from event_data @param[in] event_data: Input Dictionary which will be used when publishing events @returns None """ obj = cps_object.CPSObject(module=mod, qual="observed") for key in event_data: if isinstance(key, tuple) and len(key) > 1: obj.add_embed_attr(list(key), event_data[key], len(key)) else: obj.add_attr(key, event_data[key]) d = obj.get() d['operation'] = op cps.event_send(self.handle, d)
def send_fp_event(port): handle = cps.event_connect() fp_port_obj = cps_object.CPSObject(module='base-if-phy/front-panel-port', data={ 'npu-id': port.npu, 'front-panel-port': port.id, 'control-port': port.control_port(), 'port': port.hwports, 'default-name': port.name, 'breakout-mode': port.get_breakout_mode(), 'port-speed': port.get_port_speed() }) cps.event_send(handle, fp_port_obj.get())
import cps import cps_utils handle = cps.event_connect() obj = cps_utils.CPSObject('base-port/interface',qual='observed', data= {"ifindex":23}) cps.event_send(handle, obj.get())
import cps import cps_utils handle = cps.event_connect() obj = cps_utils.CPSObject('base-port/interface',qual='observed', data= {"ifindex":23}) cps.event_send(handle, obj.get())
_operation = ['set', 'create', 'delete'] if _in_op not in _operation: print "\nCheck operation, supported operations (set/create/delete)\n" exit(1) _qual = ['target', 'observed', 'proposed', 'realtime'] if _in_qual not in _qual: print "\nCheck qualifier, supported qualifiers (target/observed/proposed/realtime)\n" exit(1) _key = cps.key_from_name(_in_qual, sys.argv[3]) if ((_key == "") or (_key == None)): print "\nCheck the object name, not a valid object\n" exit(1) handle = cps.event_connect() print " sending event for...." _obj = cps_object.CPSObject(qual=_in_qual, module=sys.argv[3]) for e in sys.argv[4:]: attr = e.split('=', 1) _obj.add_attr(attr[0], attr[1]) cur_obj = _obj.get() ev = {'operation': _in_op, 'key': cur_obj['key'], 'data': cur_obj['data']} cps.event_send(handle, ev) if 'operation' in ev: print "Operation : ", ev['operation'] cps_utils.print_obj(cur_obj)
_operation = ['set', 'create', 'delete'] if _in_op not in _operation: print "\nCheck operation, supported operations (set/create/delete)\n" exit(1) _qual = ['target', 'observed', 'proposed', 'realtime'] if _in_qual not in _qual: print "\nCheck qualifier, supported qualifiers (target/observed/proposed/realtime)\n" exit(1) _key = cps.key_from_name(_in_qual, sys.argv[3]) if ((_key == "") or (_key == None)): print "\nCheck the object name, not a valid object\n" exit(1) handle = cps.event_connect() print " sending event for...." _obj = cps_object.CPSObject(qual=_in_qual, module=sys.argv[3]) for e in sys.argv[4:]: attr = e.split('=',1) _obj.add_attr(attr[0],attr[1]) cur_obj = _obj.get() ev = {'operation':_in_op, 'key':cur_obj['key'], 'data':cur_obj['data']} cps.event_send(handle, ev) if 'operation' in ev: print "Operation : ", ev['operation'] cps_utils.print_obj(cur_obj)