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.