<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi All,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
tried push_event scripts with the help of you old posts and mail mailing list. I am stuck at defining filterable_data, header and remainder_of_body. How to proceed further, please suggest. Below is the my code.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div>class NmsSession_I(nmsSession__POA.NmsSession_I):</div>
<div>    pass</div>
<div><br>
</div>
<div>class StructuredPushConsumerImpl(CosNotifyComm__POA.StructuredPushConsumer):</div>
<div>  def __init__(self, orb):</div>
<div>        self.orb = orb</div>
<div><br>
</div>
<div>class psconsumer(CosEventComm__POA.PushConsumer):</div>
<div>      def __init__(self):</div>
<div>          pass</div>
<div><br>
</div>
<div>def main():</div>
<div>  argv = ["-ORBInitRef", "NameService=corbaloc:iiop:10.10.118.3:12001/NameService"]
</div>
<div>#</div>
<div>  # Start orb.</div>
<div>  global orb</div>
<div>  orb=CORBA.ORB_init(argv, CORBA.ORB_ID)</div>
<div><br>
</div>
<div>  # Process Options</div>
<div>  verbose=0</div>
<div>  needNameService=0</div>
<div>  channelName="EventChannel"</div>
<div>  factoryName="EventChannelFactory"</div>
<div>  criteria=[]</div>
<div><br>
</div>
<div>  action="start"</div>
<div>  try:</div>
<div><br>
</div>
<div>    #</div>
<div>    # Get Name Service root context.</div>
<div>       rootContext=None</div>
<div>       try:</div>
<div>           action="resolve initial reference 'NameService'"</div>
<div>           obj=orb.resolve_initial_references("NameService")</div>
<div>           rootContext=obj._narrow(CosNaming.NamingContext)</div>
<div>           if rootContext is None:</div>
<div>               raise CORBA.OBJECT_NOT_EXIST(0,CORBA.COMPLETED_NO)</div>
<div>       except CORBA.Exception as ex:</div>
<div>           if needNameService:</div>
<div>               raise ex</div>
<div>           else:</div>
<div>               sys.stderr.write("Warning - failed to %s\n"%action)</div>
<div>    ### Initilizing POA ###</div>
<div>       </div>
<div>       name = [CosNaming.NameComponent("TMF_MTNM","Class"),</div>
<div>                CosNaming.NameComponent("HUAWEI","Vendor"),</div>
<div>                CosNaming.NameComponent("Huawei/NCE","EmsInstance"),</div>
<div>                CosNaming.NameComponent("2.0","Version"),</div>
<div>                CosNaming.NameComponent("Huawei/NCE","EmsSessionFactory_I")]</div>
<div><br>
</div>
<div>       </div>
<div>       try:</div>
<div>             obj = rootContext.resolve(name)</div>
<div>       except CosNaming.NamingContext.NotFound as ex:</div>
<div>             print("Except->Name not found")</div>
<div>             print(ex)</div>
<div>       try:</div>
<div>           poa = orb.resolve_initial_references("RootPOA")</div>
<div>       except Exception as ex:</div>
<div>           print('POA initial References Error: {}'.format(ex))</div>
<div><br>
</div>
<div>       try:</div>
<div>           poaManager = poa._get_the_POAManager()</div>
<div>       except Exception as ex:</div>
<div>           print('POA get manager error : {}'.format(ex))</div>
<div>       try:</div>
<div>           poaManager.activate()</div>
<div>       except Exception as ex:</div>
<div>           print('POA manager Activation Error: {}'.format(ex))</div>
<div><br>
</div>
<div>        ### Narrow the object</div>
<div>       ems_session = obj._narrow(emsSessionFactory.EmsSessionFactory_I)</div>
<div>       if ems_session is None:</div>
<div>           print("Object reference is not an EmsSessionFactory_I")</div>
<div>       ### Get NMS session</div>
<div>       nms_session_i = NmsSession_I()</div>
<div>       nms_session_o = nms_session_i._this()</div>
<div>       if nms_session_o is None:</div>
<div>           print("Object reference is not an NmsSession_I")</div>
<div>           sys.exit(1)</div>
<div><br>
</div>
<div>       ##Get ems Session ###</div>
<div>       try:</div>
<div>             session = ems_session.getEmsSession("user1", "passwd", nms_session_o)</div>
<div><br>
</div>
<div>        #print(dir(session))</div>
<div>       except Exception as ex:</div>
<div>              print('System Error: {}'.format(ex))</div>
<div>              sys.exit(1)</div>
<div>       #print(dir(session))</div>
<div>       try:</div>
<div>              eventChannel = session.getEventChannel()</div>
<div>       except globaldefs.ProcessingFailureException as ex:</div>
<div>              print('System Error: {}'.format(ex))</div>
<div>              eventChannel.destroy()</div>
<div>              session.endSession()</div>
<div>              sys.exit(1)</div>
<div>       #</div>
<div>       #impl = StructuredPushConsumerImpl(orb)</div>
<div>       #obj = impl._this()</div>
<div>       eventTypeAdd = [ CosNotification.EventType("tmf_mtnm", "NT_ALARM") ]</div>
<div>       eventTypeRemove = [ CosNotification.EventType("tmf_mtnm", "NT_HEARTBEAT") ]</div>
<div>       try:</div>
<div>          consumerAdmin, consID = eventChannel.new_for_consumers(CosNotifyChannelAdmin.AND_OP)</div>
<div>          #print(consumerAdmin[0])</div>
<div>          #print(dir(InterFilterGroupOperator))</div>
<div>       except Exception as e:</div>
<div>           print(e)</div>
<div>       try:</div>
<div>           consumerAdmin.subscription_change(eventTypeAdd, eventTypeRemove)</div>
<div>       except Exception as e:</div>
<div>           print(e)</div>
<div>       try:</div>
<div>           consumerAdmin.remove_all_filters()</div>
<div>       except Exception as e:</div>
<div>           print(e)</div>
<div>       subFilter="1==1"</div>
<div>       ffp = eventChannel._get_default_filter_factory()</div>
<div><br>
</div>
<div>       exp = [CosNotifyFilter.ConstraintExp ([ CosNotification.EventType("tmf_mtnm", "NT_ALARM") ] , subFilter)]</div>
<div><br>
</div>
<div>       exp1 = [CosNotifyFilter.ConstraintExp ([ CosNotification.EventType("tmf_mtnm", "NT_HEARTBEAT") ] , subFilter)]</div>
<div>       try: </div>
<div>           alarmFilter = eventChannel._get_default_filter_factory()</div>
<div>           channel_filter = alarmFilter.create_filter("TCL")</div>
<div>           channel_filter.add_constraints(exp)</div>
<div>           consumerAdmin.add_filter(channel_filter)</div>
<div>       except Exception as e:</div>
<div>           print(e)</div>
<div>       </div>
<div>       impl = StructuredPushConsumerImpl(orb)</div>
<div>       obj = impl._this() </div>
<div>       consumer_admin = eventChannel._get_default_consumer_admin()</div>
<div>       supplier_admin = eventChannel._get_default_supplier_admin()</div>
<div>       (proxy_consumer, proxy_id) = supplier_admin.obtain_notification_push_consumer(CosNotifyChannelAdmin.STRUCTURED_EVENT)</div>
<div>       proxy_consumer = proxy_consumer._narrow(CosNotifyChannelAdmin.StructuredProxyPushConsumer)</div>
<div>       proxy_consumer.connect_structured_push_supplier(CosNotifyComm__POA.StructuredPushSupplier()._this())</div>
<div>       </div>
<div>       if proxy_consumer != None:</div>
<div>           #     Build the filterable data array.</div>
<div><br>
</div>
<div>           AlarmSerialNo = 0</div>
<div>           nativeEMSName = ''</div>
<div>           nativeProbableCause = ''</div>
<div>           SlaveShelf = ''</div>
<div>           whatsay = ''</div>
<div>#</div>
<div>           filterable_data = [</div>
<div>                               CosNotification.Property ( "AlarmSerialNo",CORBA.Any(CORBA._tc_ulong,  AlarmSerialNo)),</div>
<div>                               CosNotification.Property ( "nativeEMSName",CORBA.Any(CORBA._tc_string, nativeEMSName)),</div>
<div>                               CosNotification.Property ( "nativeProbableCause",CORBA.Any(CORBA._tc_string, nativeProbableCause)),</div>
<div>                               CosNotification.Property ( "SlaveShelf",CORBA.Any(CORBA._tc_string,  SlaveShelf))</div>
<div>                             ]</div>
<div><br>
</div>
<div>           while True:</div>
<div>               try:</div>
<div>                   </div>
<div>                   event = CosNotification.StructuredEvent (header, filterable_data, remainder_of_body)</div>
<div>                   events = proxy_consumer.push_structured_event(event)</div>
<div>                   print(events)</div>
<div>               except Exception as e:</div>
<div>                   print(e)</div>
<div><br>
</div>
<div>       </div>
<div>       </div>
<div><br>
</div>
<div>  except CORBA.Exception as ex:</div>
<div>       sys.stderr.write("CORBA exception, unable to %s.\n"%action)</div>
<div>   </div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>################################################################################</div>
<div># If this file is executed directly, then we start here.</div>
<div>if(__name__=="__main__"):</div>
<div>  main()</div>
<span></span><br>
</div>
</body>
</html>