You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by di...@apache.org on 2016/07/12 21:32:25 UTC

ambari git commit: AMBARI-17631: preinstall-check script should use AMBARI-AGENT REST API for the list of agents (dili)

Repository: ambari
Updated Branches:
  refs/heads/trunk 9be254b71 -> 287df6499


AMBARI-17631: preinstall-check script should use AMBARI-AGENT REST API for the list of agents (dili)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/287df649
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/287df649
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/287df649

Branch: refs/heads/trunk
Commit: 287df64992ed34537fd9f2d1dad733714e54f925
Parents: 9be254b
Author: Di Li <di...@apache.org>
Authored: Tue Jul 12 17:31:43 2016 -0400
Committer: Di Li <di...@apache.org>
Committed: Tue Jul 12 17:31:43 2016 -0400

----------------------------------------------------------------------
 .../preinstall-check/src/main/python/preinstall_checker.py  | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/287df649/contrib/utils/preinstall-check/src/main/python/preinstall_checker.py
----------------------------------------------------------------------
diff --git a/contrib/utils/preinstall-check/src/main/python/preinstall_checker.py b/contrib/utils/preinstall-check/src/main/python/preinstall_checker.py
index 7ff7e4c..5d512b7 100644
--- a/contrib/utils/preinstall-check/src/main/python/preinstall_checker.py
+++ b/contrib/utils/preinstall-check/src/main/python/preinstall_checker.py
@@ -520,7 +520,7 @@ def get_ambari_agent_nodes(server_url, user, password):
   @param user: User for Ambari REST API authentication
   @param password: Password for the user used to authenticate the Ambari REST API call
   """
-  url = "{0}/api/v1/hosts".format(server_url)
+  url = "{0}/api/v1/services/AMBARI/components/AMBARI_AGENT".format(server_url)
   hosts = set()
   out, err, ec = execute_curl_command(url, user=user, password=password)
   is_erroneous_response, ec, err = is_erroneous_response_by_server(out)
@@ -529,9 +529,9 @@ def get_ambari_agent_nodes(server_url, user, password):
     return hosts
 
   response = json.loads(out)
-  host_list = response.get('items', [])
+  host_list = response.get('hostComponents', [])
   for item in host_list:
-    host_summary = item.get('Hosts', {})
+    host_summary = item.get('RootServiceHostComponents', {})
     host_name = host_summary.get('host_name', None)
     if host_name:
       hosts.add(host_name)
@@ -912,6 +912,9 @@ def run(options):
     return ec
   agents = get_ambari_agent_nodes(server_url, options.user, options.password)
   logger.info('Total number of agents {0}'.format(len(agents)))
+  if not agents:
+    logger.error('No Ambari Agent registered to the Ambari Server. Install Ambari Agent first.')
+    return CODE_ERROR
 
   if OPERATION_CHECK == options.operation:
     run_host_checks(options, agents, server_url)