#NEWLINE# @ classmethod #NEWLINE# def from_config_dict( cls , pool_name , obj ) : #NEWLINE# #INDENT# 'Build a Pool object from a config dict\n\n        args:\n            pool_name: string, pool_name of the pool\n            obj: dict, config dict\n        ' #NEWLINE# if ( obj [ 'monitor' ] not in monitors . registered ) : #NEWLINE# #INDENT# log_msg = 'unknown monitor "{}"' . format ( obj [ 'monitor' ] ) #NEWLINE# LOG . error ( log_msg ) #NEWLINE# raise Error ( log_msg ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# monitor_name = obj [ 'monitor' ] #NEWLINE# #UNINDENT# if ( 'monitor_params' in obj ) : #NEWLINE# #INDENT# if ( not obj [ 'monitor_params' ] ) : #NEWLINE# #INDENT# log_msg = 'monitor_params should not be empty' #NEWLINE# LOG . error ( log_msg ) #NEWLINE# raise Error ( log_msg ) #NEWLINE# #UNINDENT# monitor_params = obj [ 'monitor_params' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# monitor_params = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# monitor = monitors . registered [ monitor_name ] ( ** monitor_params ) #NEWLINE# lb_method = obj [ 'lb_method' ] #NEWLINE# members = [ ] #NEWLINE# if ( ( not ( 'members' in obj ) ) or ( not obj [ 'members' ] ) ) : #NEWLINE# #INDENT# log_msg = 'configuration dictionary must contain a non-empty "members" list' #NEWLINE# LOG . error ( log_msg ) #NEWLINE# raise Error ( log_msg ) #NEWLINE# #UNINDENT# for member_obj in obj [ 'members' ] : #NEWLINE# #INDENT# for _m in members : #NEWLINE# #INDENT# if ( member_obj [ 'ip' ] == _m . ip ) : #NEWLINE# #INDENT# log_msg = 'duplicate member IP {}' . format ( member_obj [ 'ip' ] ) #NEWLINE# LOG . error ( log_msg ) #NEWLINE# raise Error ( log_msg ) #NEWLINE# #UNINDENT# #UNINDENT# region = None #NEWLINE# if ( lb_method == 'twrr' ) : #NEWLINE# #INDENT# region = topology . get_region ( member_obj [ 'ip' ] , config . TOPOLOGY_MAP ) #NEWLINE# if ( not region ) : #NEWLINE# #INDENT# log_msg = 'unable to determine region for member {}({})' . format ( member_obj [ 'ip' ] , member_obj [ 'name' ] ) #NEWLINE# LOG . error ( log_msg ) #NEWLINE# raise Error ( log_msg ) #NEWLINE# #UNINDENT# #UNINDENT# _m = PoolMember ( ip = member_obj [ 'ip' ] , name = member_obj [ 'name' ] , weight = member_obj [ 'weight' ] , region = region ) #NEWLINE# members . append ( _m ) #NEWLINE# #UNINDENT# pool_optional_params = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( 'fallback' in obj ) : #NEWLINE# #INDENT# pool_optional_params [ 'fallback' ] = obj [ 'fallback' ] #NEWLINE# #UNINDENT# if ( 'max_addrs_returned' in obj ) : #NEWLINE# #INDENT# pool_optional_params [ 'max_addrs_returned' ] = obj [ 'max_addrs_returned' ] #NEWLINE# #UNINDENT# return cls ( name = pool_name , monitor = monitor , lb_method = lb_method , members = members , ** pool_optional_params )