]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: adding md5_hash stable hash to the utils collection
authorRedouane Kachach <rkachach@ibm.com>
Tue, 8 Oct 2024 11:46:47 +0000 (13:46 +0200)
committerRedouane Kachach <rkachach@ibm.com>
Thu, 17 Oct 2024 08:41:49 +0000 (10:41 +0200)
Signed-off-by: Redouane Kachach <rkachach@ibm.com>
src/pybind/mgr/cephadm/utils.py

index 3673fbf621cb9e70324fde3ea02a62064ccec20e..edd775aa178f96690bc6e1bc4a1522f4a084161a 100644 (file)
@@ -5,6 +5,7 @@ from enum import Enum
 from functools import wraps
 from typing import Optional, Callable, TypeVar, List, NewType, TYPE_CHECKING, Any, NamedTuple
 from orchestrator import OrchestratorError
+import hashlib
 
 if TYPE_CHECKING:
     from cephadm import CephadmOrchestrator
@@ -154,3 +155,9 @@ def file_mode_to_str(mode: int) -> str:
             f'{"x" if (mode >> shift) & 1 else "-"}'
         ) + r
     return r
+
+
+def md5_hash(input_value: str) -> str:
+    input_str = str(input_value).encode('utf-8')
+    hash_object = hashlib.md5(input_str)
+    return hash_object.hexdigest()