<s> """<STR_LIT>""" <EOL> from security_monkey . watcher import Watcher <EOL> from security_monkey . watcher import ChangeItem <EOL> from security_monkey . constants import TROUBLE_REGIONS <EOL> from security_monkey . exceptions import BotoConnectionIssue <EOL> from security_monkey import app <EOL> from boto . redshift import regions <EOL> class Redshift ( Watcher ) : <EOL> index = '<STR_LIT>' <EOL> i_am_singular = '<STR_LIT>' <EOL> i_am_plural = '<STR_LIT>' <EOL> def __init__ ( self , accounts = None , debug = False ) : <EOL> super ( Redshift , self ) . __init__ ( accounts = accounts , debug = debug ) <EOL> def slurp ( self ) : <EOL> """<STR_LIT>""" <EOL> self . prep_for_slurp ( ) <EOL> from security_monkey . common . sts_connect import connect <EOL> item_list = [ ] <EOL> exception_map = { } <EOL> for account in self . accounts : <EOL> for region in regions ( ) : <EOL> app . logger . debug ( "<STR_LIT>" . format ( self . index , account , region . name ) ) <EOL> try : <EOL> redshift = connect ( account , '<STR_LIT>' , region = region ) <EOL> all_clusters = [ ] <EOL> marker = None <EOL> while True : <EOL> response = self . wrap_aws_rate_limited_call ( <EOL> redshift . describe_clusters , <EOL> marker = marker <EOL> ) <EOL> all_clusters . extend ( response [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) <EOL> if response [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] is not None : <EOL> marker = response [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> else : <EOL> break <EOL> except Exception as e : <EOL> if region . name not in TROUBLE_REGIONS : <EOL> exc = BotoConnectionIssue ( str ( e ) , '<STR_LIT>' , account , region . name ) <EOL> self . slurp_exception ( ( self . index , account , region . name ) , exc , exception_map ) <EOL> continue <EOL> app . logger . debug ( "<STR_LIT>" . format ( len ( all_clusters ) , Redshift . i_am_plural ) ) <EOL> for cluster in all_clusters : <EOL> cluster_id = cluster [ '<STR_LIT>' ] <EOL> if self . check_ignore_list ( cluster_id ) : <EOL> continue <EOL> item = RedshiftCluster ( region = region . name , account = account , name = cluster_id , config = dict ( cluster ) ) <EOL> item_list . append ( item ) <EOL> return item_list , exception_map <EOL> class RedshiftCluster ( ChangeItem ) : <EOL> def __init__ ( self , region = None , account = None , name = None , config = { } ) : <EOL> super ( RedshiftCluster , self ) . __init__ ( <EOL> index = Redshift . index , <EOL> region = region , <EOL> account = account , <EOL> name = name , <EOL> new_config = config ) </s>
