Bug 7939,8082: Table 19 flow nightmares
[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 subnet_gateway_mac_address {type string; config "false";} /* optional */
32             leaf vrf-id { type string; config "false"; }
33             leaf phys-network-func {
34                 type boolean;
35                 default false;
36                 description "Value of True indicates this is an adjacency of a device in a provider network";
37             }
38         }
39     }
40
41     grouping vpn-route-list{
42         leaf-list route-entry-id{
43             type uint32;
44         }
45     }
46
47     augment "/l3vpn:vpn-interfaces/l3vpn:vpn-interface" {
48         ext:augment-identifier "adjacencies";
49         uses adjacency-list;
50     }
51
52     augment "/l3vpn:vpn-interfaces/l3vpn:vpn-interface" {
53         ext:augment-identifier "opState";
54         leaf stateUp {type boolean; config false;}
55     }
56
57     /* Operational DS containers for reverse lookups*/
58     container prefix-to-interface {
59         config false;
60         list vpn-ids {
61            key vpn-id;
62            leaf vpn-id {type uint32;}
63            list prefixes {
64               key ip_address;
65               leaf ip_address {type string;}
66               leaf dpnId {
67                  type uint64;
68               }
69               leaf vpn-interface-name {
70                   type string;
71               }
72               leaf subnet-id {
73                   type yang:uuid;
74               }
75               leaf nat-prefix {
76                   type boolean;
77                   default false;
78               }
79            }
80         }
81     }
82
83     container vpn-to-extraroutes {
84         config false;
85         list vpn {
86            key vpn-name;
87            leaf vpn-name {
88                type string;
89                description "VPN Instance name";
90            }
91            list extra-routes {
92                key vrf-id;
93                leaf vrf-id {
94                   description
95                      "The vrf-id configures unique route distinguisher (RD) for each ipv4
96                       or ipv6 prefix when its nexthop-ip-list connected to same compute node";
97                   type string;
98                }
99                list routes {
100                   key prefix;
101                   leaf prefix {type string;}
102                   leaf-list nexthop-ip-list {
103                       type string;
104                   }
105                }
106            }
107         }
108     }
109
110     /* Data models to adhere to restart requirements */
111     container vpn-instance-to-vpn-id {
112        list vpn-instance {
113           key vpn-instance-name;
114           leaf vpn-instance-name {
115              type string;
116           }
117           leaf vpn-id {
118              type uint32;
119           }
120           leaf vrf-id {
121               description
122                  "The vrf-id command configures a route distinguisher (RD)
123                   for the IPv4 or IPv6 address family of a VPN instance or
124                   vpn instance name for internal vpn case.";
125               type string;
126           }
127        }
128     }
129
130     container vpn-id-to-vpn-instance {
131            list vpn-ids {
132               key vpn-id;
133               leaf vpn-id {
134                  type uint32;
135               }
136               leaf vpn-instance-name {
137                  type string;
138               }
139               leaf vrf-id {
140                   description
141                      "The vrf-id command configures a route distinguisher (RD)
142                       for the IPv4 or IPv6 address family of a VPN instance or
143                       vpn instance name for internal vpn case.";
144                   type string;
145               }
146               leaf external-vpn {
147                   type boolean;
148                   description "The VPN is external?";
149               }
150            }
151     }
152
153     container evpn-rd-to-networks {
154         description "Holds the networks to which given evpn is attached";
155         list evpn-rd-to-network {
156            key rd;
157            leaf rd {
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 idle {
320                 value "0";
321                 description "Task in idle state";
322             }
323             enum pending_advertise {
324                 value "1";
325                 description "Task is pending advertisement state";
326             }
327             enum pending_withdraw {
328                 value "2";
329                 description "Task is pending withdrawal state";
330             }
331             enum advertised {
332                 value "3";
333                 description "Task is in advertised state";
334             }
335             enum withdrawn {
336                 value "4";
337                 description "Task is in withdrawn state";
338             }
339         }
340         description
341             "This value the status of any task.
342              The possible values are IDLE, PENDING_ADVERTISE, PENDING_WITHDRAW, ADVERTISED, WITHDRAWN.";
343     }
344
345
346     container subnet-op-data {
347         config false;
348         list subnet-op-data-entry {
349             key subnet-id;
350             leaf subnet-id {
351                 type    yang:uuid;
352                 description "UUID representing the subnet ";
353             }
354             leaf nh-dpnId {
355                 type uint64;
356                 description "DpnId for the DPN used as nexthop for this subnet";
357             }
358             leaf vpn-name {
359                 type string;
360                 description "VPN Instance name";
361             }
362             leaf vrf-id {
363                 type string;
364             }
365             leaf subnet-cidr {
366                 type string;
367                 description "Subnet in cidr notation";
368             }
369             leaf route-adv-state {
370                 type task-state;
371                 description "The status of the subnet route advertisement/withdrawal";
372             }
373             leaf elan-tag {
374                 type uint32;
375             }
376             list subnet-to-dpn {
377                 key dpnId;
378                 leaf dpnId {
379                     type uint64;
380                 }
381                 list vpn-interfaces {
382                     key interface-name;
383                     leaf interface-name {
384                         type string;
385                     }
386                 }
387             }
388             leaf label {
389                 type uint32;
390             }
391             leaf l3vni {
392                 type uint32;
393             }
394             uses nvpn:network-attributes;
395
396         }
397     }
398
399     container port-op-data {
400         config false;
401         list port-op-data-entry {
402             key port-id;
403             leaf port-id {
404                 type  string;
405                 description "UUID in string format representing the port ";
406             }
407             leaf subnet-id {
408                 type  yang:uuid;
409                 description "Back reference to obtain the subnet for a port ";
410             }
411             leaf dpnId {
412                 type uint64;
413             }
414         }
415     }
416
417
418     grouping dpn-in-vpn-event {
419         leaf dpn-id { type uint64; }
420         leaf vpn-name { type string; }
421         leaf rd { type string; }
422     }
423
424     notification add-dpn-event {
425         container add-event-data {
426            uses dpn-in-vpn-event;
427         }
428     }
429
430     notification remove-dpn-event {
431         container remove-event-data {
432            uses dpn-in-vpn-event;
433         }
434     }
435
436     /*
437      * Configured Transport Type for l3vpn service.
438      */
439     container conf-transport-type-l3vpn {
440         leaf transport-type {
441             mandatory "true";
442             type identityref {
443                 base odlif:tunnel-type-base;
444             }
445             description
446                 "L3VPN service will use this config to setup
447                 the transport type for tunnels between DPNs.";
448         }
449     }
450
451     /* container to maintain mapping between neutron router and DPN(s) on which vpn-interfaces for router are present */
452     container neutron-router-dpns {
453         config false;
454         list router-dpn-list {
455             key router-id;
456             leaf router-id { type string;}
457             list dpn-vpninterfaces-list {
458                 key dpn-id;
459                 leaf dpn-id { type uint64;}
460                 list router-interfaces {
461                     key interface;
462                     leaf interface { type string; }
463                 }
464             }
465         }
466     }
467
468     /* container to maintain mapping between DPN(s) and the routers */
469     container dpn-routers {
470         config false;
471         list dpn-routers-list {
472             key dpn-id;
473             leaf dpn-id { type uint64;}
474             list routers-list {
475                 key router;
476                 leaf router { type string;}
477             }
478         }
479     }
480
481     container router-interfaces {
482         list router-interface {
483             key interface-name;
484             leaf interface-name { type string; }
485             leaf router-name { type string; }
486         }
487     }
488
489     container learnt-vpn-vip-to-port-data {
490         config false;
491         list learnt-vpn-vip-to-port {
492             key "vpn-name port-fixedip";
493             leaf vpn-name { type string; }
494             leaf port-fixedip { type string; }
495             leaf port-name { type string; }
496             leaf mac-address { type string; }
497             leaf creation-time { type string; }
498         }
499     }
500
501     container evpn-config {
502         config true;
503         leaf multi-homing-mode {
504             type enumeration {
505                 enum "none";
506                 enum "all-active";
507                 enum "single-active";
508             }
509             default "none";
510         }
511         leaf irb-mode {
512             type enumeration {
513                 enum "symmetric";
514                 enum "asymmetric";
515             }
516             default "symmetric";
517         }
518     }
519
520     container l3vpn-lb-nexthops {
521         config false;
522         list nexthops {
523             key "nexthop-key";
524             leaf nexthop-key { type string; }
525             leaf group-id { type string; }
526             leaf-list target-device-id { type string; } //dpId or ip-address
527         }
528     }
529
530     container dpid-l3vpn-lb-nexthops {
531         config false;
532         list dpn-lb-nexthops {
533             key "src-dp-id dst-device-id";
534             leaf src-dp-id { type uint64; }
535             leaf dst-device-id { type string; } //dpId or ip-address
536             leaf-list nexthop-key { type string; }
537         }
538     }
539 }