Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Note

This feature is still not available in the trunk as of Sept-5-2013.And will be available soonavailable from 1.4.1.

Code Block
languagepython
title1. get the client object
firstline1
linenumberstrue
client = AmbariClient("localhost", 8080, "admin", "admin", version=1)
print client.version
print client.host_url
print"\n"
Code Block
languagepython
title2. get the clusterModel object of cluster
firstline1
linenumberstrue
mycluster = client.get_cluster('test46')
print mycluster
print mycluster.to_json_dict()
print"\n"

...

Code Block
languagepython
title7. add host components
firstline1
linenumberstrue
host1 = mycluster.get_host('hostname')
print host1
s4 = host1.assign_role("ZOOKEEPER_SERVER")
print s4
host1 = mycluster.get_host('r01wn02')
print host1
s4 = host1.assign_role("ZOOKEEPER_SERVER")
print s4
host1 = mycluster.get_host('r01wn03')
print host1
s4 = host1.assign_role("ZOOKEEPER_SERVER")
print s4
host1 = mycluster.get_host('r01wn03')
print host1
s4 = host1.assign_role("ZOOKEEPER_CLIENT")
print s4

...