2121cpInstDict = {}
2222cpMC = {}
2323edgeMsg = {}
24- feedDesc = {}
2524
2625mcodes = {"processPckt" :["default" ,"processOp" ], "finish" :["default" ,"finishOp" ], "measure" :["default" ,"measure" ],
2726 "srvRsp" :["default" ], "srvReq" :["default" , "request" ,"return" ], "transfer" :["default" ], "authReq" :["default" ],
28- "bckgrndLd" :[], "transfer" :[], "streamsrc" :[], "streamdst" :[]}
27+ "bckgrndLd" :[], "transfer" :[], "streamsrc" :[], "streamdst" :[], "metadata" :[] }
2928
3029messages = {}
3130classFuncs = {}
4140cmpptnDesc = {}
4241
4342pcesFuncClasses = ('srvReq' , 'srvRsp' , 'measure' , 'start' , 'feed' , 'finish' , 'bckgrndLd' ,
44- 'processPckt' , 'transfer' , 'streamsrc' , 'streamdst' )
45-
43+ 'processPckt' , 'transfer' , 'streamsrc' , 'streamdst' , 'metadata' )
4644TimingCodeFuncs = []
4745
4846strmSrcIdx = {}
8078strmDstIdx ['groups' ] = len (strmDstIdx )
8179strmDstIdx ['trace' ] = len (strmDstIdx )
8280
81+ MetaIdx = {}
82+ MetaIdx ['cmpptn' ] = 1
83+ MetaIdx ['label' ] = 2
84+ MetaIdx ['remove' ] = 3
85+ MetaIdx ['name' ] = 4
86+ MetaIdx ['value' ] = 5
87+ MetaIdx ['trace' ] = 6
88+ MetaIdx ['groups' ] = 7
89+
8390initRowLen = {}
8491initRowLen ['srvReq' ] = 14
8592initRowLen ['srvRsp' ] = 10
8693initRowLen ['measure' ] = 9
8794initRowLen ['start' ] = 11
88- initRowLen ['feed' ] = 8
95+ initRowLen ['feed' ] = 9
8996initRowLen ['finish' ] = 8
9097initRowLen ['processPckt' ] = 12
9198initRowLen ['transfer' ] = 11
9299initRowLen ['streamsrc' ] = 21
93100initRowLen ['streamdst' ] = 10
101+ initRowLen ['metadata' ] = 8
94102
95103class FuncEdge :
96104 def __init__ (self , cp , label , msgType ):
@@ -682,10 +690,11 @@ def __init__(self, row):
682690 self .fnclass = 'feed'
683691 self .cmpptn = row [1 ]
684692 self .label = row [2 ]
685- self .ip = row [3 ]
693+ self .srcip = row [3 ]
694+ self .dstip = row [4 ]
686695
687- self .init = {'ip ' : self .ip , 'msgtype' : row [4 ], 'data' : row [5 ],
688- 'groups' :[], 'trace' : row [6 ]}
696+ self .init = {'srcip ' : self .srcip , 'dstip' : self . dstip , ' msgtype' : row [5 ], 'data' : row [6 ],
697+ 'groups' :[], 'trace' : row [7 ]}
689698
690699 def addGroup (self , groupName ):
691700 if 'groups' not in self .init :
@@ -711,26 +720,60 @@ def validate(self):
711720 if not ok :
712721 msgs .append (msg )
713722
714- if self .ip .find (':' ) == - 1 :
715- msg = 'Start feed description {} not in format IP:port' .format (self .ip )
723+
724+ # at least one of self.srcip and self.dstip has to be specified, but it is not needed to
725+ # specify both
726+ if len (self .srcip ) == 0 :
727+ msg = 'feed source specification is empty'
716728 msgs .append (msg )
717- else :
718- pieces = self .ip .split (':' )
729+
730+ if len (self .dstip ) == 0 :
731+ msg = 'feed destinatino specification is empty'
732+ msgs .append (msg )
733+
734+ if len (self .srcip ) > 0 and self .srcip .find (':' ) == - 1 :
735+ msg = 'feed source description {} not in format IP:port' .format (self .srcip )
736+ msgs .append (msg )
737+ elif len (self .srcip ) > 0 :
738+ pieces = self .srcip .split (':' )
719739 if len (pieces ) != 2 :
720- msg = 'Start feed description {} not in format FeedName,IP:port' .format (self .ip )
740+ msg = 'feed source description {} not in format FeedName,IP:port' .format (self .srcip )
741+ msgs .append (msg )
742+ else :
743+ if pieces [0 ] != "*" and not is_legal_ip_address (pieces [0 ]):
744+ msg = 'feed source description {} not in format FeedName,IP:port' .format (self .srcip )
745+ msgs .append (msg )
746+
747+ if pieces [1 ] != '*' :
748+ try :
749+ portNum = int (pieces [1 ])
750+ if not portNum > 0 :
751+ msg = 'feed source description {} needs positive port number' .format (self .srcip )
752+ msgs .append (msg )
753+ except :
754+ msg = 'feed source description {} needs positive port number' .format (self .feed )
755+ msgs .append (msg )
756+
757+ if len (self .dstip ) > 0 and self .dstip .find (':' ) == - 1 :
758+ msg = 'feed destination description {} not in format IP:port' .format (self .dstip )
759+ msgs .append (msg )
760+ elif len (self .dstip ) > 0 :
761+ pieces = self .dstip .split (':' )
762+ if len (pieces ) != 2 :
763+ msg = 'feed destination description {} not in format FeedName,IP:port' .format (self .dstip )
721764 msgs .append (msg )
722765 else :
723766 if not is_legal_ip_address (pieces [0 ]):
724- msg = 'Start feed description {} not in format FeedName,IP:port' .format (self .ip )
767+ msg = 'feed destination description {} not in format FeedName,IP:port' .format (self .dstip )
725768 msgs .append (msg )
726769 elif pieces [1 ] != '*' :
727770 try :
728771 portNum = int (pieces [1 ])
729772 if not portNum > 0 :
730- msg = 'Start feed description {} needs positive port number' .format (self .ip )
773+ msg = 'feed destination description {} needs positive port number' .format (self .dstip )
731774 msgs .append (msg )
732775 except :
733- msg = 'Start feed description {} needs positive port number' .format (self .feed )
776+ msg = 'feed destination description {} needs positive port number' .format (self .feed )
734777 msgs .append (msg )
735778
736779 if len (msgs ) > 0 :
@@ -1205,6 +1248,53 @@ def serializeDict(self):
12051248 self .init ['carried' ] = cnvrtBool (self .init ['carried' ])
12061249 return self .init
12071250
1251+ class MetaData :
1252+ def __init__ (self , row ):
1253+ self .fnclass = 'metadata'
1254+ self .cmpptn = row [MetaIdx ['cmpptn' ]]
1255+ self .label = row [MetaIdx ['label' ]]
1256+
1257+ self .init = {'remove' :[], 'metadict' :{}, 'trace' :row [MetaIdx ['trace' ]], 'groups' :[]}
1258+
1259+ def addGroup (self , groupName ):
1260+ if 'groups' not in self .init :
1261+ self .init ['groups' ] = []
1262+ if groupName not in self .init ['groups' ]:
1263+ self .init ['groups' ].append (groupName )
1264+
1265+
1266+ def validate (self ):
1267+ if not validateFlag :
1268+ return True , ""
1269+
1270+ if self .cmpptn not in cmpPtnInstDict :
1271+ print_err ('cp name "{}" in Transfer init not recognized' .format (self .cmpptn ))
1272+ exit (1 )
1273+
1274+ msgs = []
1275+ if not validateBool (self .init ['trace' ]):
1276+ msg = 'transfer initialization trace parameter "{}" needs to be boolean' .format (self .init ['trace' ])
1277+ msgs .append (msg )
1278+
1279+ ok , msg = validateFuncInCP (self .cmpptn , self .label , self .fnclass , "metadata init validation" )
1280+ if not ok :
1281+ msgs .append (msg )
1282+
1283+ if len (msgs ) > 0 :
1284+ return False , '\n ' .join (msgs )
1285+
1286+ return True , ""
1287+
1288+ def addMetaDict (self , metaName , metaData ):
1289+ self .init ['metadict' ][metaName ] = metaData
1290+
1291+ def addMetaRm (self , metaName ):
1292+ self .init ['remove' ].append (metaName )
1293+
1294+ def serializeDict (self ):
1295+ self .init ['trace' ] = cnvrtBool (self .init ['trace' ])
1296+ return self .init
1297+
12081298def validateCmpPtns ():
12091299 global validateFlag
12101300
@@ -1430,9 +1520,6 @@ def main():
14301520 parser .add_argument (u'-cpuOpsDescIn' , metavar = u'input operations in the function table for a given cpu Model' ,
14311521 dest = u'cpuOpsDesc_input' , required = True )
14321522
1433- parser .add_argument (u'-feedDescIn' , metavar = u'description of feeds from convert-ipmap' ,
1434- dest = u'feedDesc_input' , required = True )
1435-
14361523 # method code file is json dictionary whose key is the known function classes
14371524 # and the value is a list of method codes recognized by that class
14381525 parser .add_argument (u'-mc' , metavar = u'input method code map file name' , dest = u'mc_input' , required = True )
@@ -1486,7 +1573,6 @@ def main():
14861573 #mc_input_file = os.path.join(descDir, args.mc_input)
14871574 exprmnt_input_file = os .path .join (descDir , 'exprmnt.json' )
14881575 cpuOpsDesc_input_file = os .path .join (descDir , args .cpuOpsDesc_input )
1489- feedDesc_input_file = os .path .join (descDir , args .feedDesc_input )
14901576
14911577 cmpptn_output_file = os .path .join (yamlDir , args .cmpptn_output )
14921578 cpInit_output_file = os .path .join (yamlDir , args .cpInit_output )
@@ -1497,8 +1583,7 @@ def main():
14971583 sysname = args .name
14981584
14991585 errs = 0
1500- #input_files = (csv_input_file, mc_input_file, cpuOpsDesc_input_file, exprmnt_input_file)
1501- input_files = (csv_input_file , cpuOpsDesc_input_file , feedDesc_input_file , exprmnt_input_file )
1586+ input_files = (csv_input_file , cpuOpsDesc_input_file , exprmnt_input_file )
15021587 for input_file in input_files :
15031588 if not os .path .isfile (input_file ):
15041589 print_err ('unable to open input file "{}"' .format (input_file ))
@@ -1554,14 +1639,12 @@ def main():
15541639 GroupsIdx ['transfer' ] = 10
15551640 GroupsIdx ['streamsrc' ] = strmSrcIdx ['groups' ]
15561641 GroupsIdx ['streamdst' ] = strmDstIdx ['groups' ]
1642+ GroupsIdx ['metadata' ] = MetaIdx ['groups' ]
1643+
15571644
15581645 with open (cpuOpsDesc_input_file ,'r' ) as rf :
15591646 cpuOps = json .load (rf )
15601647
1561- # feed description dictionary is indexed by feed name
1562- with open (feedDesc_input_file ,'r' ) as rf :
1563- feedDesc = json .load (rf )
1564-
15651648 with open (exprmnt_input_file , 'r' ) as rf :
15661649 exprmnts = json .load (rf )
15671650
@@ -1781,6 +1864,23 @@ def main():
17811864 initClassDict [cmpPtnName ] = {}
17821865 initClassDict [cmpPtnName ][funcLabel ] = StreamDst (row )
17831866
1867+ elif className == 'metadata' :
1868+ if cmpPtnName not in initClassDict :
1869+ initClassDict [cmpPtnName ] = {}
1870+ initClassDict [cmpPtnName ][funcLabel ] = MetaData (row )
1871+
1872+
1873+ name = row [MetaIdx ['remove' ]]
1874+
1875+ if len (name ) > 0 :
1876+ initClassDict [cmpPtnName ][funcLabel ].addMetaRm (name )
1877+
1878+ name = row [MetaIdx ['name' ]]
1879+ if len (name ) > 0 :
1880+ value = row [MetaIdx ['value' ]]
1881+ initClassDict [cmpPtnName ][funcLabel ].addMetaDict (name , value )
1882+
1883+
17841884 if className in Msg2MCIdx :
17851885 ridx = Msg2MCIdx [className ]
17861886 if len (row [ridx ]) > 0 :
0 commit comments