Skip to content

Commit d0db937

Browse files
committed
mgr/cephadm: adding md5_hash stable hash to the utils collection
Signed-off-by: Redouane Kachach <[email protected]>
1 parent 20af41d commit d0db937

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/pybind/mgr/cephadm/utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from functools import wraps
66
from typing import Optional, Callable, TypeVar, List, NewType, TYPE_CHECKING, Any, NamedTuple
77
from orchestrator import OrchestratorError
8+
import hashlib
89

910
if TYPE_CHECKING:
1011
from cephadm import CephadmOrchestrator
@@ -154,3 +155,9 @@ def file_mode_to_str(mode: int) -> str:
154155
f'{"x" if (mode >> shift) & 1 else "-"}'
155156
) + r
156157
return r
158+
159+
160+
def md5_hash(input_value: str) -> str:
161+
input_str = str(input_value).encode('utf-8')
162+
hash_object = hashlib.md5(input_str)
163+
return hash_object.hexdigest()

0 commit comments

Comments
 (0)