diff options
author | delano <delano@solutious.com> | 2011-04-03 16:39:47 -0400 |
---|---|---|
committer | delano <delano@solutious.com> | 2011-04-03 16:39:47 -0400 |
commit | 73d75b2c3a5465392fd6210dbb844c49dd043cdc (patch) | |
tree | 23d48166dce070d8a517b0d3551a82a6bb1c8efa /classes/Net | |
parent | bfa11f12ba9af1862a0deaf6681de7739f108141 (diff) | |
download | net-ssh-multi-73d75b2c3a5465392fd6210dbb844c49dd043cdc.tar.gz |
Updated docs
Diffstat (limited to 'classes/Net')
-rw-r--r-- | classes/Net/SSH.html | 87 | ||||
-rw-r--r-- | classes/Net/SSH/Multi.html | 154 | ||||
-rw-r--r-- | classes/Net/SSH/Multi/Channel.html | 537 | ||||
-rw-r--r-- | classes/Net/SSH/Multi/ChannelProxy.html | 166 | ||||
-rw-r--r-- | classes/Net/SSH/Multi/DynamicServer.html | 241 | ||||
-rw-r--r-- | classes/Net/SSH/Multi/PendingConnection.html | 306 | ||||
-rw-r--r-- | classes/Net/SSH/Multi/Server.html | 438 | ||||
-rw-r--r-- | classes/Net/SSH/Multi/ServerList.html | 224 | ||||
-rw-r--r-- | classes/Net/SSH/Multi/Session.html | 560 | ||||
-rw-r--r-- | classes/Net/SSH/Multi/SessionActions.html | 272 | ||||
-rw-r--r-- | classes/Net/SSH/Multi/Subsession.html | 169 | ||||
-rw-r--r-- | classes/Net/SSH/Multi/Version.html | 117 |
12 files changed, 3271 insertions, 0 deletions
diff --git a/classes/Net/SSH.html b/classes/Net/SSH.html new file mode 100644 index 0000000..241010c --- /dev/null +++ b/classes/Net/SSH.html @@ -0,0 +1,87 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html lang='en'> + <head> + <title>: Net::SSH [Control multiple Net::SSH connections via a single interface.]</title> + <meta content='text/html; charset=utf-8' http-equiv='Content-Type'> + <link href='../../rdoc-style.css' media='screen' rel='stylesheet' type='text/css'> + <script type='text/javascript'> + //<![CDATA[ + function popupCode(url) { + window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") + } + + function toggleCode(id) { + var code = document.getElementById(id) + + code.style.display = code.style.display != 'block' ? 'block' : 'none' + return true + } + + // Make codeblocks hidden by default + document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>') + //]]> + </script> + </head> + <body class='page'> + <div class='class' id='wrapper'> + <div class='header'> + <h1 class='name'> + <span class='type'>Module</span> + Net::SSH + </h1> + <ol class='paths'> + <li> + <a href="../../files/lib/net/ssh/multi/channel_rb.html">lib/net/ssh/multi/channel.rb</a> + </li> + <li class='other'> + <a href="../../files/lib/net/ssh/multi/channel_proxy_rb.html">lib/net/ssh/multi/channel_proxy.rb</a> + </li> + <li class='other'> + <a href="../../files/lib/net/ssh/multi/dynamic_server_rb.html">lib/net/ssh/multi/dynamic_server.rb</a> + </li> + <li class='other'> + <a href="../../files/lib/net/ssh/multi/pending_connection_rb.html">lib/net/ssh/multi/pending_connection.rb</a> + </li> + <li class='other'> + <a href="../../files/lib/net/ssh/multi/server_rb.html">lib/net/ssh/multi/server.rb</a> + </li> + <li class='other'> + <a href="../../files/lib/net/ssh/multi/server_list_rb.html">lib/net/ssh/multi/server_list.rb</a> + </li> + <li class='other'> + <a href="../../files/lib/net/ssh/multi/session_actions_rb.html">lib/net/ssh/multi/session_actions.rb</a> + </li> + <li class='other'> + <a href="../../files/lib/net/ssh/multi/session_rb.html">lib/net/ssh/multi/session.rb</a> + </li> + <li class='other'> + <a href="../../files/lib/net/ssh/multi/subsession_rb.html">lib/net/ssh/multi/subsession.rb</a> + </li> + <li class='other'> + <a href="../../files/lib/net/ssh/multi/version_rb.html">lib/net/ssh/multi/version.rb</a> + </li> + <li class='other'> + <a href="../../files/lib/net/ssh/multi_rb.html">lib/net/ssh/multi.rb</a> + </li> + <li> + <a class='show' href='#' onclick='this.parentNode.parentNode.className += " expanded"; this.parentNode.removeChild(this); return false'>show all</a> + </li> + </ol> + </div> + <div id='content'> + <div id='text'> + <div id='section'> + <div id='class-list'> + <h2>Classes and Modules</h2> + Module <a href="SSH/Multi.html" class="link">Net::SSH::Multi</a><br /> + </div> + </div> + </div> + </div> + <div id='footer-push'></div> + </div> + <div id='footer'> + <a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a> + </div> + </body> +</html> diff --git a/classes/Net/SSH/Multi.html b/classes/Net/SSH/Multi.html new file mode 100644 index 0000000..2fd28f8 --- /dev/null +++ b/classes/Net/SSH/Multi.html @@ -0,0 +1,154 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html lang='en'> + <head> + <title>: Net::SSH::Multi [Control multiple Net::SSH connections via a single interface.]</title> + <meta content='text/html; charset=utf-8' http-equiv='Content-Type'> + <link href='../../../rdoc-style.css' media='screen' rel='stylesheet' type='text/css'> + <script type='text/javascript'> + //<![CDATA[ + function popupCode(url) { + window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") + } + + function toggleCode(id) { + var code = document.getElementById(id) + + code.style.display = code.style.display != 'block' ? 'block' : 'none' + return true + } + + // Make codeblocks hidden by default + document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>') + //]]> + </script> + </head> + <body class='page'> + <div class='class' id='wrapper'> + <div class='header'> + <h1 class='name'> + <span class='type'>Module</span> + Net::SSH::Multi + </h1> + <ol class='paths'> + <li> + <a href="../../../files/lib/net/ssh/multi/channel_rb.html">lib/net/ssh/multi/channel.rb</a> + </li> + <li class='other'> + <a href="../../../files/lib/net/ssh/multi/channel_proxy_rb.html">lib/net/ssh/multi/channel_proxy.rb</a> + </li> + <li class='other'> + <a href="../../../files/lib/net/ssh/multi/dynamic_server_rb.html">lib/net/ssh/multi/dynamic_server.rb</a> + </li> + <li class='other'> + <a href="../../../files/lib/net/ssh/multi/pending_connection_rb.html">lib/net/ssh/multi/pending_connection.rb</a> + </li> + <li class='other'> + <a href="../../../files/lib/net/ssh/multi/server_rb.html">lib/net/ssh/multi/server.rb</a> + </li> + <li class='other'> + <a href="../../../files/lib/net/ssh/multi/server_list_rb.html">lib/net/ssh/multi/server_list.rb</a> + </li> + <li class='other'> + <a href="../../../files/lib/net/ssh/multi/session_actions_rb.html">lib/net/ssh/multi/session_actions.rb</a> + </li> + <li class='other'> + <a href="../../../files/lib/net/ssh/multi/session_rb.html">lib/net/ssh/multi/session.rb</a> + </li> + <li class='other'> + <a href="../../../files/lib/net/ssh/multi/subsession_rb.html">lib/net/ssh/multi/subsession.rb</a> + </li> + <li class='other'> + <a href="../../../files/lib/net/ssh/multi/version_rb.html">lib/net/ssh/multi/version.rb</a> + </li> + <li class='other'> + <a href="../../../files/lib/net/ssh/multi_rb.html">lib/net/ssh/multi.rb</a> + </li> + <li> + <a class='show' href='#' onclick='this.parentNode.parentNode.className += " expanded"; this.parentNode.removeChild(this); return false'>show all</a> + </li> + </ol> + </div> + <div id='content'> + <div id='text'> + <div id='description'> + <p> + <a href="Multi.html">Net::SSH::Multi</a> is a library for controlling + multiple <a href="../SSH.html">Net::SSH</a> connections via a single + interface. It exposes an API similar to that of + Net::SSH::Connection::Session and Net::SSH::Connection::Channel, making it + simpler to adapt programs designed for single connections to be used with + multiple connections. + </p> + <p> + This library is particularly useful for automating repetitive tasks that + must be performed on multiple machines. It executes the commands in + parallel, and allows commands to be executed on subsets of servers (defined + by groups). + </p> + <pre>require 'net/ssh/multi'

Net::SSH::Multi.start do |session|
 # access servers via a gateway
 session.via 'gateway', 'gateway-user'

 # define the servers we want to use
 session.use 'user1@host1'
 session.use 'user2@host2'

 # define servers in groups for more granular access
 session.group :app do
 session.use 'user@app1'
 session.use 'user@app2'
 end

 # execute commands on all servers
 session.exec "uptime"

 # execute commands on a subset of servers
 session.with(:app).exec "hostname"

 # run the aggregated event loop
 session.loop
end</pre> + <p> + See <a href="Multi/Session.html">Net::SSH::Multi::Session</a> for more + documentation. + </p> + </div> + <div id='method-list'> + <h2>Methods</h2> + <h3>public class</h3> + <ol> + <li><a href="#M000001">start</a></li> + </ol> + </div> + <div id='section'> + <div id='class-list'> + <h2>Classes and Modules</h2> + Module <a href="Multi/SessionActions.html" class="link">Net::SSH::Multi::SessionActions</a><br /> + Class <a href="Multi/Channel.html" class="link">Net::SSH::Multi::Channel</a><br /> + Class <a href="Multi/ChannelProxy.html" class="link">Net::SSH::Multi::ChannelProxy</a><br /> + Class <a href="Multi/DynamicServer.html" class="link">Net::SSH::Multi::DynamicServer</a><br /> + Class <a href="Multi/PendingConnection.html" class="link">Net::SSH::Multi::PendingConnection</a><br /> + Class <a href="Multi/Server.html" class="link">Net::SSH::Multi::Server</a><br /> + Class <a href="Multi/ServerList.html" class="link">Net::SSH::Multi::ServerList</a><br /> + Class <a href="Multi/Session.html" class="link">Net::SSH::Multi::Session</a><br /> + Class <a href="Multi/Subsession.html" class="link">Net::SSH::Multi::Subsession</a><br /> + Class <a href="Multi/Version.html" class="link">Net::SSH::Multi::Version</a><br /> + </div> + <div id='methods'> + <h2>Public class methods</h2> + <div class='method public-class' id='method-M000001'> + <a name='M000001'> </a> + <div class='synopsis'> + <span class='name'>start</span> + <span class='arguments'>(options={}) {|session| ...}</span> + </div> + <div class='description'> + <p> + This is a convenience method for instantiating a new <a + href="Multi/Session.html">Net::SSH::Multi::Session</a>. If a block is + given, the session will be yielded to the block automatically closed (see + <a href="Multi/Session.html#M000074">Net::SSH::Multi::Session#close</a>) + when the block finishes. Otherwise, the new session will be returned. + </p> + <pre>Net::SSH::Multi.start do |session|
 # ...
end

session = Net::SSH::Multi.start
# ...
session.close</pre> + <p> + Any options are passed directly to <a + href="Multi/Session.html#M000066">Net::SSH::Multi::Session.new</a> (q.v.). + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000001-source'); return false"> + [show source] + </a> + <pre id='M000001-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi.rb, line 57</span>
57: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">start</span>(<span class="ruby-identifier">options</span>={})
58: <span class="ruby-identifier">session</span> = <span class="ruby-constant">Session</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>)
59: 
60: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
61: <span class="ruby-keyword kw">begin</span>
62: <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">session</span>
63: <span class="ruby-identifier">session</span>.<span class="ruby-identifier">loop</span>
64: <span class="ruby-identifier">session</span>.<span class="ruby-identifier">close</span>
65: <span class="ruby-keyword kw">end</span>
66: <span class="ruby-keyword kw">else</span>
67: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">session</span>
68: <span class="ruby-keyword kw">end</span>
69: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + </div> + </div> + </div> + </div> + <div id='footer-push'></div> + </div> + <div id='footer'> + <a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a> + </div> + </body> +</html> diff --git a/classes/Net/SSH/Multi/Channel.html b/classes/Net/SSH/Multi/Channel.html new file mode 100644 index 0000000..779b48c --- /dev/null +++ b/classes/Net/SSH/Multi/Channel.html @@ -0,0 +1,537 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html lang='en'> + <head> + <title>: Net::SSH::Multi::Channel [Control multiple Net::SSH connections via a single interface.]</title> + <meta content='text/html; charset=utf-8' http-equiv='Content-Type'> + <link href='../../../../rdoc-style.css' media='screen' rel='stylesheet' type='text/css'> + <script type='text/javascript'> + //<![CDATA[ + function popupCode(url) { + window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") + } + + function toggleCode(id) { + var code = document.getElementById(id) + + code.style.display = code.style.display != 'block' ? 'block' : 'none' + return true + } + + // Make codeblocks hidden by default + document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>') + //]]> + </script> + </head> + <body class='page'> + <div class='class' id='wrapper'> + <div class='header'> + <h1 class='name'> + <span class='type'>Class</span> + Net::SSH::Multi::Channel + </h1> + <ol class='paths'> + <li> + <a href="../../../../files/lib/net/ssh/multi/channel_rb.html">lib/net/ssh/multi/channel.rb</a> + </li> + </ol> + <div class='parent'> + Parent: + <strong>Object</strong> + </div> + </div> + <div id='content'> + <div id='text'> + <div id='description'> + <p> + <a href="Channel.html">Net::SSH::Multi::Channel</a> encapsulates a + collection of Net::SSH::Connection::Channel instances from multiple + different connections. It allows for operations to be performed on all + contained channels, simultaneously, using an interface mostly identical to + Net::SSH::Connection::Channel itself. + </p> + <p> + You typically obtain a <a href="Channel.html">Net::SSH::Multi::Channel</a> + instance via Net::SSH::Multi::Session#open_channel or + Net::SSH::Multi::Session#exec, though there is nothing stopping you from + instantiating one yourself with a handful of Net::SSH::Connection::Channel + objects (though they should be associated with connections managed by a <a + href="Session.html">Net::SSH::Multi::Session</a> object for consistent + behavior). + </p> + <pre>channel = session.open_channel do |ch|
 # ...
end

