@@ -42,6 +42,12 @@ def __init__(self, *args, **kw):
4242 self ._exchange_tpc = self .config .get ('AMQP' , 'exchange_tpc' )
4343 self ._wlcg_exchange_tpc = self .config .get ('AMQP' , 'wlcg_exchange_tpc' )
4444
45+ if 'SCITAGS' in self .config :
46+ self ._scitags_mapping_file = self .config .get ('SCITAGS' , 'mapping_file_path' )
47+ with open (self ._scitags_mapping_file ) as scitag_file :
48+ self ._scitags_mapping = json .load (scitag_file )
49+ else :
50+ self ._scitags_mapping = None
4551
4652 self .last_flush = time .time ()
4753 self .seq_data = {}
@@ -131,6 +137,7 @@ def addRecord(self, sid, userID, fileClose, timestamp, addr, openTime, fileToClo
131137 u = self ._users [sid ][userInfo ].get ('userinfo' , None )
132138 auth = self ._users [sid ][userInfo ].get ('authinfo' , None )
133139 appinfo = self ._users [sid ][userInfo ].get ('appinfo' , None )
140+ eainfo = self ._users [sid ][userInfo ].get ('eainfo' , None )
134141
135142 if u is not None :
136143 hostname = u .host .decode ('idna' )
@@ -151,6 +158,9 @@ def addRecord(self, sid, userID, fileClose, timestamp, addr, openTime, fileToClo
151158 rec ['vo' ] = auth .on .decode ('utf-8' )
152159 if appinfo is not None :
153160 rec ['appinfo' ] = appinfo
161+ if eainfo is not None :
162+ rec ['activity' ] = eainfo .activity
163+ rec ['experiment' ] = eainfo .experiment
154164
155165 except KeyError :
156166 self .logger .exception ("File close record from unknown UserID=%i, SID=%s" , userID , sid )
@@ -582,6 +592,16 @@ def process(self, data, addr, port):
582592 elif stream_type == "P" :
583593 self .process_gstream_tpc (decoded_gstream , addr ,sid )
584594
595+ elif header .code == b'U' : #eainfo
596+ if self ._scitags_mapping :
597+ eainfo = decoding .eaInfo (rest , self ._scitags_mapping )
598+
599+ try :
600+ self .logger .debug ("Adding new eainfo: %s." , eainfo )
601+ self ._users [sid ][userInfo ]['eainfo' ] = eainfo
602+ except KeyError :
603+ self .logger .warning ("Received eainfo for a server or user not seen yet" )
604+
585605 else :
586606 infolen = len (data ) - 4
587607 mm = decoding .mapheader ._make (struct .unpack ("!I" + str (infolen ) + "s" , data ))
0 commit comments