Reply
Highlighted
Explorer
Posts: 7
Registered: ‎06-19-2018

Error while trying to decommission host with Python CM API

Hello,

 

I'm using the package cm_client (new API library for Python) to automize host decommission and recommission.

 

First of all, method ApiHostnameList() returned me None result (but of course I've hosts in the cluster):

 

Screenshot_2018-10-15 All Hosts - Cloudera Manager.png

 

Secondly, instead of use ApiHostnameList(), I'm declaring an array with host ID list to passed out in the deommission command:

 

import cm_client
from cm_client.rest import ApiException

 

# Configure HTTP basic authorization: basic
cm_client.configuration.username = 'cmapi'
cm_client.configuration.password = 'B1gd4t@'
cm_client.configuration.verify_ssl = True
cm_client.configuration.ssl_ca_cert = '/home/rlopez/certs/CA.crt.pem'

 

api_url = 'https://clouderapre-mgr.fintonic.com:7183/api/v19'
api_client = cm_client.ApiClient(api_url)

 

cluster_api_instance = cm_client.ClustersResourceApi(api_client)
services_api_instance = cm_client.ServicesResourceApi(api_client)

cloudera_manager_instance = cm_client.ClouderaManagerResourceApi(api_client)

 

body=['c945347e-fa6e-4f89-a4ff-f2266918787a']

cloudera_manager_instance.hosts_decommission_command(body=body)

 

But it's giving me this error:

 

Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Transfer-Encoding': 'chunked', 'Set-Cookie': 'CLOUDERA_MANAGER_SESSIONID=uxvrdcukujfq1hjlv9vgvovl7;Path=/;Secure;HttpOnly', 'Expires': 'Thu, 01-Jan-1970 00:00:00 GMT', 'Server': 'Jetty(6.1.26.cloudera.4)', 'Date': 'Mon, 15 Oct 2018 07:05:49 GMT', 'Content-Type': 'application/json'})
HTTP response body: {
  "message" : "Can not deserialize instance of com.cloudera.api.model.ApiHostNameList out of START_ARRAY token\n at [Source: org.apache.cxf.transport.http.AbstractHTTPDestination$1@5c671d14; line: 1, column: 1]"
}

 

Announcements