channel.wait</pre> + </div> + <div id='method-list'> + <h2>Methods</h2> + <h3>public class</h3> + <ol> + <li><a href="#M000009">new</a></li> + </ol> + <h3>public instance</h3> + <ol> + <li><a href="#M000011">[]</a></li> + <li><a href="#M000012">[]=</a></li> + <li><a href="#M000016">active?</a></li> + <li><a href="#M000018">close</a></li> + <li><a href="#M000010">each</a></li> + <li><a href="#M000019">eof!</a></li> + <li><a href="#M000013">exec</a></li> + <li><a href="#M000023">on_close</a></li> + <li><a href="#M000020">on_data</a></li> + <li><a href="#M000024">on_eof</a></li> + <li><a href="#M000021">on_extended_data</a></li> + <li><a href="#M000025">on_open_failed</a></li> + <li><a href="#M000022">on_process</a></li> + <li><a href="#M000026">on_request</a></li> + <li><a href="#M000014">request_pty</a></li> + <li><a href="#M000015">send_data</a></li> + <li><a href="#M000017">wait</a></li> + </ol> + </div> + <div id='context'> + <div id='includes'> + <h2>Included modules</h2> + <ol> + <li>Enumerable</li> + </ol> + </div> + </div> + <div id='section'> + <div id='attribute-list'> + <h2 class='section-bar'>Attributes</h2> + <div class='name-list'> + <table> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>channels</td> + <td class='context-item-value'>[R]</td> + <td class='context-item-desc'> + + The collection of Net::SSH::Connection::Channel instances that this + multi-channel aggregates. + </td> + </tr> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>connection</td> + <td class='context-item-value'>[R]</td> + <td class='context-item-desc'> + + The <a href="Session.html">Net::SSH::Multi::Session</a> instance that + controls this channel collection. + </td> + </tr> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>properties</td> + <td class='context-item-value'>[R]</td> + <td class='context-item-desc'> + + A Hash of custom properties that may be set and queried on this object. + </td> + </tr> + </table> + </div> + </div> + <div id='methods'> + <h2>Public class methods</h2> + <div class='method public-class' id='method-M000009'> + <a name='M000009'> </a> + <div class='synopsis'> + <span class='name'>new</span> + <span class='arguments'>(connection, channels)</span> + </div> + <div class='description'> + <p> + Instantiate a new <a href="Channel.html">Net::SSH::Multi::Channel</a> + instance, controlled by the given <tt>connection</tt> (a <a + href="Session.html">Net::SSH::Multi::Session</a> object) and wrapping the + given <tt>channels</tt> (Net::SSH::Connection::Channel instances). + </p> + <p> + You will typically never call this directly; rather, you’ll get your + multi-channel references via Net::SSH::Multi::Session#open_channel and + friends. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000009-source'); return false"> + [show source] + </a> + <pre id='M000009-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/channel.rb, line 38</span>
38: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">connection</span>, <span class="ruby-identifier">channels</span>)
39: <span class="ruby-ivar">@connection</span> = <span class="ruby-identifier">connection</span>
40: <span class="ruby-ivar">@channels</span> = <span class="ruby-identifier">channels</span>
41: <span class="ruby-ivar">@properties</span> = {}
42: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <h2>Public instance methods</h2> + <div class='method public-instance' id='method-M000011'> + <a name='M000011'> </a> + <div class='synopsis'> + <span class='name'>[]</span> + <span class='arguments'>(key)</span> + </div> + <div class='description'> + <p> + Retrieve the property (see properties) with the given <tt>key</tt>. + </p> + <pre>host = channel[:host]</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000011-source'); return false"> + [show source] + </a> + <pre id='M000011-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/channel.rb, line 53</span>
53: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">[]</span>(<span class="ruby-identifier">key</span>)
54: <span class="ruby-ivar">@properties</span>[<span class="ruby-identifier">key</span>]
55: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000012'> + <a name='M000012'> </a> + <div class='synopsis'> + <span class='name'>[]=</span> + <span class='arguments'>(key, value)</span> + </div> + <div class='description'> + <p> + Set the property (see properties) with the given <tt>key</tt> to the given + <tt>value</tt>. + </p> + <pre>channel[:visited] = true</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000012-source'); return false"> + [show source] + </a> + <pre id='M000012-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/channel.rb, line 61</span>
61: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">[]=</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>)
62: <span class="ruby-ivar">@properties</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>
63: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000016'> + <a name='M000016'> </a> + <div class='synopsis'> + <span class='name'>active?</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Returns true as long as any of the component channels are active. + </p> + <pre>connection.loop { channel.active? }</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000016-source'); return false"> + [show source] + </a> + <pre id='M000016-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/channel.rb, line 112</span>
112: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">active?</span>
113: <span class="ruby-identifier">channels</span>.<span class="ruby-identifier">any?</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">channel</span><span class="ruby-operator">|</span> <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">active?</span> }
114: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000018'> + <a name='M000018'> </a> + <div class='synopsis'> + <span class='name'>close</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Closes all component channels. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000018-source'); return false"> + [show source] + </a> + <pre id='M000018-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/channel.rb, line 127</span>
127: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">close</span>
128: <span class="ruby-identifier">channels</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">channel</span><span class="ruby-operator">|</span> <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">close</span> }
129: <span class="ruby-keyword kw">self</span>
130: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000010'> + <a name='M000010'> </a> + <div class='synopsis'> + <span class='name'>each</span> + <span class='arguments'>() {|channel| ...}</span> + </div> + <div class='description'> + <p> + Iterate over each component channel object, yielding each in order to the + associated block. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000010-source'); return false"> + [show source] + </a> + <pre id='M000010-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/channel.rb, line 46</span>
46: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each</span>
47: <span class="ruby-ivar">@channels</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">channel</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">channel</span> }
48: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000019'> + <a name='M000019'> </a> + <div class='synopsis'> + <span class='name'>eof!</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Tells the remote process for each component channel not to expect any + further data from this end of the channel. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000019-source'); return false"> + [show source] + </a> + <pre id='M000019-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/channel.rb, line 134</span>
134: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">eof!</span>
135: <span class="ruby-identifier">channels</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">channel</span><span class="ruby-operator">|</span> <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">eof!</span> }
136: <span class="ruby-keyword kw">self</span>
137: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000013'> + <a name='M000013'> </a> + <div class='synopsis'> + <span class='name'>exec</span> + <span class='arguments'>(command, &block)</span> + </div> + <div class='description'> + <p> + Perform an <tt>exec</tt> command on all component channels. The block, if + given, is passed to each component channel, so it will (potentially) be + invoked once for every channel in the collection. The block will receive + two parameters: the specific channel object being operated on, and a + boolean indicating whether the exec succeeded or not. + </p> + <pre>channel.exec "ls -l" do |ch, success|
 # ...
end</pre> + <p> + See the documentation in <a href="../../SSH.html">Net::SSH</a> for + Net::SSH::Connection::Channel#exec for more information on how to work with + the callback. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000013-source'); return false"> + [show source] + </a> + <pre id='M000013-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/channel.rb, line 77</span>
77: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">exec</span>(<span class="ruby-identifier">command</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
78: <span class="ruby-identifier">channels</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">channel</span><span class="ruby-operator">|</span> <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">exec</span>(<span class="ruby-identifier">command</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>) }
79: <span class="ruby-keyword kw">self</span>
80: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000023'> + <a name='M000023'> </a> + <div class='synopsis'> + <span class='name'>on_close</span> + <span class='arguments'>(&block)</span> + </div> + <div class='description'> + <p> + Registers a callback on all component channels, to be invoked when the + remote server terminates the channel. The callback will be invoked with one + argument: the specific channel object being closed. + </p> + <pre>channel.on_close do |ch|
 # ...
end</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000023-source'); return false"> + [show source] + </a> + <pre id='M000023-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/channel.rb, line 185</span>
185: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">on_close</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
186: <span class="ruby-identifier">channels</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">channel</span><span class="ruby-operator">|</span> <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">on_close</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>) }
187: <span class="ruby-keyword kw">self</span>
188: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000020'> + <a name='M000020'> </a> + <div class='synopsis'> + <span class='name'>on_data</span> + <span class='arguments'>(&block)</span> + </div> + <div class='description'> + <p> + Registers a callback on all component channels, to be invoked when the + remote process emits data (usually on its <tt>stdout</tt> stream). The + block will be invoked with two arguments: the specific channel object, and + the data that was received. + </p> + <pre>channel.on_data do |ch, data|
 puts "got data: #{data}"
end</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000020-source'); return false"> + [show source] + </a> + <pre id='M000020-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/channel.rb, line 147</span>
147: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">on_data</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
148: <span class="ruby-identifier">channels</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">channel</span><span class="ruby-operator">|</span> <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">on_data</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>) }
149: <span class="ruby-keyword kw">self</span>
150: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000024'> + <a name='M000024'> </a> + <div class='synopsis'> + <span class='name'>on_eof</span> + <span class='arguments'>(&block)</span> + </div> + <div class='description'> + <p> + Registers a callback on all component channels, to be invoked when the + remote server has no further data to send. The callback will be invoked + with one argument: the specific channel object being marked EOF. + </p> + <pre>channel.on_eof do |ch|
 # ...
end</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000024-source'); return false"> + [show source] + </a> + <pre id='M000024-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/channel.rb, line 197</span>
197: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">on_eof</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
198: <span class="ruby-identifier">channels</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">channel</span><span class="ruby-operator">|</span> <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">on_eof</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>) }
199: <span class="ruby-keyword kw">self</span>
200: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000021'> + <a name='M000021'> </a> + <div class='synopsis'> + <span class='name'>on_extended_data</span> + <span class='arguments'>(&block)</span> + </div> + <div class='description'> + <p> + Registers a callback on all component channels, to be invoked when the + remote process emits “extended” data (typically on its + <tt>stderr</tt> stream). The block will be invoked with three arguments: + the specific channel object, an integer describing the data type (usually a + 1 for <tt>stderr</tt>) and the data that was received. + </p> + <pre>channel.on_extended_data do |ch, type, data|
 puts "got extended data: #{data}"
end</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000021-source'); return false"> + [show source] + </a> + <pre id='M000021-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/channel.rb, line 161</span>
161: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">on_extended_data</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
162: <span class="ruby-identifier">channels</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">channel</span><span class="ruby-operator">|</span> <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">on_extended_data</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>) }
163: <span class="ruby-keyword kw">self</span>
164: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000025'> + <a name='M000025'> </a> + <div class='synopsis'> + <span class='name'>on_open_failed</span> + <span class='arguments'>(&block)</span> + </div> + <div class='description'> + <p> + Registers a callback on all component channels, to be invoked when the + remote server is unable to open the channel. The callback will be invoked + with three arguments: the channel object that couldn’t be opened, a + description of the error (as a string), and an integer code representing + the error. + </p> + <pre>channel.on_open_failed do |ch, description, code|
 # ...
end</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000025-source'); return false"> + [show source] + </a> + <pre id='M000025-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/channel.rb, line 211</span>
211: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">on_open_failed</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
212: <span class="ruby-identifier">channels</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">channel</span><span class="ruby-operator">|</span> <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">on_open_failed</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>) }
213: <span class="ruby-keyword kw">self</span>
214: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000022'> + <a name='M000022'> </a> + <div class='synopsis'> + <span class='name'>on_process</span> + <span class='arguments'>(&block)</span> + </div> + <div class='description'> + <p> + Registers a callback on all component channels, to be invoked during the + idle portion of the connection event loop. The callback will be invoked + with one argument: the specific channel object being processed. + </p> + <pre>channel.on_process do |ch|
 # ...
end</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000022-source'); return false"> + [show source] + </a> + <pre id='M000022-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/channel.rb, line 173</span>
173: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">on_process</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
174: <span class="ruby-identifier">channels</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">channel</span><span class="ruby-operator">|</span> <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">on_process</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>) }
175: <span class="ruby-keyword kw">self</span>
176: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000026'> + <a name='M000026'> </a> + <div class='synopsis'> + <span class='name'>on_request</span> + <span class='arguments'>(type, &block)</span> + </div> + <div class='description'> + <p> + Registers a callback on all component channels, to be invoked when the + remote server sends a channel request of the given <tt>type</tt>. The + callback will be invoked with two arguments: the specific channel object + receiving the request, and a Net::SSH::Buffer instance containing the + request-specific data. + </p> + <pre>channel.on_request("exit-status") do |ch, data|
 puts "exited with #{data.read_long}"
end</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000026-source'); return false"> + [show source] + </a> + <pre id='M000026-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/channel.rb, line 225</span>
225: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">on_request</span>(<span class="ruby-identifier">type</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
226: <span class="ruby-identifier">channels</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">channel</span><span class="ruby-operator">|</span> <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">on_request</span>(<span class="ruby-identifier">type</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>) }
227: <span class="ruby-keyword kw">self</span>
228: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000014'> + <a name='M000014'> </a> + <div class='synopsis'> + <span class='name'>request_pty</span> + <span class='arguments'>(opts={}, &block)</span> + </div> + <div class='description'> + <p> + Perform a <tt><a href="Channel.html#M000014">request_pty</a></tt> command + on all component channels. The block, if given, is passed to each component + channel, so it will (potentially) be invoked once for every channel in the + collection. The block will receive two parameters: the specific channel + object being operated on, and a boolean indicating whether the pty request + succeeded or not. + </p> + <pre>channel.request_pty do |ch, success|
 # ...
