EVPN RT2 Yang changes
[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 evpn-rd-to-networks {
148         config false;
149         description "Holds the networks to which given evpn is attached";
150         list evpn-rd-to-network {
151            key vrf-id;
152            leaf vrf-id {
153              type string;
154            }
155            leaf network-id {
156              type string;
157            }
158         }
159     }
160
161     container vpn-instance-op-data {
162         config false;
163         list vpn-instance-op-data-entry {
164            key vrf-id;
165            leaf vpn-id { type uint32;}
166            leaf vrf-id {
167               description
168                  "The vrf-id command configures a route distinguisher (RD)
169                   for the IPv4 or IPv6 address family of a VPN instance or
170                   vpn instance name for internal vpn case.";
171               type string;
172            }
173
174            leaf vpn-instance-name {
175                description "Typical the VPN Uuid";
176                type string;
177            }
178
179            leaf vpn-interface-count { type uint32; }
180            uses vpn-route-list;
181            list vpn-to-dpn-list {
182                key dpnId;
183                leaf dpnId {
184                   type uint64;
185                }
186                list vpn-interfaces {
187                   key interface-name;
188                   leaf interface-name {
189                       type string;
190                   }
191                }
192                list ip-addresses {
193                    key ip-address;
194                    leaf ip-address { type string; }
195                }
196                leaf dpn-state {
197                   description
198                   "This flag indicates the state of the DPN.
199                    Active state indicates atleast one vpn interface present on that DPN for the vpn.
200                    Inactive state indicates no vpn interface present on that DPN for this vpn.";
201
202                   type enumeration {
203                      enum active {
204                         value "0";
205                         description
206                         "Active state";
207                      }
208                      enum inactive {
209                         value "1";
210                         description
211                         "Inactive state";
212                      }
213                   }
214                   default "active";
215                }
216            }
217            leaf type {
218               description
219                  "The type of the VPN Instance.
220                   L3 indicates it is an L3VPN.
221                   L2 indicates it is an EVPN";
222
223               type enumeration {
224                  enum l3 {
225                     value "0";
226                     description â€œL3VPN";
227                  }
228                  enum l2{
229                     value "1";
230                     description "EVPN";
231                  }
232               }
233               default "l3";
234            }
235            leaf l3vni {
236               type uint32;
237            }
238            container vpnTargets {
239               description
240                 "The vpn-target command configures the export or import VPN target
241                  extended community attribute for the VPN instance IPv4/IPv6 address
242                  family.
243                  Format is ASN:nn or IP-address:nn.";
244
245               list vpnTarget {
246                  key "vrfRTValue";
247                  max-elements "unbounded";
248                  min-elements "0";
249                  description
250                     "L3vpn vpntarget configure class";
251
252                  leaf vrfRTValue {
253                     description
254                        "Vpn-target: adds VPN target extended community attribute to the
255                         export or import VPN target extended community list. The
256                         vpn-target can be expressed in either of the following formats:
257                         (1)16-bit AS number:32-bit user-defined number
258                            For example, 1:3. The AS number ranges from 0 to 65535. The
259                            user-defined number ranges from 0 to 4294967295. The AS number
260                            and the user-defined number cannot be 0s at the same time.
261                            That is, a VPN target cannot be 0:0.
262                         (2)32-bit IP address:16-bit user-defined number
263                            For example, 192.168.122.15:1. The IP address ranges from
264                            0.0.0.0 to 255.255.255.255. The user-defined number ranges from
265                            0 to 65535.
266                         (3)32-bit IP address:16-bit user-defined number
267                            For example, 192.168.122.15:1. An IP address ranges from
268                            0.0.0.0 to 255.255.255.255. A user-defined number ranges from 0
269                            to 65535.";
270                     type string {
271                        length "3..21";
272                     }
273                  }
274
275                  leaf vrfRTType {
276                     description
277                        "Specifies the vpn target type, export-extcommunity:
278                         specifies the extended community attributes carried in routing
279                         information to be sent. import-extcommunity: receives routing
280                         information carrying specified extended community attributes.";
281
282                     type enumeration {
283                        enum export_extcommunity {
284                           value "0";
285                           description "export-extcommunity:";
286                        }
287                        enum import_extcommunity {
288                           value "1";
289                           description "import-extcommunity:";
290                        }
291                        enum both {
292                           value "2";
293                           description "export-extcommunity & import-extcommunity:";
294                        }
295                     }
296                  }
297               }
298            }
299         }
300     }
301
302
303     typedef task-state {
304          type enumeration {
305            enum na {
306              value "0";
307              description
308               "Task not applicable";
309            }
310            enum pending {
311              value "1";
312              description
313               "Task is in pending state";
314            }
315            enum done {
316              value "2";
317              description
318               "Task has been completed";
319            }
320          }
321          description
322           "This value the status of any task.
323            The possible values are NA, PENDING or DONE.
324            ";
325            }
326
327
328     container subnet-op-data {
329         config false;
330         list subnet-op-data-entry {
331             key subnet-id;
332             leaf subnet-id {
333                 type    yang:uuid;
334                 description "UUID representing the subnet ";
335             }
336             leaf nh-dpnId {
337                 type uint64;
338                 description "DpnId for the DPN used as nexthop for this subnet";
339             }
340             leaf vpn-name {
341                 type string;
342                 description "VPN Instance name";
343             }
344             leaf vrf-id {
345                 type string;
346             }
347             leaf subnet-cidr {
348                 type string;
349                 description "Subnet in cidr notation";
350             }
351             leaf route-adv-state {
352                 type task-state;
353                 description "The status of the subnet route advertisement. Route advertisement could be in a NA, PENDING or DONE state.";
354             }
355             leaf elan-tag{
356                 type uint32;
357             }
358             list subnet-to-dpn {
359                 key dpnId;
360                 leaf dpnId {
361                     type uint64;
362                 }
363                 list vpn-interfaces {
364                     key interface-name;
365                     leaf interface-name {
366                         type string;
367                     }
368                 }
369             }
370
371             uses nvpn:network-attributes;
372
373         }
374     }
375
376     container port-op-data {
377         config false;
378         list port-op-data-entry {
379             key port-id;
380             leaf port-id {
381                 type  string;
382                 description "UUID in string format representing the port ";
383             }
384             leaf subnet-id {
385                 type  yang:uuid;
386                 description "Back reference to obtain the subnet for a port ";
387             }
388             leaf dpnId {
389                 type uint64;
390             }
391         }
392     }
393
394
395     grouping dpn-in-vpn-event {
396         leaf dpn-id { type uint64; }
397         leaf vpn-name { type string; }
398         leaf rd { type string; }
399     }
400
401     notification add-dpn-event {
402         container add-event-data {
403            uses dpn-in-vpn-event;
404         }
405     }
406
407     notification remove-dpn-event {
408         container remove-event-data {
409            uses dpn-in-vpn-event;
410         }
411     }
412
413     /*
414      * Configured Transport Type for l3vpn service.
415      */
416     container conf-transport-type-l3vpn {
417         leaf transport-type {
418             mandatory "true";
419             type identityref {
420                 base odlif:tunnel-type-base;
421             }
422             description
423                 "L3VPN service will use this config to setup
424                 the transport type for tunnels between DPNs.";
425         }
426     }
427
428     /* container to maintain mapping between neutron router and DPN(s) on which vpn-interfaces for router are present */
429     container neutron-router-dpns {
430         config false;
431         list router-dpn-list {
432             key router-id;
433             leaf router-id { type string;}
434             list dpn-vpninterfaces-list {
435                 key dpn-id;
436                 leaf dpn-id { type uint64;}
437                 list router-interfaces {
438                     key interface;
439                     leaf interface { type string; }
440                 }
441             }
442         }
443     }
444
445     /* container to maintain mapping between DPN(s) and the routers */
446     container dpn-routers {
447         config false;
448         list dpn-routers-list {
449             key dpn-id;
450             leaf dpn-id { type uint64;}
451             list routers-list {
452                 key router;
453                 leaf router { type string;}
454             }
455         }
456     }
457
458     container router-interfaces {
459         list router-interface {
460             key interface-name;
461             leaf interface-name { type string; }
462             leaf router-name { type string; }
463         }
464     }
465
466     container learnt-vpn-vip-to-port-data {
467         config false;
468         list learnt-vpn-vip-to-port {
469             key "vpn-name port-fixedip";
470             leaf vpn-name { type string; }
471             leaf port-fixedip { type string; }
472             leaf port-name { type string; }
473             leaf mac-address { type string; }
474         }
475     }
476
477     container evpn-config {
478         config true;
479         leaf multi-homing-mode {
480             type enumeration {
481                 enum "none";
482                 enum "all-active";
483                 enum "single-active";
484             }
485             default "none";
486         }
487         leaf irb-mode {
488             type enumeration {
489                 enum "symmetric";
490                 enum "asymmetric";
491             }
492             default "symmetric";
493         }
494     }
495
496     container l3vpn-lb-nexthops {
497         config false;
498         list nexthops {
499             key "nexthop-key";
500             leaf nexthop-key { type string; }
501             leaf group-id { type string; }
502             leaf-list target-device-id { type string; } //dpId or ip-address
503         }
504     }
505
506     container dpid-l3vpn-lb-nexthops {
507         config false;
508         list dpn-lb-nexthops {
509             key "src-dp-id dst-device-id";
510             leaf src-dp-id { type uint64; }
511             leaf dst-device-id { type string; } //dpId or ip-address
512             leaf-list nexthop-key { type string; }
513         }
514     }
515 }