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)
def restore(self): dump = self.archive.extractfile(self.filename) subprocess.call( ["systemctl", "stop", "docker-{0}.service".format(self.db)]) docker.stop_container(self.db) docker.run_in_container( "postgres", ["sudo", "-u", "postgres", "dropdb", "--if-exists", self.db], ) with docker.in_container("postgres", ["sudo", "-u", "postgres", "psql"], stdin=subprocess.PIPE) as process: process.stdin.write(dump.read()) docker.start_container(self.db) docker.wait_for_container(self.db) subprocess.call( ["systemctl", "start", "docker-{0}.service".format(self.db)])
def restore(self): dump = self.archive.extractfile(self.filename) subprocess.call([ "systemctl", "stop", "docker-{0}.service".format(self.db) ]) docker.stop_container(self.db) docker.run_in_container( "postgres", ["sudo", "-u", "postgres", "dropdb", "--if-exists", self.db], ) with docker.in_container("postgres", ["sudo", "-u", "postgres", "psql"], stdin=subprocess.PIPE) as process: process.stdin.write(dump.read()) subprocess.call([ "systemctl", "start", "docker-{0}.service".format(self.db) ]) docker.start_container(self.db)
def test_docker_stop( mocker, mock_subprocess, container_id, container_name, stop_by_docker): mock_subprocess_call_output = mocker.patch( "octane.util.subprocess.call_output", return_value=container_id) mock_stop_action = mocker.patch("octane.util.docker._container_action") docker.stop_container(container_name) mock_stop_action.assert_called_once_with(container_name, "stop") mock_subprocess_call_output.assert_called_once_with([ 'docker', 'ps', '--filter', 'name={0}'.format(container_name), '--format', '{{.ID}}' ]) if stop_by_docker: mock_subprocess.assert_called_once_with( ["docker", "stop", container_id.strip()]) else: assert not mock_subprocess.called
def post_restore_action(self, *args, **kwargs): docker.stop_container("cobbler") docker.start_container("cobbler")
def restore(self): super(CobblerArchivator, self).restore() docker.stop_container("cobbler") docker.start_container("cobbler")