end</pre> + <p> + See the documentation in <a href="../../SSH.html">Net::SSH</a> for + Net::SSH::Connection::Channel#request_pty for more information on how to + work with the callback. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000014-source'); return false"> + [show source] + </a> + <pre id='M000014-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/channel.rb, line 95</span>
95: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request_pty</span>(<span class="ruby-identifier">opts</span>={}, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
96: <span class="ruby-identifier">channels</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">channel</span><span class="ruby-operator">|</span> <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">request_pty</span>(<span class="ruby-identifier">opts</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>) }
97: <span class="ruby-keyword kw">self</span>
98: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000015'> + <a name='M000015'> </a> + <div class='synopsis'> + <span class='name'>send_data</span> + <span class='arguments'>(data)</span> + </div> + <div class='description'> + <p> + Send the given <tt>data</tt> to each component channel. It will be sent to + the remote process, typically being received on the process’ + <tt>stdin</tt> stream. + </p> + <pre>channel.send_data "password\n"</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000015-source'); return false"> + [show source] + </a> + <pre id='M000015-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/channel.rb, line 104</span>
104: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_data</span>(<span class="ruby-identifier">data</span>)
105: <span class="ruby-identifier">channels</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">channel</span><span class="ruby-operator">|</span> <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">send_data</span>(<span class="ruby-identifier">data</span>) }
106: <span class="ruby-keyword kw">self</span>
107: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000017'> + <a name='M000017'> </a> + <div class='synopsis'> + <span class='name'>wait</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Runs the connection’s event loop until the channel is no longer + active (see <a href="Channel.html#M000016">active?</a>). + </p> + <pre>channel.exec "something"
channel.wait</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000017-source'); return false"> + [show source] + </a> + <pre id='M000017-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/channel.rb, line 121</span>
121: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">wait</span>
122: <span class="ruby-identifier">connection</span>.<span class="ruby-identifier">loop</span> { <span class="ruby-identifier">active?</span> }
123: <span class="ruby-keyword kw">self</span>
124: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + </div> + </div> + </div> + </div> + <div id='footer-push'></div> + </div> + <div id='footer'> + <a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a> + </div> + </body> +</html> diff --git a/classes/Net/SSH/Multi/ChannelProxy.html b/classes/Net/SSH/Multi/ChannelProxy.html new file mode 100644 index 0000000..7a529c3 --- /dev/null +++ b/classes/Net/SSH/Multi/ChannelProxy.html @@ -0,0 +1,166 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html lang='en'> + <head> + <title>: Net::SSH::Multi::ChannelProxy [Control multiple Net::SSH connections via a single interface.]</title> + <meta content='text/html; charset=utf-8' http-equiv='Content-Type'> + <link href='../../../../rdoc-style.css' media='screen' rel='stylesheet' type='text/css'> + <script type='text/javascript'> + //<![CDATA[ + function popupCode(url) { + window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") + } + + function toggleCode(id) { + var code = document.getElementById(id) + + code.style.display = code.style.display != 'block' ? 'block' : 'none' + return true + } + + // Make codeblocks hidden by default + document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>') + //]]> + </script> + </head> + <body class='page'> + <div class='class' id='wrapper'> + <div class='header'> + <h1 class='name'> + <span class='type'>Class</span> + Net::SSH::Multi::ChannelProxy + </h1> + <ol class='paths'> + <li> + <a href="../../../../files/lib/net/ssh/multi/channel_proxy_rb.html">lib/net/ssh/multi/channel_proxy.rb</a> + </li> + </ol> + <div class='parent'> + Parent: + <strong>Object</strong> + </div> + </div> + <div id='content'> + <div id='text'> + <div id='description'> + <p> + The <a href="ChannelProxy.html">ChannelProxy</a> is a delegate class that + represents a channel that has not yet been opened. It is only used when <a + href="../Multi.html">Net::SSH::Multi</a> is running with with a concurrent + connections limit (see Net::SSH::Multi::Session#concurrent_connections). + </p> + <p> + You’ll never need to instantiate one of these directly, and will + probably (if all goes well!) never even notice when one of these is in use. + Essentially, it is spawned by a <a + href="PendingConnection.html">Net::SSH::Multi::PendingConnection</a> when + the pending connection is asked to open a channel. Any actions performed on + the channel proxy will then be recorded, until a real channel is set as the + delegate (see <a href="ChannelProxy.html#M000028">delegate_to</a>). At that + point, all recorded actions will be replayed on the channel, and any + subsequent actions will be immediately delegated to the channel. + </p> + </div> + <div id='method-list'> + <h2>Methods</h2> + <h3>public class</h3> + <ol> + <li><a href="#M000027">new</a></li> + </ol> + <h3>public instance</h3> + <ol> + <li><a href="#M000028">delegate_to</a></li> + <li><a href="#M000029">method_missing</a></li> + </ol> + </div> + <div id='section'> + <div id='attribute-list'> + <h2 class='section-bar'>Attributes</h2> + <div class='name-list'> + <table> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>on_confirm</td> + <td class='context-item-value'>[R]</td> + <td class='context-item-desc'> + + This is the “on confirm” callback that gets called when the + real channel is opened. + </td> + </tr> + </table> + </div> + </div> + <div id='methods'> + <h2>Public class methods</h2> + <div class='method public-class' id='method-M000027'> + <a name='M000027'> </a> + <div class='synopsis'> + <span class='name'>new</span> + <span class='arguments'>(&on_confirm)</span> + </div> + <div class='description'> + <p> + Instantiates a new channel proxy with the given <tt>on_confirm</tt> + callback. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000027-source'); return false"> + [show source] + </a> + <pre id='M000027-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/channel_proxy.rb, line 21</span>
21: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">on_confirm</span>)
22: <span class="ruby-ivar">@on_confirm</span> = <span class="ruby-identifier">on_confirm</span>
23: <span class="ruby-ivar">@recordings</span> = []
24: <span class="ruby-ivar">@channel</span> = <span class="ruby-keyword kw">nil</span>
25: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <h2>Public instance methods</h2> + <div class='method public-instance' id='method-M000028'> + <a name='M000028'> </a> + <div class='synopsis'> + <span class='name'>delegate_to</span> + <span class='arguments'>(channel)</span> + </div> + <div class='description'> + <p> + Instructs the proxy to delegate all further actions to the given + <tt>channel</tt> (which must be an instance of + Net::SSH::Connection::Channel). All recorded actions are immediately + replayed, in order, against the delegate channel. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000028-source'); return false"> + [show source] + </a> + <pre id='M000028-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/channel_proxy.rb, line 30</span>
30: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delegate_to</span>(<span class="ruby-identifier">channel</span>)
31: <span class="ruby-ivar">@channel</span> = <span class="ruby-identifier">channel</span>
32: <span class="ruby-ivar">@recordings</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">sym</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">block</span><span class="ruby-operator">|</span>
33: <span class="ruby-ivar">@channel</span>.<span class="ruby-identifier">__send__</span>(<span class="ruby-identifier">sym</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
34: <span class="ruby-keyword kw">end</span>
35: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000029'> + <a name='M000029'> </a> + <div class='synopsis'> + <span class='name'>method_missing</span> + <span class='arguments'>(sym, *args, &block)</span> + </div> + <div class='description'> + <p> + If a channel delegate has been specified (see <a + href="ChannelProxy.html#M000028">delegate_to</a>), the method will be + immediately sent to the delegate. Otherwise, the call is added to the list + of recorded method calls, to be played back when a delegate is specified. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000029-source'); return false"> + [show source] + </a> + <pre id='M000029-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/channel_proxy.rb, line 41</span>
41: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">sym</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
42: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@channel</span>
43: <span class="ruby-ivar">@channel</span>.<span class="ruby-identifier">__send__</span>(<span class="ruby-identifier">sym</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
44: <span class="ruby-keyword kw">else</span>
45: <span class="ruby-ivar">@recordings</span> <span class="ruby-operator"><<</span> [<span class="ruby-identifier">sym</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">block</span>]
46: <span class="ruby-keyword kw">end</span>
47: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + </div> + </div> + </div> + </div> + <div id='footer-push'></div> + </div> + <div id='footer'> + <a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a> + </div> + </body> +</html> diff --git a/classes/Net/SSH/Multi/DynamicServer.html b/classes/Net/SSH/Multi/DynamicServer.html new file mode 100644 index 0000000..2829095 --- /dev/null +++ b/classes/Net/SSH/Multi/DynamicServer.html @@ -0,0 +1,241 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html lang='en'> + <head> + <title>: Net::SSH::Multi::DynamicServer [Control multiple Net::SSH connections via a single interface.]</title> + <meta content='text/html; charset=utf-8' http-equiv='Content-Type'> + <link href='../../../../rdoc-style.css' media='screen' rel='stylesheet' type='text/css'> + <script type='text/javascript'> + //<![CDATA[ + function popupCode(url) { + window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") + } + + function toggleCode(id) { + var code = document.getElementById(id) + + code.style.display = code.style.display != 'block' ? 'block' : 'none' + return true + } + + // Make codeblocks hidden by default + document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>') + //]]> + </script> + </head> + <body class='page'> + <div class='class' id='wrapper'> + <div class='header'> + <h1 class='name'> + <span class='type'>Class</span> + Net::SSH::Multi::DynamicServer + </h1> + <ol class='paths'> + <li> + <a href="../../../../files/lib/net/ssh/multi/dynamic_server_rb.html">lib/net/ssh/multi/dynamic_server.rb</a> + </li> + </ol> + <div class='parent'> + Parent: + <strong>Object</strong> + </div> + </div> + <div id='content'> + <div id='text'> + <div id='description'> + <p> + Represents a lazily evaluated collection of servers. This will usually be + created via <a + href="Session.html#M000069">Net::SSH::Multi::Session#use</a>(&block), + and is useful for creating server definitions where the name or address of + the servers are not known until run-time. + </p> + <pre>session.use { lookup_ip_address_of_server }</pre> + <p> + This prevents <tt>lookup_ip_address_of_server</tt> from being invoked + unless the server is actually needed, at which point it is invoked and the + result cached. + </p> + <p> + The callback should return either <tt>nil</tt> (in which case no new + servers are instantiated), a String (representing a connection + specification), an array of Strings, or an array of <a + href="Server.html">Net::SSH::Multi::Server</a> instances. + </p> + </div> + <div id='method-list'> + <h2>Methods</h2> + <h3>public class</h3> + <ol> + <li><a href="#M000030">new</a></li> + </ol> + <h3>public instance</h3> + <ol> + <li><a href="#M000031">[]</a></li> + <li><a href="#M000032">[]=</a></li> + <li><a href="#M000033">each</a></li> + <li><a href="#M000034">evaluate!</a></li> + <li><a href="#M000035">to_ary</a></li> + </ol> + </div> + <div id='section'> + <div id='attribute-list'> + <h2 class='section-bar'>Attributes</h2> + <div class='name-list'> + <table> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>callback</td> + <td class='context-item-value'>[R]</td> + <td class='context-item-desc'> + + The Proc object to call to evaluate the server(s) + </td> + </tr> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>master</td> + <td class='context-item-value'>[R]</td> + <td class='context-item-desc'> + + The <a href="Session.html">Net::SSH::Multi::Session</a> instance that owns + this dynamic server record. + </td> + </tr> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>options</td> + <td class='context-item-value'>[R]</td> + <td class='context-item-desc'> + + The hash of options that will be used to initialize the server records. + </td> + </tr> + </table> + </div> + </div> + <div id='methods'> + <h2>Public class methods</h2> + <div class='method public-class' id='method-M000030'> + <a name='M000030'> </a> + <div class='synopsis'> + <span class='name'>new</span> + <span class='arguments'>(master, options, callback)</span> + </div> + <div class='description'> + <p> + Create a new <a href="DynamicServer.html">DynamicServer</a> record, owned + by the given <a href="Session.html">Net::SSH::Multi::Session</a> + <tt>master</tt>, with the given hash of <tt>options</tt>, and using the + given Proc <tt>callback</tt> to lazily evaluate the actual server + instances. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000030-source'); return false"> + [show source] + </a> + <pre id='M000030-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/dynamic_server.rb, line 32</span>
32: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">master</span>, <span class="ruby-identifier">options</span>, <span class="ruby-identifier">callback</span>)
33: <span class="ruby-ivar">@master</span>, <span class="ruby-ivar">@options</span>, <span class="ruby-ivar">@callback</span> = <span class="ruby-identifier">master</span>, <span class="ruby-identifier">options</span>, <span class="ruby-identifier">callback</span>
34: <span class="ruby-ivar">@servers</span> = <span class="ruby-keyword kw">nil</span>
35: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <h2>Public instance methods</h2> + <div class='method public-instance' id='method-M000031'> + <a name='M000031'> </a> + <div class='synopsis'> + <span class='name'>[]</span> + <span class='arguments'>(key)</span> + </div> + <div class='description'> + <p> + Returns the value for the given <tt>key</tt> in the :properties hash of the + <tt>options</tt>. If no :properties hash exists in <tt>options</tt>, this + returns <tt>nil</tt>. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000031-source'); return false"> + [show source] + </a> + <pre id='M000031-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/dynamic_server.rb, line 39</span>
39: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">[]</span>(<span class="ruby-identifier">key</span>)
40: (<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:properties</span>] <span class="ruby-operator">||=</span> {})[<span class="ruby-identifier">key</span>]
41: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000032'> + <a name='M000032'> </a> + <div class='synopsis'> + <span class='name'>[]=</span> + <span class='arguments'>(key, value)</span> + </div> + <div class='description'> + <p> + Sets the given key/value pair in the <tt>:properties</tt> key in the + options hash. If the options hash has no :properties key, it will be + created. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000032-source'); return false"> + [show source] + </a> + <pre id='M000032-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/dynamic_server.rb, line 45</span>
45: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">[]=</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>)
46: (<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:properties</span>] <span class="ruby-operator">||=</span> {})[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>
47: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000033'> + <a name='M000033'> </a> + <div class='synopsis'> + <span class='name'>each</span> + <span class='arguments'>() {|server| ...}</span> + </div> + <div class='description'> + <p> + Iterates over every instantiated server record in this dynamic server. If + the servers have not yet been instantiated, this does nothing (e.g., it + does <em>not</em> automatically invoke <a + href="DynamicServer.html#M000034">evaluate!</a>). + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000033-source'); return false"> + [show source] + </a> + <pre id='M000033-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/dynamic_server.rb, line 52</span>
52: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each</span>
53: (<span class="ruby-ivar">@servers</span> <span class="ruby-operator">||</span> []).<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">server</span> }
54: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000034'> + <a name='M000034'> </a> + <div class='synopsis'> + <span class='name'>evaluate!</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Evaluates the callback and instantiates the servers, memoizing the result. + Subsequent calls to <a href="DynamicServer.html#M000034">evaluate!</a> will + simply return the cached list of servers. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000034-source'); return false"> + [show source] + </a> + <pre id='M000034-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/dynamic_server.rb, line 59</span>
59: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">evaluate!</span>
60: <span class="ruby-ivar">@servers</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Array</span>(<span class="ruby-identifier">callback</span>[<span class="ruby-identifier">options</span>]).<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
61: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">server</span>
62: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">String</span> <span class="ruby-keyword kw">then</span> <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">SSH</span><span class="ruby-operator">::</span><span class="ruby-constant">Multi</span><span class="ruby-operator">::</span><span class="ruby-constant">Server</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">master</span>, <span class="ruby-identifier">server</span>, <span class="ruby-identifier">options</span>)
63: <span class="ruby-keyword kw">else</span> <span class="ruby-identifier">server</span>
64: <span class="ruby-keyword kw">end</span>
65: <span class="ruby-keyword kw">end</span>
66: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000035'> + <a name='M000035'> </a> + <div class='synopsis'> + <span class='name'>to_ary</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Alias for <a href="DynamicServer.html#M000034">evaluate!</a> + </p> + </div> + </div> + </div> + </div> + </div> + </div> + <div id='footer-push'></div> + </div> + <div id='footer'> + <a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a> + </div> + </body> +</html> diff --git a/classes/Net/SSH/Multi/PendingConnection.html b/classes/Net/SSH/Multi/PendingConnection.html new file mode 100644 index 0000000..9c59193 --- /dev/null +++ b/classes/Net/SSH/Multi/PendingConnection.html @@ -0,0 +1,306 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html lang='en'> + <head> + <title>: Net::SSH::Multi::PendingConnection [Control multiple Net::SSH connections via a single interface.]</title> + <meta content='text/html; charset=utf-8' http-equiv='Content-Type'> + <link href='../../../../rdoc-style.css' media='screen' rel='stylesheet' type='text/css'> + <script type='text/javascript'> + //<![CDATA[ + function popupCode(url) { + window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") + } + + function toggleCode(id) { + var code = document.getElementById(id) + + code.style.display = code.style.display != 'block' ? 'block' : 'none' + return true + } + + // Make codeblocks hidden by default + document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>') + //]]> + </script> + </head> + <body class='page'> + <div class='class' id='wrapper'> + <div class='header'> + <h1 class='name'> + <span class='type'>Class</span> + Net::SSH::Multi::PendingConnection + </h1> + <ol class='paths'> + <li> + <a href="../../../../files/lib/net/ssh/multi/pending_connection_rb.html">lib/net/ssh/multi/pending_connection.rb</a> + </li> + </ol> + <div class='parent'> + Parent: + <strong>Object</strong> + </div> + </div> + <div id='content'> + <div id='text'> + <div id='description'> + <p> + A <a href="PendingConnection.html">PendingConnection</a> instance mimics a + Net::SSH::Connection::Session instance, without actually being an open + connection to a server. It is used by <a + href="Session.html">Net::SSH::Multi::Session</a> when a concurrent + connection limit is in effect, so that a server can hang on to a + “connection” that isn’t really a connection. + </p> + <p> + Any requests against this connection (like <a + href="PendingConnection.html#M000038">open_channel</a> or <a + href="PendingConnection.html#M000039">send_global_request</a>) are not + actually sent, but are added to a list of recordings. When the real session + is opened and replaces this pending connection, all recorded actions will + be replayed against that session. + </p> + <p> + You’ll never need to initialize one of these directly, and (if all + goes well!) should never even notice that one of these is in use. <a + href="Session.html">Net::SSH::Multi::Session</a> will instantiate these as + needed, and only when there is a concurrent connection limit. + </p> + </div> + <div id='method-list'> + <h2>Methods</h2> + <h3>public class</h3> + <ol> + <li><a href="#M000036">new</a></li> + </ol> + <h3>public instance</h3> + <ol> + <li><a href="#M000040">busy?</a></li> + <li><a href="#M000042">channels</a></li> + <li><a href="#M000041">close</a></li> + <li><a href="#M000045">listeners</a></li> + <li><a href="#M000038">open_channel</a></li> + <li><a href="#M000044">postprocess</a></li> + <li><a href="#M000043">preprocess</a></li> + <li><a href="#M000037">replace_with</a></li> + <li><a href="#M000039">send_global_request</a></li> + </ol> + </div> + <div id='section'> + <div id='attribute-list'> + <h2 class='section-bar'>Attributes</h2> + <div class='name-list'> + <table> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>server</td> + <td class='context-item-value'>[R]</td> + <td class='context-item-desc'> + + The <a href="Server.html">Net::SSH::Multi::Server</a> object that + “owns” this pending connection. + </td> + </tr> + </table> + </div> + </div> + <div id='methods'> + <h2>Public class methods</h2> + <div class='method public-class' id='method-M000036'> + <a name='M000036'> </a> + <div class='synopsis'> + <span class='name'>new</span> + <span class='arguments'>(server)</span> + </div> + <div class='description'> + <p> + Instantiates a new pending connection for the given <a + href="Server.html">Net::SSH::Multi::Server</a> object. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000036-source'); return false"> + [show source] + </a> + <pre id='M000036-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/pending_connection.rb, line 52</span>
52: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">server</span>)
53: <span class="ruby-ivar">@server</span> = <span class="ruby-identifier">server</span>
54: <span class="ruby-ivar">@recordings</span> = []
55: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <h2>Public instance methods</h2> + <div class='method public-instance' id='method-M000040'> + <a name='M000040'> </a> + <div class='synopsis'> + <span class='name'>busy?</span> + <span class='arguments'>(include_invisible=false)</span> + </div> + <div class='description'> + <p> + Always returns <tt>true</tt>, so that the pending connection looks active + until it can be truly opened and replaced with a real connection. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000040-source'); return false"> + [show source] + </a> + <pre id='M000040-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/pending_connection.rb, line 82</span>
82: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">busy?</span>(<span class="ruby-identifier">include_invisible</span>=<span class="ruby-keyword kw">false</span>)
83: <span class="ruby-keyword kw">true</span>
84: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000042'> + <a name='M000042'> </a> + <div class='synopsis'> + <span class='name'>channels</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Returns an empty array, since a pending connection cannot have any real + channels. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000042-source'); return false"> + [show source] + </a> + <pre id='M000042-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/pending_connection.rb, line 92</span>
92: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">channels</span>
93: []
94: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000041'> + <a name='M000041'> </a> + <div class='synopsis'> + <span class='name'>close</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Does nothing, except to make a pending connection quack like a real + connection. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000041-source'); return false"> + [show source] + </a> + <pre id='M000041-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/pending_connection.rb, line 87</span>
87: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">close</span>
88: <span class="ruby-keyword kw">self</span>
89: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000045'> + <a name='M000045'> </a> + <div class='synopsis'> + <span class='name'>listeners</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Returns an empty hash, since a pending connection has no real listeners. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000045-source'); return false"> + [show source] + </a> + <pre id='M000045-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/pending_connection.rb, line 107</span>
107: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">listeners</span>
108: {}
109: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000038'> + <a name='M000038'> </a> + <div class='synopsis'> + <span class='name'>open_channel</span> + <span class='arguments'>(type="session", *extras, &on_confirm)</span> + </div> + <div class='description'> + <p> + Records that a channel open request has been made, and returns a new <a + href="ChannelProxy.html">Net::SSH::Multi::ChannelProxy</a> object to + represent the (as yet unopened) channel. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000038-source'); return false"> + [show source] + </a> + <pre id='M000038-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/pending_connection.rb, line 67</span>
67: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">open_channel</span>(<span class="ruby-identifier">type</span>=<span class="ruby-value str">"session"</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">extras</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">on_confirm</span>)
68: <span class="ruby-identifier">channel</span> = <span class="ruby-constant">ChannelProxy</span>.<span class="ruby-identifier">new</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">on_confirm</span>)
69: <span class="ruby-ivar">@recordings</span> <span class="ruby-operator"><<</span> <span class="ruby-constant">ChannelOpenRecording</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">extras</span>, <span class="ruby-identifier">channel</span>)
70: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">channel</span>
71: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000044'> + <a name='M000044'> </a> + <div class='synopsis'> + <span class='name'>postprocess</span> + <span class='arguments'>(readers, writers)</span> + </div> + <div class='description'> + <p> + Returns <tt>true</tt>, and does nothing else. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000044-source'); return false"> + [show source] + </a> + <pre id='M000044-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/pending_connection.rb, line 102</span>
102: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">postprocess</span>(<span class="ruby-identifier">readers</span>, <span class="ruby-identifier">writers</span>)
103: <span class="ruby-keyword kw">true</span>
104: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000043'> + <a name='M000043'> </a> + <div class='synopsis'> + <span class='name'>preprocess</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Returns <tt>true</tt>, and does nothing else. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000043-source'); return false"> + [show source] + </a> + <pre id='M000043-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/pending_connection.rb, line 97</span>
97: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">preprocess</span>
98: <span class="ruby-keyword kw">true</span>
99: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000037'> + <a name='M000037'> </a> + <div class='synopsis'> + <span class='name'>replace_with</span> + <span class='arguments'>(session)</span> + </div> + <div class='description'> + <p> + Instructs the pending session to replay all of its recordings against the + given <tt>session</tt>, and to then replace itself with the given session. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000037-source'); return false"> + [show source] + </a> + <pre id='M000037-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/pending_connection.rb, line 59</span>
59: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">replace_with</span>(<span class="ruby-identifier">session</span>)
60: <span class="ruby-ivar">@recordings</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">recording</span><span class="ruby-operator">|</span> <span class="ruby-identifier">recording</span>.<span class="ruby-identifier">replay_on</span>(<span class="ruby-identifier">session</span>) }
61: <span class="ruby-ivar">@server</span>.<span class="ruby-identifier">replace_session</span>(<span class="ruby-identifier">session</span>)
62: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000039'> + <a name='M000039'> </a> + <div class='synopsis'> + <span class='name'>send_global_request</span> + <span class='arguments'>(type, *extra, &callback)</span> + </div> + <div class='description'> + <p> + Records that a global request has been made. The request is not actually + sent, and won’t be until <a + href="PendingConnection.html#M000037">replace_with</a> is called. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000039-source'); return false"> + [show source] + </a> + <pre id='M000039-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/pending_connection.rb, line 75</span>
75: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_global_request</span>(<span class="ruby-identifier">type</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">extra</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">callback</span>)
76: <span class="ruby-ivar">@recordings</span> <span class="ruby-operator"><<</span> <span class="ruby-constant">SendGlobalRequestRecording</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">extra</span>, <span class="ruby-identifier">callback</span>)
77: <span class="ruby-keyword kw">self</span>
78: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + </div> + </div> + </div> + </div> + <div id='footer-push'></div> + </div> + <div id='footer'> + <a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a> + </div> + </body> +</html> diff --git a/classes/Net/SSH/Multi/Server.html b/classes/Net/SSH/Multi/Server.html new file mode 100644 index 0000000..17be26b --- /dev/null +++ b/classes/Net/SSH/Multi/Server.html @@ -0,0 +1,438 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html lang='en'> + <head> + <title>: Net::SSH::Multi::Server [Control multiple Net::SSH connections via a single interface.]</title> + <meta content='text/html; charset=utf-8' http-equiv='Content-Type'> + <link href='../../../../rdoc-style.css' media='screen' rel='stylesheet' type='text/css'> + <script type='text/javascript'> + //<![CDATA[ + function popupCode(url) { + window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") + } + + function toggleCode(id) { + var code = document.getElementById(id) + + code.style.display = code.style.display != 'block' ? 'block' : 'none' + return true + } + + // Make codeblocks hidden by default + document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>') + //]]> + </script> + </head> + <body class='page'> + <div class='class' id='wrapper'> + <div class='header'> + <h1 class='name'> + <span class='type'>Class</span> + Net::SSH::Multi::Server + </h1> + <ol class='paths'> + <li> + <a href="../../../../files/lib/net/ssh/multi/server_rb.html">lib/net/ssh/multi/server.rb</a> + </li> + </ol> + <div class='parent'> + Parent: + <strong>Object</strong> + </div> + </div> + <div id='content'> + <div id='text'> + <div id='description'> + <p> + Encapsulates the connection information for a single remote server, as well + as the <a href="../../SSH.html">Net::SSH</a> session corresponding to that + information. You’ll rarely need to instantiate one of these directly: + instead, you should use <a + href="Session.html#M000069">Net::SSH::Multi::Session#use</a>. + </p> + </div> + <div id='method-list'> + <h2>Methods</h2> + <h3>public class</h3> + <ol> + <li><a href="#M000046">new</a></li> + </ol> + <h3>public instance</h3> + <ol> + <li><a href="#M000050"><=></a></li> + <li><a href="#M000047">[]</a></li> + <li><a href="#M000048">[]=</a></li> + <li><a href="#M000057">busy?</a></li> + <li><a href="#M000058">close</a></li> + <li><a href="#M000055">fail!</a></li> + <li><a href="#M000054">failed?</a></li> + <li><a href="#M000051">hash</a></li> + <li><a href="#M000053">inspect</a></li> + <li><a href="#M000049">port</a></li> + <li><a href="#M000056">session</a></li> + <li><a href="#M000052">to_s</a></li> + </ol> + </div> + <div id='context'> + <div id='includes'> + <h2>Included modules</h2> + <ol> + <li>Comparable</li> + </ol> + </div> + </div> + <div id='section'> + <div id='aliases-list'> + <h2>External Aliases</h2> + <div class='name-list'> + <table summary='External aliases'> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>==</td> + <td>-></td> + <td class='context-item-value'>eql?</td> + </tr> + </table> + </div> + </div> + <div id='attribute-list'> + <h2 class='section-bar'>Attributes</h2> + <div class='name-list'> + <table> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>gateway</td> + <td class='context-item-value'>[R]</td> + <td class='context-item-desc'> + + The Net::SSH::Gateway instance to use to establish the connection. Will be + <tt>nil</tt> if the connection should be established without a gateway. + </td> + </tr> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>host</td> + <td class='context-item-value'>[R]</td> + <td class='context-item-desc'> + + The host name (or IP address) of the server to connect to. + </td> + </tr> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>master</td> + <td class='context-item-value'>[R]</td> + <td class='context-item-desc'> + + The <a href="Session.html">Net::SSH::Multi::Session</a> instance that + manages this server instance. + </td> + </tr> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>options</td> + <td class='context-item-value'>[R]</td> + <td class='context-item-desc'> + + The Hash of additional options to pass to <a + href="../../SSH.html">Net::SSH</a> when connecting (including things like + :password, and so forth). + </td> + </tr> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>user</td> + <td class='context-item-value'>[R]</td> + <td class='context-item-desc'> + + The user name to use when logging into the server. + </td> + </tr> + </table> + </div> + </div> + <div id='methods'> + <h2>Public class methods</h2> + <div class='method public-class' id='method-M000046'> + <a name='M000046'> </a> + <div class='synopsis'> + <span class='name'>new</span> + <span class='arguments'>(master, host, options={})</span> + </div> + <div class='description'> + <p> + Creates a new <a href="Server.html">Server</a> instance with the given + connection information. The <tt>master</tt> argument must be a reference to + the <a href="Session.html">Net::SSH::Multi::Session</a> instance that will + manage this server reference. The <tt>options</tt> hash must conform to the + options described for Net::SSH::start, with two additions: + </p> + <ul> + <li>:via => a Net::SSH::Gateway instance to use when establishing a connection + to this server. + + </li> + <li>:user => the name of the user to use when logging into this server. + + </li> + </ul> + <p> + The <tt>host</tt> argument may include the username and port number, in + which case those values take precedence over similar values given in the + <tt>options</tt>: + </p> + <pre>server = Net::SSH::Multi::Server.new(session, 'user@host:1234')
puts server.user #-> user
puts server.port #-> 1234</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000046-source'); return false"> + [show source] + </a> + <pre id='M000046-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/server.rb, line 43</span>
43: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">master</span>, <span class="ruby-identifier">host</span>, <span class="ruby-identifier">options</span>={})
44: <span class="ruby-ivar">@master</span> = <span class="ruby-identifier">master</span>
45: <span class="ruby-ivar">@options</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">dup</span>
46: 
47: <span class="ruby-ivar">@user</span>, <span class="ruby-ivar">@host</span>, <span class="ruby-identifier">port</span> = <span class="ruby-identifier">host</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp re">/^(?:([^;,:=]+)@|)(.*?)(?::(\d+)|)$/</span>)[<span class="ruby-value">1</span>,<span class="ruby-value">3</span>]
48: 
49: <span class="ruby-identifier">user_opt</span>, <span class="ruby-identifier">port_opt</span> = <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:user</span>), <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:port</span>)
50: 
51: <span class="ruby-ivar">@user</span> = <span class="ruby-ivar">@user</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">user_opt</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">master</span>.<span class="ruby-identifier">default_user</span>
52: <span class="ruby-identifier">port</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">port_opt</span>
53: 
54: <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:port</span>] = <span class="ruby-identifier">port</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">port</span>
55: 
56: <span class="ruby-ivar">@gateway</span> = <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:via</span>)
57: <span class="ruby-ivar">@failed</span> = <span class="ruby-keyword kw">false</span>
58: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <h2>Public instance methods</h2> + <div class='method public-instance' id='method-M000050'> + <a name='M000050'> </a> + <div class='synopsis'> + <span class='name'><=></span> + <span class='arguments'>(server)</span> + </div> + <div class='description'> + <p> + Gives server definitions a sort order, and allows comparison. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000050-source'); return false"> + [show source] + </a> + <pre id='M000050-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/server.rb, line 79</span>
79: <span class="ruby-keyword kw">def</span> <span class="ruby-operator"><=></span>(<span class="ruby-identifier">server</span>)
80: [<span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>, <span class="ruby-identifier">user</span>] <span class="ruby-operator"><=></span> [<span class="ruby-identifier">server</span>.<span class="ruby-identifier">host</span>, <span class="ruby-identifier">server</span>.<span class="ruby-identifier">port</span>, <span class="ruby-identifier">server</span>.<span class="ruby-identifier">user</span>]
81: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000047'> + <a name='M000047'> </a> + <div class='synopsis'> + <span class='name'>[]</span> + <span class='arguments'>(key)</span> + </div> + <div class='description'> + <p> + Returns the value of the server property with the given <tt>key</tt>. <a + href="Server.html">Server</a> properties are described via the + <tt>:properties</tt> key in the options hash when defining the <a + href="Server.html">Server</a>. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000047-source'); return false"> + [show source] + </a> + <pre id='M000047-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/server.rb, line 63</span>
63: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">[]</span>(<span class="ruby-identifier">key</span>)
64: (<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:properties</span>] <span class="ruby-operator">||</span> {})[<span class="ruby-identifier">key</span>]
65: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000048'> + <a name='M000048'> </a> + <div class='synopsis'> + <span class='name'>[]=</span> + <span class='arguments'>(key, value)</span> + </div> + <div class='description'> + <p> + Sets the given key/value pair in the <tt>:properties</tt> key in the + options hash. If the options hash has no :properties key, it will be + created. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000048-source'); return false"> + [show source] + </a> + <pre id='M000048-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/server.rb, line 69</span>
69: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">[]=</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>)
70: (<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:properties</span>] <span class="ruby-operator">||=</span> {})[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>
71: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000057'> + <a name='M000057'> </a> + <div class='synopsis'> + <span class='name'>busy?</span> + <span class='arguments'>(include_invisible=false)</span> + </div> + <div class='description'> + <p> + Returns <tt>true</tt> if the session has been opened, and the session is + currently busy (as defined by Net::SSH::Connection::Session#busy?). + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000057-source'); return false"> + [show source] + </a> + <pre id='M000057-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/server.rb, line 143</span>
143: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">busy?</span>(<span class="ruby-identifier">include_invisible</span>=<span class="ruby-keyword kw">false</span>)
144: <span class="ruby-identifier">session</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">session</span>.<span class="ruby-identifier">busy?</span>(<span class="ruby-identifier">include_invisible</span>)
145: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000058'> + <a name='M000058'> </a> + <div class='synopsis'> + <span class='name'>close</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Closes this server’s session. If the session has not yet been opened, + this does nothing. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000058-source'); return false"> + [show source] + </a> + <pre id='M000058-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/server.rb, line 149</span>
149: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">close</span>
150: <span class="ruby-identifier">session</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">session</span>
151: <span class="ruby-keyword kw">ensure</span>
152: <span class="ruby-identifier">master</span>.<span class="ruby-identifier">server_closed</span>(<span class="ruby-keyword kw">self</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">session</span>
153: <span class="ruby-ivar">@session</span> = <span class="ruby-keyword kw">nil</span>
154: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000055'> + <a name='M000055'> </a> + <div class='synopsis'> + <span class='name'>fail!</span> + <span class='arguments'>(flag=true)</span> + </div> + <div class='description'> + <p> + Indicates (by default) that this server has just failed a connection + attempt. If <tt>flag</tt> is false, this can be used to reset the failed + flag so that a retry may be attempted. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000055-source'); return false"> + [show source] + </a> + <pre id='M000055-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/server.rb, line 115</span>
115: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">fail!</span>(<span class="ruby-identifier">flag</span>=<span class="ruby-keyword kw">true</span>)
116: <span class="ruby-ivar">@failed</span> = <span class="ruby-identifier">flag</span>
117: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000054'> + <a name='M000054'> </a> + <div class='synopsis'> + <span class='name'>failed?</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Returns <tt>true</tt> if this server has ever failed a connection attempt. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000054-source'); return false"> + [show source] + </a> + <pre id='M000054-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/server.rb, line 108</span>
108: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">failed?</span>
109: <span class="ruby-ivar">@failed</span>
110: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000051'> + <a name='M000051'> </a> + <div class='synopsis'> + <span class='name'>hash</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Generates a <tt>Fixnum</tt> hash value for this object. This function has + the property that +a.eql?(b)+ implies +a.hash == b.hash+. The hash value is + used by class <tt>Hash</tt>. Any hash value that exceeds the capacity of a + <tt>Fixnum</tt> will be truncated before being used. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000051-source'); return false"> + [show source] + </a> + <pre id='M000051-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/server.rb, line 89</span>
89: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">hash</span>
90: <span class="ruby-ivar">@hash</span> <span class="ruby-operator">||=</span> [<span class="ruby-identifier">host</span>, <span class="ruby-identifier">user</span>, <span class="ruby-identifier">port</span>].<span class="ruby-identifier">hash</span>
91: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000053'> + <a name='M000053'> </a> + <div class='synopsis'> + <span class='name'>inspect</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Returns a human-readable representation of this server instance. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000053-source'); return false"> + [show source] + </a> + <pre id='M000053-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/server.rb, line 103</span>
103: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">inspect</span>
104: <span class="ruby-ivar">@inspect</span> <span class="ruby-operator">||=</span> <span class="ruby-value str">"#<%s:0x%x %s>"</span> <span class="ruby-operator">%</span> [<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">name</span>, <span class="ruby-identifier">object_id</span>, <span class="ruby-identifier">to_s</span>]
105: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000049'> + <a name='M000049'> </a> + <div class='synopsis'> + <span class='name'>port</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Returns the port number to use for this connection. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000049-source'); return false"> + [show source] + </a> + <pre id='M000049-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/server.rb, line 74</span>
74: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">port</span>
75: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:port</span>] <span class="ruby-operator">||</span> <span class="ruby-value">22</span>
76: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000056'> + <a name='M000056'> </a> + <div class='synopsis'> + <span class='name'>session</span> + <span class='arguments'>(require_session=false)</span> + </div> + <div class='description'> + <p> + Returns the <a href="../../SSH.html">Net::SSH</a> session object for this + server. If <tt>require_session</tt> is false and the session has not + previously been created, this will return <tt>nil</tt>. If + <tt>require_session</tt> is true, the session will be instantiated if it + has not already been instantiated, via the <tt>gateway</tt> if one is + given, or directly (via Net::SSH::start) otherwise. + </p> + <pre>if server.session.nil?
 puts "connecting..."
 server.session(true)
