# This file is an example of a Reports plugin that can be used to dump information about the platforms. # The MyReportPlugin example contains example of code that could be used to write a plugin for a new kind of report. require 'hybrid_platforms_conductor/report' module HybridPlatformsConductor module HpcPlugins module Report # Brief description of the plugin here. # The name should match the file name. # It should always inherit from ReportPlugin. # In all instance methods of a platform handler, the following variables are accessible: # * @nodes_handler (NodesHandler): Nodes handler used to access information about the platforms class MyReportPlugin < HybridPlatformsConductor::Report # Are dependencies met before using this plugin? # [API] - This method is optional # # Result:: # * Boolean: Are dependencies met before using this plugin? def self.valid? true end # Add a Mixin to the DSL parsing the platforms configuration file. # This can be used by any plugin to add plugin-specific configuration getters and setters, accessible later from NodesHandler instances. # An optional initializer can also be given. # [API] - Those calls are optional module MyDSLExtension attr_accessor :my_property # Initialize the DSL def init_my_dsl_extension @my_property = 42 end end self.extend_config_dsl_with MyDSLExtension, :init_my_dsl_extension # Give the list of supported locales by this report generator # [API] - This method is mandatory. # # Result:: # * Array: List of supported locales def self.supported_locales # This method has to publish the list of translations it accepts. [ :fr, :en ] end # Create a report for a list of nodes, in a given locale # [API] - This method is mandatory. # # Parameters:: # * *nodes* (Array): List of nodes # * *locale_code* (Symbol): The locale code def report_for(nodes, locale_code) # This method simply provides a report for a given list of nodes in the desired locale. # The locale will be one of the supported ones. output = '' case locale_code when :fr output << 'Un beau rapport' when :en output << 'A nice report' end @platforms_handler.known_platforms.each do |platform| output << "= Report for platform #{platform.repository_path} of type #{platform.platform_type}:" platform.known_nodes.each do |node| output << "== Report for node #{node}:" output << @nodes_handler.get_description_of node end end out output end end end end end