Repository: ambari Updated Branches: refs/heads/trunk 08dd22f94 -> 9e920aae7
AMBARI-10009. SLES secured cluster has alerts for Yarn and Storm.(vbrodetskyi) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9e920aae Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9e920aae Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9e920aae Branch: refs/heads/trunk Commit: 9e920aae7a7fe5e129e37791040909e0ae55ff84 Parents: 08dd22f Author: Vitaly Brodetskyi <[email protected]> Authored: Wed Mar 11 15:14:16 2015 +0200 Committer: Vitaly Brodetskyi <[email protected]> Committed: Wed Mar 11 15:14:16 2015 +0200 ---------------------------------------------------------------------- .../main/python/ambari_agent/alerts/web_alert.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/9e920aae/ambari-agent/src/main/python/ambari_agent/alerts/web_alert.py ---------------------------------------------------------------------- diff --git a/ambari-agent/src/main/python/ambari_agent/alerts/web_alert.py b/ambari-agent/src/main/python/ambari_agent/alerts/web_alert.py index d7a833e..8252781 100644 --- a/ambari-agent/src/main/python/ambari_agent/alerts/web_alert.py +++ b/ambari-agent/src/main/python/ambari_agent/alerts/web_alert.py @@ -22,6 +22,7 @@ import logging import time import subprocess import os +import uuid from tempfile import gettempdir from alerts.base_alert import BaseAlert from collections import namedtuple @@ -172,10 +173,19 @@ class WebAlert(BaseAlert): else: kerberos_env = None + # check if cookies dir exists, if not then create it + tmp_dir = self.config.get('agent', 'tmp_dir') + cookies_dir = os.path.join(tmp_dir, "cookies") + + if not os.path.exists(cookies_dir): + os.makedirs(cookies_dir) + # substitute 0.0.0.0 in url with actual fqdn url = url.replace('0.0.0.0', self.host_name) + cookie_file_name = str(uuid.uuid4()) + cookie_file = os.path.join(cookies_dir, cookie_file_name) start_time = time.time() - curl = subprocess.Popen(['curl', '--negotiate', '-u', ':', '-sL', '-w', + curl = subprocess.Popen(['curl', '--negotiate', '-u', ':', '-b', cookie_file, '-c', cookie_file, '-sL', '-w', '%{http_code}', url, '--connect-timeout', CURL_CONNECTION_TIMEOUT, '-o', '/dev/null'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=kerberos_env) @@ -192,6 +202,10 @@ class WebAlert(BaseAlert): return WebResponse(status_code=0, time_millis=0, error_msg=str(exc)) + finally: + if os.path.isfile(cookie_file): + os.remove(cookie_file) + return WebResponse(status_code=response_code, time_millis=time_millis, error_msg=None)
