def message_gen(self):
        # TEST: we can fail only in deployment stage here:
        error = self.params.get("error")
        if error != 'deployment':
            error = None
        # TEST: error message from "orchestrator"
        error_msg = self.params.get("error_msg", "")
        # TEST: we can set task to ready no matter what
        # True or False
        task_ready = self.params.get("task_ready")

        if 'godmode' in self.params:
            raise ValueError('godmode is not supported anymore, '
                             'please use override_state instead')

        override_state = self.params.get("override_state", False)

        if 'tasks_graph' in self.data['args']:
            nodes = [
                {'uid': uid}
                for uid in self.data['args']['tasks_graph']
                if uid and uid != consts.MASTER_NODE_UID
            ]
        else:
            nodes = self.data['args']['deployment_info']
        self.refresh_nodes(nodes)

        kwargs = {
            'task_uuid': self.task_uuid,
            'nodes': nodes,
            'status': 'running'
        }

        if override_state:
            progress = override_state.get("progress", 0)
            status = override_state.get("status", "running")
            for n in kwargs["nodes"]:
                n["status"] = status
                n["progress"] = progress
            kwargs["status"] = status
            yield kwargs
            raise StopIteration

        smart_nodes = [
            FSMNodeFlow(n, consts.NODE_STATUSES.provisioned)
            for n in kwargs['nodes']
        ]

        stages_errors = {
            # no errors - default deployment
            None: chain(
                self.run_until_status(
                    smart_nodes, consts.NODE_STATUSES.deploying
                ),
                self.run_until_status(
                    smart_nodes, consts.NODE_STATUSES.ready, 'controller'
                ),
                self.run_until_status(
                    smart_nodes, consts.NODE_STATUSES.ready
                )
            ),
            # error on deployment stage
            'deployment': chain(
                self.run_until_status(
                    smart_nodes, consts.NODE_STATUSES.deploying
                ),
                self.run_until_status(
                    smart_nodes, consts.NODE_STATUSES.ready,
                    'controller', random_error=True
                )
            )
        }

        mode = stages_errors[error]

        for nodes_status in mode:
            kwargs['nodes'] = nodes_status
            yield kwargs
            self.sleep(self.tick_interval)

        if not error or task_ready:
            kwargs['status'] = consts.TASK_STATUSES.ready
        else:
            kwargs['status'] = consts.TASK_STATUSES.error

        if error_msg:
            kwargs['error'] = error_msg

        yield kwargs
dataset/ETHPy150Open openstack/fuel-web/nailgun/nailgun/task/fake.py/FakeDeploymentThread.message_gen/original