[Dev] Adapter operations as new modules
Brett Wooldridge
bwooldridge at alterpoint.com
Tue Apr 8 21:56:36 CDT 2008
Very very cool. And thanks for the thorough explanation, even I could add an operation to an adapter now. :-)
-Brett
On 4/9/08 11:42 AM, "Leo Bayer" <lbayer at alterpoint.com> wrote:
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
_______________________________________________
Dev mailing list
Dev at ziptie.org
http://mailman.ziptie.org/listinfo/dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ziptie.org/pipermail/dev/attachments/20080408/9de317c3/attachment.html
More information about the Dev
mailing list