Automation

 View Only
last person joined: yesterday 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  simple rescue slax script

    Posted 08-24-2022 20:15
    I need help coming up with a script that sets rescue config and snapshot recovery.  Currently have this but it doesn't seem to be working:
    ersion 1.1;

    ns junos = "http://xml.juniper.net/junos/*/junos";
    ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
    ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";

    import "../import/junos.xsl";
    /* Junos Space annotations */
    /* @CONTEXT = "/device" */
    /* @NAME = "set rescue and recovery" */
    /* @DESCRIPTION = "set rescue and recovery" */
    /* @ISLOCAL = "true" */

    var $local = jcs:open();
    match / {
    <op-script-results> {
    var $command = <command> "request system configuration rescue save";
    var $command1 = <command> "request system snapshot recovery";
    var $results1 = jcs:execute( $local , $command , $command1 );
    copy-of $results1;
    var $close-results = jcs:close( $local);
    }
    }

    ------------------------------
    MARK JOHNS
    ------------------------------


  • 2.  RE: simple rescue slax script

    Posted 08-25-2022 10:59
    i tried slimming it down to just this and it isn't working:
    version 1.1;

    ns junos = "http://xml.juniper.net/junos/*/junos";
    ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
    ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";

    import "../import/junos.xsl";
    /* Junos Space annotations */
    /* @CONTEXT = "/device" */
    /* @NAME = "set rescue and recovery" */
    /* @DESCRIPTION = "set rescue and recovery" */
    /* @ISLOCAL = "true" */

    var $local = jcs:open();
    match / {
    <op-script-results> {
    var $command1 = <command> "request system configuration rescue save";
    var $close-results = jcs:close( $local);
    }
    }

    ------------------------------
    MARK JOHNS
    ------------------------------



  • 3.  RE: simple rescue slax script

    Posted 08-30-2022 16:01
    just checking.

    ------------------------------
    MARK JOHNS
    ------------------------------



  • 4.  RE: simple rescue slax script

     
    Posted 30 days ago
    Hi Mark,

    What is the error you are observing while running this op script ?
    Make sure you have the correct permission for the script file saved in the /var/run/scripts/op 



  • 5.  RE: simple rescue slax script

    Posted 30 days ago
    There are no errors.  Also nothing happens on the switch i'm testing with. the recovery configuration dates don't change.

    ------------------------------
    MARK JOHNS
    ------------------------------



  • 6.  RE: simple rescue slax script

     
    Posted 29 days ago
    You may have to use the following xml along with argument instead of the direct rescue command.

    <rescue-management-results>
    <routing-engine>
    <name>localre</name>
    <success/>
    </routing-engine>
    </rescue-management-results>

    You may take help from the following op script with slax.

    https://www.juniper.net/documentation/us/en/software/junos/automation-scripting/topics/example/junos-script-automation-op-script-customizing-output.html

    Hope this helps



  • 7.  RE: simple rescue slax script

    Posted 24 days ago
    I got it working using code from another script.

    ------------------------------
    MARK JOHNS
    ------------------------------



  • 8.  RE: simple rescue slax script

    Posted 13 days ago
    Hi Mark,

    would you be so kind to share your solution.

    Thanks,
    Milan

    ------------------------------
    MILAN MARKOVIC
    ------------------------------



  • 9.  RE: simple rescue slax script

    Posted 13 days ago
    version 1.1;

    ns junos = "http://xml.juniper.net/junos/*/junos";
    ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
    ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";

    import "../import/junos.xsl";
    /* Junos Space annotations */
    /* @CONTEXT = "/device" */
    /* @NAME = "System Config Rescue Save" */
    /* @DESCRIPTION = "requesting system config rescue save */
    /* @ISLOCAL = "true" */

    var $local = jcs:open();
    match / {
    <op-script-results> {
    var $command = <command> "request system configuration rescue save";
    var $results1 = jcs:execute( $local , $command );
    copy-of $results1;
    var $close-results = jcs:close( $local);
    }
    }

    ------------------------------
    MARK JOHNS
    ------------------------------



  • 10.  RE: simple rescue slax script

    Posted 12 days ago
    Hi Mark,

    I encountered issues when executing your script. System complained about line 14...

    Then, I changed script a little bit, based on some other public documentation, and it worked well. Here is my script, if anyone find issues with your:

    version 1.0;
    ns junos = "http://xml.juniper.net/junos/*/junos";
    ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
    ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
    import "/var/db/scripts/import/junos.xsl";

    match / {
    <op-script-results> {
    /* Open the connection */
    var $local = jcs:open();

    /* Set operational command to be executed */
    var $command = <command> "request system configuration rescue save";

    /* Execute command */
    expr jcs:execute($local, $command);

    /* Close the connection */
    expr jcs:close($local);
    }
    }


    Regards,
    Milan

    ------------------------------
    MILAN MARKOVIC
    ------------------------------