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