#NEWLINE# def get_serializer_for_cluster( cluster ) : #NEWLINE# #INDENT# 'Returns a serializer depends on a given `cluster`.\n\n    :param cluster: cluster to process\n    :returns: a serializer for a given cluster\n    ' #NEWLINE# serializers_map = { #NEWLINE# #INDENT# '5.0' : { #NEWLINE# #INDENT# 'multinode' : DeploymentMultinodeSerializer50 , #NEWLINE# 'ha' : DeploymentHASerializer50 , #NEWLINE# #UNINDENT# } , #NEWLINE# '5.1' : { #NEWLINE# #INDENT# 'multinode' : DeploymentMultinodeSerializer51 , #NEWLINE# 'ha' : DeploymentHASerializer51 , #NEWLINE# #UNINDENT# } , #NEWLINE# '6.0' : { #NEWLINE# #INDENT# 'multinode' : DeploymentMultinodeSerializer60 , #NEWLINE# 'ha' : DeploymentHASerializer60 , #NEWLINE# #UNINDENT# } , #NEWLINE# '6.1' : { #NEWLINE# #INDENT# 'multinode' : DeploymentMultinodeSerializer61 , #NEWLINE# 'ha' : DeploymentHASerializer61 , #NEWLINE# #UNINDENT# } , #NEWLINE# '7.0' : { #NEWLINE# #INDENT# 'ha' : DeploymentHASerializer70 , #NEWLINE# #UNINDENT# } , #NEWLINE# '8.0' : { #NEWLINE# #INDENT# 'ha' : DeploymentHASerializer80 , #NEWLINE# #UNINDENT# } , #NEWLINE# '9.0' : { #NEWLINE# #INDENT# 'ha' : DeploymentHASerializer90 , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# env_mode = ( 'ha' if cluster . is_ha_mode else 'multinode' ) #NEWLINE# for ( version , serializers ) in six . iteritems ( serializers_map ) : #NEWLINE# #INDENT# if cluster . release . environment_version . startswith ( version ) : #NEWLINE# #INDENT# return serializers [ env_mode ] #NEWLINE# #UNINDENT# #UNINDENT# latest_version = max ( serializers_map , key = ( lambda v : StrictVersion ( v ) ) ) #NEWLINE# return serializers_map [ latest_version ] [ serializers_map ]