[j-nsp] Arguments for commit scripts

Phil Shafer phil at juniper.net
Wed Mar 18 19:00:28 EDT 2015


Yup, apply-macro is the perfect spot for stuffing data.  Consider using
a top-level apply-macro with a name indicating your script, and then
the value under it:

apply-macro my-script-name {
    my-parameter my-value;
    other-paramer other-value;
}

Then you'll need something in your script like:

match / {
    <op-script-results> {
        var $params := {
            call get-params();
        }
        var $my-parameter = $params/data[name == "my-parameter"]/value;
        var $other-parameter = $params/data[name == "other-parameter"]/value;
    }
}

template get-params ($name = "my-script-name") {
    var $rpc = <get-configuration database="committed"> {
        <configuration> {
            <apply-macro> {
                <name> $name;
            }
        }
    }
    var $config = jcs:invoke($rpc);
    var $params = $config/apply-macro;

    copy-of $params;
}

The share-data script in the Junoscriptorium has some of these elements,
if that helps for reference.

https://github.com/Juniper/junoscriptorium/tree/master/library/juniper/op/network/share-data

Thanks,
 Phil





Tim Jackson writes:
>Use an apply-macro..
>
>--
>Tim
>
>On Wed, Mar 18, 2015 at 3:27 PM, Ross Vandegrift <ross at kallisti.us> wrote:
>> Hi all,
>>
>> Working on a commit script with a regex that might need occasional updates.
>> Ideally, this could be stored in the config, and loaded at run-time.
>> Possible?
>>
>> If not: any catches with abusing annotate to provide this?
>>
>> Thanks,
>> Ross
>>
>> _______________________________________________
>> juniper-nsp mailing list juniper-nsp at puck.nether.net
>> https://puck.nether.net/mailman/listinfo/juniper-nsp
>_______________________________________________
>juniper-nsp mailing list juniper-nsp at puck.nether.net
>https://puck.nether.net/mailman/listinfo/juniper-nsp


More information about the juniper-nsp mailing list