#NEWLINE# @ classmethod #NEWLINE# def get_volumes_metadata( cls , cluster ) : #NEWLINE# #INDENT# 'Get volumes metadata for cluster from all plugins which enabled it.\n\n        :param cluster: A cluster instance\n        :type cluster: Cluster model\n        :return: dict -- Object with merged volumes data from plugins\n        ' #NEWLINE# volumes_metadata = { #NEWLINE# #INDENT# 'volumes' : [ ] , #NEWLINE# 'volumes_roles_mapping' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# release_volumes = cluster . release . volumes_metadata . get ( 'volumes' , [ ] ) #NEWLINE# release_volumes_ids = [ v [ 'id' ] for v in release_volumes ] #NEWLINE# processed_volumes = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# enabled_plugins = ClusterPlugins . get_enabled ( cluster . id ) #NEWLINE# for plugin_adapter in map ( wrap_plugin , enabled_plugins ) : #NEWLINE# #INDENT# metadata = plugin_adapter . volumes_metadata #NEWLINE# for volume in metadata . get ( 'volumes' , [ ] ) : #NEWLINE# #INDENT# volume_id = volume [ 'id' ] #NEWLINE# if ( volume_id in release_volumes_ids ) : #NEWLINE# #INDENT# raise errors . AlreadyExists ( 'Plugin {0} is overlapping with release by introducing the same volume with id "{1}"' . format ( plugin_adapter . full_name , volume_id ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( volume_id in processed_volumes ) : #NEWLINE# #INDENT# raise errors . AlreadyExists ( 'Plugin {0} is overlapping with plugin {1} by introducing the same volume with id "{2}"' . format ( plugin_adapter . full_name , processed_volumes [ volume_id ] , volume_id ) ) #NEWLINE# #UNINDENT# #UNINDENT# processed_volumes [ volume_id ] = plugin_adapter . full_name #NEWLINE# #UNINDENT# volumes_metadata . get ( 'volumes_roles_mapping' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) . update ( metadata . get ( 'volumes_roles_mapping' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ) #NEWLINE# volumes_metadata . get ( 'volumes' , [ ] ) . extend ( metadata . get ( 'volumes' , [ ] ) ) #NEWLINE# #UNINDENT# return volumes_metadata