Statistics
| Branch: | Tag: | Revision:

root / lib / serializer.py @ c31ec06b

History | View | Annotate | Download (4.5 kB)

# Date Author Comment
5d630c22 11/27/2012 12:54 pm Michael Hanselmann

Factorize code to load and verify JSON

A new tool to configure the node daemon will also have to load and
verify JSON data.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Guido Trotter <>

a182a3ed 12/21/2011 04:55 pm Michael Hanselmann

serializer: Remove JSON indentation and dict key sorting

Serializing to JSON using “simplejson” is significantly slower when
indentation and/or sorting of dictionary keys is used. In simplejson 1.x
the difference isn't that big, but with simplejson 2.x the difference...

b76fd1bc 09/26/2011 01:06 pm Michael Hanselmann

serializer: Add comment about simplejson vs. built-in json

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

cdeda3b6 09/26/2011 12:35 pm Michael Hanselmann

Revert "Fail if dictionary uses invalid keys" and "Support newer “json” module"

This reverts commit fd0351aef246f5d36e641209429e2ec093d325f8 and
9869e771704ada62bab001e729c52a36525ef081. The built-in module is a lot
slower in Python 2.6.

Signed-off-by: Michael Hanselmann <>...

fd0351ae 09/23/2011 05:39 pm Michael Hanselmann

serializer: Fail if dictionary uses invalid keys

JSON only supports a very restricted set of types for dictionary keys,
among them strings, booleans and “null”. Integers and floats are
converted to strings. Since this can cause a lot of confusion in Python,...

9869e771 09/23/2011 05:39 pm Michael Hanselmann

serializer: Support newer “json” module

This module is included from Python 2.6 and is based on
simplejson.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: René Nussbaumer <>

b459a848 08/30/2011 11:24 am Andrea Spadaccini

DeprecationWarning fixes for pylint

In version 0.21, pylint unified all the disable-* (and enable-*)
directives to disable (resp. enable). This leads to a lot of
DeprecationWarning being emitted even if one uses the recommended
version of pylint (0.21.1, as stated in devnotes.rst)....

d0c8c01d 07/25/2011 04:55 pm Iustin Pop

Most boring patch ever

s/'/"/ in (hopefully) the right places.

Signed-off-by: Iustin Pop <>
Reviewed-by: Michael Hanselmann <>

3718bf6d 05/04/2010 03:38 pm Michael Hanselmann

Add optional “salt” argument to utils.{,Verify}Sha1Hmac

We're using salted hashes all over the place.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Guido Trotter <>

615aaaba 05/04/2010 03:38 pm Michael Hanselmann

Use utility functions for HMAC

HMAC will be used in more places. Centralizing some parts can't hurt.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: René Nussbaumer <>

fe7c59d5 04/09/2010 05:54 pm Guido Trotter

Fix new pylint errors

Under squeeze pylint reports the following errors:
  • Module ganeti.serializer
    E1103:155:LoadSignedJson: Instance of 'False' has no 'get' member (but some types could not be inferred)
  • Module ganeti-masterd
    E1103:166:ClientRqHandler.handle: Instance of 'False' has no 'get' member (but some types could not be inferred)...
72ca1dcb 02/26/2010 02:41 pm Balazs Lecz

Add multi-key support to the serializer

Signed-off-by: Balazs Lecz <>
Reviewed-by: Michael Hanselmann <>

d984846d 12/28/2009 02:05 pm Iustin Pop

Merge branch 'devel-2.0' into devel-2.1

  • devel-2.0:
    Fix indentation in hv_kvm
    Implement BuildHooksEnv for NoHooksLU
    Clarifiy some more wide pylint disables
    Fix two bugs in seldom-used codepaths
    Update pylintrc
    Add targetted pylint disables
    Partial cherry-pick of 6c881c5 from the 2.1 branch...
fe267188 12/28/2009 12:43 pm Iustin Pop

Add targetted pylint disables

This patch adds targeted pylint disables, where it makes sense (either
due to limitations in pylint or due to historical usage), and also a few
blanket ones in rapi where all the names are… “different”.

Signed-off-by: Iustin Pop <>...

02141fb1 11/05/2009 05:36 pm Michael Hanselmann

Cache JSON encoders and sort keys

The sort_keys argument is supported since simplejson 1.3.

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Guido Trotter <>

d357f531 10/19/2009 05:57 pm Michael Hanselmann

Fix serializer unittests

Commit d22b29997cd broke the serializer unittests with certain
versions of simplejson. This patch removes sort_keys again
and implements a slightly more efficient way of detecting
simplejson functionality. The serializer unittests no longer...

d22b2999 10/16/2009 05:51 pm Michael Hanselmann

serializer: Sort keys in JSON

Signed-off-by: Michael Hanselmann <>
Reviewed-by: Iustin Pop <>

40765aa0 08/07/2009 02:32 pm Guido Trotter

serializer.DumpSignedJson

Don't indent the final message.

Signed-off-by: Guido Trotter <>
Reviewed-by: Michael Hanselmann <>

4e9dac14 08/07/2009 12:24 pm Guido Trotter

Serializer, remove salt_verifier functionality

The salt needs to be returned anyway, so we don't have to add another
key for the sender to recognize which request an answer is answering, so
all that infrastructure is useless. :(

Signed-off-by: Guido Trotter <>...

59672ca3 08/05/2009 04:09 pm Guido Trotter

serializer: fix a few docstrings

Signed-off-by: Guido Trotter <>
Reviewed-by: Michael Hanselmann <>

541822e0 07/16/2009 01:51 pm Guido Trotter

Fix python 2.4 compatibility

I got overexcited and forgot we have to remain compatible with python
2.4. With this patch we move from sha256 to sha1 for hmac authenticated
serialized messages, and we handle both newer and older python, by
importing the right module for each....

f4a2f532 07/14/2009 01:35 pm Guido Trotter

HMAC authenticated json messages

This patch includes HMAC authenticated json messages to the serializer.
The new interface works on any json-encodable data type, and can sign it
with a private key and an optional salt. The same private key must be
used upon message loading to verify the message....

c41eea6e 12/11/2008 07:13 pm Iustin Pop

Fix epydoc format warnings

This patch should fix all outstanding epydoc parsing errors; as such, we
switch epydoc into verbose mode so that any new errors will be visible.

Reviewed-by: imsnah

071448fb 07/08/2008 12:38 pm Michael Hanselmann

serializer.DumpJson: Control indentation by parameter

If the simplejson module supports indentation, it's always used. There
are cases where we might not want to use it or enable it only for
debugging purposes, such as in RPC.

Reviewed-by: iustinp

e91ffe49 06/18/2008 03:29 pm Michael Hanselmann

Make sure serialized data ends with EOL character

Also fix the regular expression to not remove newlines. The simplejson
module puts whitespace at line endings when using indentation. Remove
unnecessary import of ConfigParser module.

Reviewed-by: ultrotter

228538cf 06/06/2008 12:27 pm Michael Hanselmann

Forward-port: Alias Dump/Load functions in ganeti.serializer to DumpJson/LoadJson

The remote API will use JSON for the foreseable future, so it's better
to put the serialization format in the function name. We can still
use another serialization format for Ganeti's core....

8d14b30d 04/21/2008 04:04 pm Iustin Pop

Abstract the json functions into a separate module

This simple patch adds a new module that holds the simplejson functions
for serialization/deserialization. This reduces the amount of redundant
code.

The patch also adds some normalizations to the json output:...