#NEWLINE# def verify_socket( interface , pub_port , ret_port ) : #NEWLINE# #INDENT# '\n    Attempt to bind to the sockets to verify that they are available\n    ' #NEWLINE# addr_family = lookup_family ( addr_family ) #NEWLINE# pubsock = socket . socket ( addr_family , socket . SOCK_STREAM ) #NEWLINE# retsock = socket . socket ( addr_family , socket . SOCK_STREAM ) #NEWLINE# try : #NEWLINE# #INDENT# pubsock . setsockopt ( socket . SOL_SOCKET , socket . SO_REUSEADDR , 1 ) #NEWLINE# pubsock . bind ( ( interface , int ( pub_port ) ) ) #NEWLINE# pubsock . close ( ) #NEWLINE# retsock . setsockopt ( socket . SOL_SOCKET , socket . SO_REUSEADDR , 1 ) #NEWLINE# retsock . bind ( ( interface , int ( ret_port ) ) ) #NEWLINE# retsock . close ( ) #NEWLINE# result = True #NEWLINE# #UNINDENT# except Exception as exc : #NEWLINE# #INDENT# if exc . args : #NEWLINE# #INDENT# msg = 'Unable to bind socket, error: {0}' . format ( str ( exc ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# msg = 'Unable to bind socket, this might not be a problem. Is there another salt-master running?' #NEWLINE# #UNINDENT# if is_console_configured ( ) : #NEWLINE# #INDENT# log . warning ( msg ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# sys . stderr . write ( 'WARNING: {0}\n' . format ( msg ) ) #NEWLINE# #UNINDENT# result = False #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# pubsock . close ( ) #NEWLINE# retsock . close ( ) #NEWLINE# #UNINDENT# return result