#NEWLINE# def talk_to_agent( address , method , data = None ) : #NEWLINE# #INDENT# 'Make a REST call. These are described in docs/API.\n\n  Args:\n    address: IP address from name_to_ip() or a hostname (if called from an\n             instance)\n    method: the HTTP call to make, should include the leading /\n    data: a Python dictionary; caller must JSONify things themselves.\n\n  Returns:\n    The reply, which will be a de-JSONified dictionary.\n  ' #NEWLINE# try : #NEWLINE# #INDENT# url = 'https://{0}:{1}{2}' . format ( address , cfg . port , method ) #NEWLINE# http = httplib2 . Http ( disable_ssl_certificate_validation = True , timeout = 5 ) #NEWLINE# if ( data is None ) : #NEWLINE# #INDENT# return json . loads ( http . request ( url , 'GET' ) [ 1 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return json . loads ( http . request ( url , 'POST' , urllib . urlencode ( data ) ) [ 1 ] ) #NEWLINE# #UNINDENT# #UNINDENT# except ( httplib2 . HttpLib2Error , socket . error , ValueError ) : #NEWLINE# #INDENT# return None