Automation

 View Only
last person joined: 6 days ago 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  scripting request system storage cleanup

    Posted 11-17-2022 09:50
    For scripting the command "request system storage cleanup" how do i pass yes for the confirmation on "Do you want to proceed?"

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


  • 2.  RE: scripting request system storage cleanup

    Posted 11-21-2022 09:19
    bumping.

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



  • 3.  RE: scripting request system storage cleanup

    Posted 11-21-2022 09:25
    sharing what i have:
    version 1.2;

    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 = "Storage Cleanup" */
    /* @DESCRIPTION = "Delete old logs and junos installation files" */
    /* @ISLOCAL = "true" */

    var $local = jcs:open();
    match / {
    <op-script-results> {
    var $command = <command> "request system storage cleanup";
    var $command2 = <command> "y";
    var $command3 = <command> "start shell user root";
    var $command4 = <command> "password";
    var $command5 = <command> "rm -r -f /packages/db/*";
    var $command6 = <command> "exit";
    }
    }

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



  • 4.  RE: scripting request system storage cleanup

     
    Posted 01-09-2023 04:45
    I don't believe that this approach will work.  The jcs:open() function doesn't behave like a command line shell environment.

    I would have thought that just using the RPC would be sufficient.

    <rpc>
        <request-system-storage-cleanup>
            <no-confirm/>
        </request-system-storage-cleanup>
    </rpc>​

    Regards

    ------------------------------
    Andy Sharp
    ------------------------------



  • 5.  RE: scripting request system storage cleanup

     
    Posted 01-09-2023 04:51
    Edited by asharp 01-16-2023 11:01

    So something like the following would be the approach IIRC.

    version 1.2;
    
    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 = "Clean storage" */
    /* @DESCRIPTION = "clean storage on selected device" */
    /* @ISLOCAL = "true" */
    
    main <op-script-results> {
        /* open connection */
        var $connection = jcs:open();
    
        var $rpc = <request-system-storage-cleanup> {
            <no-confirm>;
        }
        var $results = jcs:execute($connection, $rpc);
        /* output block */
        <output> {
            uexpr $results;
        }
    
        /* close connection */
        var $closeResult = jcs:close ( $connection );
    }
    


    ------------------------------
    Andy Sharp
    ------------------------------