def talk_to_agent(address, method, data=None):
  """Make a REST call. These are described in docs/API.

  Args:
    address: IP address from name_to_ip() or a hostname (if called from an
             instance)
    method: the HTTP call to make, should include the leading /
    data: a Python dictionary; caller must JSONify things themselves.

  Returns:
    The reply, which will be a de-JSONified dictionary.
  """
  try:
    url = 'https://{0}:{1}{2}'.format(address, cfg.port, method)
    # The coordinator's certificate is self-signed, so we cannot verify we are
    # talking to the "correct" coordinator. Eavesdropping is not a problem, but
    # man-in-the-middle attacks could be.
    http = httplib2.Http(disable_ssl_certificate_validation=True, timeout=5)
    if data is None:
      # GET
      return json.loads(http.request(url, 'GET')[1])
    else:
      # POST
      return json.loads(http.request(url, 'POST', urllib.urlencode(data))[1])
  except (httplib2.HttpLib2Error, socket.error, __HOLE__):
    return None
dataset/ETHPy150Open GoogleCloudPlatform/compute-hadoop-java-python/util.py/talk_to_agent