From: Guillaume Abrioux Date: Wed, 6 Dec 2023 12:27:46 +0000 (+0000) Subject: node-proxy: address a typing issue in agent.NodeProxy.query() X-Git-Tag: testing/wip-pdonnell-testing-20240430.123648-reef-debug~291^2~20 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=4e8b112ea2b2b4e4fa1f617c59e059fde75c00eb;p=ceph-ci.git 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) --- 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