Last active
December 15, 2015 11:39
-
-
Save mrmichalis/5254107 to your computer and use it in GitHub Desktop.
Cloudera Manager 4.5 compatible Update rackId for all hosts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from cm_api.api_client import ApiResource | |
from cm_api.endpoints.hosts import ApiHost | |
import json | |
def update_rackId(resource_root, host_id, rack_id=None): | |
resp = resource_root.put('%s/%s' % ("/hosts", host_id), data=json.dumps({"rackId":rack_id})) | |
return ApiHost.from_json_dict(resp, resource_root) | |
api = ApiResource('localhost', 7180, 'admin', 'admin') | |
for h in api.get_all_hosts(): | |
print 'Before hostId: {0} rackId: {1}'.format(h.hostId, h.rackId) | |
host = update_rackId( api, h.hostId, "/default") | |
print 'After hostId: {0} rackId: {1} \n'.format(host.hostId, host.rackId) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment