Added existsVPN API and refactored NeutronVPN
[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"; }
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 nextHopIp { 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 nexthop-ip {
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-instance-op-data {
101         config false;
102         list vpn-instance-op-data-entry {
103            key vrf-id;
104            leaf vpn-id { type uint32;}
105            leaf vrf-id {
106               description
107                  "The vrf-id command configures a route distinguisher (RD)
108                   for the IPv4 or IPv6 address family of a VPN instance or
109                   vpn instance name for internal vpn case.";
110               type string;
111            }
112
113            leaf vpn-interface-count { type uint32; }
114            uses vpn-route-list;
115            list vpn-to-dpn-list {
116                key dpnId;
117                leaf dpnId {
118                   type uint64;
119                }
120                list vpn-interfaces {
121                   key interface-name;
122                   leaf interface-name {
123                       type string;
124                   }
125                }
126                list ip-addresses {
127                   key ip-address;
128                   leaf ip-address {
129                       type string;
130                   }
131                }
132            }
133         }
134     }
135
136     typedef task-state {
137          type enumeration {
138            enum na {
139              value "0";
140              description
141               "Task not applicable";
142            }
143            enum pending {
144              value "1";
145              description
146               "Task is in pending state";
147            }
148            enum done {
149              value "2";
150              description
151               "Task has been completed";
152            }
153          }
154          description
155           "This value the status of any task.
156            The possible values are NA, PENDING or DONE.
157            ";
158     }
159
160
161     container subnet-op-data {
162         list subnet-op-data-entry {
163             key subnet-id;
164             leaf subnet-id {
165                 type    yang:uuid;
166                 description "UUID representing the subnet ";
167             }
168             leaf nh-dpnId {
169                 type uint64;
170                 description "DpnId for the DPN used as nexthop for this subnet";
171             }
172             leaf vpn-name {
173                 type string;
174                 description "VPN Instance name";
175             }
176             leaf vrf-id {
177                 type string;
178             }
179             leaf subnet-cidr {
180                 type string;
181                 description "Subnet in cidr notation";
182             }
183             leaf route-adv-state {
184                 type task-state;
185                 description "The status of the subnet route advertisement. Route advertisement could be in a NA, PENDING or DONE state.";
186             }
187             leaf elan-tag{
188                 type uint32;
189             }
190             list subnet-to-dpn {
191                 key dpnId;
192                 leaf dpnId {
193                     type uint64;
194                 }
195                 list vpn-interfaces {
196                     key interface-name;
197                     leaf interface-name {
198                         type string;
199                     }
200                 }
201             }
202
203         }
204     }
205
206     container port-op-data {
207         list port-op-data-entry {
208             key port-id;
209             leaf port-id {
210                 type  string;
211                 description "UUID in string format representing the port ";
212             }
213             leaf subnet-id {
214                 type  yang:uuid;
215                 description "Back reference to obtain the subnet for a port ";
216             }
217             leaf dpnId {
218                 type uint64;
219             }
220         }
221     }
222
223     container rd-to-elan-op{
224         list rd-to-elan-op-entry{
225             key "rd subnet-ip";
226             leaf rd {
227                 type string;
228             }
229             leaf subnet-ip {
230                 type string;
231             }
232             leaf next-hop-ip {
233                 type string;
234             }
235             leaf vpn-name {
236                 type string;
237             }
238             leaf elan-tag{
239                 type uint32;
240             }
241         }
242     }
243
244     grouping dpn-in-vpn-event {
245             leaf dpn-id { type uint64; }
246             leaf vpn-name { type string; }
247             leaf rd { type string; }
248         }
249
250         notification add-dpn-event {
251             container add-event-data {
252                uses dpn-in-vpn-event;
253             }
254         }
255
256         notification remove-dpn-event {
257             container remove-event-data {
258                uses dpn-in-vpn-event;
259             }
260         }
261
262
263     /* container to maintain mapping between neutron router and DPN(s) on which vpn-interfaces for router are present */
264     container neutron-router-dpns {
265         list router-dpn-list {
266             key router-id;
267             leaf router-id { type string;}
268             list dpn-vpninterfaces-list {
269                 key dpn-id;
270                 leaf dpn-id { type uint64;}
271                 list router-interfaces {
272                     key interface;
273                     leaf interface { type string; }
274                 }
275             }
276         }
277     }
278
279     container router-interfaces {
280         list router-interface {
281             key interface-name;
282             leaf interface-name { type string; }
283             leaf router-name { type string; }
284         }
285     }
286
287     /*
288      * Configured Transport Type for l3vpn service.
289      */
290     container conf-transport-type-l3vpn {
291         leaf transport-type {
292             mandatory "true";
293             type identityref {
294                 base odlif:tunnel-type-base;
295             }
296             description
297                 "L3VPN service will use this config to setup
298                 the transport type for tunnels between DPNs.";
299         }
300     }
301 }