|
@@ -26,7 +26,7 @@ import urllib2
|
|
|
|
|
|
from resource_management.core.environment import Environment
|
|
from resource_management.core.environment import Environment
|
|
from resource_management.core.resources import Execute
|
|
from resource_management.core.resources import Execute
|
|
-from resource_management.core.shell import call
|
|
|
|
|
|
+from resource_management.core import shell
|
|
from resource_management.libraries.functions import format
|
|
from resource_management.libraries.functions import format
|
|
from resource_management.libraries.functions import get_kinit_path
|
|
from resource_management.libraries.functions import get_kinit_path
|
|
from resource_management.libraries.functions import get_klist_path
|
|
from resource_management.libraries.functions import get_klist_path
|
|
@@ -46,6 +46,7 @@ TEMPLETON_PORT_KEY = '{{webhcat-site/templeton.port}}'
|
|
SECURITY_ENABLED_KEY = '{{cluster-env/security_enabled}}'
|
|
SECURITY_ENABLED_KEY = '{{cluster-env/security_enabled}}'
|
|
WEBHCAT_PRINCIPAL_KEY = '{{webhcat-site/templeton.kerberos.principal}}'
|
|
WEBHCAT_PRINCIPAL_KEY = '{{webhcat-site/templeton.kerberos.principal}}'
|
|
WEBHCAT_KEYTAB_KEY = '{{webhcat-site/templeton.kerberos.keytab}}'
|
|
WEBHCAT_KEYTAB_KEY = '{{webhcat-site/templeton.kerberos.keytab}}'
|
|
|
|
+SMOKEUSER_KEY = '{{cluster-env/smokeuser}}'
|
|
|
|
|
|
# The configured Kerberos executable search paths, if any
|
|
# The configured Kerberos executable search paths, if any
|
|
KERBEROS_EXECUTABLE_SEARCH_PATHS_KEY = '{{kerberos-env/executable_search_paths}}'
|
|
KERBEROS_EXECUTABLE_SEARCH_PATHS_KEY = '{{kerberos-env/executable_search_paths}}'
|
|
@@ -58,7 +59,6 @@ CONNECTION_TIMEOUT_DEFAULT = 5.0
|
|
CURL_CONNECTION_TIMEOUT_DEFAULT = str(int(CONNECTION_TIMEOUT_DEFAULT))
|
|
CURL_CONNECTION_TIMEOUT_DEFAULT = str(int(CONNECTION_TIMEOUT_DEFAULT))
|
|
|
|
|
|
# default smoke user
|
|
# default smoke user
|
|
-SMOKEUSER_KEY = "{{cluster-env/smokeuser}}"
|
|
|
|
SMOKEUSER_SCRIPT_PARAM_KEY = 'default.smoke.user'
|
|
SMOKEUSER_SCRIPT_PARAM_KEY = 'default.smoke.user'
|
|
SMOKEUSER_DEFAULT = 'ambari-qa'
|
|
SMOKEUSER_DEFAULT = 'ambari-qa'
|
|
|
|
|
|
@@ -111,9 +111,6 @@ def execute(configurations={}, parameters={}, host_name=None):
|
|
if SMOKEUSER_KEY in configurations:
|
|
if SMOKEUSER_KEY in configurations:
|
|
smokeuser = configurations[SMOKEUSER_KEY]
|
|
smokeuser = configurations[SMOKEUSER_KEY]
|
|
|
|
|
|
- if SMOKEUSER_SCRIPT_PARAM_KEY in parameters:
|
|
|
|
- smokeuser = parameters[SMOKEUSER_SCRIPT_PARAM_KEY]
|
|
|
|
-
|
|
|
|
# webhcat always uses http, never SSL
|
|
# webhcat always uses http, never SSL
|
|
query_url = "http://{0}:{1}/templeton/v1/status?user.name={2}".format(host_name, webhcat_port, smokeuser)
|
|
query_url = "http://{0}:{1}/templeton/v1/status?user.name={2}".format(host_name, webhcat_port, smokeuser)
|
|
|
|
|
|
@@ -150,20 +147,20 @@ def execute(configurations={}, parameters={}, host_name=None):
|
|
# Determine if we need to kinit by testing to see if the relevant cache exists and has
|
|
# Determine if we need to kinit by testing to see if the relevant cache exists and has
|
|
# non-expired tickets. Tickets are marked to expire after 5 minutes to help reduce the number
|
|
# non-expired tickets. Tickets are marked to expire after 5 minutes to help reduce the number
|
|
# it kinits we do but recover quickly when keytabs are regenerated
|
|
# it kinits we do but recover quickly when keytabs are regenerated
|
|
- return_code, _ = call(klist_command)
|
|
|
|
|
|
+ return_code, _ = shell.call(klist_command, user=smokeuser)
|
|
if return_code != 0:
|
|
if return_code != 0:
|
|
kinit_path_local = get_kinit_path(kerberos_executable_search_paths)
|
|
kinit_path_local = get_kinit_path(kerberos_executable_search_paths)
|
|
kinit_command = format("{kinit_path_local} -l 5m -c {ccache_file} -kt {webhcat_keytab} {webhcat_principal}; ")
|
|
kinit_command = format("{kinit_path_local} -l 5m -c {ccache_file} -kt {webhcat_keytab} {webhcat_principal}; ")
|
|
|
|
|
|
# kinit so that curl will work with --negotiate
|
|
# kinit so that curl will work with --negotiate
|
|
- Execute(kinit_command)
|
|
|
|
|
|
+ Execute(kinit_command,
|
|
|
|
+ user=smokeuser,
|
|
|
|
+ )
|
|
|
|
|
|
# make a single curl call to get just the http code
|
|
# make a single curl call to get just the http code
|
|
- curl = subprocess.Popen(['curl', '--negotiate', '-u', ':', '-sL', '-w',
|
|
|
|
|
|
+ _, stdout, stderr = shell.checked_call(['curl', '--negotiate', '-u', ':', '-sL', '-w',
|
|
'%{http_code}', '--connect-timeout', curl_connection_timeout,
|
|
'%{http_code}', '--connect-timeout', curl_connection_timeout,
|
|
- '-o', '/dev/null', query_url], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=kerberos_env)
|
|
|
|
-
|
|
|
|
- stdout, stderr = curl.communicate()
|
|
|
|
|
|
+ '-o', '/dev/null', query_url], stderr=subprocess.PIPE, env=kerberos_env)
|
|
|
|
|
|
if stderr != '':
|
|
if stderr != '':
|
|
raise Exception(stderr)
|
|
raise Exception(stderr)
|
|
@@ -183,11 +180,10 @@ def execute(configurations={}, parameters={}, host_name=None):
|
|
|
|
|
|
# now that we have the http status and it was 200, get the content
|
|
# now that we have the http status and it was 200, get the content
|
|
start_time = time.time()
|
|
start_time = time.time()
|
|
- curl = subprocess.Popen(['curl', '--negotiate', '-u', ':', '-sL',
|
|
|
|
|
|
+ _, stdout, stderr = shell.checked_call(['curl', '--negotiate', '-u', ':', '-sL',
|
|
'--connect-timeout', curl_connection_timeout, query_url, ],
|
|
'--connect-timeout', curl_connection_timeout, query_url, ],
|
|
- stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=kerberos_env)
|
|
|
|
|
|
+ stderr=subprocess.PIPE, env=kerberos_env)
|
|
|
|
|
|
- stdout, stderr = curl.communicate()
|
|
|
|
total_time = time.time() - start_time
|
|
total_time = time.time() - start_time
|
|
|
|
|
|
if stderr != '':
|
|
if stderr != '':
|