Bug-2080: BGP statistics.
[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                 uses config:service-ref {
323                     refine type {
324                         mandatory true;
325                         config:required-identity bgp-table-type;
326                     }
327                 }
328             }
329
330             leaf remote-as {
331                 description
332                     "Expected remote AS number. If not present, it is assumed
333                     to be the same as our local AS number.";
334                 type uint32;
335             }
336
337             leaf password {
338                 type tcpmd5:rfc2385-key;
339                 description "RFC2385 shared secret";
340             }
341
342             container rib {
343                 uses config:service-ref {
344                     refine type {
345                         mandatory true;
346                         config:required-identity rib-instance;
347                     }
348                 }
349             }
350
351             container peer-registry {
352                 description "BGP peer registry where current instance of BGP peer will be registered.";
353                 uses config:service-ref {
354                     refine type {
355                         // FIXME backwards compatibility. If not configured, GLOBAL instance is used
356                         mandatory false;
357                         config:required-identity bgp-peer-registry;
358                     }
359                 }
360             }
361         }
362     }
363
364     grouping message-state {
365         leaf count {
366             description "Total number of BGP messages.";
367             type uint32;
368             default 0;
369         }
370
371         leaf timestamp {
372             description "The BGP message timestamp (seconds).";
373             type uint32;
374             default 0;
375         }
376     }
377
378     grouping message-stats {
379         container received {
380             description "The received BGP messages statistics.";
381             uses message-state;
382         }
383
384         container sent {
385             description "The sent BGP messages statistics.";
386             uses message-state;
387         }
388     }
389
390     grouping error {
391         leaf code {
392             description "The BGP error code.";
393             type uint8;
394             default 0;
395         }
396
397         leaf sub-code {
398             description "The BGP error sub-code.";
399             type uint8;
400             default 0;
401         }
402     }
403
404     grouping preferences {
405         leaf bgp-id {
406             description "The BGP Identifier.";
407             type string;
408             default "";
409         }
410
411         leaf address {
412             description "The IP address of BGP connection.";
413             type string;
414             default "";
415         }
416
417         leaf port {
418             description "The port for connection between the BGP peers.";
419             type uint16;
420             default 0;
421         }
422
423         leaf as {
424             description "Autonomous system number.";
425             type uint32;
426             default 0;
427         }
428
429         leaf holdtime {
430             description "Time interval (in seconds) for HoldTimer proposed by the peer.";
431             type uint16;
432             default 0;
433         }
434
435         leaf four-octet-as-capability {
436             description "The BGP peer 4 byte AS numbers support capability.";
437             type boolean;
438             default "false";
439         }
440
441         list advertized-table-types {
442             description "The BGP Table-type capabilities advertized by the BGP peer.";
443             leaf afi {
444                 description "Address Family Identifier.";
445                 type string;
446                 default "";
447             }
448             leaf safi {
449                 description "Subsequent Address Family Identifier.";
450                 type string;
451                 default "";
452             }
453         }
454     }
455
456     identity peer-rpc;
457
458     augment "/config:modules/config:module/config:state" {
459         case bgp-peer {
460             when "/config:modules/config:module/config:type = 'bgp-peer'";
461
462             rpcx:rpc-context-instance "peer-rpc";
463
464             container bgp-peer-state {
465                 list route-table {
466
467                     leaf table-type {
468                         description "The table name - composed of AFI and SAFI.";
469                         type string;
470                     }
471
472                     leaf routes-count {
473                         description "The total number of routes in table.";
474                         type uint32;
475                         default 0;
476                     }
477                 }
478
479                 leaf session-established-count {
480                     description "The total number of time the BGP session was transitioned to Up state.";
481                     type uint32;
482                     default 0;
483                 }
484             }
485
486             container bgp-session-state {
487
488                 leaf session-state {
489                     description "The BGP peer connection state.";
490                     type string;
491                 }
492
493                 leaf session-duration {
494                     description "The session duration (time formated d:HH:mm:ss).";
495                     type string;
496                 }
497
498                 leaf holdtime-current {
499                     description "Time interval (in seconds) for HoldTimer established with the peer.";
500                     type uint16;
501                     default 0;
502                 }
503
504                 leaf keepalive-current {
505                     description "Time interval (in seconds) for KeepAlive established with the peer.";
506                     type uint16;
507                     default 0;
508                 }
509
510                 container speaker-preferences {
511                     description "The BGP speaker preferences, to which this BGP peer is connected.";
512                     uses preferences;
513                 }
514
515                 container peer-preferences {
516                     description "The BGP peer preferences.";
517                     uses preferences;
518                 }
519
520                 container messages-stats {
521                     description "The BGP messages statistics.";
522                     container total-msgs {
523                         description "The statistics for all received/sent BGP messages.";
524                         uses message-stats;
525                     }
526
527                     container keep-alive-msgs {
528                         description "The statistics for received/sent BGP Keep-Alive messages.";
529                         uses message-stats;
530                     }
531
532                     container update-msgs {
533                         description "The statistics for received/sent BGP Update messages.";
534                         uses message-stats;
535                     }
536
537                     container error-msgs {
538                         container error-received {
539                             description "The received BGP Error (notification) messages statistics.";
540                             uses message-state;
541                             uses error;
542                         }
543
544                         container error-sent {
545                             description "The sent BGP Error (notification) messages statistics.";
546                             uses message-state;
547                             uses error;
548                         }
549                     }
550                 }
551             }
552         }
553     }
554
555     rpc reset-session {
556         description "Restart the session between BGP peers";
557         input {
558             uses rpcx:rpc-context-ref {
559                 refine context-instance {
560                     rpcx:rpc-context-instance peer-rpc;
561                 }
562             }
563         }
564      }
565
566      rpc reset-stats {
567         description "Reset the BGP peer statistics.";
568         input {
569             uses rpcx:rpc-context-ref {
570                 refine context-instance {
571                     rpcx:rpc-context-instance peer-rpc;
572                 }
573             }
574         }
575      }
576
577     identity rib-impl {
578         base config:module-type;
579         config:provided-service bgprib:rib;
580         config:provided-service rib-instance;
581         config:java-name-prefix RIBImpl;
582     }
583
584     augment "/config:modules/config:module/config:configuration" {
585         case rib-impl {
586             when "/config:modules/config:module/config:type = 'rib-impl'";
587
588             container extensions {
589                 uses config:service-ref {
590                     refine type {
591                         mandatory true;
592                         config:required-identity ribspi:consumer-extensions;
593                     }
594                 }
595             }
596
597             container bgp-dispatcher {
598                 uses config:service-ref {
599                     refine type {
600                         mandatory true;
601                         config:required-identity bgp-dispatcher;
602                     }
603                 }
604             }
605
606             container session-reconnect-strategy {
607                 uses config:service-ref {
608                     refine type {
609                         mandatory true;
610                         config:required-identity pf:reconnect-strategy-factory;
611                     }
612                 }
613             }
614
615             container tcp-reconnect-strategy {
616                 uses config:service-ref {
617                     refine type {
618                         mandatory true;
619                         config:required-identity pf:reconnect-strategy-factory;
620                     }
621                 }
622             }
623
624             container data-provider {
625                 uses config:service-ref {
626                     refine type {
627                         mandatory true;
628                         config:required-identity mdsb:binding-async-data-broker;
629                     }
630                 }
631             }
632
633             leaf local-as {
634                 description "Our local AS number. Needed by best selection path attribute.";
635                 type uint32;
636                 mandatory true;
637             }
638
639             leaf bgp-rib-id {
640                 description "Our local BGP identifier. Needed by best selection path attribute.";
641                 mandatory true;
642                 type inet:ipv4-address;
643             }
644
645             list local-table {
646                 uses config:service-ref {
647                     refine type {
648                         mandatory true;
649                         config:required-identity bgp-table-type;
650                     }
651                 }
652             }
653
654             leaf rib-id {
655                 description "Identifier of this RIB in local data store.";
656                 type rib:rib-id;
657                 mandatory true;
658             }
659         }
660     }
661 }
662