end</pre> + <p> + Note that the sessions returned by this are “enhanced” + slightly, to make them easier to deal with in a multi-session environment: + they have a :server property automatically set on them, that refers to this + object (the <a href="Server.html">Server</a> instance that spawned them). + </p> + <pre>assert_equal server, server.session[:server]</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000056-source'); return false"> + [show source] + </a> + <pre id='M000056-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/server.rb, line 136</span>
136: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session</span>(<span class="ruby-identifier">require_session</span>=<span class="ruby-keyword kw">false</span>)
137: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@session</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@session</span> <span class="ruby-operator">||</span> <span class="ruby-operator">!</span><span class="ruby-identifier">require_session</span>
138: <span class="ruby-ivar">@session</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">master</span>.<span class="ruby-identifier">next_session</span>(<span class="ruby-keyword kw">self</span>)
139: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000052'> + <a name='M000052'> </a> + <div class='synopsis'> + <span class='name'>to_s</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Returns a human-readable representation of this server instance. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000052-source'); return false"> + [show source] + </a> + <pre id='M000052-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/server.rb, line 94</span>
 94: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
 95: <span class="ruby-ivar">@to_s</span> <span class="ruby-operator">||=</span> <span class="ruby-keyword kw">begin</span>
 96: <span class="ruby-identifier">s</span> = <span class="ruby-node">"#{user}@#{host}"</span>
 97: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-node">":#{options[:port]}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:port</span>]
 98: <span class="ruby-identifier">s</span>
 99: <span class="ruby-keyword kw">end</span>
