Class: Puppet::Util::NetworkDevice::Transport_ios::Telnet
- Inherits:
-
Base_ios
- Object
- Base_ios
- Puppet::Util::NetworkDevice::Transport_ios::Telnet
- Defined in:
- lib/puppet/util/network_device/transport_ios/telnet.rb
Instance Method Summary collapse
- #close ⇒ Object
- #connect ⇒ Object
- #expect(prompt) ⇒ Object
- #handles_login? ⇒ Boolean
-
#initialize ⇒ Telnet
constructor
A new instance of Telnet.
- #send(line, noop = false) ⇒ Object
Constructor Details
#initialize ⇒ Telnet
Returns a new instance of Telnet.
7 8 9 |
# File 'lib/puppet/util/network_device/transport_ios/telnet.rb', line 7 def initialize() super() end |
Instance Method Details
#close ⇒ Object
21 22 23 24 |
# File 'lib/puppet/util/network_device/transport_ios/telnet.rb', line 21 def close @telnet.close if @telnet @telnet = nil end |
#connect ⇒ Object
15 16 17 18 19 |
# File 'lib/puppet/util/network_device/transport_ios/telnet.rb', line 15 def connect @telnet = Net::Telnet::new("Host" => host, "Port" => port || 23, "Timeout" => 10, "Prompt" => default_prompt) end |
#expect(prompt) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/puppet/util/network_device/transport_ios/telnet.rb', line 26 def expect(prompt) lines = '' @telnet.waitfor(prompt) do |out| lines << out.gsub(/\r\n/no, "\n") yield out if block_given? end lines.split(/\n/).each do |line| Puppet.debug("telnet: IN #{line}") if Puppet[:debug] Puppet.fail "Executed invalid Command! For a detailed output add --debug to the next Puppet run!" if line.match(/^% Invalid input detected at '\^' marker\.$/n) end lines end |
#handles_login? ⇒ Boolean
11 12 13 |
# File 'lib/puppet/util/network_device/transport_ios/telnet.rb', line 11 def handles_login? false end |
#send(line, noop = false) ⇒ Object
39 40 41 42 |
# File 'lib/puppet/util/network_device/transport_ios/telnet.rb', line 39 def send(line, noop = false) Puppet.debug("telnet: OUT #{line}") if Puppet[:debug] @telnet.puts(line) unless noop end |