#NEWLINE# def _TranslatePolicy( self , pol , exp_info ) : #NEWLINE# #INDENT# self . juniper_policies = [ ] #NEWLINE# current_date = datetime . date . today ( ) #NEWLINE# exp_info_date = ( current_date + datetime . timedelta ( weeks = exp_info ) ) #NEWLINE# for ( header , terms ) in pol . filters : #NEWLINE# #INDENT# if ( self . _PLATFORM not in header . platforms ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# filter_options = header . FilterOptions ( self . _PLATFORM ) #NEWLINE# filter_name = header . FilterName ( self . _PLATFORM ) #NEWLINE# interface_specific = ( 'not-interface-specific' not in filter_options [ 1 : ] ) #NEWLINE# if ( not interface_specific ) : #NEWLINE# #INDENT# filter_options . remove ( 'not-interface-specific' ) #NEWLINE# #UNINDENT# filter_type = 'inet' #NEWLINE# if ( len ( filter_options ) > 1 ) : #NEWLINE# #INDENT# filter_type = filter_options [ 1 ] #NEWLINE# #UNINDENT# term_names = set ( ) #NEWLINE# new_terms = [ ] #NEWLINE# for term in terms : #NEWLINE# #INDENT# term . name = self . FixTermLength ( term . name ) #NEWLINE# if ( term . name in term_names ) : #NEWLINE# #INDENT# raise JuniperDuplicateTermError ( ( 'You have multiple terms named: %s' % term . name ) ) #NEWLINE# #UNINDENT# term_names . add ( term . name ) #NEWLINE# term = self . FixHighPorts ( term , af = filter_type ) #NEWLINE# if ( not term ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if term . expiration : #NEWLINE# #INDENT# if ( term . expiration <= exp_info_date ) : #NEWLINE# #INDENT# logging . info ( 'INFO: Term %s in policy %s expires in less than two weeks.' , term . name , filter_name ) #NEWLINE# #UNINDENT# if ( term . expiration <= terms ) : #NEWLINE# #INDENT# logging . warn ( 'WARNING: Term %s in policy %s is expired and will not be rendered.' , term . name , filter_name ) #NEWLINE# continue #NEWLINE# #UNINDENT# #UNINDENT# new_terms . append ( Term ( term , filter_type ) ) #NEWLINE# #UNINDENT# self . juniper_policies . append ( ( header , filter_name , filter_type , interface_specific , new_terms ) )