Security/Projects/Minion/PluginService

From MozillaWiki
Jump to: navigation, search

Minion Plugin Service

Overview

The Plugin Service is responsible for:

  • Providing a REST based API
  • Handling requests from trusted components (eg the Task Engine)
  • Communication with the Plugins
  • Threading requests

Notes

  • The PluginService basically provides an environment in which plugins can run.
  • The plugins run within this service, and it handles the threading and the external (REST) API.
  • The PluginService runs inline/in process
  • The PluginServiceRestAPI provides a wrapper around it so that is can run in a separate process, or even on another machine
  • The PluginServiceClient (not yet implemented;) should present the same API as PluginService, but use the REST API to communicate with a remote PluginService
  • Clients should be able to switch between PluginService and PluginServiceClient without any code changes (constructors will differ)

API

This is at a very early stage, so is still fairly fluid.

Op URL Method Notes Example response
GET /info get_info Get info about the PluginService (name/host and version) {'version': 1, 'name': '127.0.0.1'}
GET /plugins get_plugins List all of the Get info about the PluginService (name/host and version) {'plugins': [{'version': 1, 'type': 'WebApp', 'plugin': 'TemplatePlugin'}]}
GET /plugin/<plugin_name>/template get_plugin_template(plugin_name) Get the plugin template (which defines what params it needs/supports) {'template': {'target': {'type': 'url', 'required': True, 'is_list': True}}, 'safechecks': {'type': 'bool', 'value': True}}
GET /sessions get_sessions() Returns a list of all of the current sessions {'sessions': {'8db4b299106ea496c862ab3dff710155': {'status': {'status': 'PENDING', 'message': 'Plugin is pending execution.', 'success': True}, 'plugin_name': 'TemplatePlugin'}}}
PUT /session/create/<plugin_name> create_session(plugin_name) Create a session with the specified plugin {'message': "Created new session for plugin 'TemplatePlugin'", 'session': '8db4b299106ea496c862ab3dff710155'}
PUT /session/<session>/value?key=<key>&value=<value> set_session_value(session, key, value) Sets a session value None
DELETE /session/<session> terminate_session(session) Terminates the specified session {'message': 'Session terminated', 'session': '9ba4c151b3f20690390e39bc3c3b98ae'}
GET /session/<session>/status get_session_status(session) Get the status of the specified session {'status': 'PENDING', 'message': 'Plugin is pending execution.', 'success': True}
GET /session/<session>/states get_session_states(session) Returns the valid states the specified session can be set to ['START']
POST "/session/<session>/state/<state> set_session_states(session, state) Sets the session state - used for starting, stopping etc {'status': 'RUNNING', 'message': 'Plugin started: Execution is in progress.', 'success': True}
GET /session/<session>/results get_session_results(session) Returns the session results (which can be incomplete) {'issues': [ <issues - defn TBA> ]}


A typical basic sequence of calls might be:

  1. get_info - to find out the services name and its version (the API will probably change between versions;)
  2. get_plugins() - to see what plugins are available
  3. get_plugin_template(plugin_name) - to find out what parameters are needed
  4. create_session(plugin_name) - to create a new session with the specified plugin (returns the session id)
  5. set_plugin_value(session, key, value) - called potentially multiple times to set the configuration values
  6. set_session_states(session, MinionPlugin.STATE_START) - start the plugin
  7. get_session_status(session) - to monitor how its progressing
  8. get_session_results(session) - to get the results (partial results may be available before the plugin completes, depending on the plugin)

Main Classes

PluginService

This is the guts of the plugin service, and will implement (or control) all of the functionality.

It can be run 'inline' for testing / development purposes.

PluginServiceRestApi

This is a wrapper around the PluginService, and provides a simple REST API.

At some point this will become a 'proper' stand alone service.

PluginServiceClient

This provides the same interface as the PluginService, but communicates with a separate plugin service process via the REST API.

Clients should be able to switch between the PluginService and the PluginServiceClient without having to make any changes.

Notes

  • TBA