From 4e8b112ea2b2b4e4fa1f617c59e059fde75c00eb Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Wed, 6 Dec 2023 12:27:46 +0000 Subject: [PATCH] node-proxy: address a typing issue in agent.NodeProxy.query() The current logic supports str and bytes types for parameter `data`. This doesn't make sense, let's drop this logic. Signed-off-by: Guillaume Abrioux (cherry picked from commit 6cdb6f65b4ab84fcc5484ee7c6b940dd27b29587) --- src/pybind/mgr/cephadm/agent.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pybind/mgr/cephadm/agent.py b/src/pybind/mgr/cephadm/agent.py index b760fcfb93d..49f45bffef4 100644 --- a/src/pybind/mgr/cephadm/agent.py +++ b/src/pybind/mgr/cephadm/agent.py @@ -281,7 +281,7 @@ class NodeProxy: try: _status_code, _data, _headers = self.query(addr=addr, port=port, - data=oob_credentials, + data=bytes(oob_credentials, 'ascii'), headers=headers, endpoint="/redfish/v1/SessionService/Sessions/", method="POST") @@ -345,9 +345,9 @@ class NodeProxy: if not _headers.get('Content-Type'): # default to application/json if nothing provided _headers['Content-Type'] = 'application/json' - _data = bytes(data, 'ascii') if data else None + try: - req = Request(url, _data, _headers, method=method) + req = Request(url, data, _headers, method=method) with urlopen(req, context=ssl_ctx, timeout=timeout) as response: response_str = response.read() response_headers = response.headers -- 2.39.5