module OmfRc::ResourceProxy::Application

This module defines a Resource Proxy (RP) for an Application. For a detailed usage tutorial see {file:doc/DEVELOPERS.mkd Resource Proxy tutorial}

Utility dependencies: platform_toos, common_tools

This Application Proxy has the following properties:

Note: this application proxy will merge new Hash values for the properties environment, oml, and parameters properties with the old Hash values.

Two examples of valid parameters definition are:

{ :host => {:default => 'localhost', :type => 'String',
        :mandatory => true, :order => 2},
  :port => {:default => 5000, :type => 'Numeric', :cmd => '-p',
        :mandatory => true, :order => 1},
  :size => {:default => 512, :type => 'Numeric', :cmd => '--pkt-size',
        :mandatory => true, :dynamic => true}
  :title => {:type => 'String', :mandatory => false}
}

and

{ :title => {:value => "My First Application"} }

Constants

DEFAULT_MANDATORY_PARAMETER
MAX_PARAMETER_NUMBER

Public Instance Methods

process_event(res, event_type, app_id, msg) click to toggle source

This method processes an event coming from the application instance, which was started by this Resource Proxy (RP). It is a callback, which is usually called by the ExecApp class in OMF

@param [AbstractResource] res this RP @param [String] event_type the type of event from the app instance

(STARTED, EXIT, STDOUT, STDERR)

@param [String] app_id the id of the app instance @param [String] msg the message carried by the event

# File lib/omf_rc/resource_proxy/application.rb, line 148
def process_event(res, event_type, app_id, msg)
    logger.info "App Event from '#{app_id}' "+
                "(##{res.property.event_sequence}) - "+
                "#{event_type}: '#{msg}'"
    res.property.event_sequence += 1
    res.property.installed = true if app_id.include?("_INSTALL") &&
                                     event_type.to_s.include?('EXIT') &&
                                     msg == "0"
    if event_type == 'EXIT'
      res.property.state = :stopped
      res.inform(:status, {
                      status_type: 'APP_EVENT',
                      event: event_type.to_s.upcase,
                      app: app_id,
                      exit_code: msg,
                      msg: msg,
                      state: res.property.state,
                      seq: res.property.event_sequence,
                      uid: res.uid # do we really need this? Should be identical to 'src'
                    }, :ALL) unless res.property.silent
    else
      res.inform(:status, {
                    status_type: 'APP_EVENT',
                    event: event_type.to_s.upcase,
                    app: app_id,
                    msg: msg,
                    seq: res.property.event_sequence,
                    uid: res.uid
                  }, :ALL) unless res.property.quiet
    end
end