Class: Puppet::Util::NetworkDevice::Cisco_ios::Device
- Inherits:
-
Base_ios
- Object
- Base_ios
- Puppet::Util::NetworkDevice::Cisco_ios::Device
- Defined in:
- lib/puppet/util/network_device/cisco_ios/device.rb
Instance Attribute Summary collapse
-
#enable_password ⇒ Object
Returns the value of attribute enable_password.
-
#switch ⇒ Object
Returns the value of attribute switch.
Instance Method Summary collapse
- #connect_transport ⇒ Object
- #enable ⇒ Object
- #facts ⇒ Object
- #init ⇒ Object
- #init_facts ⇒ Object
- #init_switch ⇒ Object
-
#initialize(url, options = {}) ⇒ Device
constructor
A new instance of Device.
- #login ⇒ Object
- #parse_enable(query) ⇒ Object
Constructor Details
#initialize(url, options = {}) ⇒ Device
Returns a new instance of Device.
12 13 14 15 16 17 |
# File 'lib/puppet/util/network_device/cisco_ios/device.rb', line 12 def initialize(url, = {}) super(url) @enable_password = [:enable_password] || parse_enable(@url.query) @initialized = false transport.default_prompt = /[#>]\s?\z/n end |
Instance Attribute Details
#enable_password ⇒ Object
Returns the value of attribute enable_password.
10 11 12 |
# File 'lib/puppet/util/network_device/cisco_ios/device.rb', line 10 def enable_password @enable_password end |
#switch ⇒ Object
Returns the value of attribute switch.
10 11 12 |
# File 'lib/puppet/util/network_device/cisco_ios/device.rb', line 10 def switch @switch end |
Instance Method Details
#connect_transport ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/puppet/util/network_device/cisco_ios/device.rb', line 23 def connect_transport transport.connect login transport.command("terminal length 0", :noop => false) do |out| enable if out =~ />\s?\z/n end end |
#enable ⇒ Object
41 42 43 44 45 |
# File 'lib/puppet/util/network_device/cisco_ios/device.rb', line 41 def enable raise "Can't issue \"enable\" to enter privileged, no enable password set" unless enable_password transport.command("enable", {:prompt => /^Password:/, :noop => false}) transport.command(enable_password, :noop => false) end |
#facts ⇒ Object
68 69 70 71 72 |
# File 'lib/puppet/util/network_device/cisco_ios/device.rb', line 68 def facts # This is here till we can fork Puppet init @facts.facts_to_hash end |
#init ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/puppet/util/network_device/cisco_ios/device.rb', line 47 def init # TODO: Stop being an Idiot ... unless @initialized connect_transport init_facts init_switch @initialized = true end return self end |
#init_facts ⇒ Object
63 64 65 66 |
# File 'lib/puppet/util/network_device/cisco_ios/device.rb', line 63 def init_facts @facts ||= Puppet::Util::NetworkDevice::Cisco_ios::Facts.new(transport) @facts.retrieve end |
#init_switch ⇒ Object
58 59 60 61 |
# File 'lib/puppet/util/network_device/cisco_ios/device.rb', line 58 def init_switch @switch ||= Puppet::Util::NetworkDevice::Cisco_ios::Model::Switch.new(transport, @facts.facts_to_hash) @switch.retrieve end |
#login ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/puppet/util/network_device/cisco_ios/device.rb', line 31 def login return if transport.handles_login? if @url.user != '' transport.command(@url.user, {:prompt => /^Password:/, :noop => false}) else transport.expect(/^Password:/) end transport.command(@url.password, :noop => false) end |
#parse_enable(query) ⇒ Object
19 20 21 |
# File 'lib/puppet/util/network_device/cisco_ios/device.rb', line 19 def parse_enable(query) return $1 if query =~ /enable=(.*)/ end |