|
@@ -39,6 +39,7 @@ OOZIE_URL_KEY = '{{oozie-site/oozie.base.url}}'
|
|
SECURITY_ENABLED = '{{cluster-env/security_enabled}}'
|
|
SECURITY_ENABLED = '{{cluster-env/security_enabled}}'
|
|
OOZIE_PRINCIPAL = '{{oozie-site/oozie.authentication.kerberos.principal}}'
|
|
OOZIE_PRINCIPAL = '{{oozie-site/oozie.authentication.kerberos.principal}}'
|
|
OOZIE_KEYTAB = '{{oozie-site/oozie.authentication.kerberos.keytab}}'
|
|
OOZIE_KEYTAB = '{{oozie-site/oozie.authentication.kerberos.keytab}}'
|
|
|
|
+OOZIE_USER = '{{oozie-env/oozie_user}}'
|
|
OOZIE_CONF_DIR = '/usr/hdp/current/oozie-server/conf'
|
|
OOZIE_CONF_DIR = '/usr/hdp/current/oozie-server/conf'
|
|
OOZIE_CONF_DIR_LEGACY = '/etc/oozie/conf'
|
|
OOZIE_CONF_DIR_LEGACY = '/etc/oozie/conf'
|
|
|
|
|
|
@@ -58,7 +59,7 @@ def get_tokens():
|
|
Returns a tuple of tokens in the format {{site/property}} that will be used
|
|
Returns a tuple of tokens in the format {{site/property}} that will be used
|
|
to build the dictionary passed into execute
|
|
to build the dictionary passed into execute
|
|
"""
|
|
"""
|
|
- return (OOZIE_URL_KEY, OOZIE_PRINCIPAL, SECURITY_ENABLED, OOZIE_KEYTAB, KERBEROS_EXECUTABLE_SEARCH_PATHS_KEY)
|
|
|
|
|
|
+ return (OOZIE_URL_KEY, OOZIE_PRINCIPAL, SECURITY_ENABLED, OOZIE_KEYTAB, KERBEROS_EXECUTABLE_SEARCH_PATHS_KEY, OOZIE_USER)
|
|
|
|
|
|
@OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
|
|
@OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
|
|
def get_check_command(oozie_url, host_name, configurations):
|
|
def get_check_command(oozie_url, host_name, configurations):
|
|
@@ -67,10 +68,15 @@ def get_check_command(oozie_url, host_name, configurations):
|
|
oozie_home = os.environ['OOZIE_HOME']
|
|
oozie_home = os.environ['OOZIE_HOME']
|
|
oozie_cmd = os.path.join(oozie_home, 'bin', 'oozie.cmd')
|
|
oozie_cmd = os.path.join(oozie_home, 'bin', 'oozie.cmd')
|
|
command = format("cmd /c {oozie_cmd} admin -oozie {oozie_url} -status")
|
|
command = format("cmd /c {oozie_cmd} admin -oozie {oozie_url} -status")
|
|
- return (command, None)
|
|
|
|
|
|
+ return (command, None, None)
|
|
|
|
|
|
@OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
|
|
@OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
|
|
def get_check_command(oozie_url, host_name, configurations):
|
|
def get_check_command(oozie_url, host_name, configurations):
|
|
|
|
+ if OOZIE_USER in configurations:
|
|
|
|
+ oozie_user = configurations[OOZIE_USER]
|
|
|
|
+ else:
|
|
|
|
+ raise Exception("Oozie user is required")
|
|
|
|
+
|
|
security_enabled = False
|
|
security_enabled = False
|
|
if SECURITY_ENABLED in configurations:
|
|
if SECURITY_ENABLED in configurations:
|
|
security_enabled = str(configurations[SECURITY_ENABLED]).upper() == 'TRUE'
|
|
security_enabled = str(configurations[SECURITY_ENABLED]).upper() == 'TRUE'
|
|
@@ -103,13 +109,16 @@ def get_check_command(oozie_url, host_name, configurations):
|
|
# 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, _ = call(klist_command, user=oozie_user)
|
|
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 -kt {oozie_keytab} {oozie_principal}; ")
|
|
kinit_command = format("{kinit_path_local} -l 5m -kt {oozie_keytab} {oozie_principal}; ")
|
|
|
|
|
|
# kinit
|
|
# kinit
|
|
- Execute(kinit_command, environment=kerberos_env)
|
|
|
|
|
|
+ Execute(kinit_command,
|
|
|
|
+ environment=kerberos_env,
|
|
|
|
+ user=oozie_user,
|
|
|
|
+ )
|
|
|
|
|
|
# oozie configuration directory uses a symlink when > HDP 2.2
|
|
# oozie configuration directory uses a symlink when > HDP 2.2
|
|
oozie_config_directory = OOZIE_CONF_DIR_LEGACY
|
|
oozie_config_directory = OOZIE_CONF_DIR_LEGACY
|
|
@@ -119,7 +128,7 @@ def get_check_command(oozie_url, host_name, configurations):
|
|
command = "source {0}/oozie-env.sh ; oozie admin -oozie {1} -status".format(
|
|
command = "source {0}/oozie-env.sh ; oozie admin -oozie {1} -status".format(
|
|
oozie_config_directory, oozie_url)
|
|
oozie_config_directory, oozie_url)
|
|
|
|
|
|
- return (command, kerberos_env)
|
|
|
|
|
|
+ return (command, kerberos_env, oozie_user)
|
|
|
|
|
|
def execute(configurations={}, parameters={}, host_name=None):
|
|
def execute(configurations={}, parameters={}, host_name=None):
|
|
"""
|
|
"""
|
|
@@ -145,9 +154,12 @@ def execute(configurations={}, parameters={}, host_name=None):
|
|
oozie_url = oozie_url.replace(urlparse(oozie_url).hostname,localhost_address)
|
|
oozie_url = oozie_url.replace(urlparse(oozie_url).hostname,localhost_address)
|
|
|
|
|
|
try:
|
|
try:
|
|
- command, env = get_check_command(oozie_url, host_name, configurations)
|
|
|
|
|
|
+ command, env, oozie_user = get_check_command(oozie_url, host_name, configurations)
|
|
# execute the command
|
|
# execute the command
|
|
- Execute(command, environment=env)
|
|
|
|
|
|
+ Execute(command,
|
|
|
|
+ environment=env,
|
|
|
|
+ user=oozie_user,
|
|
|
|
+ )
|
|
|
|
|
|
return (RESULT_CODE_OK, ["Successful connection to {0}".format(oozie_url)])
|
|
return (RESULT_CODE_OK, ["Successful connection to {0}".format(oozie_url)])
|
|
except KerberosPropertiesNotFound, ex:
|
|
except KerberosPropertiesNotFound, ex:
|