module HybridPlatformsConductor module HpcPlugins module Action # Example of an action plugin class MyAction < HybridPlatformsConductor::Action # 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 # Setup the action. # This is called by the constructor itself, when an action is instantiated to be executed for a node. # [API] - This method is optional # [API] - @cmd_runner is accessible # [API] - @actions_executor is accessible # # Parameters:: # * *action_info* (Object): The action info def setup(action_info) @action_info[:message] = 'Default message' unless @action_info.key?(:message) end # Do we need a connector to execute this action on a node? # [API] - This method is optional # [API] - @cmd_runner is accessible # [API] - @actions_executor is accessible # # Result:: # * Boolean: Do we need a connector to execute this action on a node? def need_connector? true end # Execute the action # [API] - This method is mandatory # [API] - @cmd_runner is accessible # [API] - @actions_executor is accessible # [API] - @action_info is accessible with the action details # [API] - @node (String) can be used to know on which node the action is to be executed # [API] - @connector (Connector or nil) can be used to access the node's connector if the action needs remote connection # [API] - @timeout (Integer) should be used to make sure the action execution does not get past this number of seconds # [API] - @stdout_io can be used to log stdout messages # [API] - @stderr_io can be used to log stderr messages # [API] - run_cmd(String) method can be used to execute a command. See CmdRunner#run_cmd to know about the result's signature. def execute run_cmd "echo #{@action_info[:message]} on #{@node}" end end end end end