Automation

last person joined: yesterday 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  PyEZ saving Active Config

    Posted 09-28-2015 06:06

    Hi
    I want to save the active configuration to a text file without touching the rescue config. I found alot of info about rescue config but none about saving /transferring active configuration. How can I do it?

    Thanks
    Oscar



  • 2.  RE: PyEZ saving Active Config
    Best Answer

     
    Posted 09-30-2015 15:11

    Hi,

     

    You can simply scp the file off the device.

     

    /config/juniper.conf.gz

     

    This is just a gzipped text file so you can ungzip if you wish.

     

    Tim



  • 3.  RE: PyEZ saving Active Config

    Posted 10-01-2015 00:22

    SCP work fine thank you


    This was the solution I came up with for those interested. Basically getting the "show configuration" output as string and writing it to a file

     

    from jnpr.junos import Device
    ####Connect to Device
    dev = Device(host='192.168.56.2', user='root', password='Juniper1')
    #192.168.56.2
    dev.open()

    class Create_Config():
    def __init__(self):
    config=str(self.get_conf()) ####Get Config as Str

    #####Create/Write to Config to File
    with open("Config.config", "w") as text_file:
    text_file.write(config)
    text_file.close()
    #####Return Configuration
    def get_conf(self):
    return dev.cli("show configuration")


    run=Create_Config()