I am trying to decommission host from cloudera manager (gracefully) using cm_api. I tried following but which is deleting the role and abruptly stopping the YARN containers running on it
#!/usr/bin/env python2.6
my_cluster = "cluster"
cloudera_manager = "1.2.3.4"
cloudera_username = "admin"
cloudera_password = "admin"
import time
from datetime import datetime, timedelta
from cm_api.api_client import ApiResource
from cm_api.endpoints.cms import ClouderaManager
from cm_api.endpoints.clusters import ApiCluster
from cm_api.endpoints.hosts import get_host, delete_host
api = ApiResource(cloudera_manager, username=cloudera_username, password=cloudera_password)
cl = ApiCluster(api, my_cluster)
hosts = []
roles = []
ha = get_host(api, "$INSTANCE_ID")
for r in ha.roleRefs:
roles.append((r.serviceName, r.roleName))
for srv_name, role_name in roles:
service = cl.get_service(srv_name)
service.delete_role(role_name)
Does anyone know how do we decommission the host in cloudera manager using cm_api ?