#NEWLINE# def check_minion_cache( self , preserve_minions = False ) : #NEWLINE# #INDENT# '\n        Check the minion cache to make sure that old minion data is cleared\n        ' #NEWLINE# keys = self . list_keys ( ) #NEWLINE# minions = [ ] #NEWLINE# for ( key , val ) in six . iteritems ( keys ) : #NEWLINE# #INDENT# minions . extend ( val ) #NEWLINE# #UNINDENT# m_cache = os . path . join ( self . opts [ 'cachedir' ] , 'minions' ) #NEWLINE# if os . path . isdir ( m_cache ) : #NEWLINE# #INDENT# for minion in os . listdir ( m_cache ) : #NEWLINE# #INDENT# if ( minion not in minions ) : #NEWLINE# #INDENT# shutil . rmtree ( os . path . join ( m_cache , minion ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# kind = self . opts . get ( '__role' , '' ) #NEWLINE# if ( kind not in kinds . APPL_KINDS ) : #NEWLINE# #INDENT# emsg = "Invalid application kind = '{0}'." . format ( kind ) #NEWLINE# log . error ( ( emsg + '\n' ) ) #NEWLINE# raise ValueError ( emsg ) #NEWLINE# #UNINDENT# role = self . opts . get ( 'id' , '' ) #NEWLINE# if ( not role ) : #NEWLINE# #INDENT# emsg = 'Invalid id.' #NEWLINE# log . error ( ( emsg + '\n' ) ) #NEWLINE# raise ValueError ( emsg ) #NEWLINE# #UNINDENT# name = '{0}_{1}' . format ( role , kind ) #NEWLINE# road_cache = os . path . join ( self . opts [ 'cachedir' ] , 'raet' , name , 'remote' ) #NEWLINE# if os . path . isdir ( road_cache ) : #NEWLINE# #INDENT# for road in os . listdir ( road_cache ) : #NEWLINE# #INDENT# ( root , ext ) = os . path . splitext ( road ) #NEWLINE# if ( ext not in [ '.json' , '.msgpack' ] ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# ( prefix , sep , name ) = root . partition ( '.' ) #NEWLINE# if ( ( not name ) or ( prefix != 'estate' ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# path = os . path . join ( road_cache , road ) #NEWLINE# with salt . utils . fopen ( path , 'rb' ) as fp_ : #NEWLINE# #INDENT# if ( ext == '.json' ) : #NEWLINE# #INDENT# data = json . load ( fp_ ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ext == '.msgpack' ) : #NEWLINE# #INDENT# data = msgpack . load ( fp_ ) #NEWLINE# #UNINDENT# #UNINDENT# if ( data [ 'role' ] not in minions ) : #NEWLINE# #INDENT# os . remove ( path )