484ab8730297d28e32f4a58ccbe69daeb3ea35b8
[bgpcep.git] / bgp / rib-impl / src / main / yang / odl-bgp-rib-impl-cfg.yang
1 // vi: set smarttab et sw=4 tabstop=4:
2 module odl-bgp-rib-impl-cfg {
3     yang-version 1;
4     namespace "urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl";
5     prefix "bgprib-impl";
6
7     import bgp-multiprotocol { prefix bgp-mp; revision-date 2013-09-19; }
8     import bgp-rib { prefix rib; revision-date 2013-09-25; }
9     import bgp-types { prefix bgp-t; revision-date 2013-09-19; }
10     import odl-bgp-rib-cfg { prefix bgprib; revision-date 2013-07-01; }
11     import odl-bgp-parser-spi-cfg { prefix bgpspi; revision-date 2013-11-15; }
12     import odl-bgp-rib-spi-cfg { prefix ribspi; revision-date 2013-11-15; }
13     import ietf-inet-types { prefix inet; revision-date 2010-09-24; }
14     import opendaylight-md-sal-binding {prefix mdsb; revision-date 2013-10-28; }
15     import netty { prefix netty; revision-date 2013-11-19; }
16     import config { prefix config; revision-date 2013-04-05; }
17     import protocol-framework { prefix pf; revision-date 2014-03-13; }
18     import odl-tcpmd5-cfg { prefix tcpmd5; revision-date 2014-04-27; }
19     import odl-tcpmd5-netty-cfg { prefix tcpmd5n; revision-date 2014-04-27; }
20     import rpc-context { prefix rpcx; revision-date 2013-06-17; }
21
22     organization "Cisco Systems, Inc.";
23
24     contact "Robert Varga <rovarga@cisco.com>";
25
26     description
27         "This module contains the base YANG definitions for
28          BGP listener implementation.
29
30         Copyright (c)2013 Cisco Systems, Inc. All rights reserved.;
31
32         This program and the accompanying materials are made available
33         under the terms of the Eclipse Public License v1.0 which
34         accompanies this distribution, and is available at
35         http://www.eclipse.org/legal/epl-v10.html";
36
37     revision "2013-04-09" {
38         description
39             "Initial revision";
40     }
41
42     identity base-bgp-parser {
43         base config:module-type;
44         config:java-name-prefix BaseBGPParser;
45         config:provided-service bgpspi:extension;
46     }
47
48     augment "/config:modules/config:module/config:configuration" {
49         case base-bgp-parser {
50             when "/config:modules/config:module/config:type = 'base-bgp-parser'";
51         }
52     }
53
54     identity bgp-dispatcher {
55         description
56             "Service representing a BGP Dispatcher.";
57
58         base "config:service-type";
59         config:java-class "org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher";
60     }
61
62     identity bgp-dispatcher-impl {
63         base config:module-type;
64         config:provided-service bgp-dispatcher;
65         config:java-name-prefix BGPDispatcherImpl;
66     }
67
68     augment "/config:modules/config:module/config:configuration" {
69         case bgp-dispatcher-impl {
70             when "/config:modules/config:module/config:type = 'bgp-dispatcher-impl'";
71
72             container bgp-extensions {
73                 uses config:service-ref {
74                     refine type {
75                         mandatory true;
76                         config:required-identity bgpspi:consumer-extensions;
77                     }
78                 }
79             }
80
81             container boss-group {
82                 uses config:service-ref {
83                     refine type {
84                         mandatory true;
85                         config:required-identity netty:netty-threadgroup;
86                     }
87                 }
88             }
89
90             container worker-group {
91                 uses config:service-ref {
92                     refine type {
93                         mandatory true;
94                         config:required-identity netty:netty-threadgroup;
95                     }
96                 }
97             }
98
99             container md5-channel-factory {
100                 uses config:service-ref {
101                     refine type {
102                         mandatory false;
103                         config:required-identity tcpmd5n:md5-channel-factory;
104                     }
105                 }
106             }
107
108             container md5-server-channel-factory {
109                 uses config:service-ref {
110                     refine type {
111                         mandatory false;
112                         config:required-identity tcpmd5n:md5-server-channel-factory;
113                     }
114                 }
115             }
116         }
117     }
118
119     identity base-bgp-rib {
120         base config:module-type;
121         config:provided-service ribspi:extension;
122         config:java-name-prefix BaseBGPRIB;
123     }
124
125     augment "/config:modules/config:module/config:configuration" {
126         case base-bgp-rib {
127             when "/config:modules/config:module/config:type = 'base-bgp-rib'";
128         }
129     }
130
131     identity rib-instance {
132         description
133             "Service representing a RIB instance";
134
135         base "config:service-type";
136         config:java-class "org.opendaylight.protocol.bgp.rib.impl.spi.RIB";
137     }
138
139     identity bgp-peer-registry {
140         description
141             "Registry of BGP peers. Every new BGP in/out connection looks for peers to handle bgp messages in this registry";
142
143         base "config:service-type";
144         config:java-class "org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry";
145     }
146
147     identity strict-bgp-peer-registry {
148         description
149             "Registry of BGP peers that allows only one connection per 2 peers. Uses IP address for Peer identification and BGP Ids to resolve duplicate connections";
150
151         config:provided-service bgp-peer-registry;
152         base config:module-type;
153         config:java-name-prefix StrictBgpPeerRegistry;
154     }
155
156
157      augment "/config:modules/config:module/config:configuration" {
158         case strict-bgp-peer-registry {
159             when "/config:modules/config:module/config:type = 'strict-bgp-peer-registry'";
160         }
161     }
162
163     identity bgp-peer {
164         description
165             "BGP peer instance.";
166
167         base config:module-type;
168         config:java-name-prefix BGPPeer;
169     }
170
171     identity bgp-peer-acceptor {
172         description
173             "BGP peer acceptor that handles incomming bgp connections. Uses BGP peer registry to accept or decline incomming connections";
174
175         base config:module-type;
176         config:java-name-prefix BGPPeerAcceptor;
177     }
178
179     augment "/config:modules/config:module/config:configuration" {
180         case bgp-peer-acceptor {
181             when "/config:modules/config:module/config:type = 'bgp-peer-acceptor'";
182
183             leaf binding-address {
184                 description "IP address to bind to";
185                 type inet:ip-address;
186                 default "0.0.0.0";
187             }
188
189             leaf binding-port {
190                 description "Port to bind to";
191                 type inet:port-number;
192                 default "179";
193             }
194
195             container accepting-bgp-dispatcher {
196                 uses config:service-ref {
197                     refine type {
198                         mandatory true;
199                         config:required-identity bgp-dispatcher;
200                     }
201                 }
202             }
203
204             container accepting-peer-registry {
205                 uses config:service-ref {
206                     refine type {
207                         mandatory true;
208                         config:required-identity bgp-peer-registry;
209                     }
210                 }
211             }
212         }
213     }
214
215     identity bgp-application-peer {
216         description
217             "Application peer handler which handles translation from custom RIB into local RIB";
218
219         base config:module-type;
220         config:java-name-prefix BGPApplicationPeer;
221     }
222
223     augment "/config:modules/config:module/config:configuration" {
224         case bgp-application-peer {
225             when "/config:modules/config:module/config:type = 'bgp-application-peer'";
226
227             container data-broker {
228                 uses config:service-ref {
229                     refine type {
230                         mandatory true;
231                         config:required-identity mdsb:binding-async-data-broker;
232                     }
233                 }
234             }
235
236             container target-rib {
237                 uses config:service-ref {
238                     refine type {
239                         mandatory true;
240                         config:required-identity rib-instance;
241                     }
242                 }
243             }
244
245             leaf application-rib-id {
246                 type rib:application-rib-id;
247                 mandatory true;
248             }
249
250             leaf bgp-peer-id {
251                 type inet:ipv4-address;
252                 mandatory true;
253             }
254         }
255     }
256
257     identity bgp-table-type {
258         description
259             "Service representing a AFI/SAFI pair";
260
261         base "config:service-type";
262         config:java-class "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.BgpTableType";
263     }
264
265     identity bgp-table-type-impl {
266         description
267             "Simple provider for bgp-table-type.";
268
269         config:provided-service bgp-table-type;
270         base config:module-type;
271         config:java-name-prefix BGPTableTypeImpl;
272     }
273
274     augment "/config:modules/config:module/config:configuration" {
275         case bgp-table-type-impl {
276             when "/config:modules/config:module/config:type = 'bgp-table-type-impl'";
277
278             leaf afi {
279                 type identityref {
280                     base bgp-t:address-family;
281                 }
282                 mandatory true;
283             }
284             leaf safi {
285                 type identityref {
286                     base bgp-t:subsequent-address-family;
287                 }
288                 mandatory true;
289             }
290         }
291     }
292
293     augment "/config:modules/config:module/config:configuration" {
294         case bgp-peer {
295             when "/config:modules/config:module/config:type = 'bgp-peer'";
296
297             leaf host {
298                 description "Remote host IP address";
299                 type inet:ip-address;
300                 mandatory true;
301             }
302
303             leaf port {
304                 description "Remote host port";
305                 type inet:port-number;
306                 default 179;
307             }
308
309             leaf holdtimer {
310                 type int16;
311                 default 180;
312             }
313
314             leaf initiate-connection {
315                 description "If true, connection will be initiated right away from current device.
316                     If not, the peer will only be registered to peer registry and available for incomming bgp connections.";
317                 type boolean;
318                 default true;
319             }
320
321             list advertized-table {
322                 key "type name";
323                 uses config:service-ref {
324                     refine type {
325                         mandatory true;
326                         config:required-identity bgp-table-type;
327                     }
328                 }
329             }
330
331             leaf remote-as {
332                 description
333                     "Expected remote AS number. If not present, it is assumed
334                     to be the same as our local AS number.";
335                 type uint32;
336             }
337
338             leaf password {
339                 type tcpmd5:rfc2385-key;
340                 description "RFC2385 shared secret";
341             }
342
343             container rib {
344                 uses config:service-ref {
345                     refine type {
346                         mandatory true;
347                         config:required-identity rib-instance;
348                     }
349                 }
350             }
351
352             container peer-registry {
353                 description "BGP peer registry where current instance of BGP peer will be registered.";
354                 uses config:service-ref {
355                     refine type {
356                         // FIXME backwards compatibility. If not configured, GLOBAL instance is used
357                         mandatory false;
358                         config:required-identity bgp-peer-registry;
359                     }
360                 }
361             }
362         }
363     }
364
365     grouping message-state {
366         leaf count {
367             description "Total number of BGP messages.";
368             type uint32;
369             default 0;
370         }
371
372         leaf timestamp {
373             description "The BGP message timestamp (seconds).";
374             type uint32;
375             default 0;
376         }
377     }
378
379     grouping message-stats {
380         container received {
381             description "The received BGP messages statistics.";
382             uses message-state;
383         }
384
385         container sent {
386             description "The sent BGP messages statistics.";
387             uses message-state;
388         }
389     }
390
391     grouping error {
392         leaf code {
393             description "The BGP error code.";
394             type uint8;
395             default 0;
396         }
397
398         leaf sub-code {
399             description "The BGP error sub-code.";
400             type uint8;
401             default 0;
402         }
403     }
404
405     grouping preferences {
406         leaf bgp-id {
407             description "The BGP Identifier.";
408             type string;
409             default "";
410         }
411
412         leaf address {
413             description "The IP address of BGP connection.";
414             type string;
415             default "";
416         }
417
418         leaf port {
419             description "The port for connection between the BGP peers.";
420             type uint16;
421             default 0;
422         }
423
424         leaf as {
425             description "Autonomous system number.";
426             type uint32;
427             default 0;
428         }
429
430         leaf holdtime {
431             description "Time interval (in seconds) for HoldTimer proposed by the peer.";
432             type uint16;
433             default 0;
434         }
435
436         leaf four-octet-as-capability {
437             description "The BGP peer 4 byte AS numbers support capability.";
438             type boolean;
439             default "false";
440         }
441
442         list advertized-table-types {
443             description "The BGP Table-type capabilities advertized by the BGP peer.";
444             leaf afi {
445                 description "Address Family Identifier.";
446                 type string;
447                 default "";
448             }
449             leaf safi {
450                 description "Subsequent Address Family Identifier.";
451                 type string;
452                 default "";
453             }
454         }
455     }
456
457     identity peer-rpc;
458
459     augment "/config:modules/config:module/config:state" {
460         case bgp-peer {
461             when "/config:modules/config:module/config:type = 'bgp-peer'";
462
463             rpcx:rpc-context-instance "peer-rpc";
464
465             container bgp-peer-state {
466                 list route-table {
467
468                     leaf table-type {
469                         description "The table name - composed of AFI and SAFI.";
470                         type string;
471                     }
472
473                     leaf routes-count {
474                         description "The total number of routes in table.";
475                         type uint32;
476                         default 0;
477                     }
478                 }
479
480                 leaf session-established-count {
481                     description "The total number of time the BGP session was transitioned to Up state.";
482                     type uint32;
483                     default 0;
484                 }
485             }
486
487             container bgp-session-state {
488
489                 leaf session-state {
490                     description "The BGP peer connection state.";
491                     type string;
492                 }
493
494                 leaf session-duration {
495                     description "The session duration (time formated d:HH:mm:ss).";
496                     type string;
497                 }
498
499                 leaf holdtime-current {
500                     description "Time interval (in seconds) for HoldTimer established with the peer.";
501                     type uint16;
502                     default 0;
503                 }
504
505                 leaf keepalive-current {
506                     description "Time interval (in seconds) for KeepAlive established with the peer.";
507                     type uint16;
508                     default 0;
509                 }
510
511                 container speaker-preferences {
512                     description "The BGP speaker preferences, to which this BGP peer is connected.";
513                     uses preferences;
514                 }
515
516                 container peer-preferences {
517                     description "The BGP peer preferences.";
518                     uses preferences;
519                 }
520
521                 container messages-stats {
522                     description "The BGP messages statistics.";
523                     container total-msgs {
524                         description "The statistics for all received/sent BGP messages.";
525                         uses message-stats;
526                     }
527
528                     container keep-alive-msgs {
529                         description "The statistics for received/sent BGP Keep-Alive messages.";
530                         uses message-stats;
531                     }
532
533                     container update-msgs {
534                         description "The statistics for received/sent BGP Update messages.";
535                         uses message-stats;
536                     }
537
538                     container error-msgs {
539                         container error-received {
540                             description "The received BGP Error (notification) messages statistics.";
541                             uses message-state;
542                             uses error;
543                         }
544
545                         container error-sent {
546                             description "The sent BGP Error (notification) messages statistics.";
547                             uses message-state;
548                             uses error;
549                         }
550                     }
551                 }
552             }
553         }
554     }
555
556     rpc reset-session {
557         description "Restart the session between BGP peers";
558         input {
559             uses rpcx:rpc-context-ref {
560                 refine context-instance {
561                     rpcx:rpc-context-instance peer-rpc;
562                 }
563             }
564         }
565      }
566
567      rpc reset-stats {
568         description "Reset the BGP peer statistics.";
569         input {
570             uses rpcx:rpc-context-ref {
571                 refine context-instance {
572                     rpcx:rpc-context-instance peer-rpc;
573                 }
574             }
575         }
576      }
577
578     identity rib-impl {
579         base config:module-type;
580         config:provided-service bgprib:rib;
581         config:provided-service rib-instance;
582         config:java-name-prefix RIBImpl;
583     }
584
585     augment "/config:modules/config:module/config:configuration" {
586         case rib-impl {
587             when "/config:modules/config:module/config:type = 'rib-impl'";
588
589             container extensions {
590                 uses config:service-ref {
591                     refine type {
592                         mandatory true;
593                         config:required-identity ribspi:consumer-extensions;
594                     }
595                 }
596             }
597
598             container bgp-dispatcher {
599                 uses config:service-ref {
600                     refine type {
601                         mandatory true;
602                         config:required-identity bgp-dispatcher;
603                     }
604                 }
605             }
606
607             container session-reconnect-strategy {
608                 uses config:service-ref {
609                     refine type {
610                         mandatory true;
611                         config:required-identity pf:reconnect-strategy-factory;
612                     }
613                 }
614             }
615
616             container tcp-reconnect-strategy {
617                 uses config:service-ref {
618                     refine type {
619                         mandatory true;
620                         config:required-identity pf:reconnect-strategy-factory;
621                     }
622                 }
623             }
624
625             container data-provider {
626                 uses config:service-ref {
627                     refine type {
628                         mandatory true;
629                         config:required-identity mdsb:binding-async-data-broker;
630                     }
631                 }
632             }
633
634             leaf local-as {
635                 description "Our local AS number. Needed by best selection path attribute.";
636                 type uint32;
637                 mandatory true;
638             }
639
640             leaf bgp-rib-id {
641                 description "Our local BGP identifier. Needed by best selection path attribute.";
642                 mandatory true;
643                 type inet:ipv4-address;
644             }
645
646             list local-table {
647                 uses config:service-ref {
648                     refine type {
649                         mandatory true;
650                         config:required-identity bgp-table-type;
651                     }
652                 }
653             }
654
655             leaf rib-id {
656                 description "Identifier of this RIB in local data store.";
657                 type rib:rib-id;
658                 mandatory true;
659             }
660         }
661     }
662 }
663