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