diff --git a/octane/handlers/backup_restore/__init__.py b/octane/handlers/backup_restore/__init__.py index 69e5dbdc..3da2c136 100644 --- a/octane/handlers/backup_restore/__init__.py +++ b/octane/handlers/backup_restore/__init__.py @@ -12,7 +12,7 @@ import os -# from octane.handlers.backup_restore import astute +from octane.handlers.backup_restore import astute # from octane.handlers.backup_restore import cobbler from octane.handlers.backup_restore import fuel_keys from octane.handlers.backup_restore import fuel_uuid @@ -31,7 +31,7 @@ from octane.handlers.backup_restore import version # services are run now in OS on the host. This major change requires to # modify current archivators that use containers. ARCHIVATORS = [ - # astute.AstuteArchivator, + astute.AstuteArchivator, # SSH restore must go before Cobbler restore so it updates # /etc/cobbler/authorized_keys file automatically ssh.SshArchivator, diff --git a/octane/handlers/backup_restore/astute.py b/octane/handlers/backup_restore/astute.py index dbd138fc..0b7ffbb1 100644 --- a/octane/handlers/backup_restore/astute.py +++ b/octane/handlers/backup_restore/astute.py @@ -15,8 +15,7 @@ import shutil import yaml from octane.handlers.backup_restore import base -from octane import magic_consts -from octane.util import docker +from octane.util import puppet LOG = logging.getLogger(__name__) @@ -72,12 +71,6 @@ class AstuteArchivator(base.PathArchivator): return yaml.load(current) def pre_restore_check(self): - names = docker.get_docker_container_names(status="running") - containers = set(magic_consts.RUNNING_REQUIRED_CONTAINERS) - set(names) - if containers: - raise Exception( - "Required running containers: {0}".format( - ", ".join(containers))) backup_ip = self.get_backup_dict()["ADMIN_NETWORK"]["ipaddress"] current_ip = self.get_current_dict()["ADMIN_NETWORK"]["ipaddress"] if backup_ip != current_ip: @@ -116,17 +109,5 @@ class AstuteArchivator(base.PathArchivator): self._post_restore_action() def _post_restore_action(self): - # restart all running containers - for name in magic_consts.RUNNING_REQUIRED_CONTAINERS: - docker.stop_container(name) - # FIXME: when astute container restart corrent this may be removed - if "astute" == name: - try: - docker.start_container(name) - except Exception: - LOG.warn( - "Failed to start astute container for the first time") - docker.stop_container(name) - else: - continue - docker.start_container(name) + for task in ["hiera", "host"]: + puppet.apply_task(task) diff --git a/octane/magic_consts.py b/octane/magic_consts.py index bb947bf9..6992ca7f 100644 --- a/octane/magic_consts.py +++ b/octane/magic_consts.py @@ -47,22 +47,6 @@ NAILGUN_URL = "http://127.0.0.1:8000" KEYSTONE_API_URL = "http://127.0.0.1:5000/v2.0" KEYSTONE_TENANT_NAME = "admin" -SYNC_CONTAINERS = [] - -RUNNING_REQUIRED_CONTAINERS = [ - "postgres", - "rabbitmq", - "keystone", - "rsync", - "astute", - "rsyslog", - "nailgun", - "ostf", - "nginx", - "cobbler", - "mcollective", -] - OPENSTACK_FIXTURES = "/usr/share/fuel-openstack-metadata/openstack.yaml" OSD_REPOS_UPDATE = [ diff --git a/octane/tests/test_archivators_restore.py b/octane/tests/test_archivators_restore.py index 8d072046..6fe6445d 100644 --- a/octane/tests/test_archivators_restore.py +++ b/octane/tests/test_archivators_restore.py @@ -450,20 +450,18 @@ def test_astute_restore(mocker, mock_open, keys_in_dump_file, restored): safe_dump = mocker.patch("yaml.safe_dump") copy_mock = mocker.patch("shutil.copy2") move_mock = mocker.patch("shutil.move") + mock_puppet = mocker.patch("octane.util.puppet.apply_task") cls = astute.AstuteArchivator archive = TestArchive([member], cls) - post_restore_mock = mocker.patch.object(cls, "_post_restore_action") try: cls(archive).restore() except Exception as exc: if restored: raise assert str(exc).startswith("Not found values in backup for keys: ") - assert not post_restore_mock.called else: assert restored member.assert_extract() - post_restore_mock.assert_called_once_with() copy_mock.assert_called_once_with( "/etc/fuel/astute.yaml", "/etc/fuel/astute.yaml.old") move_mock.assert_called_once_with( @@ -471,24 +469,10 @@ def test_astute_restore(mocker, mock_open, keys_in_dump_file, restored): safe_dump.assert_called_once_with(dict_to_restore, mock_open.return_value, default_flow_style=False) - - -def test_post_restore_action_astute(mocker): - - stopped = [] - mocker.patch( - "octane.util.docker.get_docker_container_names", - return_value=["container_1", "container_2"] - ) - start = mocker.patch("octane.util.docker.start_container", - side_effect=stopped.remove) - stop = mocker.patch("octane.util.docker.stop_container", - side_effect=stopped.append) - - astute.AstuteArchivator(None)._post_restore_action() - assert start.called - assert stop.called - assert not stopped + assert mock_puppet.mock_calls == [ + mock.call("hiera"), + mock.call("host"), + ] @pytest.mark.parametrize(("dump", "calls"), [ diff --git a/octane/tests/test_restore.py b/octane/tests/test_restore.py index ba6ede0e..cdb139dd 100644 --- a/octane/tests/test_restore.py +++ b/octane/tests/test_restore.py @@ -16,7 +16,6 @@ import pytest from octane.commands import restore from octane.handlers import backup_restore from octane.handlers.backup_restore import astute -from octane import magic_consts @pytest.mark.parametrize("path,is_file", [ @@ -80,9 +79,6 @@ def test_restore_data(mocker): ]) def test_astute_checker( mocker, mock_open, backup_ip, current_ip): - mocker.patch( - "octane.util.docker.get_docker_container_names", - return_value=magic_consts.RUNNING_REQUIRED_CONTAINERS) tar_mock = mocker.Mock() mocker.patch.object( astute.AstuteArchivator,