You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ma...@apache.org on 2013/10/04 06:58:03 UTC
git commit: AMBARI-3353. Ambari-Client Bootstrap fails due to odd
status response style. (andrew onischuk via mahadev)
Updated Branches:
refs/heads/trunk 48fef3beb -> cedc67afb
AMBARI-3353. Ambari-Client Bootstrap fails due to odd status response style. (andrew onischuk via mahadev)
Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/cedc67af
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/cedc67af
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/cedc67af
Branch: refs/heads/trunk
Commit: cedc67afb2e1415082708e473be0924cbdfa72c4
Parents: 48fef3b
Author: Mahadev Konar <ma...@apache.org>
Authored: Thu Oct 3 21:58:41 2013 -0700
Committer: Mahadev Konar <ma...@apache.org>
Committed: Thu Oct 3 21:58:41 2013 -0700
----------------------------------------------------------------------
.../src/main/python/ambari_client/model/host.py | 27 +++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/cedc67af/ambari-client/src/main/python/ambari_client/model/host.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/main/python/ambari_client/model/host.py b/ambari-client/src/main/python/ambari_client/model/host.py
index ba3c08b..f261deb 100755
--- a/ambari-client/src/main/python/ambari_client/model/host.py
+++ b/ambari-client/src/main/python/ambari_client/model/host.py
@@ -177,11 +177,32 @@ def _bootstrap_hosts(root_resource , hosts_list, ssh_key):
@param hosts_list list of host_names.
@return: A StatusModel object.
"""
- #payload_dic = {'sshKey':ssh_key , 'hosts':hosts_list}
payload_dic = {'sshKey':ssh_key.encode('string_escape') , 'hosts':hosts_list}
resp = root_resource.post(paths.BOOTSTRAP_PATH, payload_dic , content_type="application/json")
- LOG.debug(resp)
- return utils.ModelUtils.create_model(status.StatusModel, resp, root_resource, "NO_KEY")
+ status_dict = _bootstrap_resp_to_status_dict(resp)
+ return utils.ModelUtils.create_model(status.StatusModel, status_dict, root_resource, "NO_KEY")
+
+def _bootstrap_resp_to_status_dict(resp):
+ """
+ Bootstrap response has a little odd format
+ that's why we have to convert it to the normal
+ format to handle it properly later.
+ """
+
+ # if we got other response, like an error 400 happened on higher level
+ if isinstance( resp['status'], int ):
+ return resp
+
+ new_resp = {}
+
+ if resp['status'] == "OK":
+ new_resp['status'] = 201
+ else: # ERROR
+ new_resp['status'] = 500
+
+ new_resp['message'] = resp['log']
+ new_resp['requestId'] = resp['requestId']
+ return new_resp