You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by fb...@apache.org on 2015/01/24 02:37:07 UTC
[3/8] ambari git commit: AMBARI-8317 Refactor the OS-dependent Ambari
Server Windows components - Part 1.4
http://git-wip-us.apache.org/repos/asf/ambari/blob/49955a35/ambari-server/src/main/python/ambari_server/serverSetup_windows.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/serverSetup_windows.py b/ambari-server/src/main/python/ambari_server/serverSetup_windows.py
deleted file mode 100644
index dce404d..0000000
--- a/ambari-server/src/main/python/ambari_server/serverSetup_windows.py
+++ /dev/null
@@ -1,300 +0,0 @@
-#!/usr/bin/env python
-
-'''
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-'''
-
-import optparse
-import os
-import socket
-import string
-
-from _winreg import (OpenKey, EnumValue, HKEY_LOCAL_MACHINE, KEY_READ, CloseKey, KEY_WRITE, QueryValueEx, SetValueEx,
- REG_EXPAND_SZ)
-
-from ambari_commons import os_utils
-
-from ambari_commons.exceptions import *
-from ambari_commons.logging_utils import *
-from ambari_commons.os_windows import run_powershell_script, UserHelper, CHECK_FIREWALL_SCRIPT
-from ambari_server.dbConfiguration import DBMSConfig
-from ambari_server.serverConfiguration import *
-from ambari_server.userInput import get_validated_string_input
-
-# Non-root user setup commands
-NR_USER_COMMENT = "Ambari user"
-NR_GET_OWNER_CMD = 'stat -c "%U" {0}'
-NR_USERADD_CMD = 'cmd /C net user {0} {1} /ADD'
-NR_SET_USER_COMMENT_CMD = 'usermod -c "{0}" {1}'
-
-NR_USER_CHANGE_PROMPT = "Ambari-server service is configured to run under user '{0}'. Change this setting [y/n] (n)? "
-NR_USER_CUSTOMIZE_PROMPT = "Customize user account for ambari-server service [y/n] (n)? "
-NR_DEFAULT_USER = "NT AUTHORITY\SYSTEM"
-
-SERVICE_USERNAME_KEY = "TMP_AMBARI_USERNAME"
-SERVICE_PASSWORD_KEY = "TMP_AMBARI_PASSWORD"
-
-# JDK setup choices
-JDK_DEFAULT_CONFIGS = [
- JDKRelease("jdk7.67", "Oracle JDK 7.67",
- "http://public-repo-1.hortonworks.com/ARTIFACTS/jdk-7u67-windows-x64.exe", "jdk-7u67-windows-x64.exe",
- "http://public-repo-1.hortonworks.com/ARTIFACTS/UnlimitedJCEPolicyJDK7.zip", "UnlimitedJCEPolicyJDK7.zip",
- None)
-]
-
-JDK_VERSION_REs = ["(jdk.*)/jre", "Creating (jdk.*)/jre"]
-JDK_PROMPT = "[{0}] {1}\n"
-JDK_CUSTOM_CHOICE_PROMPT = "[{0}] - Custom JDK\n==============================================================================\nEnter choice ({1}): "
-JDK_VALID_CHOICES = "^[{0}{1:d}]$"
-CUSTOM_JDK_NUMBER = "4"
-JDK_MIN_FILESIZE = 5000
-MAKE_FILE_EXECUTABLE_CMD = "chmod a+x {0}"
-
-JDK_DOWNLOAD_CMD = "curl --create-dirs -o {0} {1}"
-JDK_DOWNLOAD_SIZE_CMD = "curl -I {0}"
-
-# use --no-same-owner when running as root to prevent uucp as the user (AMBARI-6478)
-UNTAR_JDK_ARCHIVE = "tar --no-same-owner -xvf {0}"
-
-
-#JDBC
-USERNAME_PATTERN = "^[a-zA-Z_][a-zA-Z0-9_\-]*$"
-DATABASE_DBMS = "sqlserver"
-DATABASE_NAME = "ambari"
-DATABASE_SERVER = "localhost\\\\SQLEXPRESS"
-DATABASE_DRIVER_NAME = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
-
-JDBC_PATTERNS = {"sqlserver": "sqljdbc*.jar"}
-DATABASE_FULL_NAMES = {"sqlserver": "SQL Server"}
-JDBC_DB_OPTION_VALUES = ["sqlserver"]
-JDBC_DB_DEFAULT_DRIVER = {"sqlserver" : "sqljdbc4.jar"}
-
-
-ERROR_NOT_ROOT = 'Ambari-server setup should be run with administrator-level privileges'
-
-MESSAGE_CHECK_FIREWALL = 'Checking firewall status...'
-
-def os_check_firewall():
- out = run_powershell_script(CHECK_FIREWALL_SCRIPT)
- if out[0] != 0:
- print_warning_msg("Unable to check firewall status:{0}".format(out[2]))
- return False
- profiles_status = [i for i in out[1].split("\n") if not i == ""]
- if "1" in profiles_status:
- enabled_profiles = []
- if profiles_status[0] == "1":
- enabled_profiles.append("DomainProfile")
- if profiles_status[1] == "1":
- enabled_profiles.append("StandardProfile")
- if profiles_status[2] == "1":
- enabled_profiles.append("PublicProfile")
- print_warning_msg("Following firewall profiles enabled:{0}. Make sure that firewall properly configured.".format(",".join(enabled_profiles)))
- return False
- return True
-
-# No security enhancements in Windows
-def disable_security_enhancements():
- retcode = 0
- err = ''
- return (retcode, err)
-
-
-#
-# User account creation
-#
-
-def os_create_custom_user():
- user = get_validated_string_input(
- "Enter user account for ambari-server service ({0}):".format(NR_DEFAULT_USER),
- NR_DEFAULT_USER, None,
- "Invalid username.",
- False
- )
- if user == NR_DEFAULT_USER:
- return 0, user
- password = get_validated_string_input("Enter password for user {0}:".format(user), "", None, "Password", True, False)
-
- uh = UserHelper()
-
- status, message = uh.create_user(user,password)
- if status == UserHelper.USER_EXISTS:
- print_info_msg("User {0} already exists, make sure that you typed correct password for user, "
- "skipping user creation".format(user))
-
- elif status == UserHelper.ACTION_FAILED: # fail
- print_warning_msg("Can't create user {0}. Failed with message {1}".format(user, message))
- return UserHelper.ACTION_FAILED, None
-
- # setting SeServiceLogonRight to user
-
- status, message = uh.add_user_privilege(user, 'SeServiceLogonRight')
- if status == UserHelper.ACTION_FAILED:
- print_warning_msg("Can't add SeServiceLogonRight to user {0}. Failed with message {1}".format(user, message))
- return UserHelper.ACTION_FAILED, None
-
- print_info_msg("User configuration is done.")
- print_warning_msg("When using non SYSTEM user make sure that your user have read\write access to log directories and "
- "all server directories. In case of integrated authentication for SQL Server make sure that your "
- "user properly configured to use ambari database.")
- #storing username and password in os.environ temporary to pass them to service
- os.environ[SERVICE_USERNAME_KEY] = user
- os.environ[SERVICE_PASSWORD_KEY] = password
- return 0, user
-
-
-#
-# JDK Setup
-#
-def populate_jdk_configs(properties, jdk_num):
- if properties.has_key(JDK_RELEASES):
- jdk_names = properties[JDK_RELEASES].split(',')
- jdks = []
- for jdk_name in jdk_names:
- jdkR = JDKRelease.from_properties(properties, jdk_name)
- jdks.append(jdkR)
- else:
- jdks = JDK_DEFAULT_CONFIGS
-
- n_config = 1
- jdk_choice_prompt = ''
- jdk_choices = ''
- for jdk in jdks:
- jdk_choice_prompt += JDK_PROMPT.format(n_config, jdk.desc)
- jdk_choices_tmp = '{0}{1:d}'.format(jdk_choices, n_config)
- jdk_choices = jdk_choices_tmp
- n_config += 1
-
- jdk_choice_prompt += JDK_CUSTOM_CHOICE_PROMPT.format(n_config, jdk_num)
- jdk_valid_choices = JDK_VALID_CHOICES.format(jdk_choices, n_config)
-
- return (jdks, jdk_choice_prompt, jdk_valid_choices, n_config)
-
-
-def os_install_jdk(java_inst_file, java_home_dir):
- print "Installing JDK to {0}".format(java_home_dir)
-
- if not os.path.exists(java_home_dir):
- os.makedirs(java_home_dir)
-
- if java_inst_file.endswith(".exe"):
- (dirname, filename) = os.path.split(java_inst_file)
- installLogFilePath = os.path.join(configDefaults.OUT_DIR, filename + "-install.log")
- #jre7u67.exe /s INSTALLDIR=<dir> STATIC=1 WEB_JAVA=0 /L \\var\\log\\ambari-server\\jre7u67.exe-install.log
- installCmd = [
- java_inst_file,
- "/s",
- "INSTALLDIR=" + java_home_dir,
- "STATIC=1",
- "WEB_JAVA=0",
- "/L",
- installLogFilePath
- ]
- retcode, out, err = run_os_command(installCmd)
- #TODO: support .msi file installations
- #msiexec.exe jre.msi /s INSTALLDIR=<dir> STATIC=1 WEB_JAVA=0 /L \\var\\log\\ambari-server\\jre7u67-install.log ?
- else:
- err = "JDK installation failed.Unknown file mask."
- raise FatalException(1, err)
-
- if retcode == 1603:
- # JDK already installed
- print "JDK already installed in {0}".format(java_home_dir)
- retcode = 0
- else:
- if retcode != 0:
- err = "Installation of JDK returned exit code %s" % retcode
- raise FatalException(retcode, err)
-
- print "Successfully installed JDK to {0}".format(java_home_dir)
-
- # Don't forget to adjust the JAVA_HOME env var
-
- return (retcode, out)
-
-def os_ensure_java_home_env_var_is_set(java_home_var):
- if not os.environ.has_key(JAVA_HOME) or os.environ[JAVA_HOME] != java_home_var:
- java_home_var_val = java_home_var.replace('\\\\', '\\')
- os.system("SETX {0} {1} /M".format(JAVA_HOME, java_home_var_val))
- os.environ[JAVA_HOME] = java_home_var
- pass
-
-#
-# JDBC Setup
-#
-
-def os_check_jdbc_options(options):
- #Only SQL Server supported, no point in checking options.jdbc_db
- return (options.jdbc_driver is not None)
-
-def os_setup_jdbc_drivers(args):
- properties = get_ambari_properties()
- if properties == -1:
- print_error_msg("Error getting ambari properties")
- return -1
-
- #Only support SQL Server
- dbms = DBMSConfig.create(args, properties)
- if dbms.ensure_jdbc_driver_installed(args, properties):
- # Now save the properties file
- update_properties(properties)
- pass
-
-def os_setup_database(options):
- properties = get_ambari_properties()
- if properties == -1:
- raise FatalException(-1, "Error getting ambari properties")
-
- #Ensure the default database host is set
- options.default_database_host = "localhost\\SQLEXPRESS"
-
- #Only support SQL Server
- dbmsAmbari = DBMSConfig.create(options, properties, "Ambari")
- resultA = dbmsAmbari.configure_database(options, properties)
-
- #By default, use the same server for Metrics
- options.default_database_host = dbmsAmbari.database_host
-
- # Now save the properties file
- if resultA:
- update_properties(properties)
-
- dbmsAmbari.setup_database()
-
-def os_reset_database(options):
- properties = get_ambari_properties()
- if properties == -1:
- raise FatalException(-1, "Error getting ambari properties")
-
- if not (properties.getPropertyDict().has_key(JDBC_URL_PROPERTY) and
- properties.getPropertyDict().has_key(JDBC_RCA_URL_PROPERTY)):
- raise FatalException(-1, "Ambari Server not set up yet. Nothing to reset.")
-
- empty_options = optparse.Values()
- empty_options.silent = options.silent
- empty_options.database_host = ""
- empty_options.database_port = ""
- empty_options.database_name = ""
- empty_options.database_windows_auth = False
- empty_options.database_username = ""
- empty_options.database_password = ""
- empty_options.init_db_script_file = ""
- empty_options.cleanup_db_script_file = ""
-
- #Only support SQL Server
- dbmsAmbari = DBMSConfig.create(empty_options, properties, "Ambari")
- dbmsAmbari.reset_database()
- pass
http://git-wip-us.apache.org/repos/asf/ambari/blob/49955a35/ambari-server/src/main/python/ambari_server/serverUpgrade.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/serverUpgrade.py b/ambari-server/src/main/python/ambari_server/serverUpgrade.py
new file mode 100644
index 0000000..1d9735a
--- /dev/null
+++ b/ambari-server/src/main/python/ambari_server/serverUpgrade.py
@@ -0,0 +1,305 @@
+#!/usr/bin/env python
+
+'''
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+'''
+
+import json
+import os
+import shutil
+
+from ambari_commons.exceptions import FatalException
+from ambari_commons.logging_utils import print_info_msg, print_warning_msg, print_error_msg
+from ambari_commons.os_utils import is_root, run_os_command
+from ambari_server.dbConfiguration import DBMSConfigFactory, check_jdbc_drivers
+from ambari_server.properties import Properties
+from ambari_server.serverConfiguration import configDefaults, \
+ check_database_name_property, get_ambari_properties, get_ambari_version, get_full_ambari_classpath, \
+ get_java_exe_path, get_stack_location, parse_properties_file, read_ambari_user, update_ambari_properties, \
+ update_database_name_property, \
+ AMBARI_PROPERTIES_FILE, IS_LDAP_CONFIGURED, LDAP_PRIMARY_URL_PROPERTY, RESOURCES_DIR_PROPERTY, \
+ SETUP_OR_UPGRADE_MSG
+from ambari_server.setupSecurity import adjust_directory_permissions
+
+# constants
+from ambari_server.utils import compare_versions
+
+STACK_NAME_VER_SEP = "-"
+
+SCHEMA_UPGRADE_HELPER_CMD = "{0} -cp {1} " + \
+ "org.apache.ambari.server.upgrade.SchemaUpgradeHelper" + \
+ " > " + configDefaults.SERVER_OUT_FILE + " 2>&1"
+
+STACK_UPGRADE_HELPER_CMD = "{0} -cp {1} " + \
+ "org.apache.ambari.server.upgrade.StackUpgradeHelper" + \
+ " {2} {3} > " + configDefaults.SERVER_OUT_FILE + " 2>&1"
+
+
+#
+# Stack upgrade
+#
+
+def upgrade_stack(args, stack_id, repo_url=None, repo_url_os=None):
+ if not is_root():
+ err = 'Ambari-server upgradestack should be run with ' \
+ 'root-level privileges'
+ raise FatalException(4, err)
+ check_database_name_property()
+
+ stack_name, stack_version = stack_id.split(STACK_NAME_VER_SEP)
+ retcode = run_stack_upgrade(stack_name, stack_version, repo_url, repo_url_os)
+
+ if not retcode == 0:
+ raise FatalException(retcode, 'Stack upgrade failed.')
+
+ return retcode
+
+def load_stack_values(version, filename):
+ import xml.etree.ElementTree as ET
+ values = {}
+ root = ET.parse(filename).getroot()
+ for ostag in root:
+ ostype = ostag.attrib['type']
+ for repotag in ostag:
+ reponametag = repotag.find('reponame')
+ repoidtag = repotag.find('repoid')
+ baseurltag = repotag.find('baseurl')
+ if reponametag is not None and repoidtag is not None and baseurltag is not None:
+ key = "repo:/" + reponametag.text
+ key += "/" + version
+ key += "/" + ostype
+ key += "/" + repoidtag.text
+ key += ":baseurl"
+ values[key] = baseurltag.text
+
+ return values
+
+
+def run_stack_upgrade(stackName, stackVersion, repo_url, repo_url_os):
+ jdk_path = get_java_exe_path()
+ if jdk_path is None:
+ print_error_msg("No JDK found, please run the \"setup\" "
+ "command to install a JDK automatically or install any "
+ "JDK manually to " + configDefaults.JDK_INSTALL_DIR)
+ return 1
+ stackId = {}
+ stackId[stackName] = stackVersion
+ if repo_url is not None:
+ stackId['repo_url'] = repo_url
+ if repo_url_os is not None:
+ stackId['repo_url_os'] = repo_url_os
+
+ command = STACK_UPGRADE_HELPER_CMD.format(jdk_path, get_full_ambari_classpath(),
+ "updateStackId",
+ "'" + json.dumps(stackId) + "'")
+ (retcode, stdout, stderr) = run_os_command(command)
+ print_info_msg("Return code from stack upgrade command, retcode = " + str(retcode))
+ if retcode > 0:
+ print_error_msg("Error executing stack upgrade, please check the server logs.")
+ return retcode
+
+def run_metainfo_upgrade(keyValueMap=None):
+ jdk_path = get_java_exe_path()
+ if jdk_path is None:
+ print_error_msg("No JDK found, please run the \"setup\" "
+ "command to install a JDK automatically or install any "
+ "JDK manually to " + configDefaults.JDK_INSTALL_DIR)
+
+ retcode = 1
+ if keyValueMap:
+ command = STACK_UPGRADE_HELPER_CMD.format(jdk_path, get_full_ambari_classpath(),
+ 'updateMetaInfo',
+ "'" + json.dumps(keyValueMap) + "'")
+ (retcode, stdout, stderr) = run_os_command(command)
+ print_info_msg("Return code from stack upgrade command, retcode = " + str(retcode))
+ if retcode > 0:
+ print_error_msg("Error executing metainfo upgrade, please check the "
+ "server logs.")
+
+ return retcode
+
+
+#
+# Repo upgrade
+#
+
+def change_objects_owner(args):
+ print 'Fixing database objects owner'
+
+ properties = Properties() #Dummy, args contains the dbms name and parameters already
+
+ factory = DBMSConfigFactory()
+ dbms = factory.create(args, properties)
+
+ dbms.change_db_files_owner()
+
+def upgrade_local_repo(args):
+ properties = get_ambari_properties()
+ if properties == -1:
+ print_error_msg("Error getting ambari properties")
+ return -1
+
+ stack_location = get_stack_location(properties)
+ stack_root_local = os.path.join(stack_location, "HDPLocal")
+ if not os.path.exists(stack_root_local):
+ print_info_msg("HDPLocal stack directory does not exist, skipping")
+ return
+
+ stack_root = os.path.join(stack_location, "HDP")
+ if not os.path.exists(stack_root):
+ print_info_msg("HDP stack directory does not exist, skipping")
+ return
+
+ for stack_version_local in os.listdir(stack_root_local):
+ repo_file_local = os.path.join(stack_root_local, stack_version_local, "repos", "repoinfo.xml.rpmsave")
+ if not os.path.exists(repo_file_local):
+ repo_file_local = os.path.join(stack_root_local, stack_version_local, "repos", "repoinfo.xml")
+
+ repo_file = os.path.join(stack_root, stack_version_local, "repos", "repoinfo.xml")
+
+ print_info_msg("Local repo file: " + repo_file_local)
+ print_info_msg("Repo file: " + repo_file_local)
+
+ metainfo_update_items = {}
+
+ if os.path.exists(repo_file_local) and os.path.exists(repo_file):
+ local_values = load_stack_values(stack_version_local, repo_file_local)
+ repo_values = load_stack_values(stack_version_local, repo_file)
+ for k, v in local_values.iteritems():
+ if repo_values.has_key(k):
+ local_url = local_values[k]
+ repo_url = repo_values[k]
+ if repo_url != local_url:
+ metainfo_update_items[k] = local_url
+
+ run_metainfo_upgrade(metainfo_update_items)
+
+#
+# Schema upgrade
+#
+
+def run_schema_upgrade():
+ jdk_path = get_java_exe_path()
+ if jdk_path is None:
+ print_error_msg("No JDK found, please run the \"setup\" "
+ "command to install a JDK automatically or install any "
+ "JDK manually to " + configDefaults.JDK_INSTALL_DIR)
+ return 1
+
+ print 'Upgrading database schema'
+
+ command = SCHEMA_UPGRADE_HELPER_CMD.format(jdk_path, get_full_ambari_classpath())
+ (retcode, stdout, stderr) = run_os_command(command)
+ print_info_msg("Return code from schema upgrade command, retcode = " + str(retcode))
+ if retcode > 0:
+ print_error_msg("Error executing schema upgrade, please check the server logs.")
+ else:
+ print_info_msg('Schema upgrade completed')
+ return retcode
+
+
+#
+# Upgrades the Ambari Server.
+#
+def move_user_custom_actions():
+ print_info_msg('Moving *.py files from custom_actions to custom_actions/scripts')
+ properties = get_ambari_properties()
+ if properties == -1:
+ err = "Error getting ambari properties"
+ print_error_msg(err)
+ raise FatalException(-1, err)
+
+ try:
+ resources_dir = properties[RESOURCES_DIR_PROPERTY]
+ except (KeyError), e:
+ conf_file = properties.fileName
+ err = 'Property ' + str(e) + ' is not defined at ' + conf_file
+ print_error_msg(err)
+ raise FatalException(1, err)
+
+ custom_actions_dir_path = os.path.join(resources_dir, 'custom_actions')
+ custom_actions_scripts_dir_path = os.path.join(custom_actions_dir_path, 'scripts')
+ print_info_msg('Moving *.py files from %s to %s' % (custom_actions_dir_path, custom_actions_scripts_dir_path))
+
+ try:
+ for custom_action_file_name in os.listdir(custom_actions_dir_path):
+ custom_action_file_path = os.path.join(custom_actions_dir_path, custom_action_file_name)
+ if os.path.isfile(custom_action_file_path) and custom_action_file_path.endswith('.py'):
+ print_info_msg('Moving %s to %s' % (custom_action_file_path, custom_actions_scripts_dir_path))
+ shutil.move(custom_action_file_path, custom_actions_scripts_dir_path)
+ except (OSError, shutil.Error) as e:
+ err = 'Upgrade failed. Can not move *.py files from %s to %s. ' % (custom_actions_dir_path, custom_actions_scripts_dir_path) + str(e)
+ print_error_msg(err)
+ raise FatalException(1, err)
+
+def upgrade(args):
+ if not is_root():
+ err = configDefaults.MESSAGE_ERROR_UPGRADE_NOT_ROOT
+ raise FatalException(4, err)
+
+ print 'Updating properties in ' + AMBARI_PROPERTIES_FILE + ' ...'
+ retcode = update_ambari_properties()
+ if not retcode == 0:
+ err = AMBARI_PROPERTIES_FILE + ' file can\'t be updated. Exiting'
+ raise FatalException(retcode, err)
+
+ try:
+ update_database_name_property(upgrade=True)
+ except FatalException:
+ return -1
+
+ # Ignore the server version & database options passed via command-line arguments
+ parse_properties_file(args)
+
+ #TODO check database version
+ change_objects_owner(args)
+
+ retcode = run_schema_upgrade()
+ if not retcode == 0:
+ print_error_msg("Ambari server upgrade failed. Please look at {0}, for more details.".format(configDefaults.SERVER_LOG_FILE))
+ raise FatalException(11, 'Schema upgrade failed.')
+
+ user = read_ambari_user()
+ if user is None:
+ warn = "Can not determine custom ambari user.\n" + SETUP_OR_UPGRADE_MSG
+ print_warning_msg(warn)
+ else:
+ adjust_directory_permissions(user)
+
+ # local repo
+ upgrade_local_repo(args)
+
+ # create jdbc symlinks if jdbc drivers are available in resources
+ check_jdbc_drivers(args)
+
+ properties = get_ambari_properties()
+ if properties == -1:
+ err = "Error getting ambari properties"
+ print_error_msg(err)
+ raise FatalException(-1, err)
+
+ # Move *.py files from custom_actions to custom_actions/scripts
+ # This code exists for historic reasons in which custom action python scripts location changed from Ambari 1.7.0 to 2.0.0
+ ambari_version = get_ambari_version(properties)
+ if ambari_version is None:
+ args.warnings.append("*.py files were not moved from custom_actions to custom_actions/scripts.")
+ elif compare_versions(ambari_version, "2.0.0") == 0:
+ move_user_custom_actions()
+
+ # check if ambari has obsolete LDAP configuration
+ if properties.get_property(LDAP_PRIMARY_URL_PROPERTY) and not properties.get_property(IS_LDAP_CONFIGURED):
+ args.warnings.append("Existing LDAP configuration is detected. You must run the \"ambari-server setup-ldap\" command to adjust existing LDAP configuration.")
http://git-wip-us.apache.org/repos/asf/ambari/blob/49955a35/ambari-server/src/main/python/ambari_server/setupActions.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/setupActions.py b/ambari-server/src/main/python/ambari_server/setupActions.py
index ee8eaa0..5ca5cce 100644
--- a/ambari-server/src/main/python/ambari_server/setupActions.py
+++ b/ambari-server/src/main/python/ambari_server/setupActions.py
@@ -30,10 +30,12 @@ REFRESH_STACK_HASH_ACTION = "refresh-stack-hash"
STATUS_ACTION = "status"
SETUP_HTTPS_ACTION = "setup-https"
LDAP_SETUP_ACTION = "setup-ldap"
+LDAP_SYNC_ACTION = "sync-ldap"
SETUP_GANGLIA_HTTPS_ACTION = "setup-ganglia-https"
-SETUP_NAGIOS_HTTPS_ACTION = "setup-nagios-https"
ENCRYPT_PASSWORDS_ACTION = "encrypt-passwords"
SETUP_SECURITY_ACTION = "setup-security"
+BACKUP_ACTION = "backup"
+RESTORE_ACTION = "restore"
ACTION_REQUIRE_RESTART = [RESET_ACTION, UPGRADE_ACTION, UPGRADE_STACK_ACTION,
SETUP_SECURITY_ACTION, LDAP_SETUP_ACTION]
http://git-wip-us.apache.org/repos/asf/ambari/blob/49955a35/ambari-server/src/main/python/ambari_server/setupSecurity.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/setupSecurity.py b/ambari-server/src/main/python/ambari_server/setupSecurity.py
index 3407039..769b5f7 100644
--- a/ambari-server/src/main/python/ambari_server/setupSecurity.py
+++ b/ambari-server/src/main/python/ambari_server/setupSecurity.py
@@ -24,22 +24,27 @@ import random
import re
import shutil
import socket
-import stat
import string
-import sys
import tempfile
import urllib2
+import time
from ambari_commons.exceptions import NonFatalException, FatalException
from ambari_commons.logging_utils import get_silent, print_warning_msg, print_error_msg, print_info_msg
-from ambari_commons.os_check import OSCheck, OSConst
+from ambari_commons.os_check import OSCheck
from ambari_commons.os_utils import copy_file, is_root, is_valid_filepath, remove_file, set_file_permissions, \
run_os_command, search_file
from ambari_server.serverConfiguration import configDefaults, get_ambari_properties, read_ambari_user, \
- get_value_from_properties, find_jdk, get_ambari_classpath, get_conf_dir, is_alias_string, find_properties_file, \
+ get_value_from_properties, find_jdk, get_conf_dir, is_alias_string, find_properties_file, \
update_properties_2, \
JDBC_USE_INTEGRATED_AUTH_PROPERTY, JDBC_PASSWORD_PROPERTY, JDBC_PASSWORD_FILENAME, \
- JDBC_RCA_PASSWORD_FILE_PROPERTY, JDBC_RCA_PASSWORD_ALIAS, BOOTSTRAP_DIR_PROPERTY, GET_FQDN_SERVICE_URL, BLIND_PASSWORD
+ JDBC_RCA_PASSWORD_FILE_PROPERTY, JDBC_RCA_PASSWORD_ALIAS, \
+ BOOTSTRAP_DIR_PROPERTY, GET_FQDN_SERVICE_URL, BLIND_PASSWORD, get_full_ambari_classpath, LDAP_MGR_PASSWORD_ALIAS, \
+ LDAP_MGR_PASSWORD_PROPERTY, LDAP_MGR_USERNAME_PROPERTY, decrypt_password_for_alias, read_passwd_for_alias, \
+ get_is_secure, get_master_key_location, get_credential_store_location, get_is_persisted, get_original_master_key, \
+ get_java_exe_path, SECURITY_PROVIDER_KEY_CMD, SECURITY_PROVIDER_PUT_CMD, SECURITY_IS_ENCRYPTION_ENABLED, \
+ SECURITY_KERBEROS_JASS_FILENAME, SECURITY_KEY_ENV_VAR_NAME, SECURITY_MASTER_KEY_FILENAME, \
+ SSL_TRUSTSTORE_PASSWORD_ALIAS, SSL_TRUSTSTORE_PASSWORD_PROPERTY, SSL_TRUSTSTORE_PATH_PROPERTY, SSL_TRUSTSTORE_TYPE_PROPERTY
from setupActions import SETUP_ACTION, LDAP_SETUP_ACTION
from ambari_server.userInput import get_YN_input, get_validated_string_input, get_validated_filepath_input, \
get_prompt_default
@@ -63,28 +68,6 @@ KEYTOOL_IMPORT_CERT_CMD = "{0}" + os.sep + "bin" + os.sep + keytool_bin + " -imp
KEYTOOL_DELETE_CERT_CMD = "{0}" + os.sep + "bin" + os.sep + keytool_bin + " -delete -alias '{1}' -storepass '{2}' -noprompt"
KEYTOOL_KEYSTORE = " -keystore '{0}'"
-java_bin = "java"
-if OSCheck.is_windows_family():
- java_bin = "java.exe"
-
-SECURITY_PROVIDER_GET_CMD = "{0}" + os.sep + "bin" + os.sep + java_bin + " -cp {1}" +\
- os.pathsep + "{2} " +\
- "org.apache.ambari.server.security.encryption" +\
- ".CredentialProvider GET {3} {4} {5} " +\
- "> " + configDefaults.SERVER_OUT_FILE + " 2>&1"
-
-SECURITY_PROVIDER_PUT_CMD = "{0}" + os.sep + "bin" + os.sep + java_bin + " -cp {1}" +\
- os.pathsep + "{2} " +\
- "org.apache.ambari.server.security.encryption" +\
- ".CredentialProvider PUT {3} {4} {5} " +\
- "> " + configDefaults.SERVER_OUT_FILE + " 2>&1"
-
-SECURITY_PROVIDER_KEY_CMD = "{0}" + os.sep + "bin" + os.sep + java_bin + " -cp {1}" +\
- os.pathsep + "{2} " +\
- "org.apache.ambari.server.security.encryption" +\
- ".MasterKeyServiceImpl {3} {4} {5} " +\
- "> " + configDefaults.SERVER_OUT_FILE + " 2>&1"
-
SSL_KEY_DIR = 'security.server.keys_dir'
SSL_API_PORT = 'client.api.ssl.port'
SSL_API = 'api.ssl'
@@ -109,29 +92,12 @@ SRVR_TWO_WAY_SSL_PORT = "8441"
SRVR_ONE_WAY_SSL_PORT_PROPERTY = "security.server.one_way_ssl.port"
SRVR_ONE_WAY_SSL_PORT = "8440"
-SECURITY_KEYS_DIR = "security.server.keys_dir"
-SECURITY_MASTER_KEY_LOCATION = "security.master.key.location"
-SECURITY_KEY_IS_PERSISTED = "security.master.key.ispersisted"
-SECURITY_KEY_ENV_VAR_NAME = "AMBARI_SECURITY_MASTER_KEY"
-SECURITY_MASTER_KEY_FILENAME = "master"
-SECURITY_IS_ENCRYPTION_ENABLED = "security.passwords.encryption.enabled"
-SECURITY_KERBEROS_JASS_FILENAME = "krb5JAASLogin.conf"
-
GANGLIA_HTTPS = 'ganglia.https'
NAGIOS_HTTPS = 'nagios.https'
-SSL_TRUSTSTORE_PASSWORD_ALIAS = "ambari.ssl.trustStore.password"
-SSL_TRUSTSTORE_PATH_PROPERTY = "ssl.trustStore.path"
-SSL_TRUSTSTORE_PASSWORD_PROPERTY = "ssl.trustStore.password"
-SSL_TRUSTSTORE_TYPE_PROPERTY = "ssl.trustStore.type"
-
DEFAULT_PASSWORD = "bigdata"
PASSWORD_PATTERN = "^[a-zA-Z0-9_-]*$"
-LDAP_MGR_PASSWORD_ALIAS = "ambari.ldap.manager.password"
-LDAP_MGR_PASSWORD_PROPERTY = "authentication.ldap.managerPassword"
-LDAP_MGR_USERNAME_PROPERTY = "authentication.ldap.managerDn"
-
REGEX_IP_ADDRESS = "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"
REGEX_HOSTNAME = "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$"
REGEX_HOSTNAME_PORT = "^(.*:[0-9]{1,5}$)"
@@ -420,7 +386,7 @@ def get_truststore_password(properties):
isSecure = get_is_secure(properties)
if truststore_password:
if isSecure:
- truststore_password = decrypt_password_for_alias(SSL_TRUSTSTORE_PASSWORD_ALIAS)
+ truststore_password = decrypt_password_for_alias(properties, SSL_TRUSTSTORE_PASSWORD_ALIAS)
else:
truststore_password = read_password("", ".*", "Password for TrustStore:", "Invalid characters in password")
if truststore_password:
@@ -429,40 +395,40 @@ def get_truststore_password(properties):
return truststore_password
+def get_pass_file_path(conf_file, filename):
+ return os.path.join(os.path.dirname(conf_file), filename)
+
def read_password(passwordDefault=DEFAULT_PASSWORD,
passwordPattern=PASSWORD_PATTERN,
passwordPrompt=None,
passwordDescr=None):
- # setup password
- if passwordPrompt is None:
- passwordPrompt = 'Password (' + passwordDefault + '): '
-
- if passwordDescr is None:
- passwordDescr = "Invalid characters in password. Use only alphanumeric or " \
- "_ or - characters"
-
- password = get_validated_string_input(passwordPrompt, passwordDefault,
- passwordPattern, passwordDescr, True)
-
- if not password:
- print 'Password cannot be blank.'
- return read_password(passwordDefault, passwordPattern, passwordPrompt,
- passwordDescr)
-
- if password != passwordDefault:
- password1 = get_validated_string_input("Re-enter password: ",
- passwordDefault, passwordPattern, passwordDescr, True)
- if password != password1:
- print "Passwords do not match"
- return read_password(passwordDefault, passwordPattern, passwordPrompt,
- passwordDescr)
- return password
+ input = True
+ while(input):
+ # setup password
+ if passwordPrompt is None:
+ passwordPrompt = 'Password (' + passwordDefault + '): '
-def get_is_secure(properties):
- isSecure = properties.get_property(SECURITY_IS_ENCRYPTION_ENABLED)
- isSecure = True if isSecure and isSecure.lower() == 'true' else False
- return isSecure
+ if passwordDescr is None:
+ passwordDescr = "Invalid characters in password. Use only alphanumeric or " \
+ "_ or - characters"
+
+ password = get_validated_string_input(passwordPrompt, passwordDefault,
+ passwordPattern, passwordDescr, True)
+ if not password:
+ print 'Password cannot be blank.'
+ continue
+
+ if password != passwordDefault:
+ password1 = get_validated_string_input("Re-enter password: ",
+ passwordDefault, passwordPattern, passwordDescr, True)
+ if password != password1:
+ print "Passwords do not match"
+ continue
+
+ input = False
+
+ return password
def encrypt_password(alias, password):
properties = get_ambari_properties()
@@ -494,59 +460,6 @@ def get_alias_string(alias):
def get_alias_from_alias_string(aliasStr):
return aliasStr[8:-1]
-def read_passwd_for_alias(alias, masterKey=""):
- if alias:
- jdk_path = find_jdk()
- if jdk_path is None:
- print_error_msg("No JDK found, please run the \"setup\" "
- "command to install a JDK automatically or install any "
- "JDK manually to " + configDefaults.JDK_INSTALL_DIR)
- return 1
-
- tempFileName = "ambari.passwd"
- passwd = ""
- tempDir = tempfile.gettempdir()
- #create temporary file for writing
- tempFilePath = tempDir + os.sep + tempFileName
- file = open(tempFilePath, 'w+')
- os.chmod(tempFilePath, stat.S_IREAD | stat.S_IWRITE)
- file.close()
-
- if masterKey is None or masterKey == "":
- masterKey = "None"
-
- command = SECURITY_PROVIDER_GET_CMD.format(jdk_path,
- get_conf_dir(), get_ambari_classpath(), alias, tempFilePath, masterKey)
- (retcode, stdout, stderr) = run_os_command(command)
- print_info_msg("Return code from credential provider get passwd: " +
- str(retcode))
- if retcode != 0:
- print 'ERROR: Unable to read password from store. alias = ' + alias
- else:
- passwd = open(tempFilePath, 'r').read()
- # Remove temporary file
- os.remove(tempFilePath)
- return passwd
- else:
- print_error_msg("Alias is unreadable.")
-
-def decrypt_password_for_alias(alias):
- properties = get_ambari_properties()
- if properties == -1:
- raise FatalException(1, None)
-
- isSecure = get_is_secure(properties)
- (isPersisted, masterKeyFile) = get_is_persisted(properties)
- if isSecure:
- masterKey = None
- if not masterKeyFile:
- # Encryption enabled but no master key file found
- masterKey = get_original_master_key(properties)
-
- return read_passwd_for_alias(alias, masterKey)
- else:
- return alias
-
def save_passwd_for_alias(alias, passwd, masterKey=""):
if alias and passwd:
jdk_path = find_jdk()
@@ -559,8 +472,8 @@ def save_passwd_for_alias(alias, passwd, masterKey=""):
if masterKey is None or masterKey == "":
masterKey = "None"
- command = SECURITY_PROVIDER_PUT_CMD.format(jdk_path, get_conf_dir(),
- get_ambari_classpath(), alias, passwd, masterKey)
+ command = SECURITY_PROVIDER_PUT_CMD.format(get_java_exe_path(),
+ get_full_ambari_classpath(), alias, passwd, masterKey)
(retcode, stdout, stderr) = run_os_command(command)
print_info_msg("Return code from credential provider save passwd: " +
str(retcode))
@@ -568,61 +481,6 @@ def save_passwd_for_alias(alias, passwd, masterKey=""):
else:
print_error_msg("Alias or password is unreadable.")
-def get_is_persisted(properties):
- keyLocation = get_master_key_location(properties)
- masterKeyFile = search_file(SECURITY_MASTER_KEY_FILENAME, keyLocation)
- isPersisted = True if masterKeyFile else False
-
- return (isPersisted, masterKeyFile)
-
-def get_credential_store_location(properties):
- store_loc = properties[SECURITY_KEYS_DIR]
- if store_loc is None or store_loc == "":
- store_loc = "/var/lib/ambari-server/keys/credentials.jceks"
- else:
- store_loc += os.sep + "credentials.jceks"
- return store_loc
-
-def get_master_key_location(properties):
- keyLocation = properties[SECURITY_MASTER_KEY_LOCATION]
- if keyLocation is None or keyLocation == "":
- keyLocation = properties[SECURITY_KEYS_DIR]
- return keyLocation
-
-def get_original_master_key(properties):
- try:
- masterKey = get_validated_string_input('Enter current Master Key: ',
- "", ".*", "", True, False)
- except KeyboardInterrupt:
- print 'Exiting...'
- sys.exit(1)
-
- # Find an alias that exists
- alias = None
- property = properties.get_property(JDBC_PASSWORD_PROPERTY)
- if property and is_alias_string(property):
- alias = JDBC_RCA_PASSWORD_ALIAS
-
- alias = None
- if not alias:
- property = properties.get_property(LDAP_MGR_PASSWORD_PROPERTY)
- if property and is_alias_string(property):
- alias = LDAP_MGR_PASSWORD_ALIAS
-
- if not alias:
- property = properties.get_property(SSL_TRUSTSTORE_PASSWORD_PROPERTY)
- if property and is_alias_string(property):
- alias = SSL_TRUSTSTORE_PASSWORD_ALIAS
-
- # Decrypt alias with master to validate it, if no master return
- if alias and masterKey:
- password = read_passwd_for_alias(alias, masterKey)
- if not password:
- print "ERROR: Master key does not match."
- return get_original_master_key(properties)
-
- return masterKey
-
def read_master_key(isReset=False):
passwordPattern = ".*"
passwordPrompt = "Please provide master key for locking the credential store: "
@@ -632,19 +490,23 @@ def read_master_key(isReset=False):
if isReset:
passwordPrompt = "Enter new Master Key: "
- masterKey = get_validated_string_input(passwordPrompt, passwordDefault,
- passwordPattern, passwordDescr, True, True)
+ input = True
+ while(input):
+ masterKey = get_validated_string_input(passwordPrompt, passwordDefault,
+ passwordPattern, passwordDescr, True, True)
- if not masterKey:
- print "Master Key cannot be empty!"
- return read_master_key()
+ if not masterKey:
+ print "Master Key cannot be empty!"
+ continue
- masterKey2 = get_validated_string_input("Re-enter master key: ",
- passwordDefault, passwordPattern, passwordDescr, True, True)
+ masterKey2 = get_validated_string_input("Re-enter master key: ",
+ passwordDefault, passwordPattern, passwordDescr, True, True)
- if masterKey != masterKey2:
- print "Master key did not match!"
- return read_master_key()
+ if masterKey != masterKey2:
+ print "Master key did not match!"
+ continue
+
+ input = False
return masterKey
@@ -656,8 +518,8 @@ def save_master_key(master_key, key_location, persist=True):
"command to install a JDK automatically or install any "
"JDK manually to " + configDefaults.JDK_INSTALL_DIR)
return 1
- command = SECURITY_PROVIDER_KEY_CMD.format(jdk_path,
- get_ambari_classpath(), get_conf_dir(), master_key, key_location, persist)
+ command = SECURITY_PROVIDER_KEY_CMD.format(get_java_exe_path(),
+ get_full_ambari_classpath(), master_key, key_location, persist)
(retcode, stdout, stderr) = run_os_command(command)
print_info_msg("Return code from credential provider save KEY: " +
str(retcode))
@@ -666,8 +528,7 @@ def save_master_key(master_key, key_location, persist=True):
def store_password_file(password, filename):
conf_file = find_properties_file()
- passFilePath = os.path.join(os.path.dirname(conf_file),
- filename)
+ passFilePath = get_pass_file_path(conf_file, filename)
with open(passFilePath, 'w+') as passFile:
passFile.write(password)
@@ -694,10 +555,25 @@ def remove_password_file(filename):
def adjust_directory_permissions(ambari_user):
properties = get_ambari_properties()
- bootstrap_dir = get_value_from_properties(properties, BOOTSTRAP_DIR_PROPERTY)
+
+ bootstrap_dir = os.path.abspath(get_value_from_properties(properties, BOOTSTRAP_DIR_PROPERTY))
print_info_msg("Cleaning bootstrap directory ({0}) contents...".format(bootstrap_dir))
+
shutil.rmtree(bootstrap_dir, True) #Ignore the non-existent dir error
- os.makedirs(bootstrap_dir)
+ #Protect against directories lingering around
+ del_attempts = 0
+ while os.path.exists(bootstrap_dir) and del_attempts < 100:
+ time.sleep(50)
+ del_attempts += 1
+ if not os.path.exists(bootstrap_dir):
+ try:
+ os.makedirs(bootstrap_dir)
+ except Exception, ex:
+ print_warning_msg("Failed recreating the bootstrap directory: {0}".format(str(ex)))
+ pass
+ else:
+ print_warning_msg("Bootstrap directory lingering around after 5s. Unable to complete the cleanup.")
+
# Add master key and credential store if exists
keyLocation = get_master_key_location(properties)
masterKeyFile = search_file(SECURITY_MASTER_KEY_FILENAME, keyLocation)
@@ -710,6 +586,7 @@ def adjust_directory_permissions(ambari_user):
if trust_store_location:
configDefaults.NR_ADJUST_OWNERSHIP_LIST.append((trust_store_location, configDefaults.TRUST_STORE_LOCATION_PERMISSIONS, "{0}", "{0}", False))
print "Adjusting ambari-server permissions and ownership..."
+
for pack in configDefaults.NR_ADJUST_OWNERSHIP_LIST:
file = pack[0]
mod = pack[1]
http://git-wip-us.apache.org/repos/asf/ambari/blob/49955a35/ambari-server/src/main/python/ambari_server/userInput.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/userInput.py b/ambari-server/src/main/python/ambari_server/userInput.py
index 3e8b2c7..c15d335 100644
--- a/ambari-server/src/main/python/ambari_server/userInput.py
+++ b/ambari-server/src/main/python/ambari_server/userInput.py
@@ -41,21 +41,28 @@ def get_choice_string_input(prompt, default, firstChoice, secondChoice):
if get_silent():
print(prompt)
return default
- choice = raw_input(prompt).lower()
- if choice in firstChoice:
- return True
- elif choice in secondChoice:
- return False
- elif choice is "": # Just enter pressed
- return default
- else:
- print "input not recognized, please try again: "
- return get_choice_string_input(prompt, default, firstChoice, secondChoice)
+
+ input = True
+ result = default
+ while input:
+ choice = raw_input(prompt).lower()
+ if choice in firstChoice:
+ result = True
+ input = False
+ elif choice in secondChoice:
+ result = False
+ input = False
+ elif choice is "": # Just enter pressed
+ result = default
+ input = False
+ else:
+ print "input not recognized, please try again: "
+
+ return result
def get_validated_string_input(prompt, default, pattern, description,
is_pass, allowEmpty=True, validatorFunction=None):
-
input = ""
while not input:
if get_silent():
http://git-wip-us.apache.org/repos/asf/ambari/blob/49955a35/ambari-server/src/main/resources/custom_actions/scripts/check_host.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/custom_actions/scripts/check_host.py b/ambari-server/src/main/resources/custom_actions/scripts/check_host.py
index c335806..ff2eabd 100644
--- a/ambari-server/src/main/resources/custom_actions/scripts/check_host.py
+++ b/ambari-server/src/main/resources/custom_actions/scripts/check_host.py
@@ -192,7 +192,7 @@ class CheckHost(Script):
install_cmd = format("mkdir -p {java_dir} ; cd {java_dir} ; tar -xf {jdk_download_target} > /dev/null 2>&1")
install_path = ["/bin","/usr/bin/"]
elif jdk_name.endswith(".exe"):
- install_cmd = "{} /s INSTALLDIR={} STATIC=1 WEB_JAVA=0 /L \\var\\log\\ambari-agent".format(
+ install_cmd = "{0} /s INSTALLDIR={1} STATIC=1 WEB_JAVA=0 /L \\var\\log\\ambari-agent".format(
os_utils.quote_path(jdk_download_target), os_utils.quote_path(java64_home),
)
install_path = [java_dir]
http://git-wip-us.apache.org/repos/asf/ambari/blob/49955a35/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/before-ANY/scripts/setup_jdk.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/before-ANY/scripts/setup_jdk.py b/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/before-ANY/scripts/setup_jdk.py
index d48bb52..8c33856 100644
--- a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/before-ANY/scripts/setup_jdk.py
+++ b/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/before-ANY/scripts/setup_jdk.py
@@ -24,7 +24,7 @@ from ambari_commons.inet_utils import download_file
from resource_management import *
-_install_cmd = '{} /s INSTALLDIR={} ADDLOCAL="ToolsFeature,SourceFeature"'
+_install_cmd = '{0} /s INSTALLDIR={1} ADDLOCAL="ToolsFeature,SourceFeature"'
def _check_installed():
@@ -42,7 +42,7 @@ def setup_jdk():
if not os.path.exists(params.java_home):
os.makedirs(params.java_home)
jdk_setup_savepath = os.path.join(params.java_home, params.jdk_name)
- jdk_download_url = "{}/{}".format(params.jdk_location, params.jdk_name)
+ jdk_download_url = "{0}/{1}".format(params.jdk_location, params.jdk_name)
download_file(jdk_download_url, jdk_setup_savepath)
Execute(_install_cmd.format(jdk_setup_savepath, params.java_home))
if not _check_installed():
http://git-wip-us.apache.org/repos/asf/ambari/blob/49955a35/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/YARN/package/scripts/mapred_service_check.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/YARN/package/scripts/mapred_service_check.py b/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/YARN/package/scripts/mapred_service_check.py
index f81408f..82bb0fc 100644
--- a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/YARN/package/scripts/mapred_service_check.py
+++ b/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/YARN/package/scripts/mapred_service_check.py
@@ -40,11 +40,11 @@ class MapReduce2ServiceCheck(Script):
validateStatusFileName = "validateYarnComponentStatus.py"
validateStatusFilePath = os.path.join(os.path.dirname(params.hadoop_home), "temp", validateStatusFileName)
python_executable = sys.executable
- validateStatusCmd = "{} {} {} -p {} -s {}".format(
+ validateStatusCmd = "{0} {1} {2} -p {3} -s {4}".format(
python_executable, validateStatusFilePath, component_type, component_address, params.hadoop_ssl_enabled)
if params.security_enabled:
- kinit_cmd = "{} -kt {} {};".format(params.kinit_path_local, params.smoke_user_keytab, params.smokeuser)
+ kinit_cmd = "{0} -kt {1} {2};".format(params.kinit_path_local, params.smoke_user_keytab, params.smokeuser)
smoke_cmd = kinit_cmd + validateStatusCmd
else:
smoke_cmd = validateStatusCmd