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