]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
node-proxy: change 'idrac' terminology
authorGuillaume Abrioux <gabrioux@ibm.com>
Tue, 28 Nov 2023 08:05:47 +0000 (08:05 +0000)
committerGuillaume Abrioux <gabrioux@ibm.com>
Thu, 25 Jan 2024 15:16:05 +0000 (15:16 +0000)
The 'idrac' terminology is too specific, let's change this
to something more generic.

Signed-off-by: Guillaume Abrioux <gabrioux@ibm.com>
(cherry picked from commit a69b267cb9c425facf6fe68daa08993cf81d0816)

src/cephadm/cephadm.py
src/cephadm/cephadmlib/node_proxy/main.py
src/cephadm/cephadmlib/node_proxy/redfish_client.py
src/pybind/mgr/cephadm/agent.py
src/pybind/mgr/cephadm/inventory.py
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/tests/node_proxy_data.py
src/pybind/mgr/cephadm/tests/test_node_proxy.py
src/python-common/ceph/deployment/hostspec.py

index 513948bdd37a64483940ce5f6e7e12bc518ecc40..d69f15a2bcb2063e04cdcfe7153fbc4e1989a646 100755 (executable)
@@ -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'],
index 106d3b447bcc1b32410368ebd2e698fe5e05721c..66da0038ecc98d92638c142dc5a4982f7be1be97 100644 (file)
@@ -30,7 +30,7 @@ class NodeProxyInitialization(Exception):
     pass
 
 
-class NodeProxyFetchIdracError(Exception):
+class NodeProxyFetchOobError(Exception):
     pass
 
 
index 4107fb57c8f094f7434dc311ae8920408ab3dd2b..dec35a2c57281cf2ddeed90f4d7578c6de999276 100644 (file)
@@ -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:
index 316cc7c0da30b6dfd95454b2fd50c190265c28c3..d5563eee6c740a23d3e74fa325cfeb91e3c46962 100644 (file)
@@ -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}"}
index 23542420820d0d5083813540a036ebe5f8e2c3e2..0446dc49f8d5091ee9ba3d684ac633e79b2c54b9 100644 (file)
@@ -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
index 0a8e06dfc2ea3b128db4437a20c29d4627661ef6..9add893f04b00c0203406ea8e39d6f8aff83ca4e 100644 (file)
@@ -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:
index 1073bed274cd532f15449fa39998f5f0a9e9635b..70afc8a76483e98d3500471bdc69961e8d443fff 100644 (file)
@@ -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": {
index 42ab39139ddab0cea84a2179e68e29d85814c258..fce7152bd86ba479aaf1d83aa06b270096cff22d 100644 (file)
@@ -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')
 
index 8fc9fdc508d89f6caf5e78df01f3ee2c47601e40..f17ba81cf09bef885a308635c9261e447334b3f1 100644 (file)
@@ -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