Bug 8145 - DNAT to DNAT traffic is getting failed for 2nd FIP for EVPN/VNI
[netvirt.git] / vpnservice / vpnmanager / vpnmanager-api / src / main / yang / odl-l3vpn.yang
1 module odl-l3vpn {
2     namespace "urn:opendaylight:netvirt:l3vpn";
3     prefix odl-l3vpn;
4
5     import yang-ext {prefix ext; revision-date "2013-07-09";}
6     import l3vpn { prefix l3vpn; revision-date "2014-08-15"; }
7     import ietf-yang-types { prefix "yang"; revision-date "2013-07-15"; }
8     import odl-interface { prefix odlif; revision-date "2016-04-06"; }
9     import neutronvpn {
10         prefix nvpn;
11         revision-date "2015-06-02";
12     }
13
14     revision "2013-09-11" {
15         description "L3 VPN Service module";
16     }
17
18     grouping adjacency-list{
19         list adjacency{
20             key "ip_address";
21             leaf-list next-hop-ip-list { type string; }
22             leaf ip_address {type string;}
23             leaf primary-adjacency {
24                 type boolean;
25                 default false;
26                 description "Value of True indicates this is a primary adjacency";
27             }
28             leaf label { type uint32; config "false"; } /* optional */
29             leaf mac_address {type string;} /* optional */
30             leaf subnet_id {type yang:uuid;} /* optional */
31             leaf vrf-id { type string; config "false"; }
32             leaf phys-network-func {
33                 type boolean;
34                 default false;
35                 description "Value of True indicates this is an adjacency of a device in a provider network";
36             }
37         }
38     }
39
40     grouping vpn-route-list{
41         leaf-list route-entry-id{
42             type uint32;
43         }
44     }
45
46     augment "/l3vpn:vpn-interfaces/l3vpn:vpn-interface" {
47         ext:augment-identifier "adjacencies";
48         uses adjacency-list;
49     }
50
51     augment "/l3vpn:vpn-interfaces/l3vpn:vpn-interface" {
52         ext:augment-identifier "opState";
53         leaf stateUp {type boolean; config false;}
54     }
55
56     /* Operational DS containers for reverse lookups*/
57     container prefix-to-interface {
58         config false;
59         list vpn-ids {
60            key vpn-id;
61            leaf vpn-id {type uint32;}
62            list prefixes {
63               key ip_address;
64               leaf ip_address {type string;}
65               leaf dpnId {
66                  type uint64;
67               }
68               leaf vpn-interface-name {
69                   type string;
70               }
71               leaf subnet-id {
72                   type yang:uuid;
73               }
74               leaf nat-prefix {
75                   type boolean;
76                   default false;
77               }
78            }
79         }
80     }
81
82     container vpn-to-extraroutes {
83         config false;
84         list vpn {
85            key vpn-name;
86            leaf vpn-name {
87                type string;
88                description "VPN Instance name";
89            }
90            list extra-routes {
91                key vrf-id;
92                leaf vrf-id {
93                   description
94                      "The vrf-id configures unique route distinguisher (RD) for each ipv4
95                       or ipv6 prefix when its nexthop-ip-list connected to same compute node";
96                   type string;
97                }
98                list routes {
99                   key prefix;
100                   leaf prefix {type string;}
101                   leaf-list nexthop-ip-list {
102                       type string;
103                   }
104                }
105            }
106         }
107     }
108
109     /* Data models to adhere to restart requirements */
110     container vpn-instance-to-vpn-id {
111        list vpn-instance {
112           key vpn-instance-name;
113           leaf vpn-instance-name {
114              type string;
115           }
116           leaf vpn-id {
117              type uint32;
118           }
119           leaf vrf-id {
120               description
121                  "The vrf-id command configures a route distinguisher (RD)
122                   for the IPv4 or IPv6 address family of a VPN instance or
123                   vpn instance name for internal vpn case.";
124               type string;
125           }
126        }
127     }
128
129     container vpn-id-to-vpn-instance {
130            list vpn-ids {
131               key vpn-id;
132               leaf vpn-id {
133                  type uint32;
134               }
135               leaf vpn-instance-name {
136                  type string;
137               }
138               leaf vrf-id {
139                   description
140                      "The vrf-id command configures a route distinguisher (RD)
141                       for the IPv4 or IPv6 address family of a VPN instance or
142                       vpn instance name for internal vpn case.";
143                   type string;
144               }
145               leaf external-vpn {
146                   type boolean;
147                   description "The VPN is external?";
148               }
149            }
150     }
151
152     container evpn-rd-to-networks {
153         config false;
154         description "Holds the networks to which given evpn is attached";
155         list evpn-rd-to-network {
156            key vrf-id;
157            leaf vrf-id {
158              type string;
159            }
160            leaf network-id {
161              type string;
162            }
163         }
164     }
165
166     container vpn-instance-op-data {
167         config false;
168         list vpn-instance-op-data-entry {
169            key vrf-id;
170            leaf vpn-id { type uint32;}
171            leaf vrf-id {
172               description
173                  "The vrf-id command configures a route distinguisher (RD)
174                   for the IPv4 or IPv6 address family of a VPN instance or
175                   vpn instance name for internal vpn case.";
176               type string;
177            }
178
179            leaf vpn-instance-name {
180                description "Typical the VPN Uuid";
181                type string;
182            }
183
184            leaf vpn-interface-count { type uint32; }
185            uses vpn-route-list;
186            list vpn-to-dpn-list {
187                key dpnId;
188                leaf dpnId {
189                   type uint64;
190                }
191                list vpn-interfaces {
192                   key interface-name;
193                   leaf interface-name {
194                       type string;
195                   }
196                }
197                list ip-addresses {
198                    key ip-address;
199                    leaf ip-address { type string; }
200                    leaf ip-address-source {
201                         description
202                          "This field indicates whether the IP address here is an External-Fixed-Ip(Owned by Router).
203                           or Floating-Ip(Used by Ports).";
204                         type enumeration {
205                             enum "ExternalFixedIP";
206                             enum "FloatingIP";
207                         }
208                    }
209                }
210                leaf dpn-state {
211                   description
212                   "This flag indicates the state of the DPN.
213                    Active state indicates atleast one vpn interface present on that DPN for the vpn.
214                    Inactive state indicates no vpn interface present on that DPN for this vpn.";
215
216                   type enumeration {
217                      enum active {
218                         value "0";
219                         description
220                         "Active state";
221                      }
222                      enum inactive {
223                         value "1";
224                         description
225                         "Inactive state";
226                      }
227                   }
228                   default "active";
229                }
230            }
231            leaf type {
232               description
233                  "The type of the VPN Instance.
234                   L3 indicates it is an L3VPN.
235                   L2 indicates it is an EVPN";
236
237               type enumeration {
238                  enum l3 {
239                     value "0";
240                     description â€œL3VPN";
241                  }
242                  enum l2{
243                     value "1";
244                     description "EVPN";
245                  }
246               }
247               default "l3";
248            }
249            leaf l3vni {
250               type uint32;
251            }
252            container vpnTargets {
253               description
254                 "The vpn-target command configures the export or import VPN target
255                  extended community attribute for the VPN instance IPv4/IPv6 address
256                  family.
257                  Format is ASN:nn or IP-address:nn.";
258
259               list vpnTarget {
260                  key "vrfRTValue";
261                  max-elements "unbounded";
262                  min-elements "0";
263                  description
264                     "L3vpn vpntarget configure class";
265
266                  leaf vrfRTValue {
267                     description
268                        "Vpn-target: adds VPN target extended community attribute to the
269                         export or import VPN target extended community list. The
270                         vpn-target can be expressed in either of the following formats:
271                         (1)16-bit AS number:32-bit user-defined number
272                            For example, 1:3. The AS number ranges from 0 to 65535. The
273                            user-defined number ranges from 0 to 4294967295. The AS number
274                            and the user-defined number cannot be 0s at the same time.
275                            That is, a VPN target cannot be 0:0.
276                         (2)32-bit IP address:16-bit user-defined number
277                            For example, 192.168.122.15:1. The IP address ranges from
278                            0.0.0.0 to 255.255.255.255. The user-defined number ranges from
279                            0 to 65535.
280                         (3)32-bit IP address:16-bit user-defined number
281                            For example, 192.168.122.15:1. An IP address ranges from
282                            0.0.0.0 to 255.255.255.255. A user-defined number ranges from 0
283                            to 65535.";
284                     type string {
285                        length "3..21";
286                     }
287                  }
288
289                  leaf vrfRTType {
290                     description
291                        "Specifies the vpn target type, export-extcommunity:
292                         specifies the extended community attributes carried in routing
293                         information to be sent. import-extcommunity: receives routing
294                         information carrying specified extended community attributes.";
295
296                     type enumeration {
297                        enum export_extcommunity {
298                           value "0";
299                           description "export-extcommunity:";
300                        }
301                        enum import_extcommunity {
302                           value "1";
303                           description "import-extcommunity:";
304                        }
305                        enum both {
306                           value "2";
307                           description "export-extcommunity & import-extcommunity:";
308                        }
309                     }
310                  }
311               }
312            }
313         }
314     }
315
316
317     typedef task-state {
318          type enumeration {
319            enum na {
320              value "0";
321              description
322               "Task not applicable";
323            }
324            enum pending {
325              value "1";
326              description
327               "Task is in pending state";
328            }
329            enum done {
330              value "2";
331              description
332               "Task has been completed";
333            }
334          }
335          description
336           "This value the status of any task.
337            The possible values are NA, PENDING or DONE.
338            ";
339            }
340
341
342     container subnet-op-data {
343         config false;
344         list subnet-op-data-entry {
345             key subnet-id;
346             leaf subnet-id {
347                 type    yang:uuid;
348                 description "UUID representing the subnet ";
349             }
350             leaf nh-dpnId {
351                 type uint64;
352                 description "DpnId for the DPN used as nexthop for this subnet";
353             }
354             leaf vpn-name {
355                 type string;
356                 description "VPN Instance name";
357             }
358             leaf vrf-id {
359                 type string;
360             }
361             leaf subnet-cidr {
362                 type string;
363                 description "Subnet in cidr notation";
364             }
365             leaf route-adv-state {
366                 type task-state;
367                 description "The status of the subnet route advertisement. Route advertisement could be in a NA, PENDING or DONE state.";
368             }
369             leaf elan-tag{
370                 type uint32;
371             }
372             list subnet-to-dpn {
373                 key dpnId;
374                 leaf dpnId {
375                     type uint64;
376                 }
377                 list vpn-interfaces {
378                     key interface-name;
379                     leaf interface-name {
380                         type string;
381                     }
382                 }
383             }
384
385             uses nvpn:network-attributes;
386
387         }
388     }
389
390     container port-op-data {
391         config false;
392         list port-op-data-entry {
393             key port-id;
394             leaf port-id {
395                 type  string;
396                 description "UUID in string format representing the port ";
397             }
398             leaf subnet-id {
399                 type  yang:uuid;
400                 description "Back reference to obtain the subnet for a port ";
401             }
402             leaf dpnId {
403                 type uint64;
404             }
405         }
406     }
407
408
409     grouping dpn-in-vpn-event {
410         leaf dpn-id { type uint64; }
411         leaf vpn-name { type string; }
412         leaf rd { type string; }
413     }
414
415     notification add-dpn-event {
416         container add-event-data {
417            uses dpn-in-vpn-event;
418         }
419     }
420
421     notification remove-dpn-event {
422         container remove-event-data {
423            uses dpn-in-vpn-event;
424         }
425     }
426
427     /*
428      * Configured Transport Type for l3vpn service.
429      */
430     container conf-transport-type-l3vpn {
431         leaf transport-type {
432             mandatory "true";
433             type identityref {
434                 base odlif:tunnel-type-base;
435             }
436             description
437                 "L3VPN service will use this config to setup
438                 the transport type for tunnels between DPNs.";
439         }
440     }
441
442     /* container to maintain mapping between neutron router and DPN(s) on which vpn-interfaces for router are present */
443     container neutron-router-dpns {
444         config false;
445         list router-dpn-list {
446             key router-id;
447             leaf router-id { type string;}
448             list dpn-vpninterfaces-list {
449                 key dpn-id;
450                 leaf dpn-id { type uint64;}
451                 list router-interfaces {
452                     key interface;
453                     leaf interface { type string; }
454                 }
455             }
456         }
457     }
458
459     /* container to maintain mapping between DPN(s) and the routers */
460     container dpn-routers {
461         config false;
462         list dpn-routers-list {
463             key dpn-id;
464             leaf dpn-id { type uint64;}
465             list routers-list {
466                 key router;
467                 leaf router { type string;}
468             }
469         }
470     }
471
472     container router-interfaces {
473         list router-interface {
474             key interface-name;
475             leaf interface-name { type string; }
476             leaf router-name { type string; }
477         }
478     }
479
480     container learnt-vpn-vip-to-port-data {
481         config false;
482         list learnt-vpn-vip-to-port {
483             key "vpn-name port-fixedip";
484             leaf vpn-name { type string; }
485             leaf port-fixedip { type string; }
486             leaf port-name { type string; }
487             leaf mac-address { type string; }
488         }
489     }
490
491     container evpn-config {
492         config true;
493         leaf multi-homing-mode {
494             type enumeration {
495                 enum "none";
496                 enum "all-active";
497                 enum "single-active";
498             }
499             default "none";
500         }
501         leaf irb-mode {
502             type enumeration {
503                 enum "symmetric";
504                 enum "asymmetric";
505             }
506             default "symmetric";
507         }
508     }
509
510     container l3vpn-lb-nexthops {
511         config false;
512         list nexthops {
513             key "nexthop-key";
514             leaf nexthop-key { type string; }
515             leaf group-id { type string; }
516             leaf-list target-device-id { type string; } //dpId or ip-address
517         }
518     }
519
520     container dpid-l3vpn-lb-nexthops {
521         config false;
522         list dpn-lb-nexthops {
523             key "src-dp-id dst-device-id";
524             leaf src-dp-id { type uint64; }
525             leaf dst-device-id { type string; } //dpId or ip-address
526             leaf-list nexthop-key { type string; }
527         }
528     }
529 }