Updated list of upstream contributions in Blazar
[promise.git] / deprecated / source / schema / nfv-infrastructure.yang
1 module nfv-infrastructure {
2   namespace "urn:opnfv:promise:nfv:infrastructure";
3   prefix nfvi;
4
5   import access-control-models { prefix acm; }
6   import ietf-inet-types { prefix inet; }
7   import ietf-yang-types { prefix yang; }
8   import complex-types { prefix ct; }
9
10   description
11     "NFV Infrastructure Data Models with complex types and typed instance
12      identifiers representing the various ResourceElements available
13      in the infrastructure across compute, network, and storage.";
14
15   revision 2015-10-13 {
16     description
17       "Introduce capacity and element collection into NFVI models";
18   }
19   
20   revision 2015-08-07 {
21     description
22       "This YANG module is modeled using 'yangforge' which natively provides
23        complex types and typed instance identifiers.  This module
24        provides various collections of resource management data models
25        for instance based management";
26   }
27
28   identity manager {
29     description "used by specific modules implementing manager role for NFVI";
30   }
31   
32   grouping compute-capacity {
33     leaf cores     { type int16; default 0; }
34     leaf ram       { type int32; default 0; units 'MB'; }
35     leaf instances { type int16; default 0; }
36   }
37
38   grouping network-capacity {
39     leaf networks  { type int16; default 0; }
40     leaf ports     { type int16; default 0; }
41     leaf routers   { type int16; default 0; }
42     leaf subnets   { type int16; default 0; }
43     leaf addresses { type int32; default 0; }
44   }
45
46   grouping storage-capacity {
47     leaf gigabytes { type int32; default 0; units 'GB'; }
48     leaf snapshots { type int16; default 0; }
49     leaf volumes   { type int16; default 0; }
50   }
51
52   grouping resource-capacity {
53     uses compute-capacity;
54     uses network-capacity;
55     uses storage-capacity;
56   }
57   
58   grouping resource-collection {
59     description
60       "Information model capturing parameters for describing a collection of
61        resource capacity and resource elements";
62     
63     container capacity { uses resource-capacity; }
64     leaf-list elements {
65       type instance-identifier {
66         ct:instance-type nfvi:ResourceElement;
67         require-instance true;
68       }
69     }
70   }
71
72   grouping resource-stack {
73     description
74       "Information model describing a NFVI resource stack comprising of
75        various resource elements across compute, network, and storage";
76     
77     ct:instance-list hosts { ct:instance-type nfvi:PhysicalHost; }
78     ct:instance-list hypervisors { ct:instance-type nfvi:Hypervisor; }
79
80     container compute {
81       description "Contains compute related resources";
82
83       ct:instance-list servers { ct:instance-type nfvi:ServerInstance; }
84       ct:instance-list images { ct:instance-type nfvi:VirtualMachineImage; }
85       ct:instance-list flavors { ct:instance-type nfvi:ComputeFlavor; }
86     }
87
88     container network {
89       description "Contains networking related resources";
90         
91       ct:instance-list networks { ct:instance-type nfvi:Network; }
92       ct:instance-list subnets { ct:instance-type nfvi:SubNetwork; }
93       ct:instance-list ports { ct:instance-type nfvi:SwitchPort; }
94       //ct:instance-list routers { ct:instance-type Router; }
95     }
96   }
97   
98   /*********************************************
99    * Abstract Models (top-level)
100    *********************************************/
101
102   ct:complex-type ResourceElement {
103     ct:abstract true;
104
105     key "id";
106     leaf id { type yang:uuid; mandatory true; }
107     leaf name { type string; }
108     leaf enabled { type boolean; default true; }
109     leaf protected { type boolean; default false; }
110     leaf owner { type instance-identifier { ct:instance-type acm:Identity; } }
111     leaf visibility {
112       description "Specify visibility level available from the perspective of 'owner'";
113       type enumeration {
114         enum public;
115         enum domain;
116         enum project;
117         enum group;
118         enum user;
119       }
120       default user;
121     }
122     leaf-list tags { type string; }
123     
124     leaf-list members {
125       description "Optionally share with explicit list of members of AccessIdentity complex-type";
126       type instance-identifier {
127         ct:instance-type acm:Identity;
128       }
129     }
130   }
131
132   ct:complex-type ResourceInstance {
133     ct:extends ResourceElement;
134     ct:abstract true;
135
136     leaf status {
137       type enumeration {
138         enum active;
139         enum inactive;
140         enum pending;
141       }
142     }
143     leaf progress {
144       type uint8 { range 0..100; }
145       default 0;
146     }
147   }
148
149   ct:complex-type ResourceContainer {
150     ct:extends ResourceInstance;
151     ct:abstract true;
152
153     description
154       "An abstract resource instance which contains a collection of capacity
155        and elements.";
156
157     uses resource-collection;
158   }
159
160   /*********************************************
161    * Compute Models
162    *********************************************/
163
164   ct:complex-type AvailabilityZone {
165     ct:extends ResourceElement;
166   }
167   
168   ct:complex-type PhysicalHost {
169     ct:extends ResourceElement;
170
171     leaf type { type string; }
172     leaf version { type string; }
173
174     leaf cpu { type uint8; }
175     leaf workload { type uint8; default 0; }
176     leaf uptime { type string; }
177
178     container ram {
179       leaf total { type uint32; units 'MB'; }
180       leaf used { type uint32; units 'MB'; }
181       leaf free { type uint32; units 'MB'; }
182     }
183     container disk {
184       leaf total { type uint32; units 'GB'; }
185       leaf used { type uint32; units 'GB'; }
186       leaf free { type uint32; units 'GB'; }
187     }
188
189     leaf-list hypervisors { type instance-identifier { ct:instance-type Hypervisor; } }
190   }
191   
192   ct:complex-type Hypervisor {
193     ct:extends PhysicalHost;
194
195     leaf host {
196       type instance-identifier { ct:instance-type PhysicalHost; }
197       mandatory true;
198     }
199     container vcpu {
200       leaf total { type uint16; }
201       leaf used { type uint16; }
202       leaf free { type uint16; }
203     }
204     leaf-list servers { type instance-identifier { ct:instance-type ServerInstance; } }
205   }
206
207   ct:complex-type ComputeElement {
208     ct:extends ResourceElement;
209     ct:abstract true;
210
211     container constraint {
212       leaf disk { type uint32; units 'GB'; default 0; }
213       leaf ram { type uint32; units 'MB'; default 0; }
214       leaf vcpu { type uint16; default 0; }
215     }
216
217     leaf-list instances {
218       description "State info about instances currently using this resource element";
219       type instance-identifier {
220         ct:instance-type ResourceInstance;
221       }
222       config false;
223     }
224   }
225
226   ct:complex-type VirtualMachineImage {
227     ct:extends ComputeElement;
228
229     container data {
230       leaf checksum { type string; mandatory true; }
231       leaf size { type uint32; units 'Bytes'; mandatory true; }
232       
233       container format {
234         leaf container {
235           type enumeration { enum ami; enum ari; enum aki; enum bare; enum ovf; }
236           default bare;
237         }
238         leaf disk {
239           type enumeration { enum ami; enum ari; enum aki; enum vhd; enum vmdk; enum raw; enum qcow2; enum vdi; enum iso; }
240         }
241       }
242       leaf content {
243         description "should be a 'private' property so only direct access retrieves content";
244         type binary;
245       }
246     }
247   }
248
249   ct:complex-type ComputeFlavor {
250     ct:extends ResourceElement;
251
252     leaf disk  { type uint32; units 'GB'; default 0; }
253     leaf ram   { type uint32; units 'MB'; default 0; }
254     leaf vcpus { type uint16; default 0; }
255   }
256
257   ct:complex-type ServerInstance {
258     ct:extends ResourceInstance;
259
260     leaf flavor {
261       type instance-identifier { ct:instance-type ComputeFlavor; }
262       mandatory true;
263     }
264     leaf image {
265       type instance-identifier { ct:instance-type VirtualMachineImage; }
266       mandatory true;
267     }
268     
269     //ct:instance metadata { ct:instance-type MetaData; }
270
271     leaf host {
272       type instance-identifier { ct:instance-type PhysicalHost; }
273     }
274
275     leaf-list connections {
276       description
277         "References to collection of NetworkingElement class objects such as
278          Network, Subnet, Port, Router that this ServerInstance is
279          connected with.";
280       type instance-identifier { ct:instance-type NetworkElement; }
281     }
282   }
283
284   /*********************************************
285    * Network Models (Work-in-Progress)
286    *********************************************/
287
288   ct:complex-type NetworkElement {
289     ct:extends ResourceElement;
290     ct:abstract true;
291   }
292
293   ct:complex-type Network {
294     ct:extends NetworkElement;
295
296     leaf-list subnets {
297       type instance-identifier { ct:instance-type SubNetwork; }
298     }
299   }
300
301   ct:complex-type SubNetwork {
302     ct:extends NetworkElement;
303
304     leaf network { type instance-identifier { ct:instance-type Network; } }
305
306     leaf-list nameservers { type string; }
307     
308     container dhcp {
309       leaf enabled { type boolean; }
310       list pools {
311         leaf start { type inet:ip-address; }
312         leaf end   { type inet:ip-address; }
313       }
314     }
315   }
316
317   ct:complex-type SwitchPort {
318     ct:extends NetworkElement;
319
320     leaf subnet { type instance-identifier { ct:instance-type SubNetwork; } }
321   }
322 }