def restore(self): _, tmp_file_name = tempfile.mkstemp(dir="/etc/fuel", prefix=".astute.yaml.octane") shutil.copy("/etc/fuel/astute.yaml", tmp_file_name) try: data = helpers.get_astute_dict() data["FUEL_ACCESS"]["password"] = self.context.password with open("/etc/fuel/astute.yaml", "w") as current: yaml.safe_dump(data, current, default_flow_style=False) puppet.apply_host() finally: shutil.move(tmp_file_name, "/etc/fuel/astute.yaml")
def restore(self): _, tmp_file_name = tempfile.mkstemp( dir="/etc/fuel", prefix=".astute.yaml.octane") shutil.copy("/etc/fuel/astute.yaml", tmp_file_name) try: data = helpers.get_astute_dict() data["FUEL_ACCESS"]["password"] = self.context.password with open("/etc/fuel/astute.yaml", "w") as current: yaml.safe_dump(data, current, default_flow_style=False) puppet.apply_host() finally: shutil.move(tmp_file_name, "/etc/fuel/astute.yaml")
def post_restore_action(self, *args, **kwargs): # run 'puppet apply' in the host system puppet.apply_host() # 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): puppet.apply_host()
def test_apply_host_error(mock_subprocess): exc = subprocess.CalledProcessError(1, 'TEST_PROCESS') mock_subprocess.side_effect = exc with pytest.raises(type(exc)): puppet_util.apply_host()
def test_apply_host(mock_subprocess): puppet_util.apply_host() assert mock_subprocess.call_count == 1