[j-nsp] How to query the results tree from a commit script?
Benny Amorsen
benny+usenet at amorsen.dk
Wed May 23 04:32:50 EDT 2012
Tore Anderson <tore.anderson at redpill-linpro.com> writes:
> Hi,
>
> I'm trying to write a template for a commit script that, when called,
> will find the first unused unit on an interface and add some transient
> config to it. "Unused" means that that the unit isn't defined in the
> main configuration file and that an earlier call to the template hasn't
> written transient config to it yet.
I had almost exactly the same problem when trying to pick unit numbers
for q-in-q interfaces. I gave up on doing it transiently and now I
simply save the unit numbers in apply-macros as permanent changes.
If you don't care what the unit numbers are and you are parsing objects
from somewhere else to generate them, you can just do position() + 5000
like I did originally. This does not work if you might reach the maximum
ID or if you are parsing objects from multiple places (so position()
could repeat).
Curtis Call already pointed out the problem of ID's changing. I would
recommend testing it, as at least when it comes to l2circuits, the
router effectively tears down all the old units and builds the new ones
if the ID's change -- even if everything ends up exactly the same apart
from the unit ID's. That is service-impacting.
/Benny
More information about the juniper-nsp
mailing list