|constructor_defaults||This is an optional parameter which can be used to define a hashref of default parameters to pass to Net::SSH::Mechanize instances created by this class. These defaults can be overridden in individual cases.|
CW$hashref = $obj->constructor_defaults =head2 CW$obj->constructor_defaults(\%hashref)This is an read-write accessor which allows you to specify the default parameters to pass to the Net::SSH::Mechanize constructor. These defaults can be overridden in individual cases.
CW$hashref = $obj->namesThis is a hashref of connection names mapped to Net::SSH::Mechanize instances. It is not recommend you change this directly, use the ->add method instead.
CW$hashref = $obj->ssh_instancesThis is an arrayref listing Net::SSH::Mechanize instances we have created, in the order they have been defined via ->add (which is also the order they will be iterated over within ->in_parallel).
CW@mech_instances = $obj->add(%connections)Adds one or more named connection definitions.
%connections is a hash or list of name-value pairs defining what to connect to. The order in which they are defined here is preserved and used when iterating over them in ->in_parallel.
The names are simple string aliases, and can be anything unique (to this instance). If a duplicate is encountered, an exception will be thrown.
The values can be:
A list of the Net::SSH::Mechanize instances are returned, in the order they were defined.
<B><A B>Net::SSH::Mechanize<B> instanceB>> The instance will be used as given to connect to a host. <B><A B>Net::SSH::Mechanize::ConnectParams<B>B> instance>> The instance will be used to create a Net::SSH::Mechanize instance to use. <B>A hashref of constructor paramters for B>Net::SSH::Mechanize<B> B>> The hashref will be passed to Net::SSH::Mechanize->new to get an instance to use.
This method can be called any number of times, so long as the connection names are never duplicated.
CW@threads = $obj->in_parallel(@names, \&actions)This method accepts a list of host-names, and a callback. The callback should expect two parameters: a connection name, and a Net::SSH::Mechanize instance.
It first checks that all the names have been defined in an earlier ->add invocation. If any are unknown, an exception is thrown.
Otherwise, it iterates over the names in the order given, and invokes the callback with the name and the appropriate Net::SSH::Mechanize instance.
Note: the callback is invoked each time as a co-routine. See Coro and Coro::AnyEvent for more information about this, but it essentially means that each one is asynchronously run in parallel. This method returns a list of Coro threads, immediately, before the callbacks have completed.
Your program is then free to do other things, and/or call ->join on each of the threads to wait for their termination.
Nick Stokoe <firstname.lastname@example.org>
Copyright (c) 2011, Nick Stokoe <email@example.com>. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
|perl v5.20.3||NET::SSH::MECHANIZE::MULTI (3)||2016-04-03|