Security/Projects/Minion/PluginService: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
Line 17: Line 17:
{| border="1" cellpadding="1"
{| border="1" cellpadding="1"
|-
|-
! Op !! URL !! Method !! Notes
! Op !! URL !! Method !! Notes || Example response
|-
|-
| GET || /info || get_info || Get info about the PluginService (name/host and version)
| GET || /info || get_info || Get info about the PluginService (name/host and version) || {'version': 1, 'name': '127.0.0.1'}
|-
|-
| GET || /plugins <b>TODO</b> || get_plugins || List all of the Get info about the PluginService (name/host and version)
| 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)
| 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
| 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
| 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> <b>TODO</b> || set_plugin_value(session, key, value) <b>Should be set_session_value</b> || Sets a session value
| PUT || /session/<session>/value?key=<key>&value=<value> <b>TODO</b> || set_session_value(session, key, value) || Sets a session value
|-
|-
| DELETE || /session/<session> || terminate_session(session) || Terminates the specified session
| DELETE || /session/<session> || terminate_session(session) || Terminates the specified session

Revision as of 13:23, 23 October 2012

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.

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> TODO set_session_value(session, key, value) Sets a session value
DELETE /session/<session> terminate_session(session) Terminates the specified session
GET /session/<session>/config get_session_status(session) Get the status of the specified session
GET /session/<session>/status get_session_status(session) Get the status of the specified session
GET /session/<session>/states get_session_states(session) Returns the valid states the specified session can be set to
POST "/session/<session>/state/<state> set_session_states(session, state) Sets the session state - used for starting, stopping etc
GET /session/<session>/results TODO get_session_results(session) Returns the session results (which can be incomplete)


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