-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequireBGPpolicy.slax
More file actions
53 lines (45 loc) · 1.54 KB
/
requireBGPpolicy.slax
File metadata and controls
53 lines (45 loc) · 1.54 KB
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
50
51
52
53
version 1.1;
/* created 03APR2018 akg
this commit script requires that each external BGP peer have a policy applied (both import and export).
if a peer is configured with no policy, po_DEFAULT-BGP-POLICY-DENY-ALL is applied, and a warning is issued, but commit will succeeed.
this policy rejects everything.
this policy must exist, or the commit will fail
*/
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";
template emit-warning($message) {
<xnm:warning> {
call jcs:edit-path();
<message> $message;
}
}
template emit-error($message) {
<xnm:error> {
call jcs:edit-path();
<message> $message;
}
}
match configuration {
for-each (protocols/bgp/group) {
if (type == "external") {
if (!import) {
call jcs:emit-change() {
with $content = {
<import> "po_DEFAULT-BGP-POLICY-DENY-ALL";
}
with $message = "applying default DENY import policy to " _ name;
}
}
if (!export) {
call jcs:emit-change() {
with $content = {
<export> "po_DEFAULT-BGP-POLICY-DENY-ALL";
}
with $message = "applying default DENY export policy to " _ name;
}
}
}
}
}