Merge "NFS Backup: Fix overwritting backups"
This commit is contained in:
commit
6ad77cc4ef
@ -23,6 +23,7 @@ import stat
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from cinder.backup import chunkeddriver
|
||||
from cinder import exception
|
||||
@ -129,7 +130,11 @@ class PosixBackupDriver(chunkeddriver.ChunkedBackupDriver):
|
||||
os.remove(path)
|
||||
|
||||
def _generate_object_name_prefix(self, backup):
|
||||
return 'backup'
|
||||
timestamp = timeutils.utcnow().strftime("%Y%m%d%H%M%S")
|
||||
prefix = 'volume_%s_%s_backup_%s' % (backup.volume_id, timestamp,
|
||||
backup.id)
|
||||
LOG.debug('_generate_object_name_prefix: %s', prefix)
|
||||
return prefix
|
||||
|
||||
def get_extra_metadata(self, backup, volume):
|
||||
return None
|
||||
|
@ -24,6 +24,7 @@ from six.moves import builtins
|
||||
|
||||
from cinder.backup.drivers import posix
|
||||
from cinder import context
|
||||
from cinder import objects
|
||||
from cinder import test
|
||||
from cinder.tests.unit import fake_constants as fake
|
||||
|
||||
@ -175,3 +176,15 @@ class PosixBackupDriverTestCase(test.TestCase):
|
||||
self.assertRaises(OSError,
|
||||
self.driver.delete_object, FAKE_CONTAINER,
|
||||
FAKE_OBJECT_NAME)
|
||||
|
||||
@mock.patch.object(posix.timeutils, 'utcnow')
|
||||
def test_generate_object_name_prefix(self, utcnow_mock):
|
||||
timestamp = '20170518102205'
|
||||
utcnow_mock.return_value.strftime.return_value = timestamp
|
||||
backup = objects.Backup(self.ctxt, volume_id=fake.VOLUME_ID,
|
||||
id=fake.BACKUP_ID)
|
||||
res = self.driver._generate_object_name_prefix(backup)
|
||||
expected = 'volume_%s_%s_backup_%s' % (backup.volume_id,
|
||||
timestamp,
|
||||
backup.id)
|
||||
self.assertEqual(expected, res)
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fix NFS backup driver, we now support multiple backups on the same
|
||||
container, they are no longer overwritten.
|
Loading…
x
Reference in New Issue
Block a user