Skip to content

Commit

Permalink
Add session_cert and session_verify parameters to WebHDFS class (#1472)
Browse files Browse the repository at this point in the history
  • Loading branch information
markhatch committed Jan 4, 2024
1 parent 9c2a444 commit 0ca1762
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion fsspec/implementations/webhdfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def __init__(
kerb_kwargs=None,
data_proxy=None,
use_https=False,
session_cert=None,
session_verify=True,
**kwargs,
):
"""
Expand Down Expand Up @@ -90,12 +92,19 @@ def __init__(
``url->data_proxy(url)``.
use_https: bool
Whether to connect to the Name-node using HTTPS instead of HTTP
session_cert: str or Tuple[str, str] or None
Path to a certificate file, or tuple of (cert, key) files to use
for the requests.Session
session_verify: str, bool or None
Path to a certificate file to use for verifying the requests.Session.
kwargs
"""
if self._cached:
return
super().__init__(**kwargs)
self.url = f"{'https' if use_https else 'http'}://{host}:{port}/webhdfs/v1"
self.url = (
f"{'https' if use_https else 'http'}://{host}:{port}/webhdfs/v1" # noqa
)
self.kerb = kerberos
self.kerb_kwargs = kerb_kwargs or {}
self.pars = {}
Expand Down Expand Up @@ -128,6 +137,10 @@ def __init__(
"If using Kerberos auth, do not specify the "
"user, this is handled by kinit."
)

self.session_cert = session_cert
self.session_verify = session_verify

self._connect()

self._fsid = f"webhdfs_{tokenize(host, port)}"
Expand All @@ -138,6 +151,12 @@ def fsid(self):

def _connect(self):
self.session = requests.Session()

if self.session_cert:
self.session.cert = self.session_cert

self.session.verify = self.session_verify

if self.kerb:
from requests_kerberos import HTTPKerberosAuth

Expand Down

0 comments on commit 0ca1762

Please sign in to comment.