<s> import BroControl . plugin <EOL> import BroControl . config <EOL> class LBPFRing ( BroControl . plugin . Plugin ) : <EOL> def __init__ ( self ) : <EOL> super ( LBPFRing , self ) . __init__ ( apiversion = <NUM_LIT:1> ) <EOL> def name ( self ) : <EOL> return "<STR_LIT>" <EOL> def pluginVersion ( self ) : <EOL> return <NUM_LIT:1> <EOL> def init ( self ) : <EOL> cluster_id = BroControl . config . Config . pfringclusterid <EOL> if cluster_id == <NUM_LIT:0> : <EOL> return False <EOL> pfringtype = BroControl . config . Config . pfringclustertype <EOL> if pfringtype not in ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" ) : <EOL> self . error ( "<STR_LIT>" % pfringtype ) <EOL> return False <EOL> pftype = "<STR_LIT>" <EOL> if pfringtype != "<STR_LIT>" : <EOL> pftype = "<STR_LIT>" <EOL> if pfringtype != "<STR_LIT>" : <EOL> pftype += "<STR_LIT:_>" + pfringtype . upper ( ) . replace ( "<STR_LIT:->" , "<STR_LIT:_>" ) <EOL> useplugin = False <EOL> first_app_instance = BroControl . config . Config . pfringfirstappinstance <EOL> app_instance = first_app_instance <EOL> dd = { } <EOL> for nn in self . nodes ( ) : <EOL> if nn . type != "<STR_LIT>" or nn . lb_method != "<STR_LIT>" : <EOL> continue <EOL> useplugin = True <EOL> if nn . host in dd : <EOL> if nn . interface not in dd [ nn . host ] : <EOL> app_instance = first_app_instance <EOL> dd [ nn . host ] [ nn . interface ] = cluster_id + len ( dd [ nn . host ] ) <EOL> else : <EOL> app_instance = first_app_instance <EOL> dd [ nn . host ] = { nn . interface : cluster_id } <EOL> if pftype : <EOL> nn . env_vars . setdefault ( pftype , "<STR_LIT:1>" ) <EOL> if nn . interface . startswith ( "<STR_LIT>" ) : <EOL> nn . interface = "<STR_LIT>" % ( nn . interface , app_instance ) <EOL> elif nn . interface . startswith ( "<STR_LIT>" ) : <EOL> nn . interface = "<STR_LIT>" % ( nn . interface , app_instance ) <EOL> elif nn . interface . startswith ( "<STR_LIT>" ) : <EOL> nn . env_vars . setdefault ( "<STR_LIT>" , "<STR_LIT:1>" ) <EOL> nn . interface = "<STR_LIT>" % ( nn . interface , app_instance ) <EOL> else : <EOL> nn . env_vars . setdefault ( "<STR_LIT>" , dd [ nn . host ] [ nn . interface ] ) <EOL> app_instance += <NUM_LIT:1> <EOL> nn . env_vars . setdefault ( "<STR_LIT>" , "<STR_LIT>" % nn . interface ) <EOL> return useplugin </s>