100: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + </div> + </div> + </div> + </div> + <div id='footer-push'></div> + </div> + <div id='footer'> + <a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a> + </div> + </body> +</html> diff --git a/classes/Net/SSH/Multi/ServerList.html b/classes/Net/SSH/Multi/ServerList.html new file mode 100644 index 0000000..5c29cac --- /dev/null +++ b/classes/Net/SSH/Multi/ServerList.html @@ -0,0 +1,224 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html lang='en'> + <head> + <title>: Net::SSH::Multi::ServerList [Control multiple Net::SSH connections via a single interface.]</title> + <meta content='text/html; charset=utf-8' http-equiv='Content-Type'> + <link href='../../../../rdoc-style.css' media='screen' rel='stylesheet' type='text/css'> + <script type='text/javascript'> + //<![CDATA[ + function popupCode(url) { + window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") + } + + function toggleCode(id) { + var code = document.getElementById(id) + + code.style.display = code.style.display != 'block' ? 'block' : 'none' + return true + } + + // Make codeblocks hidden by default + document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>') + //]]> + </script> + </head> + <body class='page'> + <div class='class' id='wrapper'> + <div class='header'> + <h1 class='name'> + <span class='type'>Class</span> + Net::SSH::Multi::ServerList + </h1> + <ol class='paths'> + <li> + <a href="../../../../files/lib/net/ssh/multi/server_list_rb.html">lib/net/ssh/multi/server_list.rb</a> + </li> + </ol> + <div class='parent'> + Parent: + <strong>Object</strong> + </div> + </div> + <div id='content'> + <div id='text'> + <div id='description'> + <p> + Encapsulates a list of server objects, both dynamic (<a + href="DynamicServer.html">Net::SSH::Multi::DynamicServer</a>) and static + (<a href="Server.html">Net::SSH::Multi::Server</a>). It attempts to make it + transparent whether a dynamic server set has been evaluated or not. Note + that a <a href="ServerList.html">ServerList</a> is NOT an Array, though it + is Enumerable. + </p> + </div> + <div id='method-list'> + <h2>Methods</h2> + <h3>public class</h3> + <ol> + <li><a href="#M000059">new</a></li> + </ol> + <h3>public instance</h3> + <ol> + <li><a href="#M000060">add</a></li> + <li><a href="#M000061">concat</a></li> + <li><a href="#M000062">each</a></li> + <li><a href="#M000064">flatten</a></li> + <li><a href="#M000063">select</a></li> + <li><a href="#M000065">to_ary</a></li> + </ol> + </div> + <div id='context'> + <div id='includes'> + <h2>Included modules</h2> + <ol> + <li>Enumerable</li> + </ol> + </div> + </div> + <div id='section'> + <div id='methods'> + <h2>Public class methods</h2> + <div class='method public-class' id='method-M000059'> + <a name='M000059'> </a> + <div class='synopsis'> + <span class='name'>new</span> + <span class='arguments'>(list=[])</span> + </div> + <div class='description'> + <p> + Create a new <a href="ServerList.html">ServerList</a> that wraps the given + server list. Duplicate entries will be discarded. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000059-source'); return false"> + [show source] + </a> + <pre id='M000059-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/server_list.rb, line 15</span>
15: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">list</span>=[])
16: <span class="ruby-ivar">@list</span> = <span class="ruby-identifier">list</span>.<span class="ruby-identifier">uniq</span>
17: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <h2>Public instance methods</h2> + <div class='method public-instance' id='method-M000060'> + <a name='M000060'> </a> + <div class='synopsis'> + <span class='name'>add</span> + <span class='arguments'>(server)</span> + </div> + <div class='description'> + <p> + Adds the given server to the list, and returns the argument. If an + identical server definition already exists in the collection, the argument + is <em>not</em> added, and the existing server record is returned instead. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000060-source'); return false"> + [show source] + </a> + <pre id='M000060-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/server_list.rb, line 23</span>
23: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add</span>(<span class="ruby-identifier">server</span>)
24: <span class="ruby-identifier">index</span> = <span class="ruby-ivar">@list</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">server</span>)
25: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">index</span>
26: <span class="ruby-identifier">server</span> = <span class="ruby-ivar">@list</span>[<span class="ruby-identifier">index</span>]
27: <span class="ruby-keyword kw">else</span>
28: <span class="ruby-ivar">@list</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">server</span>)
29: <span class="ruby-keyword kw">end</span>
30: <span class="ruby-identifier">server</span>
31: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000061'> + <a name='M000061'> </a> + <div class='synopsis'> + <span class='name'>concat</span> + <span class='arguments'>(servers)</span> + </div> + <div class='description'> + <p> + Adds an array (or otherwise Enumerable list) of servers to this list, by + calling <a href="ServerList.html#M000060">add</a> for each argument. + Returns <tt>self</tt>. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000061-source'); return false"> + [show source] + </a> + <pre id='M000061-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/server_list.rb, line 35</span>
35: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">concat</span>(<span class="ruby-identifier">servers</span>)
36: <span class="ruby-identifier">servers</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span> <span class="ruby-identifier">add</span>(<span class="ruby-identifier">server</span>) }
37: <span class="ruby-keyword kw">self</span>
38: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000062'> + <a name='M000062'> </a> + <div class='synopsis'> + <span class='name'>each</span> + <span class='arguments'>() {|server| ...}</span> + </div> + <div class='description'> + <p> + Iterates over each distinct server record in the collection. This will + correctly iterate over server records instantiated by a <a + href="DynamicServer.html">DynamicServer</a> as well, but only if the + dynamic server has been “evaluated” (see <a + href="DynamicServer.html#M000034">Net::SSH::Multi::DynamicServer#evaluate!</a>). + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000062-source'); return false"> + [show source] + </a> + <pre id='M000062-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/server_list.rb, line 44</span>
44: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each</span>
45: <span class="ruby-ivar">@list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
46: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">server</span>
47: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Server</span> <span class="ruby-keyword kw">then</span> <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">server</span>
48: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">DynamicServer</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">server</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">item</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">item</span> }
49: <span class="ruby-keyword kw">else</span> <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">"server list contains non-server: #{server.class}"</span>
50: <span class="ruby-keyword kw">end</span>
51: <span class="ruby-keyword kw">end</span>
52: <span class="ruby-keyword kw">self</span>
53: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000064'> + <a name='M000064'> </a> + <div class='synopsis'> + <span class='name'>flatten</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Returns an array of all servers in the list, with dynamic server records + expanded. The result is an array of distinct server records (duplicates are + removed from the result). + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000064-source'); return false"> + [show source] + </a> + <pre id='M000064-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/server_list.rb, line 65</span>
65: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">flatten</span>
66: <span class="ruby-identifier">result</span> = <span class="ruby-ivar">@list</span>.<span class="ruby-identifier">inject</span>([]) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">aggregator</span>, <span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
67: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">server</span>
68: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Server</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">aggregator</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">server</span>)
69: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">DynamicServer</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">aggregator</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">server</span>)
70: <span class="ruby-keyword kw">else</span> <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">"server list contains non-server: #{server.class}"</span>
71: <span class="ruby-keyword kw">end</span>
72: <span class="ruby-keyword kw">end</span>
73: 
74: <span class="ruby-identifier">result</span>.<span class="ruby-identifier">uniq</span>
75: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000063'> + <a name='M000063'> </a> + <div class='synopsis'> + <span class='name'>select</span> + <span class='arguments'>() {|i| ...}</span> + </div> + <div class='description'> + <p> + Works exactly as Enumerable#select, but returns the result as a new <a + href="ServerList.html">ServerList</a> instance. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000063-source'); return false"> + [show source] + </a> + <pre id='M000063-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/server_list.rb, line 57</span>
57: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">select</span>
58: <span class="ruby-identifier">subset</span> = <span class="ruby-ivar">@list</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">i</span> }
59: <span class="ruby-constant">ServerList</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">subset</span>)
60: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000065'> + <a name='M000065'> </a> + <div class='synopsis'> + <span class='name'>to_ary</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Alias for <a href="ServerList.html#M000064">flatten</a> + </p> + </div> + </div> + </div> + </div> + </div> + </div> + <div id='footer-push'></div> + </div> + <div id='footer'> + <a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a> + </div> + </body> +</html> diff --git a/classes/Net/SSH/Multi/Session.html b/classes/Net/SSH/Multi/Session.html new file mode 100644 index 0000000..e0ba392 --- /dev/null +++ b/classes/Net/SSH/Multi/Session.html @@ -0,0 +1,560 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html lang='en'> + <head> + <title>: Net::SSH::Multi::Session [Control multiple Net::SSH connections via a single interface.]</title> + <meta content='text/html; charset=utf-8' http-equiv='Content-Type'> + <link href='../../../../rdoc-style.css' media='screen' rel='stylesheet' type='text/css'> + <script type='text/javascript'> + //<![CDATA[ + function popupCode(url) { + window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") + } + + function toggleCode(id) { + var code = document.getElementById(id) + + code.style.display = code.style.display != 'block' ? 'block' : 'none' + return true + } + + // Make codeblocks hidden by default + document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>') + //]]> + </script> + </head> + <body class='page'> + <div class='class' id='wrapper'> + <div class='header'> + <h1 class='name'> + <span class='type'>Class</span> + Net::SSH::Multi::Session + </h1> + <ol class='paths'> + <li> + <a href="../../../../files/lib/net/ssh/multi/session_rb.html">lib/net/ssh/multi/session.rb</a> + </li> + </ol> + <div class='parent'> + Parent: + <strong>Object</strong> + </div> + </div> + <div id='content'> + <div id='text'> + <div id='description'> + <p> + Represents a collection of connections to various servers. It provides an + interface for organizing the connections (<a + href="Session.html#M000067">group</a>), as well as a way to scope commands + to a subset of all connections (<a href="Session.html#M000072">with</a>). + You can also provide a default gateway connection that servers should use + when connecting (<a href="Session.html#M000068">via</a>). It exposes an + interface similar to Net::SSH::Connection::Session for opening <a + href="../../SSH.html">SSH</a> channels and executing commands, allowing for + these operations to be done in parallel across multiple connections. + </p> + <pre>Net::SSH::Multi.start do |session|
 # access servers via a gateway
 session.via 'gateway', 'gateway-user'

 # define the servers we want to use
 session.use 'user1@host1'
 session.use 'user2@host2'

 # define servers in groups for more granular access
 session.group :app do
 session.use 'user@app1'
 session.use 'user@app2'
 end

 # execute commands on all servers
 session.exec "uptime"

 # execute commands on a subset of servers
 session.with(:app).exec "hostname"

 # run the aggregated event loop
 session.loop
