Junos Automation (Scripting)
Highlighted
Junos Automation (Scripting)

Conversion from xml to set command

[ Edited ]
‎12-24-2014 05:07 AM

How to convert device configuration from xml to set format configuration? Is there any API for it?

3 REPLIES 3
Highlighted
Junos Automation (Scripting)

Re: Conversion from xml to set command

‎01-07-2015 08:13 PM

I'm no JUNOS expert, but you might want to include some more details into what you're trying to do exactly.  Are you trying to view the config on your Juniper device in set commands or are you trying to convert an xml config that was stored externally and convert that into set commands?

 

If you are trying to do the first, I hope you've already found your answer and found that you can do "show | display set" on your Juniper device.  You can also drill down into your stanzas like "show interfaces | display set".

 

I would imagine you could use SLAX or XSLT for the latter situation.

 

g'luck,

 

mrrex4

Highlighted
Junos Automation (Scripting)

Re: Conversion from xml to set command

‎01-07-2015 11:27 PM

Hi,

 

You can do reverse from Junos commands to xml view as below example

 

> show configuration interfaces ge-0/0/9 | display xml
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/11.4R7/junos">
<configuration junos:commit-seconds="1419945195" junos:commit-localtime="2014-12-30 16:13:15 AST" junos:commit-user="root">
<interfaces>
<interface>
<name>ge-0/0/9</name>
<gigether-options>
<redundant-parent>
<parent>reth3</parent>
</redundant-parent>
</gigether-options>
</interface>
</interfaces>
</configuration>
<cli>
<banner>{secondary:node1}</banner>
</cli>
</rpc-reply>

Regards,
Mohamed Elhariry
2* JNCIE (SEC # 159, SP # 1059),JNCIP-ENT

[Click the "Star" for Kudos if you think I earned it!
If this solution worked for you please flag my post as an "Accepted Solution" so others can benefit..]
Highlighted
Junos Automation (Scripting)

Re: Conversion from xml to set command

‎10-19-2018 02:50 AM

Found an external link to convert configuration from xml to set format:

 

http://www.stewartb.com/cgi-bin/juniper.pl

Feedback