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