Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

How to get full POST response in python API?

avatar

Hi

 

I enable debug logging in python scripts for installing and configuring the cluster.

 

import logging

logging.basicConfig(format='%(asctime)s [%(levelname)s] [%(name)s][%(funcName)s:%(lineno)d] - %(message)s', level=logging.DEBUG)
logger = logging.getLogger(__name__)

 

In http_client response I get only partial output printed:

 

2015-01-29 18:22:40,660 [DEBUG] [cm_api.http_client][execute:157] - GET http://cdm1b.ECS-Site-1.comverse.com:7180/api/v6/commands/153
2015-01-29 18:22:40,670 [DEBUG] [cm_api.http_client][invoke:72] - GET Got response: {
  "id" : 153,
  "name" : "Enab...
2015-01-29 18:22:45,676 [DEBUG] [cm_api.http_client][execute:157] - GET http://cdm1b.ECS-Site-1.comverse.com:7180/api/v6/commands/153
2015-01-29 18:22:45,686 [DEBUG] [cm_api.http_client][invoke:72] - GET Got response: {
  "id" : 153,
  "name" : "Enab...
2015-01-29 18:22:45,687 [DEBUG] [cm_api.http_client][execute:157] - POST http://cdm1b.ECS-Site-1.comverse.com:7180/api/v6/clusters/ECS-HBASE/services/yarn/commands/start
2015-01-29 18:22:46,281 [DEBUG] [cm_api.http_client][invoke:72] - POST Got response: {
  "id" : 161,
  "name" : "Yarn...
2015-01-29 18:22:46,281 [DEBUG] [cm_api.http_client][execute:157] - GET http://cdm1b.ECS-Site-1.comverse.com:7180/api/v6/commands/153

 

How can I get full response in the output ?

 

Thanks

1 ACCEPTED SOLUTION

avatar
Master Collaborator

The length of the message is restricted to 32 characters, see [1] in the python API

To get the full POST/GET you can replace the line with

 

self._client.logger.debug("%s Got response: %s%s" % (method, body, ""))

 

[1] https://github.com/cloudera/cm_api/blob/master/python/src/cm_api/resource.py#L70-L72

 

View solution in original post

1 REPLY 1

avatar
Master Collaborator

The length of the message is restricted to 32 characters, see [1] in the python API

To get the full POST/GET you can replace the line with

 

self._client.logger.debug("%s Got response: %s%s" % (method, body, ""))

 

[1] https://github.com/cloudera/cm_api/blob/master/python/src/cm_api/resource.py#L70-L72