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