Fix bgp-segment-routing
[bgpcep.git] / bgp / openconfig-api / src / main / yang / odl-bgp-policy.yang
1 module odl-bgp-policy {
2     yang-version 1.1;
3     namespace "urn:opendaylight:params:xml:ns:yang:odl:bgp:default:policy";
4     prefix "odl-bgp-policy";
5
6     import yang-ext { prefix ext; revision-date 2013-07-09; }
7     import openconfig-network-instance { prefix netinst; }
8     import openconfig-bgp { prefix openconfig-bgp; }
9     import openconfig-bgp-types { prefix oc-bgp-t; }
10     import bgp-rib { prefix rib; revision-date 2018-03-29; }
11     import openconfig-routing-policy { prefix rpol; }
12     import openconfig-bgp-policy { prefix bgppol; }
13     import ietf-inet-types { prefix inet; revision-date 2013-07-15; }
14     import bgp-types { prefix bgp-t; revision-date 2018-03-29; }
15
16     organization "AT&T Services, Inc.";
17     contact "Claudio D. Gasparini <claudio.gasparini@pantheon.tech>";
18
19     description
20         "This module contains odl bgp policy model
21         to be used under openconfig policy model definitions.
22
23         Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
24
25         This program and the accompanying materials are made available
26         under the terms of the Eclipse Public License v1.0 which
27         accompanies this distribution, and is available at
28         http://www.eclipse.org/legal/epl-v10.html";
29
30     revision "2018-03-29" {
31         description "Add support for add-path for all afi/safi.";
32     }
33
34     revision "2018-01-09" {
35         description
36             "ODL BGP policy models";
37     }
38
39     grouping match-role-condition-grouping {
40         leaf role-set {
41             type leafref {
42               path "/rpol:routing-policy/rpol:defined-sets/bgppol:bgp-defined-sets/role-sets/role-set/role-set-name";
43               require-instance true;
44             }
45             description "References a defined neighbor roles set";
46         }
47         uses rpol:match-set-options-restricted-group;
48     }
49
50     grouping match-role-set-condition-grouping {
51         container match-role-set {
52             description
53                 "Match a list of referenced role-set according to the logic
54                 defined in the match-set-options leaf";
55
56             container from-role {
57                 uses match-role-condition-grouping;
58             }
59
60             container to-role {
61                 uses match-role-condition-grouping;
62             }
63         }
64     }
65
66     grouping bgp-neighbor {
67         leaf neighbor-set {
68           type leafref {
69             path "/rpol:routing-policy/rpol:defined-sets/rpol:neighbor-sets/rpol:neighbor-set/rpol:neighbor-set-name";
70             require-instance true;
71           }
72           description "References a defined neighbor set";
73         }
74         uses rpol:match-set-options-restricted-group;
75     }
76
77     grouping match-bgp-neighbor-grouping {
78         container match-bgp-neighbor-set {
79             presence
80                 "The presence of this container indicates that the routes
81                 should match the neighbour address of set referenced";
82
83             description
84                 "Match a referenced neighbor set according to the logic
85                 defined in the match-set-options-leaf";
86
87             container from-neighbor {
88                 uses bgp-neighbor;
89             }
90
91             container to-neighbor {
92                 uses bgp-neighbor;
93             }
94         }
95     }
96
97     grouping match-originator-id-set-condition-grouping {
98         description
99             "Match a list of referenced originator-id-set according to the logic
100             defined in the match-set-options leaf";
101
102         container match-originator-id-set-condition {
103             leaf originator-id-set {
104                 type leafref {
105                   path "/rpol:routing-policy/rpol:defined-sets/bgppol:bgp-defined-sets/originator-id-sets/originator-id-set/originator-id-set-name";
106                   require-instance true;
107                 }
108                 description "References a defined Originator Id set";
109             }
110             uses rpol:match-set-options-restricted-group;
111         }
112     }
113
114     grouping match-cluster-id-set-condition-grouping {
115         description
116             "Match a list of referenced cluster-id-set according to the logic
117             defined in the match-set-options leaf";
118         container match-cluster-id-set-condition {
119             leaf cluster-id-set {
120                 type leafref {
121                   path "/rpol:routing-policy/rpol:defined-sets/bgppol:bgp-defined-sets/cluster-id-sets/cluster-id-set/cluster-id-set-name";
122                   require-instance true;
123                 }
124                 description "References a defined cluster Id set";
125             }
126             uses rpol:match-set-options-group;
127         }
128     }
129
130     grouping role-set {
131         description "Data definition for a list of Odl Bgp roles which
132             are matched as part of a policy";
133
134         list role-set {
135             key role-set-name;
136             description "List of the defined role sets";
137
138             leaf role-set-name {
139               type string;
140               description
141                 "name / label of the role set -- this is used to
142                 reference the set in match conditions";
143             }
144
145             leaf-list role {
146                 type rib:peer-role;
147                 description
148                 "List of role expressions that are part of the set";
149             }
150       }
151     }
152
153     grouping originator-id-set {
154         description "Data definition for a list of Originators Ids which
155             are matched as part of a policy";
156
157         list originator-id-set {
158             key originator-id-set-name;
159             description "List of the defined Originators Ids sets";
160
161             leaf originator-id-set-name {
162               type string;
163               description
164                 "name / label of the set -- this is used to
165                 reference the set in match conditions";
166             }
167
168             leaf-list originator-id {
169                 type inet:ipv4-address;
170                 description
171                 "List of role expressions that are part of the set";
172             }
173
174             container local {
175                  presence "Local originator Id";
176                  description "Validates also Local Originator Id";
177             }
178       }
179     }
180
181     grouping cluster-id-set {
182         description "Data definition for a list of Cluster Ids which
183             are matched as part of a policy";
184
185         list cluster-id-set {
186             key cluster-id-set-name;
187             description "List of the defined cluster Ids sets";
188
189             leaf cluster-id-set-name {
190               type string;
191               description
192                 "name / label of the set -- this is used to
193                 reference the set in match conditions";
194             }
195
196             leaf-list cluster-id {
197                 type bgp-t:cluster-identifier;
198                 description
199                 "List of role expressions that are part of the set";
200             }
201
202             container local {
203                  presence "Local cluster Id";
204                  description "Validates also cluster Originator Id";
205             }
206       }
207     }
208
209     augment /rpol:routing-policy/rpol:defined-sets/bgppol:bgp-defined-sets {
210         ext:augment-identifier bgp-cluster-id-sets;
211         container cluster-id-sets {
212             description "Enclosing container for defined cluster-id sets for matching";
213             uses cluster-id-set;
214         }
215     }
216
217     augment /rpol:routing-policy/rpol:defined-sets/bgppol:bgp-defined-sets {
218         ext:augment-identifier bgp-role-sets;
219         container role-sets {
220             description "Enclosing container for defined role sets for matching";
221             uses role-set;
222         }
223     }
224
225     augment /rpol:routing-policy/rpol:defined-sets/bgppol:bgp-defined-sets {
226         ext:augment-identifier bgp-originator-id-sets;
227         container originator-id-sets {
228             description "Enclosing container for defined role sets for matching";
229             uses originator-id-set;
230         }
231     }
232
233     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:conditions/bgppol:bgp-conditions {
234         ext:augment-identifier match-afi-safi-not-in-condition;
235         leaf-list afi-safi-not-in {
236             type identityref {
237               base "oc-bgp-t:afi-safi-type";
238             }
239             description
240               "List of address families which the NLRI must not be within";
241         }
242     }
243
244     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:conditions/bgppol:bgp-conditions {
245         ext:augment-identifier match-bgp-neighbor-condition;
246         uses match-bgp-neighbor-grouping;
247     }
248
249     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:conditions/bgppol:bgp-conditions {
250         ext:augment-identifier match-role-set-condition;
251         uses match-role-set-condition-grouping;
252     }
253
254     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:conditions/bgppol:bgp-conditions {
255         ext:augment-identifier match-originator-id-set-condition;
256         uses match-originator-id-set-condition-grouping;
257     }
258
259     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:conditions/bgppol:bgp-conditions {
260         ext:augment-identifier match-cluster-id-set-condition;
261         uses match-cluster-id-set-condition-grouping;
262     }
263
264     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:conditions/bgppol:bgp-conditions {
265         ext:augment-identifier vpn-non-member-condition;
266         container vpn-non-member {
267             presence "Match Route Target Attribute with Route Target memberships of destiny peer. Asserts peers is a non member.";
268         }
269     }
270
271     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:actions/bgppol:bgp-actions {
272         ext:augment-identifier reflect-attributes-actions;
273         container reflect-attributes-actions {
274             presence "Modify attributes so they are updated as per RFC4456 route reflection";
275         }
276     }
277
278     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:actions/bgppol:bgp-actions {
279         ext:augment-identifier non-transitive-attributes-filter;
280         container non-transitive-attributes-filter {
281             presence "Filters attributes, removing non transitive attributes";
282         }
283     }
284
285     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:actions/bgppol:bgp-actions {
286         ext:augment-identifier local-as-path-prepend;
287         container local-as-path-prepend {
288             presence "Prepends local AS Path";
289         }
290     }
291
292     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:actions/bgppol:bgp-actions {
293         ext:augment-identifier set-cluster-id-prepend;
294         container set-cluster-id-prepend {
295
296         presence "node is present in the config data to use the Cluster Id prepend action";
297         description "action to prepend local Cluster Id to the Cluster Id List";
298         }
299     }
300
301     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:actions/bgppol:bgp-actions {
302         ext:augment-identifier set-originator-id-prepend;
303         container set-originator-id-prepend {
304             presence "node is present in the config data to use the Originator Id prepend action";
305             description "action to prepend Originator Id if non Originator Id is present. If no Originator Id"
306             + "is defined, local Originator Id is used.";
307             leaf originator-id {
308                 type inet:ipv4-address;
309                 description "Originator Id";
310             }
311         }
312     }
313 }