Reply
New Contributor
Posts: 3
Registered: ‎03-09-2017

decommission host using cm_api

[ Edited ]

I'm using a simple script to decommission a host using the python cdh api. It throws me the below error.

 

cm_api.api_client.ApiException: Can not instantiate value of type [simple type, class com.cloudera.api.model.ApiHostNameList] from String value; no single-String constructor/factory method (error 400)

 

I used below sample code 

 

#Connecting to the Cloudera Manager with the credentials
cm_host = "XXX"
api = ApiResource(cm_host, version=13, username="XXX", password="XXX")

cm_handle = ClouderaManager(api)
cm_handle.hosts_decommission('<host.name>')

gives me below ERROR, I tried giving hostname, hostID and IP. None of them seem to work.

 

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/cm_api/endpoints/cms.py", line 235, in hosts_decommission
return self._cmd('hostsDecommission', data=host_names)
File "/usr/lib/python2.7/site-packages/cm_api/endpoints/types.py", line 331, in _cmd
data=data, params=params, api_version=api_version)
File "/usr/lib/python2.7/site-packages/cm_api/endpoints/types.py", line 362, in _post
api_version)
File "/usr/lib/python2.7/site-packages/cm_api/endpoints/types.py", line 380, in _call
api_version)
File "/usr/lib/python2.7/site-packages/cm_api/endpoints/types.py", line 137, in call
ret = method(path, data=data, params=params)
File "/usr/lib/python2.7/site-packages/cm_api/resource.py", line 148, in post
self._make_headers(contenttype))
File "/usr/lib/python2.7/site-packages/cm_api/resource.py", line 73, in invoke
headers=headers)
File "/usr/lib/python2.7/site-packages/cm_api/http_client.py", line 174, in execute
raise self._exc_class(ex)
cm_api.api_client.ApiException: Can not instantiate value of type [simple type, class com.cloudera.api.model.ApiHostNameList] from String value; no single-String constructor/factory method (error 400)

 

 

Appreciate any help.

Posts: 642
Topics: 3
Kudos: 120
Solutions: 67
Registered: ‎08-16-2016

Re: decommission host using cm_api

It is looking for a list of hostnames. Reading the CM API docs, you need to build it in a JSON array.

https://cloudera.github.io/cm_api/apidocs/v17/ns0_apiHostNameList.html

try

decommHosts = {"host.name"}
cm_handle.hosts_decommission(decommHosts)
Announcements