]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
pybind/mgr: Appropriately rename function.
authorPaulo E. Castro <pecastro@wormholenet.com>
Fri, 25 Apr 2025 22:52:39 +0000 (23:52 +0100)
committerJohn Mulligan <jmulligan@redhat.com>
Mon, 7 Jul 2025 13:32:24 +0000 (09:32 -0400)
Signed-off-by: Paulo E. Castro <pecastro@wormholenet.com>
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 aabc587db175f35d3ca98988af279db51e6db113..b0514b0695b91a05c465b8e7f9e829d0c9491304 100644 (file)
@@ -2,7 +2,7 @@ from typing import TYPE_CHECKING, Tuple, Union, List, Dict, Optional, cast, Any
 import logging
 
 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
 from cephadm.tlsobject_store import TLSObjectStore, TLSObjectScope, TLSObjectException
@@ -350,7 +350,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 f5c04f0189c542dd263a3ff2a15a8002cc2d93b7..b343f1a038475edf1e541a62a37521f2cd9cbebe 100644 (file)
@@ -643,10 +643,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}')
 
@@ -662,7 +662,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)))
@@ -681,7 +681,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,