fix kerberos

This commit is contained in:
Yatsishin Ilya 2021-02-19 18:39:27 +03:00
parent 34fd15ca40
commit b5f59446b7

View File

@ -56,7 +56,7 @@ class HDFSApi(object):
if kerberized: if kerberized:
self._run_kinit() self._run_kinit()
self.kerberos_auth = reqkerb.HTTPKerberosAuth(mutual_authentication=reqkerb.DISABLED, hostname_override=self.host, principal=self.principal) self.kerberos_auth = reqkerb.HTTPKerberosAuth(mutual_authentication=reqkerb.DISABLED, hostname_override="kerberizedhdfs1", principal=self.principal)
#principal=self.principal, #principal=self.principal,
#hostname_override=self.host, principal=self.principal) #hostname_override=self.host, principal=self.principal)
# , mutual_authentication=reqkerb.REQUIRED, force_preemptive=True) # , mutual_authentication=reqkerb.REQUIRED, force_preemptive=True)
@ -106,6 +106,7 @@ class HDFSApi(object):
else: else:
location = response.headers['Location'].replace("hdfs1:50075", "{}:{}".format(self.host, self.data_port)) location = response.headers['Location'].replace("hdfs1:50075", "{}:{}".format(self.host, self.data_port))
logging.debug("redirected to {}".format(location)) logging.debug("redirected to {}".format(location))
response_data = requests.get(location, headers={'host': 'localhost'}, response_data = requests.get(location, headers={'host': 'localhost'},
verify=False, auth=self.kerberos_auth) verify=False, auth=self.kerberos_auth)
if response_data.status_code != 200: if response_data.status_code != 200:
@ -125,12 +126,6 @@ class HDFSApi(object):
named_file.write(content) named_file.write(content)
named_file.flush() named_file.flush()
if self.kerberized:
self._run_kinit()
self.kerberos_auth = reqkerb.HTTPKerberosAuth(mutual_authentication=reqkerb.DISABLED,
hostname_override="kerberizedhdfs1",
principal=self.principal)
response = requests.put( response = requests.put(
"{protocol}://{host}:{port}/webhdfs/v1{path}?op=CREATE".format(protocol=self.protocol, host='localhost', "{protocol}://{host}:{port}/webhdfs/v1{path}?op=CREATE".format(protocol=self.protocol, host='localhost',
port=self.proxy_port, port=self.proxy_port,