end</pre> + <p> + Note that connections are established lazily, as soon as they are needed. + You can force the connections to be opened immediately, though, using the + connect! method. + </p> + <h2>Concurrent Connection Limiting</h2> + <p> + Sometimes you may be dealing with a large number of servers, and if you try + to have connections open to all of them simultaneously you’ll run + into open file handle limitations and such. If this happens to you, you can + set the concurrent_connections property of the session. <a + href="../Multi.html">Net::SSH::Multi</a> will then ensure that no more than + this number of connections are ever open simultaneously. + </p> + <pre>Net::SSH::Multi.start(:concurrent_connections => 5) do |session|
 # ...
end</pre> + <p> + Opening channels and executing commands will still work exactly as before, + but <a href="../Multi.html">Net::SSH::Multi</a> will transparently close + finished connections and open pending ones. + </p> + <h2>Controlling Connection Errors</h2> + <p> + By default, <a href="../Multi.html">Net::SSH::Multi</a> will raise an + exception if a connection error occurs when connecting to a server. This + will typically bubble up and abort the entire connection process. + Sometimes, however, you might wish to ignore connection errors, for + instance when starting a daemon on a large number of boxes and you know + that some of the boxes are going to be unavailable. + </p> + <p> + To do this, simply set the on_error property of the session to :ignore (or + to :warn, if you want a warning message when a connection attempt fails): + </p> + <pre>Net::SSH::Multi.start(:on_error => :ignore) do |session|
 # ...
end</pre> + <p> + The default is :fail, which causes the exception to bubble up. + Additionally, you can specify a Proc object as the value for on_error, + which will be invoked with the server in question if the connection attempt + fails. You can force the connection attempt to retry by throwing the :go + symbol, with :retry as the payload, or force the exception to be reraised + by throwing :go with :raise as the payload: + </p> + <pre>handler = Proc.new do |server|
 server[:connection_attempts] ||= 0
 if server[:connection_attempts] < 3
 server[:connection_attempts] += 1
 throw :go, :retry
 else
 throw :go, :raise
 end
end

Net::SSH::Multi.start(:on_error => handler) do |session|
 # ...
end</pre> + <p> + Any other thrown value (or no thrown value at all) will result in the + failure being ignored. + </p> + <h2>Lazily Evaluated <a href="Server.html">Server</a> Definitions</h2> + <p> + Sometimes you might be dealing with an environment where you don’t + know the names or addresses of the servers until runtime. You can certainly + dynamically build server names and pass them to <a + href="Session.html#M000069">use</a>, but if the operation to determine the + server names is expensive, you might want to defer it until the server is + actually needed (especially if the logic of your program is such that you + might not even need to connect to that server every time the program runs). + </p> + <p> + You can do this by passing a block to <a + href="Session.html#M000069">use</a>: + </p> + <pre>session.use do |opt|
 lookup_ip_address_of_remote_host
end</pre> + <p> + See <a href="Session.html#M000069">use</a> for more information about this + usage. + </p> + </div> + <div id='method-list'> + <h2>Methods</h2> + <h3>public class</h3> + <ol> + <li><a href="#M000066">new</a></li> + </ol> + <h3>public instance</h3> + <ol> + <li><a href="#M000074">close</a></li> + <li><a href="#M000067">group</a></li> + <li><a href="#M000075">loop</a></li> + <li><a href="#M000076">loop_forever</a></li> + <li><a href="#M000073">on</a></li> + <li><a href="#M000077">process</a></li> + <li><a href="#M000070">servers</a></li> + <li><a href="#M000071">servers_for</a></li> + <li><a href="#M000069">use</a></li> + <li><a href="#M000068">via</a></li> + <li><a href="#M000072">with</a></li> + </ol> + </div> + <div id='context'> + <div id='includes'> + <h2>Included modules</h2> + <ol> + <li><a href="SessionActions.html">SessionActions</a></li> + </ol> + </div> + </div> + <div id='section'> + <div id='attribute-list'> + <h2 class='section-bar'>Attributes</h2> + <div class='name-list'> + <table> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>concurrent_connections</td> + <td class='context-item-value'>[RW]</td> + <td class='context-item-desc'> + + The number of allowed concurrent connections. No more than this number of + sessions will be open at any given time. + </td> + </tr> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>default_gateway</td> + <td class='context-item-value'>[R]</td> + <td class='context-item-desc'> + + The default Net::SSH::Gateway instance to use to connect to the servers. If + <tt>nil</tt>, no default gateway will be used. + </td> + </tr> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>default_user</td> + <td class='context-item-value'>[RW]</td> + <td class='context-item-desc'> + + The default user name to use when connecting to a server. If a user name is + not given for a particular server, this value will be used. It defaults to + ENV[‘USER’] || ENV[‘USERNAME’], or + “unknown” if neither of those are set. + </td> + </tr> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>groups</td> + <td class='context-item-value'>[R]</td> + <td class='context-item-desc'> + + The hash of group definitions, mapping each group name to a corresponding + <a href="ServerList.html">Net::SSH::Multi::ServerList</a>. + </td> + </tr> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>on_error</td> + <td class='context-item-value'>[RW]</td> + <td class='context-item-desc'> + + How connection errors should be handled. This defaults to :fail, but may be + set to :ignore if connection errors should be ignored, or :warn if + connection errors should cause a warning. + </td> + </tr> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>server_list</td> + <td class='context-item-value'>[R]</td> + <td class='context-item-desc'> + + The <a href="ServerList.html">Net::SSH::Multi::ServerList</a> managed by + this session. + </td> + </tr> + </table> + </div> + </div> + <div id='methods'> + <h2>Public class methods</h2> + <div class='method public-class' id='method-M000066'> + <a name='M000066'> </a> + <div class='synopsis'> + <span class='name'>new</span> + <span class='arguments'>(options={})</span> + </div> + <div class='description'> + <p> + Creates a new <a href="Session.html">Net::SSH::Multi::Session</a> instance. + Initially, it contains no server definitions, no group definitions, and no + default gateway. + </p> + <p> + You can set the concurrent_connections property in the options. Setting it + to <tt>nil</tt> (the default) will cause <a + href="../Multi.html">Net::SSH::Multi</a> to ignore any concurrent + connection limit and allow all defined sessions to be open simultaneously. + Setting it to an integer will cause <a + href="../Multi.html">Net::SSH::Multi</a> to allow no more than that number + of concurrently open sessions, opening subsequent sessions only when other + sessions finish and close. + </p> + <pre>Net::SSH::Multi.start(:concurrent_connections => 10) do |session|
 session.use ...
end</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000066-source'); return false"> + [show source] + </a> + <pre id='M000066-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/session.rb, line 171</span>
171: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">options</span>={})
172: <span class="ruby-ivar">@server_list</span> = <span class="ruby-constant">ServerList</span>.<span class="ruby-identifier">new</span>
173: <span class="ruby-ivar">@groups</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">h</span>,<span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-constant">ServerList</span>.<span class="ruby-identifier">new</span> }
174: <span class="ruby-ivar">@gateway</span> = <span class="ruby-keyword kw">nil</span>
175: <span class="ruby-ivar">@open_groups</span> = []
176: <span class="ruby-ivar">@connect_threads</span> = []
177: <span class="ruby-ivar">@on_error</span> = <span class="ruby-identifier">:fail</span>
178: <span class="ruby-ivar">@default_user</span> = <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'USER'</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'USERNAME'</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">"unknown"</span>
179: 
180: <span class="ruby-ivar">@open_connections</span> = <span class="ruby-value">0</span>
181: <span class="ruby-ivar">@pending_sessions</span> = []
182: <span class="ruby-ivar">@session_mutex</span> = <span class="ruby-constant">Mutex</span>.<span class="ruby-identifier">new</span>
183: 
184: <span class="ruby-identifier">options</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">opt</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">send</span>(<span class="ruby-node">"#{opt}="</span>, <span class="ruby-identifier">value</span>) }
185: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <h2>Public instance methods</h2> + <div class='method public-instance' id='method-M000074'> + <a name='M000074'> </a> + <div class='synopsis'> + <span class='name'>close</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Closes the multi-session by shutting down all open server sessions, and the + default gateway (if one was specified using <a + href="Session.html#M000068">via</a>). Note that other gateway connections + (e.g., those passed to <a href="Session.html#M000069">use</a> directly) + will <em>not</em> be closed by this method, and must be managed externally. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000074-source'); return false"> + [show source] + </a> + <pre id='M000074-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/session.rb, line 402</span>
402: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">close</span>
403: <span class="ruby-identifier">server_list</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span> <span class="ruby-identifier">server</span>.<span class="ruby-identifier">close_channels</span> }
404: <span class="ruby-identifier">loop</span>(<span class="ruby-value">0</span>) { <span class="ruby-identifier">busy?</span>(<span class="ruby-keyword kw">true</span>) }
405: <span class="ruby-identifier">server_list</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span> <span class="ruby-identifier">server</span>.<span class="ruby-identifier">close</span> }
406: <span class="ruby-identifier">default_gateway</span>.<span class="ruby-identifier">shutdown!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">default_gateway</span>
407: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000067'> + <a name='M000067'> </a> + <div class='synopsis'> + <span class='name'>group</span> + <span class='arguments'>(*args) {|self| ...}</span> + </div> + <div class='description'> + <p> + At its simplest, this associates a named group with a server definition. It + can be used in either of two ways: + </p> + <p> + First, you can use it to associate a group (or array of groups) with a + server definition (or array of server definitions). The server definitions + must already exist in the server_list array (typically by calling <a + href="Session.html#M000069">use</a>): + </p> + <pre>server1 = session.use('host1', 'user1')
server2 = session.use('host2', 'user2')
session.group :app => server1, :web => server2
session.group :staging => [server1, server2]
session.group %w(xen linux) => server2
session.group %w(rackspace backup) => [server1, server2]</pre> + <p> + Secondly, instead of a mapping of groups to servers, you can just provide a + list of group names, and then a block. Inside the block, any calls to <a + href="Session.html#M000069">use</a> will automatically associate the new + server definition with those groups. You can nest <a + href="Session.html#M000067">group</a> calls, too, which will aggregate the + group definitions. + </p> + <pre>session.group :rackspace, :backup do
 session.use 'host1', 'user1'
 session.group :xen do
 session.use 'host2', 'user2'
 end
