<s> import itertools <EOL> from nailgun . orchestrator import plugins_serializers <EOL> from nailgun . orchestrator . priority_serializers import PriorityStrategy <EOL> def stage_serialize ( serializer , graph_tasks ) : <EOL> """<STR_LIT>""" <EOL> tasks = list ( itertools . chain ( <EOL> serializer . serialize_begin_tasks ( ) , <EOL> graph_tasks , <EOL> serializer . serialize_end_tasks ( ) ) ) <EOL> PriorityStrategy ( ) . one_by_one ( tasks ) <EOL> return tasks <EOL> def pre_deployment_serialize ( orchestrator_graph , cluster , nodes , <EOL> role_resolver = None ) : <EOL> graph_tasks = orchestrator_graph . pre_tasks_serialize ( nodes ) <EOL> return stage_serialize ( <EOL> plugins_serializers . PluginsPreDeploymentHooksSerializer ( <EOL> cluster , nodes , role_resolver = role_resolver ) , graph_tasks ) <EOL> def post_deployment_serialize ( orchestrator_graph , cluster , nodes , <EOL> role_resolver = None ) : <EOL> graph_tasks = orchestrator_graph . post_tasks_serialize ( nodes ) <EOL> return stage_serialize ( <EOL> plugins_serializers . PluginsPostDeploymentHooksSerializer ( <EOL> cluster , nodes , role_resolver = role_resolver ) , graph_tasks ) </s>
