Fixed address domain to match documentation.
[affinity.git] / affinity / yang / src / main / yang / affinity-config-all.yang
1 module affinity-config-all { 
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   // Stationary location within the network -- switch + port, including physical switch port 
18   // or virtual switch port within a hypervisor virtual switch. 
19   //**************************************************
20   grouping affinity-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   // Whenever possible, the affinity service must resolve the address domain
34   // into a list of endpoints especially when the address is present on the network. 
35   // 
36   // Affinity address domains specify one or more of the following: 
37   // layer 2 address (vlan + mac range)
38   // layer 3 address (IP prefix)
39   // layer 4 address (tcp or udp port number)
40   //**************************************************
41
42    grouping affinity-address-domain {
43        // l2-domain-address is vlan + MAC address range
44        container l2-address {
45            leaf vlan-id {
46                type l2types:vlan-id; 
47            }
48            container mac-address-range {
49                uses mac-address-range;
50            }
51        }
52
53        // l3-domain-address is IPv4 prefix
54        leaf l3-address {
55            type inet:ipv4-prefix;
56        }
57
58        // l4 port number 
59        container l4-address {
60            leaf proto {
61                type string; // "tcp" or "udp"
62            }
63            leaf port-number {   
64                type inet:port-number;
65            }
66        }        
67    }       
68
69    grouping mac-address-range {
70        leaf start-address {
71            type yang:mac-address;
72        }
73        leaf end-address {
74            type yang:mac-address;
75        }
76    }
77
78    typedef affinity-group-ref {
79        type instance-identifier;
80    }
81    
82    typedef affinity-link-ref {
83        type instance-identifier;
84    }
85    
86    grouping affinity-element {
87        leaf id {
88            type string;
89        }
90        choice element {
91            description "affinity element";
92            case affinity-endpoint {
93                    uses affinity-endpoint;
94                }
95                
96                case affinity-address-domain {
97                        uses affinity-address-domain;
98                    }
99        }
100    }       
101    //**************************************************
102    // Affinity group
103    //**************************************************
104     grouping affinity-group {
105         leaf id {
106             type string;
107         }   
108         list affinity-element {
109             key id;
110             uses affinity-element;
111         }
112     }
113
114     //**************************************************
115     // Affinity link connects one group (from group) to another (to
116     // group). It represents a set of flows that start from the source group
117     // and end in the destination group.  An affinity link has attributes
118     // (policies) attached to it that represent how these flows must be
119     // handled. An affinity link also has directionality associated with
120     // it. A bidirectional affinity link is equivalent to two unidirectional
121     // affinity links, one in each direction.
122     //**************************************************
123     grouping affinity-link {
124         leaf id {
125             type string;
126         }
127         leaf from-affinity-group {
128             type affinity-group-ref;
129         }
130         leaf to-affinity-group {
131             type affinity-group-ref;
132         }
133         container attribute {
134             uses affinity-attribute; 
135         }
136     }
137
138     typedef affinity-access-control-type {
139               type enumeration {
140                   enum permit;
141                   enum deny;
142               }
143     }
144
145     //**************************************************
146     // Affinity attribute. Each is expanded in their own grouping construct below. 
147     //**************************************************
148     grouping affinity-attribute {
149         leaf id {
150             type string;
151         }
152         choice attribute-type {
153             description "affinity attribute";
154             // Apply access control to selected flows. 
155             case affinity-access-control {
156                     leaf affinity-access-control {
157                         type  affinity-access-control-type;
158                     }
159                 }
160                 
161                 // Apply waypoint routing to the selected flows and send it through service chain. 
162             case network-service-chain {
163                     leaf network-service-chain  {
164                         type network-service-chain-ref;
165                     }
166             }
167         }
168     }
169
170     //**************************************************
171     // Network service chain configuration. 
172     //**************************************************
173     typedef network-service-chain-ref {
174         type instance-identifier;
175     }
176     
177     grouping network-service-chain {
178         leaf id {
179             type string;
180         }   
181         list service-chain {
182             key id;
183             uses network-service-function;
184         }
185     }
186
187     //**************************************************
188     // Network-service-function represented by one of the following
189     // types of addresses.
190     //**************************************************
191     grouping network-service-function {
192         leaf id {
193             type string;
194         }
195         // Address is either an IP address, MAC address, or switch/port. 
196         leaf location {
197             description "Mac or Inet address";
198             type union {
199                 type inv:node-connector-id;
200                 type yang:mac-address;
201                 type inet:ip-address;
202             }
203         }
204     }
205
206     // Main container that represents the complete set of affinity
207     // groups and links. Each set is represented as a YANG list with 'id'
208     // as the key. List contains affinity group and affinity link objects
209     // defined above.
210     container affinity-config {
211         list affinity-group {
212             key id;
213             ext:context-instance "affinity-group-context";
214             uses affinity-group;
215         }
216         list affinity-link {
217             key id;
218             ext:context-instance "affinity-link-context";
219             uses affinity-link;
220         }
221     }
222
223     //******************************
224     // RPCs to create affinity groups, add endpoints and address domains. 
225     //******************************
226     rpc create-affinity-group {
227         input {
228             uses affinity-group;
229         }
230         output {
231             leaf status {
232                 type string;
233             }
234         }
235     }
236
237     rpc add-affinity-endpoint {
238         input {
239             leaf affinity-endpoint {
240                 type inv:node-connector-id;
241             }
242         }
243         output {
244             leaf status {
245                 type string;
246             }
247         }
248     }
249
250     rpc add-affinity-domain {
251         input {
252             container affinity-domain {
253                 uses affinity-address-domain;
254             }
255         }    
256         output {
257             leaf status {
258                 type string;
259             }
260         }
261     }
262
263     rpc get-affinity-groups {
264         output {
265             list affinity-group {
266             key id;
267             uses affinity-group;
268             }
269         }
270     }
271     rpc get-affinity-links;
272     rpc get-affinity-group;
273     rpc get-affinity-link;
274
275     rpc get-stats-per-affinity-link;
276
277     //**************************************************
278     // Notifications 
279     //**************************************************
280     notification new-affinity-endpoint;
281     notification new-affinity-domain;
282     notification modify-affinity-attribute;
283
284 }
285
286