go-junos icon indicating copy to clipboard operation
go-junos copied to clipboard

RPC error "expecting </configuration>" returned on use of GetConfig

Open radcool opened this issue 9 years ago • 10 comments

Hi,

Whenever I try to retrieve a Junos config using:

jnpr, err := junos.NewSession(hostname, username, password)
config, err := jnpr.GetConfig("", "text")

I always get this error: netconf rpc [error]: syntax error, expecting </configuration>.

This doesn't seem to be device-specific as I get the same error on SRX, MX and QFX.

Is this a know bug or simply an error on my part?

I used go get about a week ago so the go-junos code I'm using should be fairly recent.

Thanks, -Martin

radcool avatar Sep 12 '16 14:09 radcool

It might be a bug. Thanks for catching this and I'll take a look at it!

scottdware avatar Sep 12 '16 15:09 scottdware

Actually, I see the problem. You have the parameters backwards. The "section" is supposed to be the second (optional) parameter. If you just specify the following:

config, err := jnpr.GetConfig("text")

Then you will get the entire config, vs something like:

config, err := jnpr.GetConfig("text", "interfaces")

I will have to work on the MX parsing, as it's not coming through as it should. Everything else should work ok - I tested it on a QFX, EX, and SRX.

scottdware avatar Sep 12 '16 17:09 scottdware

OK, I think I know what might have happened. I stumbled upon your library from this blog entry. One of the examples on the page is the following:

routing, _ := jnpr.GetConfig("routing-instances", "text")  
fmt.Println(routing)

I just used that example as a start for my program and didn't double check with the GoDoc documentation. The RPC error returned wasn't obviously clear (to me), so it didn't dawn on me to double-check the docs to make sure I was using the function correctly.

Switching the argument order in my function call made it work, as you explained. Thanks for looking into it!

Do you need me to test anything with an MX?

Thanks, -Martin

radcool avatar Sep 13 '16 01:09 radcool

Ah...forgot to update my blog when I changed the function parameters around :) Thanks a lot!

Yeah, if you wouldn't mind testing, that would be great. I spent just a couple minutes diving into it yesterday, and apparently the XML response on the "get-software-information" RPC call is different than that of the other platforms.

scottdware avatar Sep 13 '16 10:09 scottdware

I tested using routing, err := jnpr.GetConfig("text") on an MX960 running 14.1R4.10 and was able to retrieve the config without any error. XML format retrieval also worked fine.

radcool avatar Sep 13 '16 12:09 radcool

Do you have dual routing engines?

scottdware avatar Sep 13 '16 23:09 scottdware

Yes.

radcool avatar Sep 14 '16 12:09 radcool

I'm running 14.2R5.8 on our MX104's and get an error. Must be tied to the model. I'll dig into it more. Thanks for the continued effort!

scottdware avatar Sep 15 '16 14:09 scottdware

My pleasure!

radcool avatar Sep 15 '16 15:09 radcool

@scottdware if you can provide me with the sanitized XML output of the equivalent SSH command, and the error you get from go-junos, I can try to fix it. I don't have access to any dual-RE MX gear, though.

daemus avatar Dec 06 '18 19:12 daemus