Issue #12614 has been updated by Chris Price.

Thanks for all of the extra info, that is helpful.
----------------------------------------
Bug #12614: Possible problem in util/network_device/transport/telnet.rb
https://projects.puppetlabs.com/issues/12614#change-55355

Author: Gary Richards
Status: Accepted
Priority: Normal
Assignee: 
Category: network
Target version: 
Affected Puppet version: 2.7.10
Keywords: 
Branch: 


Hi,

I think there's a bug in util/network_device/transport/telnet.rb

I've been trying to modify a copy of the existing cisco network code work with 
HP Procurve switches and spent a little while trying to work out why I couldn't 
get the enable part to work.

in util/network_device/cisco/device.rb, in the enable method:
    transport.command("enable", :prompt => /^Password:/)

It just so happens the switch I was using to test my changes doesn't have an 
enable password. So when you type 'enable' you get dumped back into slightly 
changed prompt.

Now looking at the code in util/network_device/transport/telnet.rb
    def command(cmd, options = {})
      send(cmd)
      expect(options[:prompt] || default_prompt) do |output|
        yield output if block_given?
      end
    end
    
I think that's supposed to expect either the passed in prompt or the default 
prompt.

Now as suggested, the code that calls enable expects a prompt of Password: so 
looking at the above code, that should match Password: or the default prompt. 
So according to my calculations... that should mean that my switch, which 
doesn't require a password be entered should work with the same code. But it 
doesn't seem to work.

The prompt is never matched. I modified the code in 
util/network_device/cisco/device.rb, in the enable method by removing the 
prompt (to make sure that it only matches the default prompt):
    transport.command("enable")

Lo and behold it matches the default prompt and the enable method works fine.

That suggests to me that the
    options[:prompt] || default_prompt

Part of the code doesn't work however the original developer expected?

I guess it's possible that on cisco devices it's not possible to have no 
password for enable (I have no cisco device to check on)? Regardless of that, 
it's possible this code may be used some somewhere else either now or in the 
future where someone expects it to match a specific prompt or the default 
prompt and it might not work?


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to