Junos Automation (Scripting)
Highlighted
Junos Automation (Scripting)

Convert set commands to XML?

‎07-26-2015 07:05 AM

Is it possible given a flat file config of set commands to somehow convert that into an XML-based config? Anyone know of any tools written to do that? 

3 REPLIES 3
Highlighted
Junos Automation (Scripting)

Re: Convert set commands to XML?

‎07-29-2015 02:14 AM

You can just paste the set commands to Junos device and then without commit do:

#show xxxx | display xml
Highlighted
Junos Automation (Scripting)

Re: Convert set commands to XML?

3 weeks ago

If you have access to device, you can use "show | compare | display xml".

 

kido@vmx-dev# show | compare
[edit interfaces ge-0/0/0]
-   description test;
+   description test2;
kido@vmx-dev# show | compare | display xml
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/17.2R1/junos">
<configuration>
<interfaces>
<interface>
<name>ge-0/0/0</name>
<description operation="delete"/>
<description operation="create">test2</description>
</interface>
</interfaces>
</configuration>
<cli>
<banner>[edit]</banner>
</cli>
</rpc-reply>
Highlighted
Junos Automation (Scripting)

Re: Convert set commands to XML?

3 weeks ago

Hello Crutcha,

 

Greetings!

 

Once committing the configuration, you can view them in XML format from operational mode (">")  also:-

> show configuration |display xml

 

<rpc-reply xmlns:junos="http://xml.juniper.net/junos/19.1R0/junos">
<configuration junos:commit-seconds="1588849378" junos:commit-localtime="2020-05-07 11:02:58 UTC" junos:commit-user="labroot">
<version>20190319.203446_builder.r1013243</version>
<groups>

.

.

.

</configuration>
<cli>
<banner></banner>
</cli>
</rpc-reply>

 

---------------------------------------------------

 

> show configuration |display set |match services
set system services ftp
set system services ssh root-login allow
set system services telnet
set chassis network-services enhanced-ip

 

> show configuration |match services|display xml
<services>
</services>
<network-services>enhanced-ip</network-services>

 

I hope this helps. Please mark this post "Accept as solution" if this answers your query. 

 

Kudos are always appreciated! Smiley Happy

 

Best Regards,

Lingabasappa H