cinderlib.serialization module

Oslo Versioned Objects helper file.

These methods help with the serialization of Cinderlib objects that uses the OVO serialization mechanism, so we remove circular references when doing the JSON serialization of objects (for example in a Volume OVO it has a ‘snapshot’ field which is a Snapshot OVO that has a ‘volume’ back reference), piggy back on the OVO’s serialization mechanism to add/get additional data we want.

datetime_to_primitive(obj, attr, value, visited=None)[source]

Stringify time in ISO 8601 with subsecond format.

This is the same code as the one used by the OVO DateTime to_primitive but adding the subsecond resolution with the ‘.%f’ part in strftime call.

This is backward compatible with cinderlib using code that didn’t generate subsecond resolution, because the from_primitive code of the OVO field uses oslo_utils.timeutils.parse_isotime which in the end uses iso8601.parse_date, and since the subsecond format is also ISO8601 it is properly parsed.

dict_to_primitive(self, obj, attr, value, visited=None)[source]
dump()[source]

Convert to Json everything we have in this system.

dumps()[source]

Convert to a Json string everything we have in this system.

field_ovo_to_primitive(obj, attr, value, visited=None)[source]
field_to_primitive(self, obj, attr, value, visited=None)[source]
iterable_to_primitive(self, obj, attr, value, visited=None)[source]
json()[source]

Convert to Json everything we have in this system.

jsons()[source]

Convert to a Json string everything we have in this system.

load(json_src, save=False)[source]

Load any json serialized cinderlib object.

obj_from_primitive(cls, primitive, context=None, original_method=cinder.objects.base.CinderObject.obj_from_primitive)[source]
obj_to_primitive(self, target_version=None, version_manifest=None, visited=None)[source]
setup(backend_class)[source]
wrap_to_primitive(cls)[source]