After looking into this some more I think the current approach of utf-8 encoding in VolumeMetadataBackup.set() prior to the write and utf-8 decoding in VolumeMetadataBackup.get() after the read makes sense. More details:
On the way in json_meta is a json-encoded dict containing all metadata is actually set to in the calls to VolumeMetadataBackup.set(json_meta):
1) In CephBackupDriver._backup_metadata(), 'json_meta = self.get_metadata' is set before calling VolumeMetadataBackup.set(json_meta)
2) CephBackupDriver inherits from driver.BackupDriver (from cinder.backup import driver)
3) In cinder/backup/driver.py, class BackupDriver has get_metadata which calls BackupMetadataAPI.get.
4) BackupMetadataAPI.get() gets the volume metadata, returning jsonutils.dumps(container), a json-encoded dict containing all metadata [1].
And on the way back out from VolumeMetadataBackup.get(json_meta):
1) CephBackupDriver._restore_metadata() calls VolumeMetadataBackup.get() to read the object from ceph.
2) The result (meta) is then sent to self.put_metadata(volume_id, meta), from driver.BackupDriver.
3) put_metadata() calls BackupMetadataAPI.put()
4) BackupMetadataAPI.put() restores volume metadata to a volume, using jsonutils.loads(json_metadata) to decode the encoded dict.
jsonutils.dumps() is from oslo.serialization (oslo_serialization/jsonutils.py) and serialize an obj to a JSON formatted str. jsonutils.loads() deserializes the JSON formatted str back to an obj [1]
[1] For example:
>>> from oslo_serialization import jsonutils
>>> container = {'version': 1}
>>> jsonutils.dumps(container) # on the way in
'{"version": 1}'
>>> jsonutils.loads(jsonutils.dumps(container)) # on the way out
{'version': 1}
After looking into this some more I think the current approach of utf-8 encoding in VolumeMetadataB ackup.set( ) prior to the write and utf-8 decoding in VolumeMetadataB ackup.get( ) after the read makes sense. More details:
On the way in json_meta is a json-encoded dict containing all metadata is actually set to in the calls to VolumeMetadataB ackup.set( json_meta) : r._backup_ metadata( ), 'json_meta = self.get_metadata' is set before calling VolumeMetadataB ackup.set( json_meta) backup/ driver. py, class BackupDriver has get_metadata which calls BackupMetadataA PI.get. PI.get( ) gets the volume metadata, returning jsonutils. dumps(container ), a json-encoded dict containing all metadata [1].
1) In CephBackupDrive
2) CephBackupDriver inherits from driver.BackupDriver (from cinder.backup import driver)
3) In cinder/
4) BackupMetadataA
And on the way back out from VolumeMetadataB ackup.get( json_meta) : r._restore_ metadata( ) calls VolumeMetadataB ackup.get( ) to read the object from ceph. metadata( volume_ id, meta), from driver. BackupDriver. PI.put( ) PI.put( ) restores volume metadata to a volume, using jsonutils. loads(json_ metadata) to decode the encoded dict.
1) CephBackupDrive
2) The result (meta) is then sent to self.put_
3) put_metadata() calls BackupMetadataA
4) BackupMetadataA
jsonutils.dumps() is from oslo.serialization (oslo_serializa tion/jsonutils. py) and serialize an obj to a JSON formatted str. jsonutils.loads() deserializes the JSON formatted str back to an obj [1]
[1] For example: dumps(container ) # on the way in loads(jsonutils .dumps( container) ) # on the way out
>>> from oslo_serialization import jsonutils
>>> container = {'version': 1}
>>> jsonutils.
'{"version": 1}'
>>> jsonutils.
{'version': 1}