Skip to content

Instantly share code, notes, and snippets.

@sit
Created October 29, 2013 03:38
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save sit/7208850 to your computer and use it in GitHub Desktop.
Save sit/7208850 to your computer and use it in GitHub Desktop.
A quick and dirty script to dump the cluster/service/role configuration via the Cloudera Manager API http://cloudera.github.io/cm_api/.
#!/usr/bin/env python
from cm_api.api_client import ApiResource
def main(args):
cm_host = get(args, 1, "localhost")
cm_user = get(args, 2, "admin")
cm_pass = get(args, 3, "admin")
api = ApiResource(cm_host, username=cm_user, password=cm_pass)
dump(api)
def dump(api):
clusters = api.get_all_clusters()
for c in clusters:
print "CLUSTER", c.name
for s in c.get_all_services():
print " SERVICE", s
for rg in s.get_all_role_config_groups():
print " RG", rg, rg.get_config()
for r in s.get_all_roles(view="full"):
print " RO", r
print " ", r.roleConfigGroupRef
print " ", r.hostRef
def get(l, i, default):
try:
return l[i]
except IndexError:
return default
if __name__ == '__main__':
import sys
main(sys.argv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment