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