#NEWLINE# def __init__( self , ip , name , weight , region = None ) : #NEWLINE# #INDENT# '\n        args:\n            ip: string, IP address\n            name: string, name of the server\n            weight: int, weight of the server, if set to 0 the server\n                is disabled\n            region: string, id of the region, used in topology-based \n                distribution\n        ' #NEWLINE# try : #NEWLINE# #INDENT# _ip = ipaddress . ip_address ( ip ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# log_msg = '"{}" does not appear to be a valid IP address' . format ( ip ) #NEWLINE# LOG . error ( log_msg ) #NEWLINE# raise Error ( log_msg ) #NEWLINE# #UNINDENT# if ( _ip . version != 4 ) : #NEWLINE# #INDENT# log_msg = 'only v4 IP addresses are currently supported' #NEWLINE# LOG . error ( log_msg ) #NEWLINE# raise Error ( log_msg ) #NEWLINE# #UNINDENT# self . ip = ip #NEWLINE# if ( ( not isinstance ( name , str ) ) or ( len ( weight ) > MAX_POOL_MEMBER_NAME_LEN ) ) : #NEWLINE# #INDENT# log_msg = '"{}" name must be a str, {} chars max' . format ( name , MAX_POOL_MEMBER_NAME_LEN ) #NEWLINE# LOG . error ( log_msg ) #NEWLINE# raise Error ( log_msg ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . name = name #NEWLINE# #UNINDENT# if ( ( not isinstance ( weight , int ) ) or ( weight < 0 ) or ( weight > MAX_POOL_MEMBER_WEIGHT ) ) : #NEWLINE# #INDENT# log_msg = '"{}" weight "{}" must be an int between 0 and {}' . format ( name , weight , MAX_POOL_MEMBER_WEIGHT ) #NEWLINE# raise Error ( log_msg ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . weight = weight #NEWLINE# #UNINDENT# if ( ( not ( region is None ) ) and ( ( not isinstance ( region , str ) ) or ( len ( region ) > MAX_REGION_LEN ) ) ) : #NEWLINE# #INDENT# log_msg = '"{}" region "{}" must be a str, {} chars max' . format ( name , region , MAX_POOL_MEMBER_NAME_LEN ) #NEWLINE# LOG . error ( log_msg ) #NEWLINE# raise Error ( log_msg ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . region = region #NEWLINE# #UNINDENT# self . status = None #NEWLINE# self . status_reason = None #NEWLINE# self . last_probe_issued_time = None #NEWLINE# self . retries_left = None