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