On Mon, Sep 28, 2015 at 12:37:10PM +0200, 'Klaus Aehlig' via ganeti-devel wrote:
The function extracts the hmac key from the provided
initial data; it also raises an appropriate error if
the key is not provided.

Signed-off-by: Klaus Aehlig <[email protected]>
---
lib/tools/common.py | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/lib/tools/common.py b/lib/tools/common.py
index a9149f6..83abc1b 100644
--- a/lib/tools/common.py
+++ b/lib/tools/common.py
@@ -182,6 +182,19 @@ def VerifyClusterName(data, error_fn, 
cluster_name_constant,
  return name


+def VerifyHmac(data, error_fn):
+  """Verifies the presence of the hmac secret.
+
+  @type data: dict
+
+  """
+  hmac = data.get(constants.NDS_HMAC)
+  if not hmac:
+    raise error_fn("Hmac key must be provided")
+
+  return hmac
+
+
def LoadData(raw, data_check):
  """Parses and verifies input data.

--
2.6.0.rc2.230.g3dd15c0


LGTM

Reply via email to