Merge "Add requirement doc"
[promise.git] / requirements / resource_management / 07-schemas.rst
1 Promise YANG Schemas based on StormForge
2 ----------------------------------------
3
4 Promise Schema
5 ^^^^^^^^^^^^^^
6
7 .. code::
8
9   module opnfv-promise {
10     namespace "urn:opnfv:vim:promise";
11     prefix prom;
12
13     import opnfv-promise-models { prefix opm; }
14     import complex-types { prefix ct; }
15
16     description
17       "OPNFV Promise Resource Reservation/Allocation controller module";
18
19     revision 2015-04-16 {
20       description
21         "Initial revision.";
22     }
23
24     // MAIN CONTAINER
25
26     container promise {
27       ct:instance-list reservations {
28         description
29           "Aggregate collection of all registered ResourceReservation
30            instances";
31         ct:instance-type opm:ResourceReservation;
32       }
33     }
34
35     rpc list-reservations;
36     rpc create-reservation;
37     rpc cancel-reservation;
38
39     notification reservation-event;
40     notification capacity-event;
41     notification allocation-event;
42   }
43
44 OPNFV Promise YANG Schema
45 ^^^^^^^^^^^^^^^^^^^^^^^^^
46
47 .. code::
48
49   module opnfv-promise-models {
50     prefix opm;
51
52     import storm-common-models { prefix scm; }
53     import complex-types { prefix ct; }
54
55     feature resource-reservation;
56
57     ct:complex-type ResourceReservation {
58       ct:extends scm:ResourceElement;
59
60       description
61         "Contains the capacities of various resource services being reserved
62          along with any resource elements needed to be available at
63          the time of allocation(s).";
64
65       reference "OPNFV-PROMISE, Section 3.4.1";
66
67       leaf start { type ct:date-and-time; }
68       leaf end   { type ct:date-and-time; }
69       leaf expiry {
70         description
71           "Duration in seconds from start when unallocated reserved resources
72            will be released back into the pool";
73         type number; units "seconds";
74       }
75       leaf zone {
76         type instance-identifier { ct:instance-type scm:AvailabilityZone; }
77       }
78       container capacity {
79         uses scm:compute-capacity;
80         uses scm:networking-capcity;
81         uses scm:storage-capacity;
82       }
83       leaf-list resources {
84         description
85           "Reference to a collection of existing resource elements required by
86            this reservation. It can contain any instance derived from
87            ResourceElement, such as ServerInstances or even other
88            ResourceReservations. If the ResourceReservation request is
89            accepted, the ResourceElement(s) listed here will be placed
90            into 'protected' mode as to prevent accidental delete.";
91         type instance-identifier {
92           ct:instance-type scm:ResourceElement;
93         }
94         // following 'must' statement applies to each element
95         must "boolean(/provider/elements/*[@id=id])" {
96           error-message
97             "One or more of the ResourceElement(s) does not exist in the
98              provider to be reserved";
99         }
100       }
101
102       leaf provider {
103         if-feature multi-provider;
104         config false;
105
106         description
107           "Reference to a specified existing provider from which this
108            reservation will be drawn if used in the context of multi-provider
109            environment.";
110         type instance-identifier {
111           ct:instance-type scm:ResourceProvider;
112           require-instance true;
113         }
114       }
115
116       container remaining {
117         config false;
118         description
119           "Provides visibility into total remaining capacity for this
120            reservation based on allocations that took effect utilizing
121            this reservation ID as a reference.";
122
123         uses scm:compute-capacity;
124         uses scm:networking-capcity;
125         uses scm:storage-capacity;
126       }
127
128       leaf-list allocations {
129         config false;
130         description
131           "Reference to a collection of consumed allocations referencing
132            this reservation.";
133         type instance-identifier {
134           ct:instance-type ResourceAllocation;
135         }
136       }
137
138     }
139
140     ct:complex-type ResourceAllocation {
141       ct:extends scm:ResourceElement;
142
143       description
144          "Contains a list of resources to be allocated with optional reference
145          to an existing reservation.
146
147          If reservation is specified but this request is received prior
148          to reservation start timestamp, then it will be rejected unless
149          'allocate-on-start' is set to true.  'allocate-on-start' allows
150          the allocation to be auto-initiated and scheduled to run in the
151          future.
152
153          The 'priority' state indicates the classification for dealing
154          with resource starvation scenarios. Lower priority allocations
155          will be forcefully terminated to allow for higher priority
156          allocations to be fulfilled.
157
158          Allocations without reference to an existing reservation will
159          receive the lowest priority.";
160
161       reference "OPNFV-PROMISE, Section 3.4.3";
162
163       leaf reservation {
164         description "Reference to an existing reservation identifier";
165
166         type instance-identifier {
167           ct:instance-type ResourceReservation;
168           require-instance true;
169         }
170       }
171
172       leaf allocate-on-start {
173         description
174          "If 'allocate-on-start' is set to true, the 'planned' allocations will
175          take effect automatically at the reservation 'start' date/time.";
176         type boolean; default false;
177       }
178
179       ct:instance-list resources {
180         description "Contains list of new ResourceElements that will be
181                      allocated";
182         ct:instance-type scm:ResourceElement;
183       }
184
185       leaf priority {
186         description
187           "Reflects current priority level of the allocation according to
188            classification rules";
189         type number;
190         config false;
191       }
192     }
193   }
194
195 .. -*