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