Issue #12614 has been updated by Gary Richards.
As i'm slowly getting further with my project to get puppet working with my own switches, I wonder if I jumped the gun on this request due to not understanding how the code worked. As I had assumed that both the default prompt and the prompt passed to the command method should match in the output, I based my thinking around that assumption and therefore this ticket turned into more of a request for that ability rather than fully understanding what was actually happening and why it might only make sense to match against the specific prompt specified. I realise now that there may be a situation where you would try to expect(/Password:/) or something and you really would only ever want to match on that output NEVER on the default prompt. If you received the default prompt it might actually mean that something went wrong and that you don't want to continue. I also realise that due to my misunderstanding of how the code worked, I had assumed that this underlying code needed to be changed to be 'correct' when actually it was correct and that once it was explained above how this code works (ie. it's not a match this or match that, it's match this if it's not otherwise match that), I should have realised that making my switch code work this way and expect very specific things makes far far more sense than expecting something or the default prompt. That said, I can see that there may be instances where you might want to match a prompt or the default prompt. So perhaps this functionality could somehow be changed so that by default it works how it originally worked, but also have a way to tell it to work in a way that the patch allows. Essentially supporting both, but defaulting to how it originally worked. If I find time, perhaps i'll be able to provide such a patch myself! Anyhow, cutting a long post short, this patch as it is now probably should NOT end up merged into the mainline code. ---------------------------------------- Bug #12614: Possible problem in util/network_device/transport/telnet.rb https://projects.puppetlabs.com/issues/12614#change-55914 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.
