trigger.contrib — Extra, optional tools that solve common problems, extend, or modify core functionality.

trigger.contrib.commando.

Simple command running for Trigger meant to be used with a long-running reactor loop (such using the Twisted XMLRPC server).

This differs from Commando in that:

  • It does not start/stop the reactor, instead it uses sentinel values and a task monitor to detect when it’s done.

  • The .run() method returns a twisted.internet.defer.Deferred object.

  • Results/errors are stored in a list instead of a dict.

  • Each result object is meant to be easily serialized (e.g. to JSON).

class trigger.contrib.commando.CommandoApplication(*args, **kwargs)

Commando subclass to be used in an application where the reactor is always running (e.g. twistd or an application server).

Stores results as a list of dictionaries ideal for serializing to JSON.

device_object(device_name, **kwargs)

Create a basic device dictionary with optional data.

from_base(results, device, commands=None)

Call store_results directly.

from_juniper(results, device, commands=None)

(Maybe) convert Juniper XML results into a strings.

map_results(commands=None, results=None)

Return a list of command objects.

[{‘command’: ‘foo’, ‘result’: ‘bar’}, …]

monitor_result(result, reactor)

Loop periodically or until the factory stops to monitor the results and return them.

run()

Nothing happens until you execute this to perform the actual work.

store_error(device, error)

Called when an errback is fired.

Should do somethign meaningful with the errors, but for now just stores it as it would a result.

store_results(device, results)

Called by the parse (from) methods to store command output.

Device:

A NetDevice object

Parameters:

results – The results to store. Anything you want really.

trigger.contrib.commando.plugins.

This package provides facilities for running commands on devices using the CLI. Plugins for the Commando API built around Trigger.

trigger.contrib.xmlrpc.

XMLRPC Server for Trigger with SSH manhole service.

Trigger Twisted XMLRPC server with an SSH manhole. Supports SSL.

This provides a daemonized Twisted reactor loop, Trigger and client applications do not have to co-habitate. Using the XMLRPC server model, all Trigger compatibility tasks can be executed using simple XMLRPC clients that call the appropriate method with arguments on the local XMLRPC server instance.

New methods can be added by way of plugins.

See examples/xmlrpc_server in the Trigger source distribution for a simple usage example.

class trigger.contrib.xmlrpc.server.TriggerXMLRPCServer(*args, **kwargs)

Twisted XMLRPC server front-end for Commando.

addHandler(handler)

Add a handler and bind it to an XMLRPC procedure.

Handler must a be a function or an instance of an object with handler methods.

addHandlers(handlers)

Add multiple handlers.

listProcedures()

Return a list of the registered procedures.

lookupProcedure(procedurePath)

Lookup a method dynamically.

  1. First, see if it’s provided by a sub-handler.

  2. Or try a self-defined method (prefixed with xmlrpc_)

  3. Lastly, try dynamically mapped methods.

  4. Or fail loudly.

xmlrpc_add(x, y)

Adds x and y.

xmlrpc_add_handler(mod_name, task_name, force=False)

Add a handler object from a remote call.

xmlrpc_execute_commands(args, kwargs)

Execute commands on devices.

xmlrpc_fault()

Raise a Fault indicating that the procedure should not be used.

trigger.contrib.xmlrpc.server.main()

To daemonize as a twistd plugin! Except this doesn’t work and these.