BUG 6839: Fixes for import/export RT and router dissociation in L3Vpn
[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
10     revision "2013-09-11" {
11         description "L3 VPN Service module";
12     }
13
14     grouping adjacency-list{
15         list adjacency{
16             key "ip_address";
17             leaf-list next-hop-ip-list { type string; }
18             leaf ip_address {type string;}
19             leaf label { type uint32; config "false"; } /* optional */
20             leaf mac_address {type string;} /* optional */
21         }
22     }
23
24     grouping vpn-route-list{
25         leaf-list route-entry-id{
26             type uint32;
27         }
28     }
29
30     augment "/l3vpn:vpn-interfaces/l3vpn:vpn-interface" {
31         ext:augment-identifier "adjacencies";
32         uses adjacency-list;
33     }
34
35     augment "/l3vpn:vpn-interfaces/l3vpn:vpn-interface" {
36         ext:augment-identifier "opState";
37         leaf stateUp {type boolean; config false;}
38     }
39
40     /* Operational DS containers for reverse lookups*/
41     container prefix-to-interface {
42         config false;
43         list vpn-ids {
44            key vpn-id;
45            leaf vpn-id {type uint32;}
46            list prefixes {
47               key ip_address;
48               leaf ip_address {type string;}
49               leaf dpnId {
50                  type uint64;
51               }
52               leaf vpn-interface-name {
53                   type string;
54               }
55            }
56         }
57     }
58
59     container vpn-to-extraroute {
60         config false;
61         list vpn {
62            key vrf-id;
63            leaf vrf-id {
64               description
65                  "The vrf-id command configures a route distinguisher (RD)
66                   for the IPv4 or IPv6 address family of a VPN instance or
67                   vpn instance name for internal vpn case.";
68               type string;
69            }
70            list extraroute {
71               key prefix;
72               leaf prefix {type string;}
73               leaf-list nexthop-ip-list {
74                   type string;
75               }
76            }
77         }
78     }
79
80     /* Data models to adhere to restart requirements */
81     container vpn-instance-to-vpn-id {
82        list vpn-instance {
83           key vpn-instance-name;
84           leaf vpn-instance-name {
85              type string;
86           }
87           leaf vpn-id {
88              type uint32;
89           }
90           leaf vrf-id {
91               description
92                  "The vrf-id command configures a route distinguisher (RD)
93                   for the IPv4 or IPv6 address family of a VPN instance or
94                   vpn instance name for internal vpn case.";
95               type string;
96           }
97        }
98     }
99
100     container vpn-id-to-vpn-instance {
101            list vpn-ids {
102               key vpn-id;
103               leaf vpn-id {
104                  type uint32;
105               }
106               leaf vpn-instance-name {
107                  type string;
108               }
109               leaf vrf-id {
110                   description
111                      "The vrf-id command configures a route distinguisher (RD)
112                       for the IPv4 or IPv6 address family of a VPN instance or
113                       vpn instance name for internal vpn case.";
114                   type string;
115               }
116               leaf external-vpn {
117                   type boolean;
118                   description "The VPN is external?";
119               }
120            }
121     }
122
123     container vpn-to-pseudo-port-tag-data {
124         description "Makes a correspondence between VRFs and their corresponding VpnPseudoPort";
125         list vpn-to-pseudo-port-tag {
126             key vrf-id;
127             leaf vrf-id {
128                 type string;
129             }
130             leaf lport-tag {
131                 description "Vpn Pseudo Logical Port Tag";
132                 type uint32;
133             }
134         }
135     }
136
137     container vpn-instance-op-data {
138         config false;
139         list vpn-instance-op-data-entry {
140            key vrf-id;
141            leaf vpn-id { type uint32;}
142            leaf vrf-id {
143               description
144                  "The vrf-id command configures a route distinguisher (RD)
145                   for the IPv4 or IPv6 address family of a VPN instance or
146                   vpn instance name for internal vpn case.";
147               type string;
148            }
149
150            leaf vpn-instance-name {
151                description "Typical the VPN Uuid";
152                type string;
153            }
154
155            leaf vpn-interface-count { type uint32; }
156            uses vpn-route-list;
157            list vpn-to-dpn-list {
158                key dpnId;
159                leaf dpnId {
160                   type uint64;
161                }
162                list vpn-interfaces {
163                   key interface-name;
164                   leaf interface-name {
165                       type string;
166                   }
167                }
168                list ip-addresses {
169                    key ip-address;
170                    leaf ip-address { type string; }
171                }
172                leaf dpn-state {
173                         description
174                         "This flag indicates the state of the DPN.
175                         Active state indicates atleast one vpn interface present on that DPN for the vpn.
176                         Inactive state indicates no vpn interface present on that DPN for this vpn.";
177
178                     type enumeration {
179                          enum active {
180                             value "0";
181                             description
182                                 "Active state";
183                              }
184                              enum inactive {
185                                  value "1";
186                                  description
187                                  "Inactive state";
188                              }
189                         }
190                         default "active";
191                    }
192            }
193            container vpnTargets {
194               description
195                 "The vpn-target command configures the export or import VPN target
196                  extended community attribute for the VPN instance IPv4/IPv6 address
197                  family.
198                  Format is ASN:nn or IP-address:nn.";
199
200               list vpnTarget {
201                  key "vrfRTValue";
202                  max-elements "unbounded";
203                  min-elements "0";
204                  description
205                     "L3vpn vpntarget configure class";
206
207                  leaf vrfRTValue {
208                     description
209                        "Vpn-target: adds VPN target extended community attribute to the
210                         export or import VPN target extended community list. The
211                         vpn-target can be expressed in either of the following formats:
212                         (1)16-bit AS number:32-bit user-defined number
213                            For example, 1:3. The AS number ranges from 0 to 65535. The
214                            user-defined number ranges from 0 to 4294967295. The AS number
215                            and the user-defined number cannot be 0s at the same time.
216                            That is, a VPN target cannot be 0:0.
217                         (2)32-bit IP address:16-bit user-defined number
218                            For example, 192.168.122.15:1. The IP address ranges from
219                            0.0.0.0 to 255.255.255.255. The user-defined number ranges from
220                            0 to 65535.
221                         (3)32-bit IP address:16-bit user-defined number
222                            For example, 192.168.122.15:1. An IP address ranges from
223                            0.0.0.0 to 255.255.255.255. A user-defined number ranges from 0
224                            to 65535.";
225                     type string {
226                        length "3..21";
227                     }
228                  }
229
230                  leaf vrfRTType {
231                     description
232                        "Specifies the vpn target type, export-extcommunity:
233                         specifies the extended community attributes carried in routing
234                         information to be sent. import-extcommunity: receives routing
235                         information carrying specified extended community attributes.";
236
237                     type enumeration {
238                        enum export_extcommunity {
239                           value "0";
240                           description "export-extcommunity:";
241                        }
242                        enum import_extcommunity {
243                           value "1";
244                           description "import-extcommunity:";
245                        }
246                        enum both {
247                           value "2";
248                           description "export-extcommunity & import-extcommunity:";
249                        }
250                     }
251                  }
252               }
253            }
254         }
255     }
256
257
258     typedef task-state {
259          type enumeration {
260            enum na {
261              value "0";
262              description
263               "Task not applicable";
264            }
265            enum pending {
266              value "1";
267              description
268               "Task is in pending state";
269            }
270            enum done {
271              value "2";
272              description
273               "Task has been completed";
274            }
275          }
276          description
277           "This value the status of any task.
278            The possible values are NA, PENDING or DONE.
279            ";
280            }
281
282
283     container subnet-op-data {
284         config false;
285         list subnet-op-data-entry {
286             key subnet-id;
287             leaf subnet-id {
288                 type    yang:uuid;
289                 description "UUID representing the subnet ";
290             }
291             leaf nh-dpnId {
292                 type uint64;
293                 description "DpnId for the DPN used as nexthop for this subnet";
294             }
295             leaf vpn-name {
296                 type string;
297                 description "VPN Instance name";
298             }
299             leaf vrf-id {
300                 type string;
301             }
302             leaf subnet-cidr {
303                 type string;
304                 description "Subnet in cidr notation";
305             }
306             leaf route-adv-state {
307                 type task-state;
308                 description "The status of the subnet route advertisement. Route advertisement could be in a NA, PENDING or DONE state.";
309             }
310             leaf elan-tag{
311                 type uint32;
312             }
313             list subnet-to-dpn {
314                 key dpnId;
315                 leaf dpnId {
316                     type uint64;
317                 }
318                 list vpn-interfaces {
319                     key interface-name;
320                     leaf interface-name {
321                         type string;
322                     }
323                 }
324             }
325
326         }
327     }
328
329     container port-op-data {
330         config false;
331         list port-op-data-entry {
332             key port-id;
333             leaf port-id {
334                 type  string;
335                 description "UUID in string format representing the port ";
336             }
337             leaf subnet-id {
338                 type  yang:uuid;
339                 description "Back reference to obtain the subnet for a port ";
340             }
341             leaf dpnId {
342                 type uint64;
343             }
344         }
345     }
346
347
348     grouping dpn-in-vpn-event {
349         leaf dpn-id { type uint64; }
350         leaf vpn-name { type string; }
351         leaf rd { type string; }
352     }
353
354     notification add-dpn-event {
355         container add-event-data {
356            uses dpn-in-vpn-event;
357         }
358     }
359
360     notification remove-dpn-event {
361         container remove-event-data {
362            uses dpn-in-vpn-event;
363         }
364     }
365
366     /*
367      * Configured Transport Type for l3vpn service.
368      */
369     container conf-transport-type-l3vpn {
370         leaf transport-type {
371             mandatory "true";
372             type identityref {
373                 base odlif:tunnel-type-base;
374             }
375             description
376                 "L3VPN service will use this config to setup
377                 the transport type for tunnels between DPNs.";
378         }
379     }
380
381     /* container to maintain mapping between neutron router and DPN(s) on which vpn-interfaces for router are present */
382     container neutron-router-dpns {
383         config false;
384         list router-dpn-list {
385             key router-id;
386             leaf router-id { type string;}
387             list dpn-vpninterfaces-list {
388                 key dpn-id;
389                 leaf dpn-id { type uint64;}
390                 list router-interfaces {
391                     key interface;
392                     leaf interface { type string; }
393                 }
394             }
395         }
396     }
397
398
399     container router-interfaces {
400         list router-interface {
401             key interface-name;
402             leaf interface-name { type string; }
403             leaf router-name { type string; }
404         }
405     }
406 }