[Dev] Adapter operations as new modules
Leo Bayer
lbayer at alterpoint.com
Tue Apr 8 21:42:18 CDT 2008
I've updated the adapter invoker to allow two things.
1. The main invoker code is now in a module called
ZipTie::Adapters::Invoker. This allows operations to be easily invoked
arbitrarily from scripts. Specifically it allows script tools to invoke
operations without having to perform crazy evals.
2. The invoker now supports reading operations from modules other than
the main adapter modules. This allows new operations to be added to
adapters without having to touch the original adapter. This means new
operations don't even have to be in the same bundle as the original
adapter. (Third parties can define and implement operations without
modifying existing adapters. )
For example, to add a "restore" operation to the IOS adapter you can now
do one of two things:
First, you can do it the same way as before; create a sub in IOS.pm
called "restore".
Or, now you can create a new perl module anywhere that would be in the
perl path. This module would be called
ZipTie::Adapters::Cisco::IOS::Restore and have a sub called "invoke".
The "invoke" sub is written exactly the same way the "IOS->restore"
method would be written. (If there is a 'restore' sub and a 'Restore'
module, the invoker will use the main sub.)
Going forward this means that we don't need really long adapter files.
Instead of adding them to the end of really long files, each new
operation can be placed in its own module next to the other operations
modules.
Enjoy,
- Leo
More information about the Dev
mailing list