Package ganeti :: Module serializer
[hide private]
[frames] | no frames]

Module serializer

source code

Serializer abstraction module

This module introduces a simple abstraction over the serialization backend (currently json).

Functions [hide private]
 
DumpJson(data)
Serialize a given object.
source code
 
LoadJson(txt)
Unserialize data from a string.
source code
 
DumpSignedJson(data, key, salt=None, key_selector=None)
Serialize a given object and authenticate it.
source code
tuple of original data, string
LoadSignedJson(txt, key)
Verify that a given message was signed with the given key, and load it.
source code
 
LoadAndVerifyJson(raw, verify_fn)
Parses and verifies JSON data.
source code
 
Dump(data)
Serialize a given object.
source code
 
Load(txt)
Unserialize data from a string.
source code
 
DumpSigned(data, key, salt=None, key_selector=None)
Serialize a given object and authenticate it.
source code
tuple of original data, string
LoadSigned(txt, key)
Verify that a given message was signed with the given key, and load it.
source code
Variables [hide private]
  _RE_EOLSP = re.compile("[ \t]+$", re.MULTILINE)

Imports: re, simplejson, errors, utils


Function Details [hide private]

DumpJson(data)

source code 

Serialize a given object.

Parameters:
  • data - the data to serialize
Returns:
the string representation of data

LoadJson(txt)

source code 

Unserialize data from a string.

Parameters:
  • txt - the json-encoded form
Returns:
the original data

DumpSignedJson(data, key, salt=None, key_selector=None)

source code 

Serialize a given object and authenticate it.

Parameters:
  • data - the data to serialize
  • key - shared hmac key
  • key_selector - name/id that identifies the key (in case there are multiple keys in use, e.g. in a multi-cluster environment)
Returns:
the string representation of data signed by the hmac key

LoadSignedJson(txt, key)

source code 

Verify that a given message was signed with the given key, and load it.

Parameters:
  • txt - json-encoded hmac-signed message
  • key - the shared hmac key or a callable taking one argument (the key selector), which returns the hmac key belonging to the key selector. Typical usage is to pass a reference to the get method of a dict.
Returns: tuple of original data, string
original data, salt
Raises:

LoadAndVerifyJson(raw, verify_fn)

source code 

Parses and verifies JSON data.

Parameters:
  • raw (string) - Input data in JSON format
  • verify_fn (callable) - Verification function, usually from ht
Returns:
De-serialized data

Dump(data)

source code 

Serialize a given object.

Parameters:
  • data - the data to serialize
Returns:
the string representation of data

Load(txt)

source code 

Unserialize data from a string.

Parameters:
  • txt - the json-encoded form
Returns:
the original data

DumpSigned(data, key, salt=None, key_selector=None)

source code 

Serialize a given object and authenticate it.

Parameters:
  • data - the data to serialize
  • key - shared hmac key
  • key_selector - name/id that identifies the key (in case there are multiple keys in use, e.g. in a multi-cluster environment)
Returns:
the string representation of data signed by the hmac key

LoadSigned(txt, key)

source code 

Verify that a given message was signed with the given key, and load it.

Parameters:
  • txt - json-encoded hmac-signed message
  • key - the shared hmac key or a callable taking one argument (the key selector), which returns the hmac key belonging to the key selector. Typical usage is to pass a reference to the get method of a dict.
Returns: tuple of original data, string
original data, salt
Raises: