]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
pybind/mgr: Appropriately rename function.
authorJustin Caratzas <jcaratza@ibm.com>
Mon, 6 Oct 2025 23:25:43 +0000 (19:25 -0400)
committerJustin Caratzas <jcaratza@ibm.com>
Mon, 6 Oct 2025 23:25:43 +0000 (19:25 -0400)
Signed-off-by: Paulo E. Castro <pecastro@wormholenet.com>
(cherry picked from commit 21d6e1d493dc5652b2242ef2e0dc7e1c12714d20)

Resolves: rhbz#2401206

src/pybind/mgr/cephadm/cert_mgr.py
src/pybind/mgr/mgr_util.py
src/pybind/mgr/tests/test_tls.py
src/python-common/ceph/cryptotools/cryptotools.py
src/python-common/ceph/cryptotools/remote.py

index e5705e04b8466b80b44be27d0f869986c713fe14..6627017f31d00d435d04dfcc63e3b819b8a7b819 100644 (file)
@@ -4,7 +4,7 @@ from fnmatch import fnmatch
 from enum import Enum
 
 from cephadm.ssl_cert_utils import SSLCerts, SSLConfigException
-from mgr_util import verify_tls, verify_cacrt_content, ServerConfigException
+from mgr_util import verify_tls, certificate_days_to_expire, ServerConfigException
 from cephadm.ssl_cert_utils import get_certificate_info, get_private_key_info
 from cephadm.tlsobject_types import Cert, PrivKey, TLSObjectScope, TLSObjectException, CertKeyPair
 from cephadm.tlsobject_store import TLSObjectStore
@@ -568,7 +568,7 @@ class CertMgr:
         Returns: CertInfo
         """
         try:
-            days_to_expiration = verify_tls(cert.cert, key.key) if key else verify_cacrt_content(cert.cert)
+            days_to_expiration = verify_tls(cert.cert, key.key) if key else certificate_days_to_expire(cert.cert)
             is_close_to_expiration = days_to_expiration < self.mgr.certificate_renewal_threshold_days
             return CertInfo(cert_name, target, cert.user_made, True, is_close_to_expiration, days_to_expiration, "")
         except ServerConfigException as e:
index 802b040051d0eb522499e4b86857d6d52fef3844..93de1439798190c3e31148f40b642acaa78eac3f 100644 (file)
@@ -646,10 +646,10 @@ def create_self_signed_cert(organisation: str = 'Ceph',
     return cert, pkey
 
 
-def verify_cacrt_content(crt: str) -> int:
+def certificate_days_to_expire(crt: str) -> int:
     try:
         cc = ceph.cryptotools.remote.CryptoCaller()
-        return cc.verify_cacrt_content(crt)
+        return cc.certificate_days_to_expire(crt)
     except ValueError as err:
         raise ServerConfigException(f'Invalid certificate: {err}')
 
@@ -665,7 +665,7 @@ def verify_cacrt(cert_fname):
 
     try:
         with open(cert_fname) as f:
-            verify_cacrt_content(f.read())
+            certificate_days_to_expire(f.read())
     except ValueError as e:
         raise ServerConfigException(
             'Invalid certificate {}: {}'.format(cert_fname, str(e)))
@@ -684,7 +684,7 @@ def verify_tls(crt, key):
     # type: (str, str) -> int
     cc = ceph.cryptotools.remote.CryptoCaller()
     try:
-        days_to_expiration = cc.verify_cacrt_content(crt)
+        days_to_expiration = cc.certificate_days_to_expire(crt)
         cc.verify_tls(crt, key)
     except ValueError as err:
         raise ServerConfigException(str(err))
index 7cba929fe438f960114abe907185b1466d506903..840869514f1bf6e03a7fb5cd7273bb7c8e197801 100644 (file)
@@ -1,4 +1,4 @@
-from mgr_util import create_self_signed_cert, verify_tls, ServerConfigException, get_cert_issuer_info, verify_cacrt_content
+from mgr_util import create_self_signed_cert, verify_tls, ServerConfigException, get_cert_issuer_info, certificate_days_to_expire
 from OpenSSL import crypto, SSL
 
 import unittest
@@ -59,4 +59,4 @@ class TLSchecks(unittest.TestCase):
         # expired certificate
         self.assertRaisesRegex(ServerConfigException,
                                'Certificate issued by "Ceph/cephadm" expired',
-                               verify_cacrt_content, expired_cert)
+                               certificate_days_to_expire, expired_cert)
index 15284276ff881aac684d242d171939378562c8b2..9d2f6d6db04e43ec80b19517c8892dc5d1a7d818 100644 (file)
@@ -88,7 +88,7 @@ def _get_cert_issuer_info(crt: str) -> Tuple[Optional[str], Optional[str]]:
     return (org_name, cn)
 
 
-def verify_cacrt_content(args: Namespace) -> None:
+def certificate_days_to_expire(args: Namespace) -> None:
     crt = sys.stdin.read()
 
     crt_buffer = crt.encode() if isinstance(crt, str) else crt
@@ -180,9 +180,9 @@ if __name__ == "__main__":
     parser_bar.add_argument('--certificate', required=False, action='store_true')
     parser_bar.set_defaults(func=create_self_signed_cert)
 
-    # create the parser for the "verify_cacrt_content" command
-    parser_bar = subparsers.add_parser('verify_cacrt_content')
-    parser_bar.set_defaults(func=verify_cacrt_content)
+    # create the parser for the "certificate_days_to_expire" command
+    parser_bar = subparsers.add_parser('certificate_days_to_expire')
+    parser_bar.set_defaults(func=certificate_days_to_expire)
 
     # create the parser for the "get_cert_issuer_info" command
     parser_bar = subparsers.add_parser('get_cert_issuer_info')
index 04d015382a10509bff49e7290d5654884a57ff6e..6271288e4f8ce5c01df5ae1d27e75cebe83efe33 100644 (file)
@@ -129,10 +129,10 @@ class CryptoCaller:
         )
         self._result_json(result)  # for errors only
 
-    def verify_cacrt_content(self, crt: str) -> int:
+    def certificate_days_to_expire(self, crt: str) -> int:
         """Verify a CA Certificate return the number of days until expiration."""
         result = self._run(
-            ["verify_cacrt_content"],
+            ["certificate_days_to_expire"],
             input_data=crt,
             capture_output=True,
             check=True,