/
16-e1-limit.slax
50 lines (43 loc) · 1.49 KB
/
16-e1-limit.slax
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* Machine Crafted with Care (tm) by slaxWriter */
version 1.0;
/*
- $Id: 16-e1-limit.slax,v 1.1 2007/10/17 18:37:03 phil Exp $
-
- Copyright (c) 2004-2005, Juniper Networks, Inc.
- All rights reserved.
-
*/
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";
param $limit = 16;
/*
- This example tests the number of e1 interfaces configured
- on a cstm1 interface. For each cstm1 interface, the set
- of corresponding e1 interfaces is selected. The count()
- of those interfaces should not exceed the limit given in the
- global variable $limit. If there are more than $limit, a
- commit error is generated and the commit fails.
*/
match configuration {
var $interfaces = interfaces;
for-each ($interfaces/interface[starts-with(name, "cstm1-")]) {
var $triple = substring-after(name, "cstm1-");
var $e1name = "e1-" _ $triple;
var $count = count($interfaces/interface[starts-with(name, $e1name)]);
if ($count > $limit) {
<xnm:error> {
<edit-path> "[edit interfaces]";
<statement> name;
<message> {
expr "e1/cstm1 limit exceeded; ";
expr $count;
expr " are configured but only ";
expr $limit;
expr " are allowed";
}
}
}
}
}