summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGuillaume Abrioux <gabrioux@ibm.com>2024-01-17 09:47:36 +0100
committerGuillaume Abrioux <gabrioux@ibm.com>2024-01-25 16:07:21 +0100
commitf99decff89e594ecc7bd3b19d71cbc77559eaf07 (patch)
tree628cf42bf0279f8ed0088fcd9825a62da8c176ee /src
parentnode-proxy: enhance debug log messages for locking operations (diff)
downloadceph-f99decff89e594ecc7bd3b19d71cbc77559eaf07.tar.xz
ceph-f99decff89e594ecc7bd3b19d71cbc77559eaf07.zip
node-proxy: rename attribute and class
This renames the mgr's NodeProxyCache attribute from `self.node_proxy` to `self.node_proxy_cache` and the class `NodeProxy` in agent.py from `NodeProxy` to `NodeProxyEndpoint` to make it clearer and avoid confusion. Signed-off-by: Guillaume Abrioux <gabrioux@ibm.com>
Diffstat (limited to 'src')
-rw-r--r--src/pybind/mgr/cephadm/agent.py36
-rw-r--r--src/pybind/mgr/cephadm/module.py12
-rw-r--r--src/pybind/mgr/cephadm/serve.py2
-rw-r--r--src/pybind/mgr/cephadm/tests/test_node_proxy.py22
4 files changed, 36 insertions, 36 deletions
diff --git a/src/pybind/mgr/cephadm/agent.py b/src/pybind/mgr/cephadm/agent.py
index d2a155d5de0..b589886e566 100644
--- a/src/pybind/mgr/cephadm/agent.py
+++ b/src/pybind/mgr/cephadm/agent.py
@@ -56,7 +56,7 @@ class AgentEndpoint:
conf = {'/': {'tools.trailing_slash.on': False}}
cherrypy.tree.mount(self.host_data, '/data', config=conf)
- cherrypy.tree.mount(self.node_proxy, '/node-proxy', config=conf)
+ cherrypy.tree.mount(self.node_proxy_endpoint, '/node-proxy', config=conf)
def configure_tls(self, server: Server) -> None:
old_cert = self.mgr.get_store(self.KV_STORE_AGENT_ROOT_CERT)
@@ -87,12 +87,12 @@ class AgentEndpoint:
def configure(self) -> None:
self.host_data = HostData(self.mgr, self.server_port, self.server_addr)
self.configure_tls(self.host_data)
- self.node_proxy = NodeProxy(self.mgr)
+ self.node_proxy_endpoint = NodeProxyEndpoint(self.mgr)
self.configure_routes()
self.find_free_port()
-class NodeProxy:
+class NodeProxyEndpoint:
def __init__(self, mgr: "CephadmOrchestrator"):
self.mgr = mgr
self.ssl_root_crt = self.mgr.http_server.agent.ssl_certs.get_root_cert()
@@ -106,7 +106,7 @@ class NodeProxy:
self.redfish_token: str = ''
self.redfish_session_location: str = ''
- def _cp_dispatch(self, vpath: List[str]) -> "NodeProxy":
+ def _cp_dispatch(self, vpath: List[str]) -> "NodeProxyEndpoint":
if len(vpath) > 1: # /{hostname}/<endpoint>
hostname = vpath.pop(0) # /<endpoint>
cherrypy.request.params['hostname'] = hostname
@@ -139,7 +139,7 @@ class NodeProxy:
self.validate_node_proxy_data(data)
host = data["cephx"]["name"]
- results['result'] = self.mgr.node_proxy.oob.get(host)
+ results['result'] = self.mgr.node_proxy_cache.oob.get(host)
if not results['result']:
raise cherrypy.HTTPError(400, 'The provided host has no iDrac details.')
return results
@@ -261,7 +261,7 @@ class NodeProxy:
if 'patch' not in data.keys():
raise cherrypy.HTTPError(400, 'Malformed data received.')
host = data['cephx']['name']
- self.mgr.node_proxy.save(host, data['patch'])
+ self.mgr.node_proxy_cache.save(host, data['patch'])
self.raise_alert(data)
@cherrypy.expose
@@ -311,7 +311,7 @@ class NodeProxy:
self.mgr.log.debug(msg)
raise cherrypy.HTTPError(400, msg)
- if hostname not in self.mgr.node_proxy.data.keys():
+ if hostname not in self.mgr.node_proxy_cache.data.keys():
# TODO(guits): update unit test for this
msg = f"'{hostname}' not found."
self.mgr.log.debug(msg)
@@ -323,7 +323,7 @@ class NodeProxy:
data = json.dumps(cherrypy.request.json)
if led_type == 'drive':
- if id_drive not in self.mgr.node_proxy.data[hostname]['status']['storage'].keys():
+ if id_drive not in self.mgr.node_proxy_cache.data[hostname]['status']['storage'].keys():
# TODO(guits): update unit test for this
msg = f"'{id_drive}' not found."
self.mgr.log.debug(msg)
@@ -372,7 +372,7 @@ class NodeProxy:
:raises cherrypy.HTTPError 404: If the passed hostname is not found.
"""
try:
- results = self.mgr.node_proxy.fullreport(**kw)
+ results = self.mgr.node_proxy_cache.fullreport(**kw)
except KeyError:
raise cherrypy.HTTPError(404, f"{kw.get('hostname')} not found.")
return results
@@ -396,7 +396,7 @@ class NodeProxy:
:raises cherrypy.HTTPError 404: If the passed hostname is not found.
"""
try:
- results = self.mgr.node_proxy.criticals(**kw)
+ results = self.mgr.node_proxy_cache.criticals(**kw)
except KeyError:
raise cherrypy.HTTPError(404, f"{kw.get('hostname')} not found.")
return results
@@ -420,7 +420,7 @@ class NodeProxy:
:raises cherrypy.HTTPError 404: If the passed hostname is not found.
"""
try:
- results = self.mgr.node_proxy.summary(**kw)
+ results = self.mgr.node_proxy_cache.summary(**kw)
except KeyError:
raise cherrypy.HTTPError(404, f"{kw.get('hostname')} not found.")
return results
@@ -445,7 +445,7 @@ class NodeProxy:
:raises cherrypy.HTTPError 404: If the passed hostname is not found.
"""
try:
- results = self.mgr.node_proxy.common('memory', **kw)
+ results = self.mgr.node_proxy_cache.common('memory', **kw)
except KeyError:
raise cherrypy.HTTPError(404, f"{kw.get('hostname')} not found.")
return results
@@ -470,7 +470,7 @@ class NodeProxy:
:raises cherrypy.HTTPError 404: If the passed hostname is not found.
"""
try:
- results = self.mgr.node_proxy.common('network', **kw)
+ results = self.mgr.node_proxy_cache.common('network', **kw)
except KeyError:
raise cherrypy.HTTPError(404, f"{kw.get('hostname')} not found.")
return results
@@ -495,7 +495,7 @@ class NodeProxy:
:raises cherrypy.HTTPError 404: If the passed hostname is not found.
"""
try:
- results = self.mgr.node_proxy.common('processors', **kw)
+ results = self.mgr.node_proxy_cache.common('processors', **kw)
except KeyError:
raise cherrypy.HTTPError(404, f"{kw.get('hostname')} not found.")
return results
@@ -520,7 +520,7 @@ class NodeProxy:
:raises cherrypy.HTTPError 404: If the passed hostname is not found.
"""
try:
- results = self.mgr.node_proxy.common('storage', **kw)
+ results = self.mgr.node_proxy_cache.common('storage', **kw)
except KeyError:
raise cherrypy.HTTPError(404, f"{kw.get('hostname')} not found.")
return results
@@ -545,7 +545,7 @@ class NodeProxy:
:raises cherrypy.HTTPError 404: If the passed hostname is not found.
"""
try:
- results = self.mgr.node_proxy.common('power', **kw)
+ results = self.mgr.node_proxy_cache.common('power', **kw)
except KeyError:
raise cherrypy.HTTPError(404, f"{kw.get('hostname')} not found.")
return results
@@ -570,7 +570,7 @@ class NodeProxy:
:raises cherrypy.HTTPError 404: If the passed hostname is not found.
"""
try:
- results = self.mgr.node_proxy.common('fans', **kw)
+ results = self.mgr.node_proxy_cache.common('fans', **kw)
except KeyError:
raise cherrypy.HTTPError(404, f"{kw.get('hostname')} not found.")
return results
@@ -594,7 +594,7 @@ class NodeProxy:
:raises cherrypy.HTTPError 404: If the passed hostname is not found.
"""
try:
- results = self.mgr.node_proxy.firmwares(**kw)
+ results = self.mgr.node_proxy_cache.firmwares(**kw)
except KeyError:
raise cherrypy.HTTPError(404, f"{kw.get('hostname')} not found.")
return results
diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py
index 3029b7b6b5b..b82f861ce6a 100644
--- a/src/pybind/mgr/cephadm/module.py
+++ b/src/pybind/mgr/cephadm/module.py
@@ -600,8 +600,8 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule,
self.cache = HostCache(self)
self.cache.load()
- self.node_proxy = NodeProxyCache(self)
- self.node_proxy.load()
+ self.node_proxy_cache = NodeProxyCache(self)
+ self.node_proxy_cache.load()
self.agent_cache = AgentCache(self)
self.agent_cache.load()
@@ -1654,19 +1654,19 @@ Then run the following:
@handle_orch_error
def node_proxy_summary(self, hostname: Optional[str] = None) -> Dict[str, Any]:
- return self.node_proxy.summary(hostname=hostname)
+ return self.node_proxy_cache.summary(hostname=hostname)
@handle_orch_error
def node_proxy_firmwares(self, hostname: Optional[str] = None) -> Dict[str, Any]:
- return self.node_proxy.firmwares(hostname=hostname)
+ return self.node_proxy_cache.firmwares(hostname=hostname)
@handle_orch_error
def node_proxy_criticals(self, hostname: Optional[str] = None) -> Dict[str, Any]:
- return self.node_proxy.criticals(hostname=hostname)
+ return self.node_proxy_cache.criticals(hostname=hostname)
@handle_orch_error
def node_proxy_common(self, category: str, hostname: Optional[str] = None) -> Dict[str, Any]:
- return self.node_proxy.common(category, hostname=hostname)
+ return self.node_proxy_cache.common(category, hostname=hostname)
@handle_orch_error
def remove_host(self, host: str, force: bool = False, offline: bool = False, rm_crush_entry: bool = False) -> str:
diff --git a/src/pybind/mgr/cephadm/serve.py b/src/pybind/mgr/cephadm/serve.py
index ecd94ac084e..262ecbd27f6 100644
--- a/src/pybind/mgr/cephadm/serve.py
+++ b/src/pybind/mgr/cephadm/serve.py
@@ -117,7 +117,7 @@ class CephadmServe:
continue
# refresh node-proxy cache
- self.mgr.node_proxy.load()
+ self.mgr.node_proxy_cache.load()
except OrchestratorError as e:
if e.event_subject:
diff --git a/src/pybind/mgr/cephadm/tests/test_node_proxy.py b/src/pybind/mgr/cephadm/tests/test_node_proxy.py
index 3b05a4f39a5..b713d04cd59 100644
--- a/src/pybind/mgr/cephadm/tests/test_node_proxy.py
+++ b/src/pybind/mgr/cephadm/tests/test_node_proxy.py
@@ -2,7 +2,7 @@ import cherrypy
import json
from _pytest.monkeypatch import MonkeyPatch
from cherrypy.test import helper
-from cephadm.agent import NodeProxy
+from cephadm.agent import NodeProxyEndpoint
from unittest.mock import MagicMock, call, patch
from cephadm.inventory import AgentCache, NodeProxyCache, Inventory
from cephadm.ssl_cert_utils import SSLCerts
@@ -21,8 +21,8 @@ class FakeMgr:
self.inventory = Inventory(self)
self.agent_cache = AgentCache(self)
self.agent_cache.agent_ports = {"host01": 1234}
- self.node_proxy = NodeProxyCache(self)
- self.node_proxy.save = MagicMock()
+ self.node_proxy_cache = NodeProxyCache(self)
+ self.node_proxy_cache.save = MagicMock()
self.http_server = MagicMock()
self.http_server.agent = MagicMock()
self.http_server.agent.ssl_certs = SSLCerts()
@@ -32,9 +32,9 @@ class FakeMgr:
return '0.0.0.0'
-class TestNodeProxy(helper.CPWebCase):
+class TestNodeProxyEndpoint(helper.CPWebCase):
mgr = FakeMgr()
- app = NodeProxy(mgr)
+ app = NodeProxyEndpoint(mgr)
mgr.agent_cache.agent_keys = {"host01": "fake-secret01",
"host02": "fake-secret02"}
mgr.node_proxy.oob = {"host01": {"username": "oob-user01",
@@ -45,8 +45,8 @@ class TestNodeProxy(helper.CPWebCase):
@classmethod
def setup_server(cls):
- # cherrypy.tree.mount(NodeProxy(TestNodeProxy.mgr))
- cherrypy.tree.mount(TestNodeProxy.app)
+ # cherrypy.tree.mount(NodeProxyEndpoint(TestNodeProxyEndpoint.mgr))
+ cherrypy.tree.mount(TestNodeProxyEndpoint.app)
cherrypy.config.update({'global': {
'server.socket_host': '127.0.0.1',
'server.socket_port': PORT}})
@@ -115,7 +115,7 @@ class TestNodeProxy(helper.CPWebCase):
detail=['dimm.socket.a1 is critical: Enabled'],
summary='1 memory member is not ok')]
- assert TestNodeProxy.mgr.set_health_warning.mock_calls == calls
+ assert TestNodeProxyEndpoint.mgr.set_health_warning.mock_calls == calls
# @pytest.mark.parametrize("method", ["GET", "PATCH"])
# def test_led_no_hostname(self, method):
@@ -213,7 +213,7 @@ class TestNodeProxy(helper.CPWebCase):
self.assertStatus('200 OK')
# def test_led_endpoint_unreachable(self):
- # TestNodeProxy.app.query_endpoint = MagicMock(side_effect=URLError("fake-error"))
+ # TestNodeProxyEndpoint.app.query_endpoint = MagicMock(side_effect=URLError("fake-error"))
# self.getPage("/host02/led", method="GET")
# calls = [call(addr='10.10.10.12',
# data=None,
@@ -221,9 +221,9 @@ class TestNodeProxy(helper.CPWebCase):
# headers={},
# method='GET',
# port=8080,
- # ssl_ctx=TestNodeProxy.app.ssl_ctx)]
+ # ssl_ctx=TestNodeProxyEndpoint.app.ssl_ctx)]
# self.assertStatus('502 Bad Gateway')
- # assert TestNodeProxy.app.query_endpoint.mock_calls == calls
+ # assert TestNodeProxyEndpoint.app.query_endpoint.mock_calls == calls
def test_fullreport_with_valid_hostname(self):
self.getPage("/host02/fullreport", method="GET")