From bde8ed8faffcfb155ec32b76c93485d311bc339c Mon Sep 17 00:00:00 2001 From: Brian Candler Date: Mon, 25 Jun 2018 12:19:49 +0100 Subject: Tidy up logic for sending 'enable' with or without password (#1418) --- lib/oxidized/model/netgear.rb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/netgear.rb b/lib/oxidized/model/netgear.rb index 951af1c..67675ad 100644 --- a/lib/oxidized/model/netgear.rb +++ b/lib/oxidized/model/netgear.rb @@ -14,15 +14,12 @@ class Netgear < Oxidized::Model end cfg :telnet, :ssh do - if vars :enable - post_login do - send "enable\n" - # Interpret enable: true as meaning we won't be prompted for a password - unless vars(:enable).is_a? TrueClass - expect /[pP]assword:\s?$/ - send vars(:enable) + "\n" - end - expect /^.+[#]$/ + post_login do + if vars(:enable) == true + cmd "enable" + elsif vars(:enable) + cmd "enable", /[pP]assword:\s?$/ + cmd vars(:enable) end end post_login 'terminal length 0' -- cgit v1.2.1