ssh_update: log data that is received
authorHelga Velroyen <helgav@google.com>
Tue, 15 Dec 2015 14:03:53 +0000 (15:03 +0100)
committerHelga Velroyen <helgav@google.com>
Fri, 8 Jan 2016 13:47:20 +0000 (14:47 +0100)
Debugging ssh_update can be annoying, because the data
used as input is not dumped anywhere. This patch logs
makes sure it gets logged (at DEBUG level) when
ssh_update receives the data.

Signed-off-by: Helga Velroyen <helgav@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Cherry-picked-from: 5c370ec180
Signed-off-by: Helga Velroyen <helgav@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

lib/tools/common.py

index a9149f6..3297025 100644 (file)
@@ -188,7 +188,14 @@ def LoadData(raw, data_check):
   @rtype: dict
 
   """
-  return serializer.LoadAndVerifyJson(raw, data_check)
+  result = None
+  try:
+    result = serializer.LoadAndVerifyJson(raw, data_check)
+    logging.debug("Received data: %s", serializer.DumpJson(result))
+  except Exception as e:
+    logging.warn("Received data is not valid json: %s.", str(raw))
+    raise e
+  return result
 
 
 def GenerateRootSshKeys(error_fn, _suffix="", _homedir_fn=None):