Junos Automation (Scripting)
Highlighted
Junos Automation (Scripting)

Convert JSON formatted data to JunOS cli Configuration

‎02-23-2018 07:55 PM

Hello All,

 

Good day!

 

Is there a script available to map the configuration which is in json format (captured using 'display json' and then modified) to the JunOS cli configuration?

 

I'm runing 15.x version and cannot load the configurations as json data. 

 

Thanks,

Yaseen

 

Regards,

Yaseen

3 REPLIES 3
Highlighted
Junos Automation (Scripting)

Re: Convert JSON formatted data to JunOS cli Configuration

‎02-24-2018 04:02 AM

You shoud be able to load json directly via via 'load merge' or 'load override' as shown below:

 

jh@fw# load merge json terminal
[Type ^D at a new line to end input]
{
    "configuration" : {
        "@" : {
            "junos:changed-seconds" : "1518614114",
            "junos:changed-localtime" : "2018-02-14 14:15:14 CET"
        },
        "applications" : {
            "application" : [
            {
                "name" : "ip-tunnel",
                "protocol" : "ipip"
            }
            ]
        }
    }
}
load complete

[edit]
jh@fw#

--
Best regards,

Jonas Hauge Klingenberg
Juniper Ambassador & Technology Architect, SEC DATACOM A/S (Denmark)
Highlighted
Junos Automation (Scripting)

Re: Convert JSON formatted data to JunOS cli Configuration

‎02-24-2018 07:41 AM

Hi Jonas,

 

Thanks for your response.

 

I've two reasons why I cant do that -

 

1. I'm running a version thats not supporting load json, I think that option is available from 16.1. show commands with | display is supported though.

2. I've a use case in which I want to show the json stored data in my DB as a Junos configuration  before doing the actual configuration changes in a tool that I'm working on.

Highlighted
Junos Automation (Scripting)

Re: Convert JSON formatted data to JunOS cli Configuration

‎07-17-2018 09:17 PM

Might not be the best practice. Have you tried getting a dedicated Junos VM, load the json, then display in structured junos format?