#NEWLINE# @ lazy #NEWLINE# def instances( self ) : #NEWLINE# #INDENT# result = LazyInstanceDict ( self ) #NEWLINE# try : #NEWLINE# #INDENT# config = self . config #NEWLINE# #UNINDENT# except SystemExit : #NEWLINE# #INDENT# return result #NEWLINE# #UNINDENT# for instance_id in config . get ( 'instance' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# iconfig = config [ 'instance' ] [ instance_id ] #NEWLINE# if ( 'master' not in iconfig ) : #NEWLINE# #INDENT# log . error ( ( "Instance 'instance:%s' has no master set." % instance_id ) ) #NEWLINE# sys . exit ( 1 ) #NEWLINE# #UNINDENT# master = self . masters [ iconfig [ 'master' ] ] #NEWLINE# if ( instance_id in master . instances ) : #NEWLINE# #INDENT# log . error ( ( "Instance 'instance:%s' conflicts with another instance with id '%s' in master '%s'." % ( instance_id , instance_id , master . id ) ) ) #NEWLINE# sys . exit ( 1 ) #NEWLINE# #UNINDENT# instance_class = master . section_info . get ( None ) #NEWLINE# if ( instance_class is None ) : #NEWLINE# #INDENT# log . error ( ( "Master '%s' has no default instance class." % master . id ) ) #NEWLINE# sys . exit ( 1 ) #NEWLINE# #UNINDENT# instance = instance_class ( master , instance_id , iconfig ) #NEWLINE# instance . sectiongroupname = 'instance' #NEWLINE# master . instances [ instance_id ] = instance #NEWLINE# #UNINDENT# shortname_map = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for master in self . masters . values ( ) : #NEWLINE# #INDENT# for instance_id in master . instances : #NEWLINE# #INDENT# instance = master . instances [ instance_id ] #NEWLINE# key = instance . uid #NEWLINE# result [ key ] = instance #NEWLINE# shortname_map . setdefault ( instance_id , [ ] ) . append ( instance ) #NEWLINE# #UNINDENT# #UNINDENT# for ( shortname , instances ) in shortname_map . items ( ) : #NEWLINE# #INDENT# if ( len ( instances ) == 1 ) : #NEWLINE# #INDENT# result [ shortname ] = instances [ 0 ] #NEWLINE# #UNINDENT# #UNINDENT# result . plugins = self . plugins #NEWLINE# return result