f3b40122b5aa01a29b62e53b3f1c684397f71c0b
[netvirt.git] / vpnservice / vpnmanager / vpnmanager-api / src / main / yang / odl-l3vpn.yang
1 module odl-l3vpn {
2     namespace "urn:opendaylight:netvirt:l3vpn";
3     prefix odl-l3vpn;
4
5     import yang-ext {prefix ext; revision-date "2013-07-09";}
6     import l3vpn { prefix l3vpn; revision-date "2014-08-15"; }
7     import ietf-yang-types { prefix "yang"; revision-date "2013-07-15"; }
8     import odl-interface { prefix odlif; revision-date "2016-04-06"; }
9     import neutronvpn {
10         prefix nvpn;
11         revision-date "2015-06-02";
12     }
13
14     revision "2013-09-11" {
15         description "L3 VPN Service module";
16     }
17
18     grouping adjacency-list{
19         list adjacency{
20             key "ip_address";
21             leaf-list next-hop-ip-list { type string; }
22             leaf ip_address {type string;}
23             leaf adjacency_type {
24                 description "The type of adjacency";
25                 type enumeration {
26                     enum "primary-adjacency" {
27                         value 1;
28                         description
29                             "Primary adjacency type.";
30                     }
31                     enum "learnt-ip" {
32                         value 2;
33                         description
34                             "Learnt ip adjacency type.";
35                     }
36                     enum "extra-route" {
37                         value 3;
38                         description
39                             "Extra route adjacency type.";
40                     }
41                 }
42                 default "extra-route";
43             }
44             leaf label { type uint32; config "false"; } /* optional */
45             leaf mac_address {type string;} /* optional */
46             leaf subnet_id {type yang:uuid;} /* optional */
47             leaf subnet_gateway_mac_address {type string; config "false";} /* optional */
48             leaf vrf-id { type string; config "false"; }
49             leaf phys-network-func {
50                 type boolean;
51                 default false;
52                 description "Value of True indicates this is an adjacency of a device in a provider network";
53             }
54         }
55     }
56
57     grouping vpn-route-list{
58         leaf-list route-entry-id{
59             type uint32;
60         }
61     }
62
63     augment "/l3vpn:vpn-interfaces/l3vpn:vpn-interface" {
64         ext:augment-identifier "adjacencies";
65         uses adjacency-list;
66     }
67
68     augment "/l3vpn:vpn-interfaces/l3vpn:vpn-interface" {
69         ext:augment-identifier "opState";
70         leaf stateUp {type boolean; config false;}
71     }
72
73     /* Operational DS containers for reverse lookups*/
74     container prefix-to-interface {
75         config false;
76         list vpn-ids {
77            key vpn-id;
78            leaf vpn-id {type uint32;}
79            list prefixes {
80               key ip_address;
81               leaf ip_address {type string;}
82               leaf dpnId {
83                  type uint64;
84               }
85               leaf vpn-interface-name {
86                   type string;
87               }
88               leaf subnet-id {
89                   type yang:uuid;
90               }
91               leaf prefix-cue {
92                   type enumeration {
93                       enum none {
94                           value "0";
95                           description "Nothing special";
96                       }
97                       enum nat {
98                           value "1";
99                           description "NAT prefix";
100                       }
101                       enum phys-net-func {
102                           value "2";
103                           description "Physical Network Function(PNF) prefix";
104                       }
105                       enum subnet-route {
106                           value "3";
107                           description "Subnet Route prefix";
108                       }
109                   }
110                   default "none";
111               }
112            }
113         }
114     }
115
116     container vpn-to-extraroutes {
117         config false;
118         list vpn {
119            key vpn-name;
120            leaf vpn-name {
121                type string;
122                description "VPN Instance name";
123            }
124            list extra-routes {
125                key vrf-id;
126                leaf vrf-id {
127                   description
128                      "The vrf-id configures unique route distinguisher (RD) for each ipv4
129                       or ipv6 prefix when its nexthop-ip-list connected to same compute node";
130                   type string;
131                }
132                list routes {
133                   key prefix;
134                   leaf prefix {type string;}
135                   leaf-list nexthop-ip-list {
136                       type string;
137                   }
138                }
139            }
140         }
141     }
142
143     /* Data models to adhere to restart requirements */
144     container vpn-instance-to-vpn-id {
145        list vpn-instance {
146           key vpn-instance-name;
147           leaf vpn-instance-name {
148              type string;
149           }
150           leaf vpn-id {
151              type uint32;
152           }
153           leaf vrf-id {
154               description
155                  "The vrf-id command configures a route distinguisher (RD)
156                   for the IPv4 or IPv6 address family of a VPN instance or
157                   vpn instance name for internal vpn case.";
158               type string;
159           }
160        }
161     }
162
163     container vpn-id-to-vpn-instance {
164            list vpn-ids {
165               key vpn-id;
166               leaf vpn-id {
167                  type uint32;
168               }
169               leaf vpn-instance-name {
170                  type string;
171               }
172               leaf vrf-id {
173                   description
174                      "The vrf-id command configures a route distinguisher (RD)
175                       for the IPv4 or IPv6 address family of a VPN instance or
176                       vpn instance name for internal vpn case.";
177                   type string;
178               }
179               leaf external-vpn {
180                   type boolean;
181                   description "The VPN is external?";
182               }
183            }
184     }
185
186     container evpn-rd-to-networks {
187         description "Holds the networks to which given evpn is attached";
188         list evpn-rd-to-network {
189            key rd;
190            leaf rd {
191              type string;
192            }
193            leaf network-id {
194              type string;
195            }
196         }
197     }
198
199     /* Binding Interfaces to a VPN Instance. */
200     container vpn-interface-op-data {
201         config false;
202         list vpn-interface-op-data-entry {
203             key "name vpn-instance-name";
204             leaf name {
205               type string;
206             }
207             leaf vpn-instance-name {
208               type string {
209                 length "1..40";
210               }
211             }
212             max-elements "unbounded";
213             min-elements "0";
214             leaf dpn-id {
215               type uint64;
216             }
217             leaf scheduled-for-remove {
218               type boolean;
219             }
220             leaf router-interface {
221                 type boolean;
222             }
223             leaf vpn-interface-state {
224               description
225                "This flag indicates the state of this interface in the VPN identified by vpn-name.
226                 ACTIVE state indicates that this vpn-interface is currently associated to vpn-name
227                 available as one of the keys.
228                 INACTIVE state indicates that this vpn-interface has already been dis-associated
229                 from vpn-name available as one of the keys.";
230
231                 type enumeration {
232                  enum active {
233                     value "0";
234                     description
235                     "Active state";
236                  }
237                  enum inactive {
238                     value "1";
239                     description
240                     "Inactive state";
241                  }
242                 }
243                 default "active";
244            }
245         }
246     }
247
248     augment "/odl-l3vpn:vpn-interface-op-data/odl-l3vpn:vpn-interface-op-data-entry" {
249         ext:augment-identifier "adjacencies-op";
250         uses adjacency-list;
251     }
252
253     container vpn-instance-op-data {
254         config false;
255         list vpn-instance-op-data-entry {
256            key vrf-id;
257            leaf vpn-id { type uint32;}
258            leaf vrf-id {
259               description
260                  "The vrf-id command configures a route distinguisher (RD)
261                   for the IPv4 or IPv6 address family of a VPN instance or
262                   vpn instance name for internal vpn case.";
263               type string;
264            }
265
266            leaf vpn-instance-name {
267                description "Typical the VPN Uuid";
268                type string;
269            }
270
271            leaf vpn-interface-count { type uint32; }
272            uses vpn-route-list;
273            list vpn-to-dpn-list {
274                key dpnId;
275                leaf dpnId {
276                   type uint64;
277                }
278                list vpn-interfaces {
279                   key interface-name;
280                   leaf interface-name {
281                       type string;
282                   }
283                }
284                list ip-addresses {
285                    key ip-address;
286                    leaf ip-address { type string; }
287                    leaf ip-address-source {
288                         description
289                          "This field indicates whether the IP address here is an External-Fixed-Ip(Owned by Router).
290                           or Floating-Ip(Used by Ports).";
291                         type enumeration {
292                             enum "ExternalFixedIP";
293                             enum "FloatingIP";
294                         }
295                    }
296                }
297                leaf dpn-state {
298                   description
299                   "This flag indicates the state of the DPN.
300                    Active state indicates atleast one vpn interface present on that DPN for the vpn.
301                    Inactive state indicates no vpn interface present on that DPN for this vpn.";
302
303                   type enumeration {
304                      enum active {
305                         value "0";
306                         description
307                         "Active state";
308                      }
309                      enum inactive {
310                         value "1";
311                         description
312                         "Inactive state";
313                      }
314                   }
315                   default "active";
316                }
317            }
318            leaf ipv4-configured {
319               type boolean;
320               description
321                  "This VPN Instance handles IPv4 traffic";
322               default false;
323            }
324            leaf ipv6-configured {
325               type boolean;
326               description
327                  "This VPN Instance handles IPv6 traffic";
328               default false;
329            }
330            leaf bgpvpn-type {
331               type enumeration {
332                  enum BGPVPNInternet {
333                     value "0";
334                     description "BGPVPN Internet";
335                  }
336                  enum BGPVPNExternal {
337                     value "1";
338                     description "BGPVPN External";
339                  }
340                  enum VPN {
341                     value "2";
342                     description "Default VPN";
343                  }
344               }
345            }
346            leaf type {
347               description
348                  "The type of the VPN Instance.
349                   L3 indicates it is an L3VPN.
350                   L2 indicates it is an EVPN";
351
352               type enumeration {
353                  enum l3 {
354                     value "0";
355                     description "L3VPN";
356                  }
357                  enum l2{
358                     value "1";
359                     description "EVPN";
360                  }
361               }
362               default "l3";
363            }
364            leaf l3vni {
365               type uint32;
366            }
367            container vpnTargets {
368               description
369                 "The vpn-target command configures the export or import VPN target
370                  extended community attribute for the VPN instance IPv4/IPv6 address
371                  family.
372                  Format is ASN:nn or IP-address:nn.";
373
374               list vpnTarget {
375                  key "vrfRTValue";
376                  max-elements "unbounded";
377                  min-elements "0";
378                  description
379                     "L3vpn vpntarget configure class";
380
381                  leaf vrfRTValue {
382                     description
383                        "Vpn-target: adds VPN target extended community attribute to the
384                         export or import VPN target extended community list. The
385                         vpn-target can be expressed in either of the following formats:
386                         (1)16-bit AS number:32-bit user-defined number
387                            For example, 1:3. The AS number ranges from 0 to 65535. The
388                            user-defined number ranges from 0 to 4294967295. The AS number
389                            and the user-defined number cannot be 0s at the same time.
390                            That is, a VPN target cannot be 0:0.
391                         (2)32-bit IP address:16-bit user-defined number
392                            For example, 192.168.122.15:1. The IP address ranges from
393                            0.0.0.0 to 255.255.255.255. The user-defined number ranges from
394                            0 to 65535.
395                         (3)32-bit IP address:16-bit user-defined number
396                            For example, 192.168.122.15:1. An IP address ranges from
397                            0.0.0.0 to 255.255.255.255. A user-defined number ranges from 0
398                            to 65535.";
399                     type string {
400                        length "3..21";
401                     }
402                  }
403
404                  leaf vrfRTType {
405                     description
406                        "Specifies the vpn target type, export-extcommunity:
407                         specifies the extended community attributes carried in routing
408                         information to be sent. import-extcommunity: receives routing
409                         information carrying specified extended community attributes.";
410
411                     type enumeration {
412                        enum export_extcommunity {
413                           value "0";
414                           description "export-extcommunity:";
415                        }
416                        enum import_extcommunity {
417                           value "1";
418                           description "import-extcommunity:";
419                        }
420                        enum both {
421                           value "2";
422                           description "export-extcommunity & import-extcommunity:";
423                        }
424                     }
425                  }
426               }
427            }
428            leaf vpn-state {
429               description
430                  "Represents a stage in this VpnInstance's lifecycle.";
431               type enumeration {
432                  enum created {
433                     value "0";
434                     description
435                     "VPNInstance is successfully created";
436                  }
437                  enum pending_delete {
438                     value "3";
439                     description
440                     "VpnInstance marked for deletion.";
441                  }
442               }
443               default "created";
444            }
445            leaf-list rd {
446               type string;
447            }
448         }
449     }
450
451
452     typedef task-state {
453         type enumeration {
454             enum idle {
455                 value "0";
456                 description "Task in idle state";
457             }
458             enum pending_advertise {
459                 value "1";
460                 description "Task is pending advertisement state";
461             }
462             enum pending_withdraw {
463                 value "2";
464                 description "Task is pending withdrawal state";
465             }
466             enum advertised {
467                 value "3";
468                 description "Task is in advertised state";
469             }
470             enum withdrawn {
471                 value "4";
472                 description "Task is in withdrawn state";
473             }
474         }
475         description
476             "This value the status of any task.
477              The possible values are IDLE, PENDING_ADVERTISE, PENDING_WITHDRAW, ADVERTISED, WITHDRAWN.";
478     }
479
480
481     container subnet-op-data {
482         config false;
483         list subnet-op-data-entry {
484             key subnet-id;
485             leaf subnet-id {
486                 type    yang:uuid;
487                 description "UUID representing the subnet ";
488             }
489             leaf nh-dpnId {
490                 type uint64;
491                 description "DpnId for the DPN used as nexthop for this subnet";
492             }
493             leaf vpn-name {
494                 type string;
495                 description "VPN Instance name";
496             }
497             leaf vrf-id {
498                 type string;
499             }
500             leaf subnet-cidr {
501                 type string;
502                 description "Subnet in cidr notation";
503             }
504             leaf route-adv-state {
505                 type task-state;
506                 description "The status of the subnet route advertisement/withdrawal";
507             }
508             leaf last-adv-state {
509                 type task-state;
510                 description "The previous status of the subnet route advertisement/withdrawal.";
511             }
512             leaf elan-tag {
513                 type uint32;
514             }
515             list subnet-to-dpn {
516                 key dpnId;
517                 leaf dpnId {
518                     type uint64;
519                 }
520                 list vpn-interfaces {
521                     key interface-name;
522                     leaf interface-name {
523                         type string;
524                     }
525                 }
526             }
527             leaf label {
528                 type uint32;
529             }
530             leaf l3vni {
531                 type uint32;
532             }
533             uses nvpn:network-attributes;
534
535         }
536     }
537
538     container port-op-data {
539         config false;
540         list port-op-data-entry {
541             key port-id;
542             leaf port-id {
543                 type  string;
544                 description "UUID in string format representing the port ";
545             }
546             leaf-list subnet-ids {
547                 type  yang:uuid;
548                 description "Back reference to obtain the subnet for a port ";
549             }
550             leaf dpnId {
551                 type uint64;
552             }
553         }
554     }
555
556
557     grouping dpn-in-vpn-event {
558         leaf dpn-id { type uint64; }
559         leaf vpn-name { type string; }
560         leaf rd { type string; }
561     }
562
563     notification add-dpn-event {
564         container add-event-data {
565            uses dpn-in-vpn-event;
566         }
567     }
568
569     notification remove-dpn-event {
570         container remove-event-data {
571            uses dpn-in-vpn-event;
572         }
573     }
574
575     notification add-interface-to-dpn-on-vpn-event {
576         container add-interface-event-data {
577            uses dpn-in-vpn-event;
578            leaf interface-name { type string; }
579            leaf vpn-id { type uint32; }
580         }
581     }
582
583     notification remove-interface-from-dpn-on-vpn-event {
584         container remove-interface-event-data {
585            uses dpn-in-vpn-event;
586            leaf interface-name { type string; }
587            leaf vpn-id { type uint32; }
588         }
589     }
590
591     /*
592      * Configured Transport Type for l3vpn service.
593      */
594     container conf-transport-type-l3vpn {
595         leaf transport-type {
596             mandatory "true";
597             type identityref {
598                 base odlif:tunnel-type-base;
599             }
600             description
601                 "L3VPN service will use this config to setup
602                 the transport type for tunnels between DPNs.";
603         }
604     }
605
606     /* container to maintain mapping between neutron router and DPN(s) on which vpn-interfaces for router are present */
607     container neutron-router-dpns {
608         config false;
609         list router-dpn-list {
610             key router-id;
611             leaf router-id { type string;}
612             list dpn-vpninterfaces-list {
613                 key dpn-id;
614                 leaf dpn-id { type uint64;}
615                 list router-interfaces {
616                     key interface;
617                     leaf interface { type string; }
618                 }
619             }
620         }
621     }
622
623     /* container to maintain mapping between DPN(s) and the routers */
624     container dpn-routers {
625         config false;
626         list dpn-routers-list {
627             key dpn-id;
628             leaf dpn-id { type uint64;}
629             list routers-list {
630                 key router;
631                 leaf router { type string;}
632             }
633         }
634     }
635
636     container router-interfaces {
637         list router-interface {
638             key interface-name;
639             leaf interface-name { type string; }
640             leaf router-name { type string; }
641         }
642     }
643
644     container learnt-vpn-vip-to-port-data {
645         config false;
646         list learnt-vpn-vip-to-port {
647             key "vpn-name port-fixedip";
648             leaf vpn-name { type string; }
649             leaf port-fixedip { type string; }
650             leaf port-name { type string; }
651             leaf mac-address { type string; }
652             leaf creation-time { type string; }
653         }
654     }
655
656     container evpn-config {
657         config true;
658         leaf multi-homing-mode {
659             type enumeration {
660                 enum "none";
661                 enum "all-active";
662                 enum "single-active";
663             }
664             default "none";
665         }
666         leaf irb-mode {
667             type enumeration {
668                 enum "symmetric";
669                 enum "asymmetric";
670             }
671             default "symmetric";
672         }
673     }
674
675     container l3vpn-lb-nexthops {
676         config false;
677         list nexthops {
678             key "nexthop-key";
679             leaf nexthop-key { type string; }
680             leaf group-id { type string; }
681             leaf-list target-device-id { type string; } //dpId or ip-address
682         }
683     }
684
685     container dpid-l3vpn-lb-nexthops {
686         config false;
687         list dpn-lb-nexthops {
688             key "src-dp-id dst-device-id";
689             leaf src-dp-id { type uint64; }
690             leaf dst-device-id { type string; } //dpId or ip-address
691             leaf-list nexthop-key { type string; }
692         }
693     }
694 }