Ejemplo n.º 1
0
  def __init__(self, server_host, server_port=None,
               username="******", password="******",
               use_tls=False, version=API_CURRENT_VERSION):
    """
    Creates a Resource object that provides API endpoints.

    @param server_host: The hostname of the Cloudera Manager server.
    @param server_port: The port of the server. Defaults to 7180 (http) or
      7183 (https).
    @param username: Login name.
    @param password: Login password.
    @param use_tls: Whether to use tls (https).
    @param version: API version.
    @return Resource object referring to the root.
    """
    self._version = version
    protocol = use_tls and "https" or "http"
    if server_port is None:
      server_port = use_tls and 7183 or 7180
    base_url = "%s://%s:%s/api/v%s" % \
        (protocol, server_host, server_port, version)

    client = HttpClient(base_url, exc_class=ApiException)
    client.set_basic_auth(username, password, API_AUTH_REALM)
    client.set_headers( { "Content-Type" : "application/json" } )
    Resource.__init__(self, client)
Ejemplo n.º 2
0
    def __init__(self,
                 server_host,
                 server_port=None,
                 username="******",
                 password="******",
                 use_tls=False,
                 version=API_CURRENT_VERSION):
        """
    Creates a Resource object that provides API endpoints.

    @param server_host: The hostname of the Cloudera Manager server.
    @param server_port: The port of the server. Defaults to 7180 (http) or
      7183 (https).
    @param username: Login name.
    @param password: Login password.
    @param use_tls: Whether to use tls (https).
    @param version: API version.
    @return: Resource object referring to the root.
    """
        self._version = version
        protocol = use_tls and "https" or "http"
        if server_port is None:
            server_port = use_tls and 7183 or 7180
        base_url = "%s://%s:%s/api/v%s" % \
            (protocol, server_host, server_port, version)

        client = HttpClient(base_url, exc_class=ApiException)
        client.set_basic_auth(username, password, API_AUTH_REALM)
        client.set_headers({"Content-Type": "application/json"})
        Resource.__init__(self, client)
Ejemplo n.º 3
0
def main(argv):
    test = ApiClient()

    protocol = "http"
    server_port = 7180
    base_url = "%s://%s:%s" % \
        (protocol, CM_HOST, server_port)

    client = HttpClient(base_url, exc_class=ApiException, ssl_context=None)
    client.set_basic_auth(CM_USER, CM_PASSWD, "Cloudera Manager")
    client.set_headers({"Content-Type": "application/json"})

    test1 = Resource(client, )

    params = {
        'startTime':
        1495702493388,
        'endTime':
        1495704364740,
        'filters':
        'application_id=job_1495442492363_9417',
        'offset':
        0,
        'limit':
        100,
        'serviceName':
        'yarn',
        'histogramAttributes':
        'allocated_memory_seconds%2Callocated_vcore_seconds%2Ccpu_milliseconds%2Capplication_duration%2Cfile_bytes_read%2Cfile_bytes_written%2Chdfs_bytes_read%2Chdfs_bytes_written%2Chive_query_string%2Cmb_millis%2Cpool%2Cunused_memory_seconds%2Cunused_vcore_seconds%2Cuser&_=1495704510726'
    }
    test3 = test1.get(relpath="/api/v13/cm/log")
    # test3= test1.get(relpath="/cmf/yarn/completedApplications?startTime=1495702493388&endTime=1495704364740&filters=application_id%3Djob_1495442492363_9417&offset=0&limit=100&serviceName=yarn&histogramAttributes=allocated_memory_seconds%2Callocated_vcore_seconds%2Ccpu_milliseconds%2Capplication_duration%2Cfile_bytes_read%2Cfile_bytes_written%2Chdfs_bytes_read%2Chdfs_bytes_written%2Chive_query_string%2Cmb_millis%2Cpool%2Cunused_memory_seconds%2Cunused_vcore_seconds%2Cuser&_=1495704510726")
    # test = client.execute(http_method="GET", path="/cmf/yarn/completedApplications?startTime=1495702493388&endTime=1495704364740&filters=application_id%3Djob_1495442492363_9417&offset=0&limit=100&serviceName=yarn&histogramAttributes=allocated_memory_seconds%2Callocated_vcore_seconds%2Ccpu_milliseconds%2Capplication_duration%2Cfile_bytes_read%2Cfile_bytes_written%2Chdfs_bytes_read%2Chdfs_bytes_written%2Chive_query_string%2Cmb_millis%2Cpool%2Cunused_memory_seconds%2Cunused_vcore_seconds%2Cuser&_=1495704510726", params=params)
    print test3
    pass