* Added affinity config yang.
[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 -- switch + port, includes physical or virtual 
18   // ports for example within a hypervisor representing a virtual switch. 
19   //**************************************************
20   grouping affinity-endpoint {
21       leaf switch-port {
22           type inv:node-connector-id;
23       }
24   }
25
26
27   //**************************************************
28   // Affinity address domain: This represents a domain (i.e, set) of one or
29   // more addresses. An affinity address may not have a corresponding
30   // endpoint on the network, for example, for traffic from a set of
31   // external addresses (north-south traffic in a data center), the source
32   // IP address domain is not required to map exactly to endpoints or node
33   // connectors on the network. We assume that there will be a resolution 
34   // service that resolves one of these into an endpoint, when the address 
35   // is present on the network. 
36   //**************************************************
37    grouping affinity-address-domain {
38         leaf id {
39             type string;
40         }
41         // Address is either an IP address, IP prefix, IP range, or
42         // MAC address, or MAC range. Address may also be a transport
43         // protocol layer address.
44
45         leaf address {
46             description "Mac or Inet address";
47             type union {
48                 type inet:ip-address;
49                 type inet:ip-prefix; 
50                 type l2types:vlan-id; // tbd
51                 type yang:mac-address;
52 //                type yang:mac-address-range;
53 //                type yang:tp-address; // tbd
54             }
55         }
56     }
57
58     typedef affinity-group-ref {
59         type instance-identifier;
60     }
61     
62     typedef affinity-link-ref {
63         type instance-identifier;
64     }
65     
66     typedef network-service-chain-ref {
67         type instance-identifier;
68     }
69
70
71     grouping affinity-element {
72         leaf id {
73             type string;
74         }
75         choice element {
76             description "affinity element";
77             case affinity-endpoint {
78                  uses affinity-endpoint;
79                 }
80                 
81             // Apply waypoint routing to the selected flows and send it through service chain. 
82             case affinity-address-domain {
83                  uses affinity-address-domain;
84             }
85         }
86     }       
87   //**************************************************
88   // Affinity group
89   //**************************************************
90     grouping affinity-group {
91         leaf id {
92             type string;
93         }   
94         list affinity-element {
95             key id;
96             uses affinity-element;
97         }
98     }
99
100     //**************************************************
101     // Affinity link connects one group (from group) to another (to
102     // group). It represents a set of flows that start from the source group
103     // and end in the destination group.  An affinity link has attributes
104     // (policies) attached to it that represent how these flows must be
105     // handled. An affinity link also has directionality associated with
106     // it. A bidirectional affinity link is equivalent to two unidirectional
107     // affinity links, one in each direction.
108     //**************************************************
109     grouping affinity-link {
110         leaf id {
111             type string;
112         }
113         leaf from-affinity-group {
114             type affinity-group-ref;
115         }
116         leaf to-affinity-group {
117             type affinity-group-ref;
118         }
119         container attribute {
120             uses affinity-attribute; 
121         }
122     }
123
124     typedef affinity-access-control-type {
125               type enumeration {
126                   enum permit;
127                   enum deny;
128               }
129     }
130
131     //**************************************************
132     // Affinity attribute. Each is expanded in their own grouping construct below. 
133     //**************************************************
134     grouping affinity-attribute {
135         leaf id {
136             type string;
137         }
138         choice attribute-type {
139             description "affinity attribute";
140             // Apply access control to selected flows. 
141             case affinity-access-control {
142                     leaf affinity-access-control {
143                         type  affinity-access-control-type;
144                     }
145                 }
146                 
147                 // Apply waypoint routing to the selected flows and send it through service chain. 
148             case network-service-chain {
149                     leaf network-service-chain  {
150                         type network-service-chain-ref;
151                     }
152             }
153         }
154     }
155
156     //**************************************************
157     // Network service chain configuration. 
158     //**************************************************
159     grouping network-service-chain {
160         leaf id {
161             type string;
162         }   
163         list service-chain {
164             key id;
165             uses network-service-function;
166         }
167     }
168
169     //**************************************************
170     // Network-service-function represented by one of the following
171     // types of addresses.
172     //**************************************************
173     grouping network-service-function {
174         leaf id {
175             type string;
176         }
177         // Address is either an IP address, MAC address, or switch/port. 
178         leaf location {
179             description "Mac or Inet address";
180             type union {
181                 type inv:node-connector-id;
182                 type yang:mac-address;
183                 type inet:ip-address;
184             }
185         }
186     }
187
188     // Main container that represents the complete set of affinity
189     // groups and links. Each set is represented as a YANG list with 'id'
190     // as the key. List contains affinity group and affinity link objects
191     // defined above.
192     container affinity-config {
193         list affinity-group {
194             key id;
195             ext:context-instance "affinity-group-context";
196             uses affinity-group;
197         }
198         list affinity-link {
199             key id;
200             ext:context-instance "affinity-link-context";
201             uses affinity-link;
202         }
203     }
204
205 }
206
207