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