Automation

last person joined: 3 days ago 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  Save config to file

    Posted 04-25-2013 12:56

    Hi all,

     

    Not sure what I am missing here, but this isn't saving to a file no matter what I've tried so far.

     

     

    Option 1:

     var $config-save-command = <get-configuration save="/var/tmp/router.config">;
     var $save-rslt = jcs:execute( $jre, $config-save-command );

     

    Option 2:

    var $config-save-command = <command>"show configuration | save /var/tmp/router.config";

    var $save-rslt = jsc:invoke($config-save-command);

     

    Neither of these are creating a file in /var/tmp/ called router.config

     

    Any thoughts?



  • 2.  RE: Save config to file

    Posted 04-26-2013 03:36

    @ed_gpc,

     

    The <get-configuration> RPC does not support a "save" attribute (your option 1).  That would be cool, but here are the attribute options for <get-configuration> taken from our techpubs (circa 12.2)

     

       [changed="changed"]
       [commit-scripts="(apply | apply-no-transients | view)"]
       [compare="rollback" [rollback="[0-49]"]]
       [database="(candidate | committed)"]
       [format="(text | xml)"]
       [inherit="(defaults | inherit)"
       [groups="groups"] [interface-ranges="interface-ranges"]]
       [(junos:key | key )="key"]
    

     

    What you will need to do is retrieve the contents of the configuration using the RPC and then use a or other file write RPC. There are a few options that are described in the "Mastering Junos Automation" book.  I would also recommend you download the "Junos Automation Reference for SLAX" as well.

     

    Hope this helps!

     



  • 3.  RE: Save config to file
    Best Answer

    Posted 05-07-2013 06:38
      |   view attached

    Thanks Jeremy,


    Attached is the script I ended up with.

     

    Parts of it pulled from your ztp script!

     

    var $config-save-command = <command>"show configuration | display omit";
    			 var $save-rslt = jcs:execute( $jre, $config-save-command );
    			 var $fileput-cmd = <file-put> {
    				<filename> "/var/tmp/router.config";
    				<permission> "644";
    				<encoding> "ascii";
    				<delete-if-exist>;
    				<file-contents> {
    				expr  $save-rslt;
    			  }
    			}

     

    Attachment(s)

    zip
    backup-config-local.zip   1 KB 1 version