Merge "add info logging on backup and restore"
This commit is contained in:
commit
7576747bc9
|
@ -37,7 +37,9 @@ def backup(path_to_backup, archivators):
|
|||
tar_obj = tarfile.open(fileobj=temp, mode="w|{0}".format(ext))
|
||||
with contextlib.closing(tar_obj) as archive:
|
||||
for manager in archivators:
|
||||
LOG.info("Start backup {0}".format(manager.archivator_name))
|
||||
manager(archive).backup()
|
||||
LOG.info("Finish backup {0}".format(manager.archivator_name))
|
||||
if not archive.getmembers():
|
||||
raise Exception("Nothing to backup")
|
||||
shutil.move(temp.name, abs_path_to_backup)
|
||||
|
|
|
@ -28,7 +28,9 @@ def restore_data(path_to_backup, archivators, context):
|
|||
for archivator in archivators:
|
||||
archivator.pre_restore_check()
|
||||
for archivator in archivators:
|
||||
LOG.info("Start restore {0}".format(archivator.archivator_name))
|
||||
archivator.restore()
|
||||
LOG.info("Finish restore {0}".format(archivator.archivator_name))
|
||||
|
||||
|
||||
class BaseRestoreCommand(command.Command):
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
# under the License.
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
from octane.util import archivate
|
||||
from octane.util import docker
|
||||
|
@ -23,6 +24,16 @@ class Base(object):
|
|||
self.archive = archive
|
||||
self.context = context
|
||||
|
||||
@property
|
||||
def archivator_name(self):
|
||||
name = re.sub(
|
||||
'([A-Z]+)', r' \1', self.__class__.__name__
|
||||
).lower().strip()
|
||||
for replacer in ["archivator", "backup"]:
|
||||
if name.endswith(replacer):
|
||||
name = name[:-len(replacer)].strip()
|
||||
return name
|
||||
|
||||
def backup(self):
|
||||
raise NotImplemented
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import os
|
|||
import pytest
|
||||
|
||||
from octane.handlers.backup_restore import astute
|
||||
from octane.handlers.backup_restore import base
|
||||
from octane.handlers.backup_restore import cobbler
|
||||
from octane.handlers.backup_restore import fuel_keys
|
||||
from octane.handlers.backup_restore import fuel_uuid
|
||||
|
@ -249,3 +250,15 @@ def test_repos_backup(
|
|||
],
|
||||
any_order=True)
|
||||
assert test_archive.add.call_count == len(archive_add_list)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name, expected_name", [
|
||||
("TestArchivator", "test"),
|
||||
("TestBackup", "test"),
|
||||
("Test", "test"),
|
||||
("NotTestArchivator", "not test"),
|
||||
("NewBornTestCase", "new born test case"),
|
||||
])
|
||||
def test_archivator_name(mocker, name, expected_name):
|
||||
|
||||
assert expected_name == type(name, (base.Base, ), {})(None).archivator_name
|
||||
|
|
Loading…
Reference in New Issue