summaryrefslogtreecommitdiffstats
path: root/docs/requirements/schemas.rst
blob: e42e02e29c61f169012e8ce0a9aca58bb325681d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
ANNEX B: Promise YANG schema based on YangForge
===============================================

.. code::

  module opnfv-promise {
  namespace "urn:opnfv:promise";
  prefix promise;

  import complex-types { prefix ct; }
  import iana-crypt-hash { prefix ianach; }
  import ietf-inet-types { prefix inet; }
  import ietf-yang-types { prefix yang; }
  import opnfv-promise-vim { prefix vim; }

  feature multi-provider {
    description "";
  }

  description
    "OPNFV Promise Resource Reservation/Allocation controller module";

  revision 2015-04-16 {
    description "Initial revision.";
  }

  revision 2015-08-06 {
    description "Updated to incorporate YangForge framework";
  }

  grouping resource-capacity {
    container capacity {
      container quota { description 'Conceptual container that should be extended'; }
      container usage { description 'Conceptual container that should be extended';
                        config false; }
      container reserved { description 'Conceptual container that should be extended';
                           config false; }
      container available { description 'Conceptual container that should be extended';
                            config false; }
    }
  }

  grouping compute-capacity {
    leaf cores { type number; }
    leaf ram { type number; }
    leaf instances { type number; }
  }

  grouping networking-capacity {
    leaf network { type number; }
    leaf port { type number; }
    leaf router { type number; }
    leaf subnet { type number; }
    leaf address { type number; }
  }

  ct:complex-type ResourceReservation {
    ct:extends vim:ResourceElement;

    description
      "Contains the capacities of various resource services being reserved
       along with any resource elements needed to be available at
       the time of allocation(s).";

    reference "OPNFV-PROMISE, Section 3.4.1";

    leaf start { type yang:date-and-time; }
    leaf end   { type yang:date-and-time; }
    leaf expiry {
      description "Duration in seconds from start when unallocated reserved resources
                   will be released back into the pool";
      type number; units "seconds";
    }
    leaf zone { type instance-identifier { ct:instance-type vim:AvailabilityZone; } }
    container capacity {
      uses vim:compute-capacity;
      uses vim:networking-capcity;
      uses vim:storage-capacity;
    }
    leaf-list resources {
      description
        "Reference to a collection of existing resource elements required by
         this reservation. It can contain any instance derived from
         ResourceElement, such as ServerInstances or even other
         ResourceReservations. If the ResourceReservation request is
         accepted, the ResourceElement(s) listed here will be placed
         into 'protected' mode as to prevent accidental delete.";
      type instance-identifier {
        ct:instance-type vim:ResourceElement;
      }
      // following 'must' statement applies to each element
      must "boolean(/provider/elements/*[@id=id])" {
        error-message "One or more of the ResourceElement(s) does not exist in
                       the provider to be reserved";
      }
    }

    leaf provider {
      if-feature multi-provider;
      config false;

      description
        "Reference to a specified existing provider from which this reservation
         will be drawn if used in the context of multi-provider
         environment.";
      type instance-identifier {
        ct:instance-type vim:ResourceProvider;
        require-instance true;
      }
    }

    container remaining {
      config false;
      description
        "Provides visibility into total remaining capacity for this
         reservation based on allocations that took effect utilizing
         this reservation ID as a reference.";

      uses vim:compute-capacity;
      uses vim:networking-capcity;
      uses vim:storage-capacity;
    }

    leaf-list allocations {
      config false;
      description
        "Reference to a collection of consumed allocations referencing
         this reservation.";
      type instance-identifier {
        ct:instance-type ResourceAllocation;
      }
    }
  }

  ct:complex-type ResourceAllocation {
    ct:extends vim:ResourceElement;

    description
       "Contains a list of resources to be allocated with optional reference
       to an existing reservation.

       If reservation is specified but this request is received prior
       to reservation start timestamp, then it will be rejected unless
       'allocate-on-start' is set to true.  'allocate-on-start' allows
       the allocation to be auto-initiated and scheduled to run in the
       future.

       The 'priority' state indicates the classification for dealing
       with resource starvation scenarios. Lower priority allocations
       will be forcefully terminated to allow for higher priority
       allocations to be fulfilled.

       Allocations without reference to an existing reservation will
       receive the lowest priority.";

    reference "OPNFV-PROMISE, Section 3.4.3";

    leaf reservation {
      description "Reference to an existing reservation identifier";

      type instance-identifier {
        ct:instance-type ResourceReservation;
        require-instance true;
      }
    }

    leaf allocate-on-start {
      description
       "If 'allocate-on-start' is set to true, the 'planned' allocations will
       take effect automatically at the reservation 'start' date/time.";
      type boolean; default false;
    }

    ct:instance-list resources {
      description "Contains list of new ResourceElements that will be allocated";
      ct:instance-type vim:ResourceElement;
    }

    leaf priority {
      description
        "Reflects current priority level of the allocation according to classification rules";
      type number;
      config false;
    }
  }

  // MAIN CONTAINER
  container promise {
    ct:instance-list providers {
      description "Aggregate collection of all registered ResourceProvider instances";
      ct:instance-type vim:ResourceProvider;
      config false;

     // augment compute container with capacity elements
     augment "compute" {
       uses resource-capacity {
         augment "capacity/quota" { uses compute-capacity; }
         augment "capacity/usage" { uses compute-capacity; }
         augment "capacity/reserved" { uses compute-capacity; }
         augment "capacity/available" { uses compute-capacity; }
       }
     }

     // augment networking container with capacity elements
     augment "networking" {
       uses resource-capacity {
         if-feature has-networking-capacity;
         augment "capacity/quota" { uses networking-capacity; }
         augment "capacity/usage" { uses networking-capacity; }
         augment "capacity/reserved" { uses networking-capacity; }
         augment "capacity/available" { uses networking-capacity; }
       }
     }

     // track references to reservations for this resource provider
     leaf-list reservations {
       type instance-identifier {
         ct:instance-type ResourceReservation;
       }
     }
    }

    ct:instance-list reservations {
      description "Aggregate collection of all registered ResourceReservation instances";
      ct:instance-type ResourceReservation;
    }

    ct:instance-list allocations {
      description "Aggregate collection of all active ResourceAllocation instances";
      ct:instance-type ResourceAllocation;
    }
  }

  rpc add-provider {
    description "This operation allows you to register a new ResourceProvider
                 into promise management service";
    input {
      leaf provider {
        description "Select a specific resource provider";
        mandatory true;
        type enumeration {
          enum openstack;
          enum hp;
          enum rackspace;
          enum amazon {
            status planned;
          }
          enum joyent {
            status planned;
          }
          enum azure {
            status planned;
          }
        }
      }
      leaf username {
        type string;
        mandatory true;
      }
      leaf password {
        type ianach:crypt-hash;
        mandatory true;
      }
      leaf endpoint {
        type inet:uri;
        description "The target URL endpoint for the resource provider";
        mandatory true;
      }
      leaf region {
        type string;
        description "Optional specified regsion for the provider";
      }
    }
    output {
      leaf id {
        description "Unique identifier for the newly added provider found in /promise/providers";
        type instance-identifier {
          ct:instance-type ResourceProvider;
        }
      }
      leaf result {
        type enumeration {
          enum success;
          enum error;
        }
      }
    }
  }
  rpc remove-provider;
  rpc list-providers;

  rpc check-capacity;

  rpc list-reservations;
  rpc create-reservation;
  rpc update-reservation;
  rpc cancel-reservation;

  rpc list-allocations;
  rpc create-allocation;

  notification reservation-event;
  notification capacity-event;
  notification allocation-event;
  }