diff --git a/ambari-common/src/main/python/resource_management/core/shell.py b/ambari-common/src/main/python/resource_management/core/shell.py index 045ce383cc1..e24df14e832 100644 --- a/ambari-common/src/main/python/resource_management/core/shell.py +++ b/ambari-common/src/main/python/resource_management/core/shell.py @@ -105,7 +105,7 @@ def checked_call(command, quiet=False, logoutput=None, stdout=subprocess.PIPE,st @log_function_call def call(command, quiet=False, logoutput=None, stdout=subprocess.PIPE,stderr=subprocess.STDOUT, cwd=None, env=None, preexec_fn=preexec_fn, user=None, wait_for_finish=True, timeout=None, on_timeout=None, - path=None, sudo=False, on_new_line=None, tries=1, try_sleep=0, timeout_kill_strategy=TerminateStrategy.TERMINATE_PARENT, returns=[0]): + path=None, sudo=False, on_new_line=None, tries=1, try_sleep=0, timeout_kill_strategy=TerminateStrategy.TERMINATE_PARENT, shell=True, returns=[0]): """ Execute the shell command despite failures. @return: return_code, output @@ -213,11 +213,8 @@ def _call(command, logoutput=None, throw_on_failure=True, stdout=subprocess.PIPE # replace placeholder from as_sudo / as_user if present env_str = _get_environment_str(env) for placeholder, replacement in PLACEHOLDERS_TO_STR.items(): - command = command.replace(placeholder, replacement.format(env_str=env_str)) subprocess_command = [cmd.replace(placeholder, replacement.format(env_str=env_str)) for cmd in subprocess_command] - # --noprofile is used to preserve PATH set for ambari-agent - subprocess_command = ["/bin/bash","--login","--noprofile","-c", command] if shell: # --noprofile is used to preserve PATH set for ambari-agent subprocess_command = ["/bin/bash","--login","--noprofile","-c"] + subprocess_command diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/WidgetResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/WidgetResourceProvider.java index 3b4b5c90695..f29b2c0c5c3 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/WidgetResourceProvider.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/WidgetResourceProvider.java @@ -56,10 +56,10 @@ import com.google.common.collect.ImmutableSet; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import com.google.gson.JsonSerializer; import com.google.gson.JsonElement; -import com.google.gson.JsonSerializationContext; import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; import com.google.inject.Inject; /** 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 3e0871727c4..1f5eac7acfd 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 @@ -454,7 +454,10 @@ def execute_db_connection_check(self, config, tmp_dir): db_connection_check_command = "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:{0}{1} {2}".format(agent_cache_dir, LIBS_PATH_IN_ARCHIVE_SQLA, db_connection_check_command) - code, out = shell.call(split(db_connection_check_command, comments=True), shell=False) + if isinstance(db_connection_check_command, str): + code, out = shell.call(split(db_connection_check_command, comments=True), shell=False) + else: + code, out = shell.call(db_connection_check_command, shell=False) if code == 0: db_connection_check_structured_output = {"exit_code" : 0, "message": "DB connection check completed successfully!" }