From d0db937cbb378cc2fb95c9080ee5b8e8281a603d Mon Sep 17 00:00:00 2001 From: Redouane Kachach Date: Tue, 8 Oct 2024 13:46:47 +0200 Subject: [PATCH] mgr/cephadm: adding md5_hash stable hash to the utils collection Signed-off-by: Redouane Kachach --- src/pybind/mgr/cephadm/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pybind/mgr/cephadm/utils.py b/src/pybind/mgr/cephadm/utils.py index 3673fbf621cb9..edd775aa178f9 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() -- 2.39.5