end</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000067-source'); return false"> + [show source] + </a> + <pre id='M000067-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/session.rb, line 213</span>
213: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">group</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
214: <span class="ruby-identifier">mapping</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> {}
215: 
216: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">mapping</span>.<span class="ruby-identifier">any?</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">block_given?</span>
217: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"must provide group mapping OR block, not both"</span>
218: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">block_given?</span>
219: <span class="ruby-keyword kw">begin</span>
220: <span class="ruby-identifier">saved_groups</span> = <span class="ruby-identifier">open_groups</span>.<span class="ruby-identifier">dup</span>
221: <span class="ruby-identifier">open_groups</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">args</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">to_sym</span> }).<span class="ruby-identifier">uniq!</span>
222: <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">self</span>
223: <span class="ruby-keyword kw">ensure</span>
224: <span class="ruby-identifier">open_groups</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-identifier">saved_groups</span>)
225: <span class="ruby-keyword kw">end</span>
226: <span class="ruby-keyword kw">else</span>
227: <span class="ruby-identifier">mapping</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
228: (<span class="ruby-identifier">open_groups</span> <span class="ruby-operator">+</span> <span class="ruby-constant">Array</span>(<span class="ruby-identifier">key</span>)).<span class="ruby-identifier">uniq</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">grp</span><span class="ruby-operator">|</span>
229: <span class="ruby-identifier">groups</span>[<span class="ruby-identifier">grp</span>.<span class="ruby-identifier">to_sym</span>].<span class="ruby-identifier">concat</span>(<span class="ruby-constant">Array</span>(<span class="ruby-identifier">value</span>))
230: <span class="ruby-keyword kw">end</span>
231: <span class="ruby-keyword kw">end</span>
232: <span class="ruby-keyword kw">end</span>
233: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000075'> + <a name='M000075'> </a> + <div class='synopsis'> + <span class='name'>loop</span> + <span class='arguments'>(wait=nil, &block)</span> + </div> + <div class='description'> + <p> + Run the aggregated event loop for all open server sessions, until the given + block returns <tt>false</tt>. If no block is given, the loop will run for + as long as busy? returns <tt>true</tt> (in other words, for as long as + there are any (non-invisible) channels open). + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000075-source'); return false"> + [show source] + </a> + <pre id='M000075-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/session.rb, line 415</span>
415: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">loop</span>(<span class="ruby-identifier">wait</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
416: <span class="ruby-identifier">running</span> = <span class="ruby-identifier">block</span> <span class="ruby-operator">||</span> <span class="ruby-constant">Proc</span>.<span class="ruby-identifier">new</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">busy?</span> }
417: <span class="ruby-identifier">loop_forever</span> { <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">process</span>(<span class="ruby-identifier">wait</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">running</span>) }
418: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000076'> + <a name='M000076'> </a> + <div class='synopsis'> + <span class='name'>loop_forever</span> + <span class='arguments'>(wait=nil, &block)</span> + </div> + <div class='description'> + <p> + Alias for <a href="Session.html#M000075">loop</a> + </p> + </div> + </div> + <div class='method public-instance' id='method-M000073'> + <a name='M000073'> </a> + <div class='synopsis'> + <span class='name'>on</span> + <span class='arguments'>(*servers) {|subsession if block_given?| ...}</span> + </div> + <div class='description'> + <p> + Works as <a href="Session.html#M000072">with</a>, but for specific servers + rather than groups. It will return a new subsession (<a + href="Subsession.html">Net::SSH::Multi::Subsession</a>) consisting of the + given servers. (Note that it requires that the servers in question have + been created via calls to <a href="Session.html#M000069">use</a> on this + session object, or things will not work quite right.) If a block is given, + the new subsession will also be yielded to the block. + </p> + <pre>srv1 = session.use('host1', 'user')
srv2 = session.use('host2', 'user')
# ...
session.on(srv1, srv2).exec('hostname')</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000073-source'); return false"> + [show source] + </a> + <pre id='M000073-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/session.rb, line 392</span>
392: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">on</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">servers</span>)
393: <span class="ruby-identifier">subsession</span> = <span class="ruby-constant">Subsession</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">servers</span>)
394: <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">subsession</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
395: <span class="ruby-identifier">subsession</span>
396: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000077'> + <a name='M000077'> </a> + <div class='synopsis'> + <span class='name'>process</span> + <span class='arguments'>(wait=nil, &block)</span> + </div> + <div class='description'> + <p> + Run a single iteration of the aggregated event loop for all open server + sessions. The <tt>wait</tt> parameter indicates how long to wait for an + event to appear on any of the different sessions; <tt>nil</tt> (the + default) means “wait forever”. If the block is given, then it + will be used to determine whether <a + href="Session.html#M000077">process</a> returns <tt>true</tt> (the block + did not return <tt>false</tt>), or <tt>false</tt> (the block returned + <tt>false</tt>). + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000077-source'); return false"> + [show source] + </a> + <pre id='M000077-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/session.rb, line 426</span>
426: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process</span>(<span class="ruby-identifier">wait</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
427: <span class="ruby-identifier">realize_pending_connections!</span>
428: <span class="ruby-identifier">wait</span> = <span class="ruby-ivar">@connect_threads</span>.<span class="ruby-identifier">any?</span> <span class="ruby-value">? </span><span class="ruby-value">0</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">wait</span>
429: 
430: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">preprocess</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
431: 
432: <span class="ruby-identifier">readers</span> = <span class="ruby-identifier">server_list</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">readers</span> }.<span class="ruby-identifier">flatten</span>
433: <span class="ruby-identifier">writers</span> = <span class="ruby-identifier">server_list</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">writers</span> }.<span class="ruby-identifier">flatten</span>
434: 
435: <span class="ruby-identifier">readers</span>, <span class="ruby-identifier">writers</span>, = <span class="ruby-constant">IO</span>.<span class="ruby-identifier">select</span>(<span class="ruby-identifier">readers</span>, <span class="ruby-identifier">writers</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">wait</span>)
436: 
437: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">readers</span>
438: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">postprocess</span>(<span class="ruby-identifier">readers</span>, <span class="ruby-identifier">writers</span>)
439: <span class="ruby-keyword kw">else</span>
440: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
441: <span class="ruby-keyword kw">end</span>
442: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000070'> + <a name='M000070'> </a> + <div class='synopsis'> + <span class='name'>servers</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Essentially an alias for <a href="Session.html#M000071">servers_for</a> + without any arguments. This is used primarily to satistfy the expectations + of the <a href="SessionActions.html">Net::SSH::Multi::SessionActions</a> + module. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000070-source'); return false"> + [show source] + </a> + <pre id='M000070-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/session.rb, line 293</span>
293: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">servers</span>
294: <span class="ruby-identifier">servers_for</span>
295: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000071'> + <a name='M000071'> </a> + <div class='synopsis'> + <span class='name'>servers_for</span> + <span class='arguments'>(*criteria)</span> + </div> + <div class='description'> + <p> + Returns the set of servers that match the given criteria. It can be used in + any (or all) of three ways. + </p> + <p> + First, you can omit any arguments. In this case, the full list of servers + will be returned. + </p> + <pre>all = session.servers_for</pre> + <p> + Second, you can simply specify a list of group names. All servers in all + named groups will be returned. If a server belongs to multiple matching + groups, then it will appear only once in the list (the resulting list will + contain only unique servers). + </p> + <pre>servers = session.servers_for(:app, :db)</pre> + <p> + Last, you can specify a hash with group names as keys, and property + constraints as the values. These property constraints are either + “only” constraints (which restrict the set of servers to + “only” those that match the given properties) or + “except” constraints (which restrict the set of servers to + those whose properties do <em>not</em> match). Properties are described + when the server is defined (via the :properties key): + </p> + <pre>session.group :db do
 session.use 'dbmain', 'user', :properties => { :primary => true }
 session.use 'dbslave', 'user2'
 session.use 'dbslve2', 'user2'
end

# return ONLY on the servers in the :db group which have the :primary
# property set to true.
primary = session.servers_for(:db => { :only => { :primary => true } })</pre> + <p> + You can, naturally, combine these methods: + </p> + <pre># all servers in :app and :web, and all servers in :db with the
# :primary property set to true
servers = session.servers_for(:app, :web, :db => { :only => { :primary => true } })</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000071-source'); return false"> + [show source] + </a> + <pre id='M000071-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/session.rb, line 334</span>
334: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">servers_for</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">criteria</span>)
335: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">criteria</span>.<span class="ruby-identifier">empty?</span>
336: <span class="ruby-identifier">server_list</span>.<span class="ruby-identifier">flatten</span>
337: <span class="ruby-keyword kw">else</span>
338: <span class="ruby-comment cmt"># normalize the criteria list, so that every entry is a key to a</span>
339: <span class="ruby-comment cmt"># criteria hash (possibly empty).</span>
340: <span class="ruby-identifier">criteria</span> = <span class="ruby-identifier">criteria</span>.<span class="ruby-identifier">inject</span>({}) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">hash</span>, <span class="ruby-identifier">entry</span><span class="ruby-operator">|</span>
341: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">entry</span>
342: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Hash</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">entry</span>)
343: <span class="ruby-keyword kw">else</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">entry</span> =<span class="ruby-operator">></span> {})
344: <span class="ruby-keyword kw">end</span>
345: <span class="ruby-keyword kw">end</span>
346: 
347: <span class="ruby-identifier">list</span> = <span class="ruby-identifier">criteria</span>.<span class="ruby-identifier">inject</span>([]) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">aggregator</span>, (<span class="ruby-identifier">group</span>, <span class="ruby-identifier">properties</span>)<span class="ruby-operator">|</span>
348: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">"the value for any group must be a Hash, but got a #{properties.class} for #{group.inspect}"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">properties</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
349: <span class="ruby-identifier">bad_keys</span> = <span class="ruby-identifier">properties</span>.<span class="ruby-identifier">keys</span> <span class="ruby-operator">-</span> [<span class="ruby-identifier">:only</span>, <span class="ruby-identifier">:except</span>]
350: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">"unknown constraint(s) #{bad_keys.inspect} for #{group.inspect}"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">bad_keys</span>.<span class="ruby-identifier">empty?</span>
351: 
352: <span class="ruby-identifier">servers</span> = <span class="ruby-identifier">groups</span>[<span class="ruby-identifier">group</span>].<span class="ruby-identifier">select</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
353: (<span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:only</span>] <span class="ruby-operator">||</span> {}).<span class="ruby-identifier">all?</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">prop</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">server</span>[<span class="ruby-identifier">prop</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">value</span> } <span class="ruby-operator">&&</span>
354: <span class="ruby-operator">!</span>(<span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:except</span>] <span class="ruby-operator">||</span> {}).<span class="ruby-identifier">any?</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">prop</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">server</span>[<span class="ruby-identifier">prop</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">value</span> }
355: <span class="ruby-keyword kw">end</span>
356: 
357: <span class="ruby-identifier">aggregator</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">servers</span>)
358: <span class="ruby-keyword kw">end</span>
359: 
360: <span class="ruby-identifier">list</span>.<span class="ruby-identifier">uniq</span>
361: <span class="ruby-keyword kw">end</span>
362: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000069'> + <a name='M000069'> </a> + <div class='synopsis'> + <span class='name'>use</span> + <span class='arguments'>(*hosts, &block)</span> + </div> + <div class='description'> + <p> + Defines a new server definition, to be managed by this session. The server + is at the given <tt>host</tt>, and will be connected to as the given + <tt>user</tt>. The other options are passed as-is to the <a + href="../../SSH.html">Net::SSH</a> session constructor. + </p> + <p> + If a default gateway has been specified previously (with <a + href="Session.html#M000068">via</a>) it will be passed to the new server + definition. You can override this by passing a different Net::SSH::Gateway + instance (or <tt>nil</tt>) with the :via key in the <tt>options</tt>. + </p> + <pre>session.use 'host'
session.use 'user@host2', :via => nil
session.use 'host3', :user => "user3", :via => Net::SSH::Gateway.new('gateway.host', 'user')</pre> + <p> + If only a single host is given, the new server instance is returned. You + can give multiple hosts at a time, though, in which case an array of server + instances will be returned. + </p> + <pre>server1, server2 = session.use "host1", "host2"</pre> + <p> + If given a block, this will save the block as a <a + href="DynamicServer.html">Net::SSH::Multi::DynamicServer</a> definition, to + be evaluated lazily the first time the server is needed. The block will + recive any options hash given to <a href="Session.html#M000069">use</a>, + and should return <tt>nil</tt> (if no servers are to be added), a String or + an array of Strings (to be interpreted as a connection specification), or a + <a href="Server.html">Server</a> or an array of Servers. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000069-source'); return false"> + [show source] + </a> + <pre id='M000069-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/session.rb, line 274</span>
274: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">use</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">hosts</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
275: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">hosts</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">hosts</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> {}
276: <span class="ruby-identifier">options</span> = { <span class="ruby-identifier">:via</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">default_gateway</span> }.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">options</span>)
277: 
278: <span class="ruby-identifier">results</span> = <span class="ruby-identifier">hosts</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">host</span><span class="ruby-operator">|</span>
279: <span class="ruby-identifier">server_list</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Server</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">host</span>, <span class="ruby-identifier">options</span>))
280: <span class="ruby-keyword kw">end</span>
281: 
282: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span>
283: <span class="ruby-identifier">results</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">server_list</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">DynamicServer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">options</span>, <span class="ruby-identifier">block</span>))
284: <span class="ruby-keyword kw">end</span>
285: 
286: <span class="ruby-identifier">group</span> [] =<span class="ruby-operator">></span> <span class="ruby-identifier">results</span>
287: <span class="ruby-identifier">results</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">></span> <span class="ruby-value">1</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">results</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">results</span>.<span class="ruby-identifier">first</span>
288: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000068'> + <a name='M000068'> </a> + <div class='synopsis'> + <span class='name'>via</span> + <span class='arguments'>(host, user, options={})</span> + </div> + <div class='description'> + <p> + Sets up a default gateway to use when establishing connections to servers. + Note that any servers defined prior to this invocation will not use the + default gateway; it only affects servers defined subsequently. + </p> + <pre>session.via 'gateway.host', 'user'</pre> + <p> + You may override the default gateway on a per-server basis by passing the + :via key to the <a href="Session.html#M000069">use</a> method; see <a + href="Session.html#M000069">use</a> for details. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000068-source'); return false"> + [show source] + </a> + <pre id='M000068-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/session.rb, line 243</span>
243: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">via</span>(<span class="ruby-identifier">host</span>, <span class="ruby-identifier">user</span>, <span class="ruby-identifier">options</span>={})
244: <span class="ruby-ivar">@default_gateway</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">SSH</span><span class="ruby-operator">::</span><span class="ruby-constant">Gateway</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">host</span>, <span class="ruby-identifier">user</span>, <span class="ruby-identifier">options</span>)
245: <span class="ruby-keyword kw">self</span>
246: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000072'> + <a name='M000072'> </a> + <div class='synopsis'> + <span class='name'>with</span> + <span class='arguments'>(*groups) {|subsession if block_given?| ...}</span> + </div> + <div class='description'> + <p> + Returns a new <a href="Subsession.html">Net::SSH::Multi::Subsession</a> + instance consisting of the servers that meet the given criteria. If a block + is given, the subsession will be yielded to it. See <a + href="Session.html#M000071">servers_for</a> for a discussion of how these + criteria are interpreted. + </p> + <pre>session.with(:app).exec('hostname')

session.with(:app, :db => { :primary => true }) do |s|
 s.exec 'date'
 s.exec 'uptime'
end</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000072-source'); return false"> + [show source] + </a> + <pre id='M000072-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/session.rb, line 375</span>
375: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">with</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">groups</span>)
376: <span class="ruby-identifier">subsession</span> = <span class="ruby-constant">Subsession</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">servers_for</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">groups</span>))
377: <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">subsession</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
378: <span class="ruby-identifier">subsession</span>
379: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + </div> + </div> + </div> + </div> + <div id='footer-push'></div> + </div> + <div id='footer'> + <a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a> + </div> + </body> +</html> diff --git a/classes/Net/SSH/Multi/SessionActions.html b/classes/Net/SSH/Multi/SessionActions.html new file mode 100644 index 0000000..ad9a7b4 --- /dev/null +++ b/classes/Net/SSH/Multi/SessionActions.html @@ -0,0 +1,272 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html lang='en'> + <head> + <title>: Net::SSH::Multi::SessionActions [Control multiple Net::SSH connections via a single interface.]</title> + <meta content='text/html; charset=utf-8' http-equiv='Content-Type'> + <link href='../../../../rdoc-style.css' media='screen' rel='stylesheet' type='text/css'> + <script type='text/javascript'> + //<![CDATA[ + function popupCode(url) { + window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") + } + + function toggleCode(id) { + var code = document.getElementById(id) + + code.style.display = code.style.display != 'block' ? 'block' : 'none' + return true + } + + // Make codeblocks hidden by default + document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>') + //]]> + </script> + </head> + <body class='page'> + <div class='class' id='wrapper'> + <div class='header'> + <h1 class='name'> + <span class='type'>Module</span> + Net::SSH::Multi::SessionActions + </h1> + <ol class='paths'> + <li> + <a href="../../../../files/lib/net/ssh/multi/session_actions_rb.html">lib/net/ssh/multi/session_actions.rb</a> + </li> + </ol> + </div> + <div id='content'> + <div id='text'> + <div id='description'> + <p> + This module represents the actions that are available on session + collections. Any class that includes this module needs only provide a + <tt>servers</tt> method that returns a list of <a + href="Server.html">Net::SSH::Multi::Server</a> instances, and the rest just + works. See <a href="Session.html">Net::SSH::Multi::Session</a> and <a + href="Subsession.html">Net::SSH::Multi::Subsession</a> for consumers of + this module. + </p> + </div> + <div id='method-list'> + <h2>Methods</h2> + <h3>public instance</h3> + <ol> + <li><a href="#M000004">busy?</a></li> + <li><a href="#M000003">connect!</a></li> + <li><a href="#M000008">exec</a></li> + <li><a href="#M000002">master</a></li> + <li><a href="#M000007">open_channel</a></li> + <li><a href="#M000006">send_global_request</a></li> + <li><a href="#M000005">sessions</a></li> + </ol> + </div> + <div id='section'> + <div id='methods'> + <h2>Public instance methods</h2> + <div class='method public-instance' id='method-M000004'> + <a name='M000004'> </a> + <div class='synopsis'> + <span class='name'>busy?</span> + <span class='arguments'>(include_invisible=false)</span> + </div> + <div class='description'> + <p> + Returns <tt>true</tt> if any server in the current container has an open <a + href="../../SSH.html">SSH</a> session that is currently processing any + channels. If <tt>include_invisible</tt> is <tt>false</tt> (the default) + then invisible channels (such as those created by port forwarding) will not + be counted; otherwise, they will be. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000004-source'); return false"> + [show source] + </a> + <pre id='M000004-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/session_actions.rb, line 29</span>
29: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">busy?</span>(<span class="ruby-identifier">include_invisible</span>=<span class="ruby-keyword kw">false</span>)
30: <span class="ruby-identifier">servers</span>.<span class="ruby-identifier">any?</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span> <span class="ruby-identifier">server</span>.<span class="ruby-identifier">busy?</span>(<span class="ruby-identifier">include_invisible</span>) }
31: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000003'> + <a name='M000003'> </a> + <div class='synopsis'> + <span class='name'>connect!</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Connections are normally established lazily, as soon as they are needed. + This method forces all servers in the current container to have their + connections established immediately, blocking until the connections have + been made. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000003-source'); return false"> + [show source] + </a> + <pre id='M000003-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/session_actions.rb, line 20</span>
20: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">connect!</span>
21: <span class="ruby-identifier">sessions</span>
22: <span class="ruby-keyword kw">self</span>
23: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000008'> + <a name='M000008'> </a> + <div class='synopsis'> + <span class='name'>exec</span> + <span class='arguments'>(command, &block)</span> + </div> + <div class='description'> + <p> + A convenience method for executing a command on multiple hosts and either + displaying or capturing the output. It opens a channel on all active + sessions (see <a href="SessionActions.html#M000007">open_channel</a> and + active_sessions), and then executes a command on each channel + (Net::SSH::Connection::Channel#exec). + </p> + <p> + If a block is given, it will be invoked whenever data is received across + the channel, with three arguments: the channel object, a symbol identifying + which output stream the data was received on (<tt>:stdout</tt> or + <tt>:stderr</tt>) and a string containing the data that was received: + </p> + <pre>session.exec("command") do |ch, stream, data|
 puts "[#{ch[:host]} : #{stream}] #{data}"
end</pre> + <p> + If no block is given, all output will be written to +$stdout+ or +$stderr+, + as appropriate. + </p> + <p> + Note that <a href="SessionActions.html#M000008">exec</a> will also capture + the exit status of the process in the <tt>:exit_status</tt> property of + each channel. Since <a href="SessionActions.html#M000008">exec</a> returns + all of the channels in a <a + href="Channel.html">Net::SSH::Multi::Channel</a> object, you can check for + the exit status like this: + </p> + <pre>channel = session.exec("command") { ... }
channel.wait

if channel.any? { |c| c[:exit_status] != 0 }
 puts "executing failed on at least one host!"
