Skip to content

Commit 21d6e1d

Browse files
pecastrophlogistonjohn
authored andcommitted
pybind/mgr: Appropriately rename function.
Signed-off-by: Paulo E. Castro <pecastro@wormholenet.com>
1 parent e364df3 commit 21d6e1d

5 files changed

Lines changed: 14 additions & 14 deletions

File tree

src/pybind/mgr/cephadm/cert_mgr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import logging
33

44
from cephadm.ssl_cert_utils import SSLCerts, SSLConfigException
5-
from mgr_util import verify_tls, verify_cacrt_content, ServerConfigException
5+
from mgr_util import verify_tls, certificate_days_to_expire, ServerConfigException
66
from cephadm.ssl_cert_utils import get_certificate_info, get_private_key_info
77
from cephadm.tlsobject_types import Cert, PrivKey
88
from cephadm.tlsobject_store import TLSObjectStore, TLSObjectScope, TLSObjectException
@@ -350,7 +350,7 @@ def _check_certificate_state(self, cert_name: str, target: Optional[str], cert:
350350
Returns: CertInfo
351351
"""
352352
try:
353-
days_to_expiration = verify_tls(cert.cert, key.key) if key else verify_cacrt_content(cert.cert)
353+
days_to_expiration = verify_tls(cert.cert, key.key) if key else certificate_days_to_expire(cert.cert)
354354
is_close_to_expiration = days_to_expiration < self.mgr.certificate_renewal_threshold_days
355355
return CertInfo(cert_name, target, cert.user_made, True, is_close_to_expiration, days_to_expiration, "")
356356
except ServerConfigException as e:

src/pybind/mgr/mgr_util.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -643,10 +643,10 @@ def create_self_signed_cert(organisation: str = 'Ceph',
643643
return cert, pkey
644644

645645

646-
def verify_cacrt_content(crt: str) -> int:
646+
def certificate_days_to_expire(crt: str) -> int:
647647
try:
648648
cc = ceph.cryptotools.remote.CryptoCaller()
649-
return cc.verify_cacrt_content(crt)
649+
return cc.certificate_days_to_expire(crt)
650650
except ValueError as err:
651651
raise ServerConfigException(f'Invalid certificate: {err}')
652652

@@ -662,7 +662,7 @@ def verify_cacrt(cert_fname):
662662

663663
try:
664664
with open(cert_fname) as f:
665-
verify_cacrt_content(f.read())
665+
certificate_days_to_expire(f.read())
666666
except ValueError as e:
667667
raise ServerConfigException(
668668
'Invalid certificate {}: {}'.format(cert_fname, str(e)))
@@ -681,7 +681,7 @@ def verify_tls(crt, key):
681681
# type: (str, str) -> int
682682
cc = ceph.cryptotools.remote.CryptoCaller()
683683
try:
684-
days_to_expiration = cc.verify_cacrt_content(crt)
684+
days_to_expiration = cc.certificate_days_to_expire(crt)
685685
cc.verify_tls(crt, key)
686686
except ValueError as err:
687687
raise ServerConfigException(str(err))

src/pybind/mgr/tests/test_tls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from mgr_util import create_self_signed_cert, verify_tls, ServerConfigException, get_cert_issuer_info, verify_cacrt_content
1+
from mgr_util import create_self_signed_cert, verify_tls, ServerConfigException, get_cert_issuer_info, certificate_days_to_expire
22
from OpenSSL import crypto, SSL
33

44
import unittest
@@ -59,4 +59,4 @@ def test_get_cert_issuer_info(self):
5959
# expired certificate
6060
self.assertRaisesRegex(ServerConfigException,
6161
'Certificate issued by "Ceph/cephadm" expired',
62-
verify_cacrt_content, expired_cert)
62+
certificate_days_to_expire, expired_cert)

src/python-common/ceph/cryptotools/cryptotools.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def _get_cert_issuer_info(crt: str) -> Tuple[Optional[str], Optional[str]]:
8888
return (org_name, cn)
8989

9090

91-
def verify_cacrt_content(args: Namespace) -> None:
91+
def certificate_days_to_expire(args: Namespace) -> None:
9292
crt = sys.stdin.read()
9393

9494
crt_buffer = crt.encode() if isinstance(crt, str) else crt
@@ -180,9 +180,9 @@ def verify_tls(args: Namespace) -> None:
180180
parser_bar.add_argument('--certificate', required=False, action='store_true')
181181
parser_bar.set_defaults(func=create_self_signed_cert)
182182

183-
# create the parser for the "verify_cacrt_content" command
184-
parser_bar = subparsers.add_parser('verify_cacrt_content')
185-
parser_bar.set_defaults(func=verify_cacrt_content)
183+
# create the parser for the "certificate_days_to_expire" command
184+
parser_bar = subparsers.add_parser('certificate_days_to_expire')
185+
parser_bar.set_defaults(func=certificate_days_to_expire)
186186

187187
# create the parser for the "get_cert_issuer_info" command
188188
parser_bar = subparsers.add_parser('get_cert_issuer_info')

src/python-common/ceph/cryptotools/remote.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ def verify_tls(self, crt: str, key: str) -> None:
129129
)
130130
self._result_json(result) # for errors only
131131

132-
def verify_cacrt_content(self, crt: str) -> int:
132+
def certificate_days_to_expire(self, crt: str) -> int:
133133
"""Verify a CA Certificate return the number of days until expiration."""
134134
result = self._run(
135-
["verify_cacrt_content"],
135+
["certificate_days_to_expire"],
136136
input_data=crt,
137137
capture_output=True,
138138
check=True,

0 commit comments

Comments
 (0)