Avoid hosttracker resolution for flow endpoints since these may be in address/mask...
[affinity.git] / affinity / yang / src / main / yang / affinity-config.yang
1 module affinity-config { 
2     namespace "urn:opendaylight:affinity";
3     prefix affinity;
4
5     import ietf-inet-types { prefix inet; }
6     import ietf-yang-types { prefix yang; }
7     import yang-ext { prefix ext; }
8     import opendaylight-inventory {prefix inv;}
9     import opendaylight-l2-types { prefix l2types; }
10
11     revision "2013-09-25" {
12         description "Initial revision of affinity model to be reviewed";
13     }
14
15
16   //**************************************************
17   // Switch + port. Access port on a physical switch. 
18   // Includes access port on a hypervisor ovswitch to which a VM is connected.
19   //**************************************************
20   grouping endpoint {
21       leaf switch-port {
22           type inv:node-connector-id;
23       }
24   }
25
26   //**************************************************
27   // Affinity address domain: This represents a domain (i.e, set) of one or
28   // more addresses. An affinity address may not always have a corresponding
29   // endpoint on the network, for example, an address domain representing 
30   // external addresses, or north-south traffic in a data center). Here the 
31   // IP address domain representing such external addresses does not map to 
32   // endpoints or node connectors on the network. 
33   //
34   // Affinity address domains specify one or more of the following: 
35   // layer 2 address (vlan + mac range)
36   // layer 3 address (IP prefix)
37   //**************************************************
38
39    grouping address-domain {
40        // l2-domain-address is vlan + MAC address range
41        container l2-address {
42            leaf vlan-id {
43                type l2types:vlan-id; 
44            }
45            container mac-address-range {
46                uses mac-address-range;
47            }
48        }
49
50        // l3-domain-address is IPv4 prefix
51        leaf l3-address {
52            type inet:ipv4-prefix;
53        }
54    }       
55
56    grouping mac-address-range {
57        leaf start-address {
58            type yang:mac-address;
59        }
60        leaf end-address {
61            type yang:mac-address;
62        }
63    }
64
65    typedef group-ref {
66        type instance-identifier;
67    }
68    
69    typedef link-ref {
70        type instance-identifier;
71    }
72    
73    grouping element {
74        leaf id {
75            type string;
76        }
77        choice element {
78            description "affinity element";
79            case endpoint {
80                    uses endpoint;
81                }
82                
83                case address-domain {
84                        uses address-domain;
85                    }
86        }
87    }       
88    //**************************************************
89    // Affinity group
90    //**************************************************
91     grouping group {
92         leaf id {
93             type string;
94         }   
95         list element {
96             key id;
97             uses element;
98         }
99     }
100
101     //**************************************************
102     // Affinity link connects one group (from group) to another (to
103     // group). It represents a set of flows that start from the source group
104     // and end in the destination group.  An affinity link has attributes
105     // (policies) attached to it that represent how these flows must be
106     // handled. An affinity link also has directionality associated with
107     // it. A bidirectional affinity link is equivalent to two unidirectional
108     // affinity links, one in each direction.
109     //**************************************************
110     grouping link {
111         leaf id {
112             type string;
113         }
114         leaf from-group {
115             type group-ref;
116         }
117         leaf to-group {
118             type group-ref;
119         }
120         container attribute {
121             uses attribute; 
122         }
123     }
124
125     grouping access-control-rule {
126         leaf proto {
127             type string; // "tcp" or "udp"
128         }
129         leaf port-number {   
130             type inet:port-number;
131         }
132         // permit flag - false here means no access to be allowed for
133         // flows in the affinity link matching the traffic spec.
134         leaf permit {
135             type boolean; 
136         }
137     }
138
139     grouping access-control {
140         list rules {
141             key id;
142             uses access-control-rule;
143         }
144     }
145
146     //**************************************************
147     // Affinity attribute. Each is expanded in their own grouping construct below. 
148     //**************************************************
149     // Various types of affinity topologies. Used in union 'attribute'. 
150
151     // Affinity attribute. 
152     grouping attribute {
153         leaf id {
154             type string;
155         }
156         choice attribute-type {
157             description "affinity attribute";
158             case isolate-path {
159                  container isolate-path {
160                      uses isolate-path;
161                  }
162             }
163             case shortest-path {
164                     container shortest-path {
165                         uses shortest-path;
166                     }
167             }
168             case bandwidth-optimized-path {
169                     container bandwidth-optimized-path {
170                         uses bandwidth-optimized-path;
171                     }
172             }
173             // Redirect through service chain. 
174             case redirect-path {
175                     leaf redirect-path  {
176                         type network-service-chain-ref;
177                     }
178             }
179             // Apply access control to selected flows. 
180             case access-control {
181                     container access-control {
182                         uses access-control;
183                     }
184             }           
185         }
186     }
187
188
189     // Isolate flows according to certain constraints. 
190     grouping isolate-path {
191         leaf max-flows-per-link {
192             type uint16;
193         }
194         leaf strict {
195             type boolean;
196         }
197     }
198
199     // Route through shortest path 
200     grouping shortest-path {
201         leaf max-flows-per-link {
202             type uint16;
203         }
204         leaf strict {
205             type boolean;
206         }
207     }
208    
209     // bandwidth optimized path
210     grouping bandwidth-optimized-path {
211         leaf max-link-oversubscription-percent {
212             type uint16;
213         }
214         leaf strict {
215             type boolean;
216         }
217     }
218
219     //**************************************************
220     // Network service chain configuration. 
221     //**************************************************
222     typedef network-service-chain-ref {
223         type instance-identifier;
224     }
225     
226     grouping network-service-chain {
227         leaf id {
228             type string;
229         }   
230         list service-chain {
231             key id;
232             uses network-service-function;
233         }
234     }
235
236     //**************************************************
237     // Network-service-function represented by one of the following
238     // types of addresses.
239     //**************************************************
240     grouping network-service-function {
241         leaf id {
242             type string;
243         }
244         // Address is either an IP address, MAC address, or switch/port. 
245         leaf location {
246             description "Mac or Inet address";
247             type union {
248                 type inv:node-connector-id;
249                 type yang:mac-address;
250                 type inet:ip-address;
251             }
252         }
253     }
254
255     // Main container that represents the complete set of affinity
256     // groups and links. Each set is represented as a YANG list with 'id'
257     // as the key. List contains affinity group and affinity link objects
258     // defined above.
259     container config {
260         list group {
261             key id;
262             ext:context-instance "group-context";
263             uses group;
264         }
265         list link {
266             key id;
267             ext:context-instance "link-context";
268             uses link;
269         }
270     }
271
272     //******************************
273     // RPCs to create affinity groups, add endpoints and address domains. 
274     //******************************
275     rpc create-group {
276         input {
277             uses group;
278         }
279         output {
280             leaf status {
281                 type string;
282             }
283         }
284     }
285
286     rpc add-endpoint {
287         input {
288             leaf endpoint {
289                 type inv:node-connector-id;
290             }
291         }
292         output {
293             leaf status {
294                 type string;
295             }
296         }
297     }
298
299     rpc add-domain {
300         input {
301             container domain {
302                 uses address-domain;
303             }
304         }    
305         output {
306             leaf status {
307                 type string;
308             }
309         }
310     }
311
312     rpc get-groups {
313         output {
314             list group {
315             key id;
316             uses group;
317             }
318         }
319     }
320     rpc get-links;
321     rpc get-group;
322     rpc get-link;
323
324     rpc get-stats-per-link;
325
326     //**************************************************
327     // Notifications 
328     //**************************************************
329     notification new-endpoint;
330     notification new-domain;
331     notification modify-attribute;
332
333 }
334
335