24d8739c2f0706170e3a00b7d6af08f84a05898e
[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-bgp-neighbor-condition;
234         uses match-bgp-neighbor-grouping;
235     }
236
237     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:conditions/bgppol:bgp-conditions {
238         ext:augment-identifier match-role-set-condition;
239         uses match-role-set-condition-grouping;
240     }
241
242     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:conditions/bgppol:bgp-conditions {
243         ext:augment-identifier match-originator-id-set-condition;
244         uses match-originator-id-set-condition-grouping;
245     }
246
247     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:conditions/bgppol:bgp-conditions {
248         ext:augment-identifier match-cluster-id-set-condition;
249         uses match-cluster-id-set-condition-grouping;
250     }
251
252     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:actions/bgp-pol:bgp-actions {
253         ext:augment-identifier reflect-attributes-actions;
254         container reflect-attributes-actions {
255             presence "Modify attributes so they are updated as per RFC4456 route reflection";
256         }
257     }
258
259     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:actions/bgp-pol:bgp-actions {
260         ext:augment-identifier non-transitive-attributes-filter;
261         container non-transitive-attributes-filter {
262             presence "Filters attributes, removing non transitive attributes";
263         }
264     }
265
266     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:actions/bgp-pol:bgp-actions {
267         ext:augment-identifier local-as-path-prepend;
268         container local-as-path-prepend {
269             presence "Prepends local AS Path";
270         }
271     }
272
273     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:actions/bgp-pol:bgp-actions {
274         ext:augment-identifier set-cluster-id-prepend;
275         container set-cluster-id-prepend {
276
277         presence "node is present in the config data to use the Cluster Id prepend action";
278         description "action to prepend local Cluster Id to the Cluster Id List";
279         }
280     }
281
282     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:actions/bgp-pol:bgp-actions {
283         ext:augment-identifier set-originator-id-prepend;
284         container set-originator-id-prepend {
285             presence "node is present in the config data to use the Originator Id prepend action";
286             description "action to prepend Originator Id if non Originator Id is present. If no Originator Id"
287             + "is defined, local Originator Id is used.";
288             leaf originator-id {
289                 type inet:ipv4-address;
290                 description "Originator Id";
291             }
292         }
293     }
294 }