Juniper / net-netconf

A Ruby gem for NETCONF
Other
64 stars 37 forks source link

unable to call Junos::Ez::Provider #47

Open lucasiglesias opened 8 years ago

lucasiglesias commented 8 years ago

Hi, I´m having almost the same issue as listed in https://github.com/Juniper/net-netconf/issues/37 But already checked to be correctly using 'net/netconf/jnpr'

Here is the script:

    #!/usr/bin/ruby

    require 'pp'
    require 'net/netconf/jnpr'
    require 'junos-ez/stdlib'
    require 'highline/import'

    # Create a hash map to hold login parameters for NetConf session
    login = Hash.new

    # Prompt for system IP, username and password
    login[:target]   = "192.168.108.199"
    login[:username] = ask("username: "){     |a| a.echo = true }

    # Connect to target and start netconf ssh session
    dev = Netconf::SSH.new( login ) 
    dev.open

    Junos::Ez::Provider( dev )

    pp dev.facts.catalog

    dev.close

And here the output:

# ./ruby_ez_1.rb 
username: test
/usr/local/rvm/gems/ruby-2.2.1/gems/net-netconf-0.4.3/lib/net/netconf/rpc.rb:32:in `block (3 levels) in method_missing': undefined method `each' for "show version":String (NoMethodError)
        from /usr/local/rvm/gems/ruby-2.2.1/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/builder.rb:391:in `call'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/builder.rb:391:in `insert'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/builder.rb:375:in `method_missing'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/net-netconf-0.4.3/lib/net/netconf/rpc.rb:31:in `block (2 levels) in method_missing'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/builder.rb:391:in `call'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/builder.rb:391:in `insert'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/builder.rb:375:in `method_missing'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/net-netconf-0.4.3/lib/net/netconf/rpc.rb:31:in `block in method_missing'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/builder.rb:293:in `initialize'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/net-netconf-0.4.3/lib/net/netconf/rpc.rb:30:in `new'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/net-netconf-0.4.3/lib/net/netconf/rpc.rb:30:in `method_missing'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/net-netconf-0.4.3/lib/net/netconf/rpc.rb:65:in `method_missing'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/junos-ez-stdlib-0.1.2/lib/junos-ez/facts/version.rb:22:in `block in <top (required)>'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/junos-ez-stdlib-0.1.2/lib/junos-ez/facts.rb:67:in `block in read!'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/junos-ez-stdlib-0.1.2/lib/junos-ez/facts.rb:64:in `each'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/junos-ez-stdlib-0.1.2/lib/junos-ez/facts.rb:64:in `read!'
        from /usr/local/rvm/gems/ruby-2.2.1/gems/junos-ez-stdlib-0.1.2/lib/junos-ez/facts.rb:16:in `Provider'
        from ./ruby_ez_1.rb:20:in `<main>'

Any ideas?

dgjnpr commented 8 years ago

Hi @lucasiglesias

I have submitted a pull request to fix the bug you have found.

The problem is with a new method recently added that caused a few methods (including the command method) to masked. This results in method_missing getting called which does not handle the input correctly.

ehayon commented 7 years ago

I am having the same issue - unable to use Junos::Ez at all. Any fixes? Running ruby-2.2.2