Repository: ambari
Updated Branches:
  refs/heads/branch-2.0.0 a842630e4 -> ee0a7ce95


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/ee0a7ce9
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ee0a7ce9
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ee0a7ce9

Branch: refs/heads/branch-2.0.0
Commit: ee0a7ce95d0e25a46eaaf1c1dde0023d3cdbf40f
Parents: a842630
Author: Vitaly Brodetskyi <[email protected]>
Authored: Wed Mar 11 15:15:29 2015 +0200
Committer: Vitaly Brodetskyi <[email protected]>
Committed: Wed Mar 11 15:15:29 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/ee0a7ce9/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)
 
 

Reply via email to