From: Guillaume Abrioux Date: Tue, 28 Nov 2023 08:05:47 +0000 (+0000) Subject: node-proxy: change 'idrac' terminology X-Git-Tag: v18.2.4~314^2~28 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=e52055aac0700e59d3445f23e72e6c2222bfb3a2;p=ceph.git node-proxy: change 'idrac' terminology The 'idrac' terminology is too specific, let's change this to something more generic. Signed-off-by: Guillaume Abrioux (cherry picked from commit a69b267cb9c425facf6fe68daa08993cf81d0816) --- diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index 513948bdd37a6..d69f15a2bcb20 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -40,7 +40,7 @@ from threading import Thread, Event from urllib.error import HTTPError, URLError from urllib.request import urlopen, Request from pathlib import Path -from cephadmlib.node_proxy.main import NodeProxy, NodeProxyInitialization, NodeProxyFetchIdracError +from cephadmlib.node_proxy.main import NodeProxy, NodeProxyInitialization, NodeProxyFetchOobError FuncT = TypeVar('FuncT', bound=Callable) @@ -4939,8 +4939,8 @@ WantedBy=ceph-{fsid}.target logger.error(f'node-proxy not running: {e.__class__.__name__}: {e}') try: self.init_node_proxy(ssl_ctx) - except NodeProxyFetchIdracError: - logger.info("No iDrac details could be loaded. " + except NodeProxyFetchOobError: + logger.info("No oob details could be loaded. " "Aborting node-proxy initialization. " "Will retry in 120s.") time.sleep(120) @@ -4953,12 +4953,12 @@ WantedBy=ceph-{fsid}.target } } status, result = self.query_endpoint(data=json.dumps(node_proxy_meta).encode('ascii'), - endpoint='/node-proxy/idrac', + endpoint='/node-proxy/oob', ssl_ctx=ssl_ctx) if status != 200: - msg = f"Couldn't load iDrac details: {status}, {result}" + msg = f"Couldn't load oob details: {status}, {result}" logger.debug(msg) - raise NodeProxyFetchIdracError(msg) + raise NodeProxyFetchOobError(msg) result_json = json.loads(result) kwargs = { 'host': result_json['result']['addr'], diff --git a/src/cephadm/cephadmlib/node_proxy/main.py b/src/cephadm/cephadmlib/node_proxy/main.py index 106d3b447bcc1..66da0038ecc98 100644 --- a/src/cephadm/cephadmlib/node_proxy/main.py +++ b/src/cephadm/cephadmlib/node_proxy/main.py @@ -30,7 +30,7 @@ class NodeProxyInitialization(Exception): pass -class NodeProxyFetchIdracError(Exception): +class NodeProxyFetchOobError(Exception): pass diff --git a/src/cephadm/cephadmlib/node_proxy/redfish_client.py b/src/cephadm/cephadmlib/node_proxy/redfish_client.py index 4107fb57c8f09..dec35a2c57281 100644 --- a/src/cephadm/cephadmlib/node_proxy/redfish_client.py +++ b/src/cephadm/cephadmlib/node_proxy/redfish_client.py @@ -27,12 +27,12 @@ class RedFishClient(BaseClient): if not self.is_logged_in(): self.log.logger.info("Logging in to " f"{self.url} as '{self.username}'") - idrac_credentials = json.dumps({"UserName": self.username, - "Password": self.password}) + oob_credentials = json.dumps({"UserName": self.username, + "Password": self.password}) headers = {"Content-Type": "application/json"} try: - _headers, _data, _status_code = self.query(data=idrac_credentials, + _headers, _data, _status_code = self.query(data=oob_credentials, headers=headers, endpoint='/redfish/v1/SessionService/Sessions/') if _status_code != 201: diff --git a/src/pybind/mgr/cephadm/agent.py b/src/pybind/mgr/cephadm/agent.py index 316cc7c0da30b..d5563eee6c740 100644 --- a/src/pybind/mgr/cephadm/agent.py +++ b/src/pybind/mgr/cephadm/agent.py @@ -114,11 +114,11 @@ class NodeProxy: @cherrypy.tools.allow(methods=['POST']) @cherrypy.tools.json_in() @cherrypy.tools.json_out() - def idrac(self) -> Dict[str, Any]: + def oob(self) -> Dict[str, Any]: """ - Get the iDrac details for a given host. + Get the out-of-band management tool details for a given host. - :return: idrac details. + :return: oob details. :rtype: dict """ data: Dict[str, Any] = cherrypy.request.json @@ -127,7 +127,7 @@ class NodeProxy: self.validate_node_proxy_data(data) host = data["cephx"]["name"] - results['result'] = self.mgr.node_proxy.idrac.get(host) + results['result'] = self.mgr.node_proxy.oob.get(host) if not results['result']: raise cherrypy.HTTPError(400, 'The provided host has no iDrac details.') return results @@ -324,8 +324,8 @@ class NodeProxy: # TODO(guits): need to check the request is authorized # allowing a specific keyring only ? (client.admin or client.agent.. ?) data: str = json.dumps(cherrypy.request.json) - username = self.mgr.node_proxy.idrac[hostname]['username'] - password = self.mgr.node_proxy.idrac[hostname]['password'] + username = self.mgr.node_proxy.oob[hostname]['username'] + password = self.mgr.node_proxy.oob[hostname]['password'] auth = f"{username}:{password}".encode("utf-8") auth = base64.b64encode(auth).decode("utf-8") headers = {"Authorization": f"Basic {auth}"} diff --git a/src/pybind/mgr/cephadm/inventory.py b/src/pybind/mgr/cephadm/inventory.py index 23542420820d0..0446dc49f8d50 100644 --- a/src/pybind/mgr/cephadm/inventory.py +++ b/src/pybind/mgr/cephadm/inventory.py @@ -1410,11 +1410,11 @@ class NodeProxyCache: def __init__(self, mgr: "CephadmOrchestrator") -> None: self.mgr = mgr self.data: Dict[str, Any] = {} - self.idrac = {} + self.oob: Dict[str, Any] = {} def load(self) -> None: - _idrac = self.mgr.get_store('node_proxy/idrac', "{}") - self.idrac = json.loads(_idrac) + _oob = self.mgr.get_store('node_proxy/oob', "{}") + self.oob = json.loads(_oob) for k, v in self.mgr.get_store_prefix(NODE_PROXY_CACHE_PREFIX).items(): host = k.split('/')[-1:][0] @@ -1423,7 +1423,7 @@ class NodeProxyCache: # remove entry for host that no longer exists self.mgr.set_store(f"{NODE_PROXY_CACHE_PREFIX}/{host}", None) try: - self.idrac.pop(host) + self.oob.pop(host) self.data.pop(host) except KeyError: pass diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 0a8e06dfc2ea3..9add893f04b00 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1600,18 +1600,18 @@ Then run the following: if spec.hostname in self.inventory and self.inventory.get_addr(spec.hostname) != spec.addr: self.cache.refresh_all_host_info(spec.hostname) - if spec.idrac: - if not spec.idrac.get('addr'): - spec.idrac['addr'] = spec.hostname - if not spec.idrac.get('port'): - spec.idrac['port'] = '443' - data = json.loads(self.get_store('node_proxy/idrac', '{}')) + if spec.oob: + if not spec.oob.get('addr'): + spec.oob['addr'] = spec.hostname + if not spec.oob.get('port'): + spec.oob['port'] = '443' + data = json.loads(self.get_store('node_proxy/oob', '{}')) data[spec.hostname] = dict() - data[spec.hostname]['addr'] = spec.idrac['addr'] - data[spec.hostname]['port'] = spec.idrac['port'] - data[spec.hostname]['username'] = spec.idrac['username'] - data[spec.hostname]['password'] = spec.idrac['password'] - self.set_store('node_proxy/idrac', json.dumps(data)) + data[spec.hostname]['addr'] = spec.oob['addr'] + data[spec.hostname]['port'] = spec.oob['port'] + data[spec.hostname]['username'] = spec.oob['username'] + data[spec.hostname]['password'] = spec.oob['password'] + self.set_store('node_proxy/oob', json.dumps(data)) # prime crush map? if spec.location: diff --git a/src/pybind/mgr/cephadm/tests/node_proxy_data.py b/src/pybind/mgr/cephadm/tests/node_proxy_data.py index 1073bed274cd5..70afc8a76483e 100644 --- a/src/pybind/mgr/cephadm/tests/node_proxy_data.py +++ b/src/pybind/mgr/cephadm/tests/node_proxy_data.py @@ -89,16 +89,16 @@ mgr_inventory_cache = {"host01": {"hostname": "host01", "addr": "10.10.10.11", "labels": ["_admin"], "status": "", - "idrac": {"hostname": "10.10.10.11", - "username": "root", - "password": "ceph123"}}, + "oob": {"hostname": "10.10.10.11", + "username": "root", + "password": "ceph123"}}, "host02": {"hostname": "host02", "addr": "10.10.10.12", "labels": [], "status": "", - "idrac": {"hostname": "10.10.10.12", - "username": "root", - "password": "ceph123"}}} + "oob": {"hostname": "10.10.10.12", + "username": "root", + "password": "ceph123"}}} full_set = { "host01": { diff --git a/src/pybind/mgr/cephadm/tests/test_node_proxy.py b/src/pybind/mgr/cephadm/tests/test_node_proxy.py index 42ab39139ddab..fce7152bd86ba 100644 --- a/src/pybind/mgr/cephadm/tests/test_node_proxy.py +++ b/src/pybind/mgr/cephadm/tests/test_node_proxy.py @@ -38,10 +38,10 @@ class TestNodeProxy(helper.CPWebCase): app = NodeProxy(mgr) mgr.agent_cache.agent_keys = {"host01": "fake-secret01", "host02": "fake-secret02"} - mgr.node_proxy.idrac = {"host01": {"username": "idrac-user01", - "password": "idrac-pass01"}, - "host02": {"username": "idrac-user02", - "password": "idrac-pass02"}} + mgr.node_proxy.oob = {"host01": {"username": "oob-user01", + "password": "oob-pass01"}, + "host02": {"username": "oob-user02", + "password": "oob-pass02"}} mgr.node_proxy.data = node_proxy_data.full_set @classmethod @@ -56,39 +56,39 @@ class TestNodeProxy(helper.CPWebCase): self.PORT = PORT self.monkeypatch = MonkeyPatch() - def test_idrac_data_misses_cephx_field(self): + def test_oob_data_misses_cephx_field(self): data = '{}' - self.getPage("/idrac", method="POST", body=data, headers=[('Content-Type', 'application/json'), + self.getPage("/oob", method="POST", body=data, headers=[('Content-Type', 'application/json'), ('Content-Length', str(len(data)))]) self.assertStatus('400 Bad Request') - def test_idrac_data_misses_name_field(self): + def test_oob_data_misses_name_field(self): data = '{"cephx": {"secret": "fake-secret"}}' - self.getPage("/idrac", method="POST", body=data, headers=[('Content-Type', 'application/json'), + self.getPage("/oob", method="POST", body=data, headers=[('Content-Type', 'application/json'), ('Content-Length', str(len(data)))]) self.assertStatus('400 Bad Request') - def test_idrac_data_misses_secret_field(self): + def test_oob_data_misses_secret_field(self): data = '{"cephx": {"name": "host01"}}' - self.getPage("/idrac", method="POST", body=data, headers=[('Content-Type', 'application/json'), + self.getPage("/oob", method="POST", body=data, headers=[('Content-Type', 'application/json'), ('Content-Length', str(len(data)))]) self.assertStatus('400 Bad Request') - def test_idrac_agent_not_running(self): + def test_oob_agent_not_running(self): data = '{"cephx": {"name": "host03", "secret": "fake-secret03"}}' - self.getPage("/idrac", method="POST", body=data, headers=[('Content-Type', 'application/json'), + self.getPage("/oob", method="POST", body=data, headers=[('Content-Type', 'application/json'), ('Content-Length', str(len(data)))]) self.assertStatus('502 Bad Gateway') - def test_idrac_wrong_keyring(self): + def test_oob_wrong_keyring(self): data = '{"cephx": {"name": "host01", "secret": "wrong-keyring"}}' - self.getPage("/idrac", method="POST", body=data, headers=[('Content-Type', 'application/json'), + self.getPage("/oob", method="POST", body=data, headers=[('Content-Type', 'application/json'), ('Content-Length', str(len(data)))]) self.assertStatus('403 Forbidden') - def test_idrac_ok(self): + def test_oob_ok(self): data = '{"cephx": {"name": "host01", "secret": "fake-secret01"}}' - self.getPage("/idrac", method="POST", body=data, headers=[('Content-Type', 'application/json'), + self.getPage("/oob", method="POST", body=data, headers=[('Content-Type', 'application/json'), ('Content-Length', str(len(data)))]) self.assertStatus('200 OK') diff --git a/src/python-common/ceph/deployment/hostspec.py b/src/python-common/ceph/deployment/hostspec.py index 8fc9fdc508d89..f17ba81cf09be 100644 --- a/src/python-common/ceph/deployment/hostspec.py +++ b/src/python-common/ceph/deployment/hostspec.py @@ -16,11 +16,11 @@ def assert_valid_host(name: str) -> None: raise SpecValidationError(str(e) + f'. Got "{name}"') -def assert_valid_idrac(idrac: Dict[str, str]) -> None: +def assert_valid_oob(oob: Dict[str, str]) -> None: fields = ['username', 'password'] try: for field in fields: - assert field in idrac.keys() + assert field in oob.keys() except AssertionError as e: raise SpecValidationError(str(e)) @@ -47,7 +47,7 @@ class HostSpec(object): labels: Optional[List[str]] = None, status: Optional[str] = None, location: Optional[Dict[str, str]] = None, - idrac: Optional[Dict[str, str]] = None, + oob: Optional[Dict[str, str]] = None, ): self.service_type = 'host' @@ -65,13 +65,13 @@ class HostSpec(object): self.location = location - #: idrac details, if provided - self.idrac = idrac + #: oob details, if provided + self.oob = oob def validate(self) -> None: assert_valid_host(self.hostname) - if self.idrac: - assert_valid_idrac(self.idrac) + if self.oob: + assert_valid_oob(self.oob) def to_json(self) -> Dict[str, Any]: r: Dict[str, Any] = { @@ -82,8 +82,8 @@ class HostSpec(object): } if self.location: r['location'] = self.location - if self.idrac: - r['idrac'] = self.idrac + if self.oob: + r['oob'] = self.oob return r @classmethod @@ -96,7 +96,7 @@ class HostSpec(object): host_spec['labels'])) if 'labels' in host_spec else None, host_spec['status'] if 'status' in host_spec else None, host_spec.get('location'), - host_spec['idrac'] if 'idrac' in host_spec else None, + host_spec['oob'] if 'oob' in host_spec else None, ) return _cls