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:
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.
Create a basic device dictionary with optional data.
Call store_results directly
(Maybe) convert Juniper XML results into a strings
Return a list of command objects.
[{‘command’: ‘foo’, ‘result’: ‘bar’}, ...]
Loop periodically or until the factory stops to monitor the results and return them.
Called when an errback is fired.
Should do somethign meaningful with the errors, but for now just stores it as it would a result.
This package provides facilities for running commands on devices using the CLI. Plugins for the Commando API built around Trigger.
This package provides facilities for running commands on devices using the CLI.
Base class for docommand action classes.
Call store_results without calling map_results
Run commands on network devices.
Usage:
n = CommandRunner(devices=['dev1', dev2'], files=['file1', 'file2'])
n.run()
This will execute all commands inside of each file (‘file1’,’file2’) onto all listed devices (‘dev1, ‘dev2’).
Parameters: |
|
---|
Define how we’re storing results.
Load configuration changes on network devices.
Usage:
n = ConfigLoader(devices=['dev1', dev2'], files=['file1', 'file2'])
n.run()
This will load all listed config files (‘file1’,’file2’) onto all listed devices (‘dev1, ‘dev2’).
Parameters: | files – List of files named after the FQDN of each device.
|
---|
Parse results from a Juniper device.
Store the results from a commands.
If you’d rather just change the default method for storing results, overload this. All default parse/generate methods call this.
Configure a Juniper device using JunoScript.
Returns: | list |
---|
Display XML in a tree format.
Parameters: |
|
---|
list results = do_work(list work)
list commands = get_commands_from_opts(dict opts)
User specified on cmdline either a path to a file containing a list of commands/config or an actual list. Return the list!
list devicenames = get_devices_from_opts(dict opts)
User specified on cmdline either a path to a file containing a list of devices or an actual list. Return the list!
list devicenames = get_devices_from_path(str path)
If path specified for devices/configs, then the list of filenames in dir will correspond to the list of devices.
The contents of each file contain the config/commands to be loaded/run on the specific device.
Future enhancements
list jobs = get_jobs(dict opts)
Based on which arguments are provided, figure out what is loaded/run on which devices and create a list of objects matching the 2:
job = {'d': [],'c': [],'f': []}
Is read as “load ALL configs listed in ‘c’ on ALL devs listed in ‘d’”. Each such grouping is a separate job.
Future enhancements:
list text = get_list_from_file(str path)
Specified file (path) will contain a list of newline-separated items. This function is used for loading both configs/cmds as well as devices.
void = main(CommandoClass action_class)
binary success = print_results(list results)
void = do_work(list work)
Cycle through the list of jobs and then display the work to be done.
Need to edit this for cmds, not just acls, but the basic idea is borrowed from bin/load_acl.
Validate opts and return whether they are ok.
returns True if all is good, otherwise (False, errormsg)
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.
Twisted XMLRPC server front-end for Commando
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.
Add multiple handlers
Return a list of the registered procedures
Lookup a method dynamically.
Adds x and y
Add a handler object from a remote call.
Execute commands on devices
Raise a Fault indicating that the procedure should not be used.
To daemonize as a twistd plugin! Except this doesn’t work and these