Browse Source

Merge remote-tracking branch 'apache/trunk' into trunk-branch-3.0-perf

Myroslav Papirkovskyi 7 years ago
parent
commit
e4b51f9394

+ 0 - 1
ambari-agent/src/main/python/ambari_agent/Constants.py

@@ -43,5 +43,4 @@ ALERTS_STATUS_REPORTS_ENDPOINT = '/reports/alerts_status'
 HEARTBEAT_ENDPOINT = '/heartbeat'
 REGISTRATION_ENDPOINT = '/register'
 
-AGENT_TMP_DIR = "/var/lib/ambari-agent/tmp"
 CORRELATION_ID_STRING = 'correlationId'

+ 3 - 1
ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py

@@ -31,6 +31,8 @@ from resource_management.libraries.functions.log_process_information import log_
 from resource_management.core.utils import PasswordString
 from ambari_agent.Utils import Utils
 import subprocess
+from ambari_commons.constants import AGENT_TMP_DIR
+import hostname
 import Constants
 
 
@@ -82,7 +84,7 @@ class CustomServiceOrchestrator():
     self.tmp_dir = self.config.get('agent', 'prefix')
     self.force_https_protocol = self.config.get_force_https_protocol_name()
     self.ca_cert_file_path = self.config.get_ca_cert_file_path()
-    self.exec_tmp_dir = Constants.AGENT_TMP_DIR
+    self.exec_tmp_dir = AGENT_TMP_DIR
     self.file_cache = initializer_module.file_cache
     self.status_commands_stdout = os.path.join(self.tmp_dir,
                                                'status_command_stdout.txt')

+ 1 - 1
ambari-agent/src/main/python/ambari_agent/HostCleanup.py

@@ -39,7 +39,7 @@ import glob
 import pwd
 import re
 from AmbariConfig import AmbariConfig
-from ambari_agent.Constants import AGENT_TMP_DIR
+from ambari_commons.constants import AGENT_TMP_DIR
 from ambari_commons import OSCheck, OSConst
 from ambari_commons.constants import AMBARI_SUDO_BINARY
 from ambari_commons.os_family_impl import OsFamilyImpl, OsFamilyFuncImpl

+ 2 - 2
ambari-agent/src/main/python/ambari_agent/alerts/metric_alert.py

@@ -31,7 +31,7 @@ from ambari_commons.urllib_handlers import RefreshHeaderProcessor
 from resource_management.libraries.functions.get_port_from_url import get_port_from_url
 from resource_management.libraries.functions.curl_krb_request import curl_krb_request
 from ambari_commons import inet_utils
-from ambari_agent import Constants
+from ambari_commons.constants import AGENT_TMP_DIR
 
 logger = logging.getLogger(__name__)
 
@@ -203,7 +203,7 @@ class MetricAlert(BaseAlert):
       content = ''
       try:
         if kerberos_principal is not None and kerberos_keytab is not None and security_enabled:
-          tmp_dir = Constants.AGENT_TMP_DIR
+          tmp_dir = AGENT_TMP_DIR
           if tmp_dir is None:
             tmp_dir = gettempdir()
 

+ 2 - 2
ambari-agent/src/main/python/ambari_agent/alerts/script_alert.py

@@ -26,7 +26,7 @@ from alerts.base_alert import BaseAlert
 from resource_management.core.environment import Environment
 from resource_management.libraries.script.script import Script
 from resource_management.libraries.functions.curl_krb_request import KERBEROS_KINIT_TIMER_PARAMETER
-from ambari_agent import Constants
+from ambari_commons.constants import AGENT_TMP_DIR
 
 logger = logging.getLogger(__name__)
 
@@ -115,7 +115,7 @@ class ScriptAlert(BaseAlert):
       matchObj = re.match( r'((.*)services(.*)package)', self.path_to_script)
       if matchObj:
         basedir = matchObj.group(1)
-        with Environment(basedir, tmp_dir=Constants.AGENT_TMP_DIR, logger=logging.getLogger('ambari_alerts')) as env:
+        with Environment(basedir, tmp_dir=AGENT_TMP_DIR, logger=logging.getLogger('ambari_alerts')) as env:
           result = cmd_module.execute(configurations, self.parameters, self.host_name)
       else:
         result = cmd_module.execute(configurations, self.parameters, self.host_name)

+ 2 - 2
ambari-agent/src/main/python/ambari_agent/alerts/web_alert.py

@@ -32,7 +32,7 @@ from resource_management.libraries.functions.get_path_from_url import get_path_f
 from resource_management.libraries.functions.curl_krb_request import curl_krb_request
 from ambari_commons import OSCheck
 from ambari_commons.inet_utils import resolve_address, ensure_ssl_using_protocol, get_host_from_url
-from ambari_agent import Constants
+from ambari_commons.constants import AGENT_TMP_DIR
 from ambari_agent.AmbariConfig import AmbariConfig
 
 # hashlib is supplied as of Python 2.5 as the replacement interface for md5
@@ -192,7 +192,7 @@ class WebAlert(BaseAlert):
         # Create the kerberos credentials cache (ccache) file and set it in the environment to use
         # when executing curl. Use the md5 hash of the combination of the principal and keytab file
         # to generate a (relatively) unique cache filename so that we can use it as needed.
-        tmp_dir = Constants.AGENT_TMP_DIR
+        tmp_dir = AGENT_TMP_DIR
         if tmp_dir is None:
           tmp_dir = gettempdir()
 

+ 1 - 0
ambari-common/src/main/python/ambari_commons/constants.py

@@ -24,6 +24,7 @@ UPGRADE_TYPE_ROLLING = "rolling"
 UPGRADE_TYPE_NON_ROLLING = "nonrolling"
 UPGRADE_TYPE_HOST_ORDERED = "host_ordered"
 
+AGENT_TMP_DIR = "/var/lib/ambari-agent/tmp"
 
 class SERVICE:
   """

+ 2 - 2
ambari-common/src/main/python/ambari_commons/kerberos/kerberos_common.py

@@ -21,7 +21,7 @@ import base64
 import getpass
 import os
 import stat
-from ambari_agent import Constants
+from ambari_commons.constants import AGENT_TMP_DIR
 from collections import namedtuple
 from resource_management.core import sudo
 from resource_management.core.logger import Logger
@@ -97,7 +97,7 @@ def write_krb5_conf(params):
 
 
 def clear_tmp_cache():
-  tmp_dir = Constants.AGENT_TMP_DIR
+  tmp_dir = AGENT_TMP_DIR
   if tmp_dir is None:
     tmp_dir = gettempdir()
   curl_krb_cache_path = os.path.join(tmp_dir, "curl_krb_cache")

+ 2 - 2
ambari-server/src/main/resources/stacks/PERF/1.0/services/KERBEROS/package/scripts/kerberos_common.py

@@ -29,7 +29,7 @@ from tempfile import gettempdir
 from resource_management import *
 from utils import get_property_value
 from ambari_commons.os_utils import remove_file
-from ambari_agent import Constants
+from ambari_commons.constants import AGENT_TMP_DIR
 from collections import namedtuple
 from resource_management.core import sudo
 from resource_management.core.resources.klist import Klist
@@ -289,7 +289,7 @@ class KerberosScript(Script):
 
   @staticmethod
   def clear_tmp_cache():
-    tmp_dir = Constants.AGENT_TMP_DIR
+    tmp_dir = AGENT_TMP_DIR
     if tmp_dir is None:
       tmp_dir = gettempdir()
     curl_krb_cache_path = os.path.join(tmp_dir, "curl_krb_cache")