"""Base class for all backup drivers."""
import abc
+import base64
from oslo_config import cfg
from oslo_log import log as logging
:returns backup_url - a string describing the backup record
"""
retval = jsonutils.dumps(backup)
- return retval.encode("base64")
+ if six.PY3:
+ retval = retval.encode('utf-8')
+ return base64.encodestring(retval)
def import_record(self, backup_url):
"""Import and verify backup record.
:param backup_url: driver specific backup record string
:returns dictionary object with database updates
"""
- return jsonutils.loads(backup_url.decode("base64"))
+ return jsonutils.loads(base64.decodestring(backup_url))
@six.add_metaclass(abc.ABCMeta)
# Set up the reservation expiration
if expire is None:
expire = CONF.reservation_expire
- if isinstance(expire, (int, long)):
+ if isinstance(expire, six.integer_types):
expire = datetime.timedelta(seconds=expire)
if isinstance(expire, datetime.timedelta):
expire = timeutils.utcnow() + expire
# under the License.
""" Tests for the backup service base driver. """
+import base64
import uuid
import mock
def test_export_record(self):
export_string = self.driver.export_record(self.backup)
- export_dict = jsonutils.loads(export_string.decode("base64"))
+ export_dict = jsonutils.loads(base64.decodestring(export_string))
# Make sure we don't lose data when converting to string
for key in _backup_db_fields:
self.assertTrue(key in export_dict)
commands =
python -m testtools.run \
cinder.tests.unit.test_api_urlmap \
+ cinder.tests.unit.test_backup \
+ cinder.tests.unit.test_backup_driver_base \
cinder.tests.unit.test_block_device \
cinder.tests.unit.test_cloudbyte \
cinder.tests.unit.test_conf \