end</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000008-source'); return false"> + [show source] + </a> + <pre id='M000008-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/session_actions.rb, line 119</span>
119: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">exec</span>(<span class="ruby-identifier">command</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
120: <span class="ruby-identifier">open_channel</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">channel</span><span class="ruby-operator">|</span>
121: <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">exec</span>(<span class="ruby-identifier">command</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ch</span>, <span class="ruby-identifier">success</span><span class="ruby-operator">|</span>
122: <span class="ruby-identifier">raise</span> <span class="ruby-node">"could not execute command: #{command.inspect} (#{ch[:host]})"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">success</span>
123: 
124: <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">on_data</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ch</span>, <span class="ruby-identifier">data</span><span class="ruby-operator">|</span>
125: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span>
126: <span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">ch</span>, <span class="ruby-identifier">:stdout</span>, <span class="ruby-identifier">data</span>)
127: <span class="ruby-keyword kw">else</span>
128: <span class="ruby-identifier">data</span>.<span class="ruby-identifier">chomp</span>.<span class="ruby-identifier">each_line</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
129: <span class="ruby-identifier">$stdout</span>.<span class="ruby-identifier">puts</span>(<span class="ruby-node">"[#{ch[:host]}] #{line}"</span>)
130: <span class="ruby-keyword kw">end</span>
131: <span class="ruby-keyword kw">end</span>
132: <span class="ruby-keyword kw">end</span>
133: 
134: <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">on_extended_data</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ch</span>, <span class="ruby-identifier">type</span>, <span class="ruby-identifier">data</span><span class="ruby-operator">|</span>
135: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span>
136: <span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">ch</span>, <span class="ruby-identifier">:stderr</span>, <span class="ruby-identifier">data</span>)
137: <span class="ruby-keyword kw">else</span>
138: <span class="ruby-identifier">data</span>.<span class="ruby-identifier">chomp</span>.<span class="ruby-identifier">each_line</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
139: <span class="ruby-identifier">$stderr</span>.<span class="ruby-identifier">puts</span>(<span class="ruby-node">"[#{ch[:host]}] #{line}"</span>)
140: <span class="ruby-keyword kw">end</span>
141: <span class="ruby-keyword kw">end</span>
142: <span class="ruby-keyword kw">end</span>
143: 
144: <span class="ruby-identifier">channel</span>.<span class="ruby-identifier">on_request</span>(<span class="ruby-value str">"exit-status"</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ch</span>, <span class="ruby-identifier">data</span><span class="ruby-operator">|</span>
145: <span class="ruby-identifier">ch</span>[<span class="ruby-identifier">:exit_status</span>] = <span class="ruby-identifier">data</span>.<span class="ruby-identifier">read_long</span>
146: <span class="ruby-keyword kw">end</span>
147: <span class="ruby-keyword kw">end</span>
148: <span class="ruby-keyword kw">end</span>
149: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000002'> + <a name='M000002'> </a> + <div class='synopsis'> + <span class='name'>master</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Returns the session that is the “master”. This defaults to + <tt>self</tt>, but classes that include this module may wish to change this + if they are subsessions that depend on a master session. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000002-source'); return false"> + [show source] + </a> + <pre id='M000002-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/session_actions.rb, line 12</span>
12: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">master</span>
13: <span class="ruby-keyword kw">self</span>
14: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000007'> + <a name='M000007'> </a> + <div class='synopsis'> + <span class='name'>open_channel</span> + <span class='arguments'>(type="session", *extra, &on_confirm)</span> + </div> + <div class='description'> + <p> + Asks all sessions for all contained servers (see <a + href="SessionActions.html#M000005">sessions</a>) to open a new channel. + When each server responds, the <tt>on_confirm</tt> block will be invoked + with a single argument, the channel object for that server. This means that + the block will be invoked one time for each session. + </p> + <p> + All new channels will be collected and returned, aggregated into a new <a + href="Channel.html">Net::SSH::Multi::Channel</a> instance. + </p> + <p> + Note that the channels are “enhanced” slightly—they have + two properties set on them automatically, to make dealing with them in a + multi-session environment slightly easier: + </p> + <ul> + <li>:server => the <a href="Server.html">Net::SSH::Multi::Server</a> instance + that spawned the channel + + </li> + <li>:host => the host name of the server + + </li> + </ul> + <p> + Having access to these things lets you more easily report which host (e.g.) + data was received from: + </p> + <pre>session.open_channel do |channel|
 channel.exec "command" do |ch, success|
 ch.on_data do |ch, data|
 puts "got data #{data} from #{ch[:host]}"
 end
 end
end</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000007-source'); return false"> + [show source] + </a> + <pre id='M000007-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/session_actions.rb, line 80</span>
80: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">open_channel</span>(<span class="ruby-identifier">type</span>=<span class="ruby-value str">"session"</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">extra</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">on_confirm</span>)
81: <span class="ruby-identifier">channels</span> = <span class="ruby-identifier">sessions</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ssh</span><span class="ruby-operator">|</span>
82: <span class="ruby-identifier">ssh</span>.<span class="ruby-identifier">open_channel</span>(<span class="ruby-identifier">type</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">extra</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span>
83: <span class="ruby-identifier">c</span>[<span class="ruby-identifier">:server</span>] = <span class="ruby-identifier">c</span>.<span class="ruby-identifier">connection</span>[<span class="ruby-identifier">:server</span>]
84: <span class="ruby-identifier">c</span>[<span class="ruby-identifier">:host</span>] = <span class="ruby-identifier">c</span>.<span class="ruby-identifier">connection</span>[<span class="ruby-identifier">:server</span>].<span class="ruby-identifier">host</span>
85: <span class="ruby-identifier">on_confirm</span>[<span class="ruby-identifier">c</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">on_confirm</span>
86: <span class="ruby-keyword kw">end</span>
87: <span class="ruby-keyword kw">end</span>
88: <span class="ruby-constant">Multi</span><span class="ruby-operator">::</span><span class="ruby-constant">Channel</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">master</span>, <span class="ruby-identifier">channels</span>)
89: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000006'> + <a name='M000006'> </a> + <div class='synopsis'> + <span class='name'>send_global_request</span> + <span class='arguments'>(type, *extra, &callback)</span> + </div> + <div class='description'> + <p> + Sends a global request to the sessions for all contained servers (see <a + href="SessionActions.html#M000005">sessions</a>). This can be used to + (e.g.) ping the remote servers to prevent them from timing out. + </p> + <pre>session.send_global_request("keep-alive@openssh.com")</pre> + <p> + If a block is given, it will be invoked when the server responds, with two + arguments: the <a href="../../SSH.html">Net::SSH</a> connection that is + responding, and a boolean indicating whether the request succeeded or not. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000006-source'); return false"> + [show source] + </a> + <pre id='M000006-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/session_actions.rb, line 50</span>
50: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_global_request</span>(<span class="ruby-identifier">type</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">extra</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">callback</span>)
51: <span class="ruby-identifier">sessions</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">ssh</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ssh</span>.<span class="ruby-identifier">send_global_request</span>(<span class="ruby-identifier">type</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">extra</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">callback</span>) }
52: <span class="ruby-keyword kw">self</span>
53: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000005'> + <a name='M000005'> </a> + <div class='synopsis'> + <span class='name'>sessions</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Returns an array of all <a href="../../SSH.html">SSH</a> sessions, blocking + until all sessions have connected. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000005-source'); return false"> + [show source] + </a> + <pre id='M000005-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/session_actions.rb, line 35</span>
35: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sessions</span>
36: <span class="ruby-identifier">threads</span> = <span class="ruby-identifier">servers</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span> <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> { <span class="ruby-identifier">server</span>.<span class="ruby-identifier">session</span>(<span class="ruby-keyword kw">true</span>) } <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">server</span>.<span class="ruby-identifier">session</span>.<span class="ruby-identifier">nil?</span> }
37: <span class="ruby-identifier">threads</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">thread</span><span class="ruby-operator">|</span> <span class="ruby-identifier">thread</span>.<span class="ruby-identifier">join</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">thread</span> }
38: <span class="ruby-identifier">servers</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span> <span class="ruby-identifier">server</span>.<span class="ruby-identifier">session</span> }.<span class="ruby-identifier">compact</span>
39: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + </div> + </div> + </div> + </div> + <div id='footer-push'></div> + </div> + <div id='footer'> + <a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a> + </div> + </body> +</html> diff --git a/classes/Net/SSH/Multi/Subsession.html b/classes/Net/SSH/Multi/Subsession.html new file mode 100644 index 0000000..e6268a7 --- /dev/null +++ b/classes/Net/SSH/Multi/Subsession.html @@ -0,0 +1,169 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html lang='en'> + <head> + <title>: Net::SSH::Multi::Subsession [Control multiple Net::SSH connections via a single interface.]</title> + <meta content='text/html; charset=utf-8' http-equiv='Content-Type'> + <link href='../../../../rdoc-style.css' media='screen' rel='stylesheet' type='text/css'> + <script type='text/javascript'> + //<![CDATA[ + function popupCode(url) { + window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") + } + + function toggleCode(id) { + var code = document.getElementById(id) + + code.style.display = code.style.display != 'block' ? 'block' : 'none' + return true + } + + // Make codeblocks hidden by default + document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>') + //]]> + </script> + </head> + <body class='page'> + <div class='class' id='wrapper'> + <div class='header'> + <h1 class='name'> + <span class='type'>Class</span> + Net::SSH::Multi::Subsession + </h1> + <ol class='paths'> + <li> + <a href="../../../../files/lib/net/ssh/multi/subsession_rb.html">lib/net/ssh/multi/subsession.rb</a> + </li> + </ol> + <div class='parent'> + Parent: + <strong>Object</strong> + </div> + </div> + <div id='content'> + <div id='text'> + <div id='description'> + <p> + A trivial class for representing a subset of servers. It is used internally + for restricting operations to a subset of all defined servers. + </p> + <pre>subsession = session.with(:app)
subsession.exec("hostname")</pre> + </div> + <div id='method-list'> + <h2>Methods</h2> + <h3>public class</h3> + <ol> + <li><a href="#M000078">new</a></li> + </ol> + <h3>public instance</h3> + <ol> + <li><a href="#M000080">first</a></li> + <li><a href="#M000079">slice</a></li> + </ol> + </div> + <div id='context'> + <div id='includes'> + <h2>Included modules</h2> + <ol> + <li><a href="SessionActions.html">SessionActions</a></li> + </ol> + </div> + </div> + <div id='section'> + <div id='attribute-list'> + <h2 class='section-bar'>Attributes</h2> + <div class='name-list'> + <table> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>master</td> + <td class='context-item-value'>[R]</td> + <td class='context-item-desc'> + + The master session that spawned this subsession. + </td> + </tr> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>servers</td> + <td class='context-item-value'>[R]</td> + <td class='context-item-desc'> + + The list of servers that this subsession can operate on. + </td> + </tr> + </table> + </div> + </div> + <div id='methods'> + <h2>Public class methods</h2> + <div class='method public-class' id='method-M000078'> + <a name='M000078'> </a> + <div class='synopsis'> + <span class='name'>new</span> + <span class='arguments'>(master, server_list)</span> + </div> + <div class='description'> + <p> + Create a new subsession of the given <tt>master</tt> session, that operates + on the given <tt>server_list</tt>. + </p> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000078-source'); return false"> + [show source] + </a> + <pre id='M000078-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/subsession.rb, line 22</span>
22: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">master</span>, <span class="ruby-identifier">server_list</span>)
23: <span class="ruby-ivar">@master</span> = <span class="ruby-identifier">master</span>
24: <span class="ruby-ivar">@servers</span> = <span class="ruby-identifier">server_list</span>.<span class="ruby-identifier">uniq</span>
25: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <h2>Public instance methods</h2> + <div class='method public-instance' id='method-M000080'> + <a name='M000080'> </a> + <div class='synopsis'> + <span class='name'>first</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Returns a new subsession that consists of only the first server in the + server list of the current subsession. This is just convenience for + slice(0): + </p> + <pre>s1 = subsession.first</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000080-source'); return false"> + [show source] + </a> + <pre id='M000080-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/subsession.rb, line 43</span>
43: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">first</span>
44: <span class="ruby-identifier">slice</span>(<span class="ruby-value">0</span>)
45: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000079'> + <a name='M000079'> </a> + <div class='synopsis'> + <span class='name'>slice</span> + <span class='arguments'>(*args)</span> + </div> + <div class='description'> + <p> + Works as Array#slice, but returns a new subsession consisting of the given + slice of servers in this subsession. The new subsession will have the same + master session as this subsession does. + </p> + <pre>s1 = subsession.slice(0)
s2 = subsession.slice(3, -1)
s3 = subsession.slice(1..4)</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000079-source'); return false"> + [show source] + </a> + <pre id='M000079-source'> <span class="ruby-comment cmt"># File lib/net/ssh/multi/subsession.rb, line 34</span>
34: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">slice</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
35: <span class="ruby-constant">Subsession</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">master</span>, <span class="ruby-constant">Array</span>(<span class="ruby-identifier">servers</span>.<span class="ruby-identifier">slice</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)))
36: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + </div> + </div> + </div> + </div> + <div id='footer-push'></div> + </div> + <div id='footer'> + <a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a> + </div> + </body> +</html> diff --git a/classes/Net/SSH/Multi/Version.html b/classes/Net/SSH/Multi/Version.html new file mode 100644 index 0000000..3b9b8ad --- /dev/null +++ b/classes/Net/SSH/Multi/Version.html @@ -0,0 +1,117 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html lang='en'> + <head> + <title>: Net::SSH::Multi::Version [Control multiple Net::SSH connections via a single interface.]</title> + <meta content='text/html; charset=utf-8' http-equiv='Content-Type'> + <link href='../../../../rdoc-style.css' media='screen' rel='stylesheet' type='text/css'> + <script type='text/javascript'> + //<![CDATA[ + function popupCode(url) { + window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") + } + + function toggleCode(id) { + var code = document.getElementById(id) + + code.style.display = code.style.display != 'block' ? 'block' : 'none' + return true + } + + // Make codeblocks hidden by default + document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>') + //]]> + </script> + </head> + <body class='page'> + <div class='class' id='wrapper'> + <div class='header'> + <h1 class='name'> + <span class='type'>Class</span> + Net::SSH::Multi::Version + </h1> + <ol class='paths'> + <li> + <a href="../../../../files/lib/net/ssh/multi/version_rb.html">lib/net/ssh/multi/version.rb</a> + </li> + </ol> + <div class='parent'> + Parent: + <strong>Net::SSH::Version</strong> + </div> + </div> + <div id='content'> + <div id='text'> + <div id='description'> + <p> + A trivial class for representing the version of this library. + </p> + </div> + <div id='section'> + <div id='constants-list'> + <h2>Constants</h2> + <div class='name-list'> + <table summary='Constants'> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>MAJOR</td> + <td>=</td> + <td class='context-item-value'>1</td> + <td> </td> + <td class='context-item-desc'> + + The major component of the library’s version + </td> + </tr> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>MINOR</td> + <td>=</td> + <td class='context-item-value'>1</td> + <td> </td> + <td class='context-item-desc'> + + The minor component of the library’s version + </td> + </tr> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>TINY</td> + <td>=</td> + <td class='context-item-value'>0</td> + <td> </td> + <td class='context-item-desc'> + + The tiny component of the library’s version + </td> + </tr> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>CURRENT</td> + <td>=</td> + <td class='context-item-value'>new(MAJOR, MINOR, TINY)</td> + <td> </td> + <td class='context-item-desc'> + + The library’s version as a <a href="Version.html">Version</a> + instance + </td> + </tr> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>STRING</td> + <td>=</td> + <td class='context-item-value'>CURRENT.to_s</td> + <td> </td> + <td class='context-item-desc'> + + The library’s version as a String instance + </td> + </tr> + </table> + </div> + </div> + </div> + </div> + </div> + <div id='footer-push'></div> + </div> + <div id='footer'> + <a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a> + </div> + </body> +</html> |