summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRedouane Kachach <rkachach@ibm.com>2024-10-08 13:46:47 +0200
committerRedouane Kachach <rkachach@ibm.com>2024-10-17 10:41:49 +0200
commitd0db937cbb378cc2fb95c9080ee5b8e8281a603d (patch)
treea36d09216d584b41e491bc04662b06c7a809f740
parentMerge pull request #55808 from neesingh-rh/wip-63700 (diff)
downloadceph-d0db937cbb378cc2fb95c9080ee5b8e8281a603d.tar.xz
ceph-d0db937cbb378cc2fb95c9080ee5b8e8281a603d.zip
mgr/cephadm: adding md5_hash stable hash to the utils collection
Signed-off-by: Redouane Kachach <rkachach@ibm.com>
-rw-r--r--src/pybind/mgr/cephadm/utils.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/pybind/mgr/cephadm/utils.py b/src/pybind/mgr/cephadm/utils.py
index 3673fbf621c..edd775aa178 100644
--- a/src/pybind/mgr/cephadm/utils.py
+++ b/src/pybind/mgr/cephadm/utils.py
@@ -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()