Class: Puppet::Util::NetworkDevice::Transport_ios::Base_ios
- Inherits:
-
Object
- Object
- Puppet::Util::NetworkDevice::Transport_ios::Base_ios
- Defined in:
- lib/puppet/util/network_device/transport_ios/base_ios.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#default_prompt ⇒ Object
Returns the value of attribute default_prompt.
-
#host ⇒ Object
Returns the value of attribute host.
-
#password ⇒ Object
Returns the value of attribute password.
-
#port ⇒ Object
Returns the value of attribute port.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #command(cmd, options = {}) ⇒ Object
- #expect(prompt) ⇒ Object
-
#initialize ⇒ Base_ios
constructor
A new instance of Base_ios.
- #send(cmd, noop) ⇒ Object
Constructor Details
#initialize ⇒ Base_ios
Returns a new instance of Base_ios.
7 8 9 10 |
# File 'lib/puppet/util/network_device/transport_ios/base_ios.rb', line 7 def initialize @timeout = 10 @cache = {} end |
Instance Attribute Details
#cache ⇒ Object
Returns the value of attribute cache.
5 6 7 |
# File 'lib/puppet/util/network_device/transport_ios/base_ios.rb', line 5 def cache @cache end |
#default_prompt ⇒ Object
Returns the value of attribute default_prompt.
5 6 7 |
# File 'lib/puppet/util/network_device/transport_ios/base_ios.rb', line 5 def default_prompt @default_prompt end |
#host ⇒ Object
Returns the value of attribute host.
5 6 7 |
# File 'lib/puppet/util/network_device/transport_ios/base_ios.rb', line 5 def host @host end |
#password ⇒ Object
Returns the value of attribute password.
5 6 7 |
# File 'lib/puppet/util/network_device/transport_ios/base_ios.rb', line 5 def password @password end |
#port ⇒ Object
Returns the value of attribute port.
5 6 7 |
# File 'lib/puppet/util/network_device/transport_ios/base_ios.rb', line 5 def port @port end |
#timeout ⇒ Object
Returns the value of attribute timeout.
5 6 7 |
# File 'lib/puppet/util/network_device/transport_ios/base_ios.rb', line 5 def timeout @timeout end |
#user ⇒ Object
Returns the value of attribute user.
5 6 7 |
# File 'lib/puppet/util/network_device/transport_ios/base_ios.rb', line 5 def user @user end |
Instance Method Details
#command(cmd, options = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/puppet/util/network_device/transport_ios/base_ios.rb', line 18 def command(cmd, = {}) noop = [:noop].nil? ? Puppet[:noop] : [:noop] if [:cache] return @cache[cmd] if @cache[cmd] send(cmd, noop) unless noop @cache[cmd] = expect([:prompt] || default_prompt) end else send(cmd, noop) unless noop expect([:prompt] || default_prompt) do |output| yield output if block_given? end end end end |
#expect(prompt) ⇒ Object
15 16 |
# File 'lib/puppet/util/network_device/transport_ios/base_ios.rb', line 15 def expect(prompt) end |
#send(cmd, noop) ⇒ Object
12 13 |
# File 'lib/puppet/util/network_device/transport_ios/base_ios.rb', line 12 def send(cmd, noop) end |