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