From: Redouane Kachach Date: Tue, 8 Oct 2024 11:46:47 +0000 (+0200) Subject: mgr/cephadm: adding md5_hash stable hash to the utils collection X-Git-Tag: v20.0.0~766^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d0db937cbb378cc2fb95c9080ee5b8e8281a603d;p=ceph.git mgr/cephadm: adding md5_hash stable hash to the utils collection Signed-off-by: Redouane Kachach --- diff --git a/src/pybind/mgr/cephadm/utils.py b/src/pybind/mgr/cephadm/utils.py index 3673fbf621cb..edd775aa178f 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()