4ef4ccd1daa2b985e518f92eb114a4a425e642dc
[affinity.git] / affinity / yang / src / main / yang / affinity.yang
1 module affinity { 
2     namespace "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   //**************************************************
19   grouping switch_endpoint {
20       leaf switch-port {
21           type inv:node-connector-id;
22       }
23   }
24
25   //**************************************************
26   // Affinity address domain: This represents a domain (i.e, set) of one or
27   // more addresses. An affinity address may not always have a corresponding
28   // endpoint on the network, for example, an address domain representing 
29   // external addresses, or north-south traffic in a data center). Here the 
30   // IP address domain representing such external addresses does not map to 
31   // endpoints or node connectors on the network. 
32   //
33   // Affinity address domains specify one or more of the following: 
34   // layer 2 address (vlan + mac range)
35   // layer 3 address (IP prefix)
36   //**************************************************
37
38   // xxx  -- Includes access port on a hypervisor ovswitch to which a VM is connected.
39    grouping host_endpoint {
40        container l2address {
41            leaf vlan {
42                type l2types:vlan-id; 
43            }
44            leaf mac {
45                type yang:mac-address;
46            }
47        }
48
49        // l3-domain-address is IPv4 prefix
50        leaf l3address {
51            type inet:ipv4-prefix;
52        }
53    }       
54
55    typedef group-ref {
56        type instance-identifier;
57    }
58    
59    typedef link-ref {
60        type instance-identifier;
61    }
62    
63    //**************************************************
64    // Affinity group
65    //**************************************************
66     grouping group {
67         leaf id {
68             type string;
69         }   
70         list endpoints {
71             key id;
72             uses host_endpoint;
73         }
74     }
75
76     //**************************************************
77     // Affinity link connects one group (from group) to another (to
78     // group). It represents a set of flows that start from the source group
79     // and end in the destination group.  An affinity link has attributes
80     // (policies) attached to it that represent how these flows must be
81     // handled. An affinity link also has directionality associated with
82     // it. A bidirectional affinity link is equivalent to two unidirectional
83     // affinity links, one in each direction.
84     //**************************************************
85     grouping link {
86         leaf id {
87             type string;
88         }
89         leaf from-group {
90             type group-ref;
91         }
92         leaf to-group {
93             type group-ref;
94         }
95         container attribute {
96             uses attribute; 
97         }
98     }
99
100     //**************************************************
101     // Affinity attribute. Each is expanded in their own grouping construct below. 
102     //**************************************************
103     // Various types of affinity topologies. Used in union 'attribute'. 
104
105     // Affinity attribute. xxx add case statements for each type later. 
106     grouping attribute {
107         leaf attribute-type {   
108             description "affinity attribute";
109             type string;
110         }
111     }
112
113     // Main container that represents the complete set of affinity
114     // groups and links. Each set is represented as a YANG list with 'id'
115     // as the key. List contains affinity group and affinity link objects
116     // defined above.
117     container config {
118         list group {
119             key id;
120             ext:context-instance "group-context";
121             uses group;
122         }
123         list link {
124             key id;
125             ext:context-instance "link-context";
126             uses link;
127         }
128     }
129
130     //******************************
131     // RPCs to create affinity groups, add endpoints and address domains. 
132     //******************************
133     rpc creategroup {
134         input {
135             leaf name {
136                 type string;
137             }
138         }
139     }
140
141     rpc addendpoint {
142         input {
143             leaf groupname {
144                 type string;
145             }
146             container endpoint {
147                 uses host_endpoint;
148             }
149         }
150     }
151
152 /*
153     rpc getgroups {
154         output {
155             list group {
156             key id;
157             uses group;
158             }
159         }
160     }
161     rpc get-links;
162     rpc get-group;
163     rpc get-link;
164
165     rpc get-stats-per-link;
166
167     //**************************************************
168     // Notifications 
169     //**************************************************
170     notification new-endpoint;
171     notification new-domain;
172     notification modify-attribute;
173 */
174 }
175
176