071d685ed40643ee4c1d7bc7f7970a3242ad2bd1
[promise.git] / deprecated / source / index.yaml
1 synth: source
2 name: opnfv-promise
3 version: !<tag:yaml.org,2002:js/undefined> ''
4 description: Resource Management for Virtualized Infrastructure
5 license: Apache-2.0
6 schema:
7   module:
8     opnfv-promise:
9       namespace: 'urn:opnfv:promise'
10       prefix: promise
11       import:
12         complex-types:
13           prefix: ct
14         ietf-yang-types:
15           prefix: yang
16         ietf-inet-types:
17           prefix: inet
18         access-control-models:
19           prefix: acm
20         nfv-infrastructure:
21           prefix: nfvi
22       description: OPNFV Promise Resource Reservation/Allocation controller module
23       revision:
24         '2015-10-05':
25           description: Complete coverage of reservation related intents
26         '2015-08-06':
27           description: Updated to incorporate YangForge framework
28         '2015-04-16':
29           description: Initial revision.
30       feature:
31         reservation-service:
32           description: 'When enabled, provides resource reservation service'
33         multi-provider:
34           description: 'When enabled, provides resource management across multiple providers'
35       grouping:
36         resource-utilization:
37           container:
38             capacity:
39               container:
40                 total:
41                   description: Conceptual container that should be extended
42                 reserved:
43                   description: Conceptual container that should be extended
44                   config: false
45                 usage:
46                   description: Conceptual container that should be extended
47                   config: false
48                 available:
49                   description: Conceptual container that should be extended
50                   config: false
51         temporal-resource-collection:
52           description: Information model capturing resource-collection with start/end time window
53           leaf:
54             start:
55               type: 'yang:date-and-time'
56             end:
57               type: 'yang:date-and-time'
58           container:
59             capacity:
60               uses: {}
61               leaf:
62                 cores:
63                   type: int16
64                   default: '0'
65                 ram:
66                   type: int32
67                   default: '0'
68                   units: MB
69                 instances:
70                   type: int16
71                   default: '0'
72                 networks:
73                   type: int16
74                   default: '0'
75                 ports:
76                   type: int16
77                   default: '0'
78                 routers:
79                   type: int16
80                   default: '0'
81                 subnets:
82                   type: int16
83                   default: '0'
84                 addresses:
85                   type: int32
86                   default: '0'
87                 gigabytes:
88                   type: int32
89                   default: '0'
90                   units: GB
91                 snapshots:
92                   type: int16
93                   default: '0'
94                 volumes:
95                   type: int16
96                   default: '0'
97           leaf-list:
98             elements:
99               type:
100                 instance-identifier:
101                   'ct:instance-type': 'nfvi:ResourceElement'
102                   require-instance: true
103         resource-usage-request:
104           description: |-
105             Information model capturing available parameters to make a resource
106             usage request.
107           reference: 'OPNFV-PROMISE, Section 3.4.1'
108           uses: {}
109           leaf:
110             zone:
111               description: Optional identifier to an Availability Zone
112               type:
113                 instance-identifier:
114                   'ct:instance-type': 'nfvi:AvailabilityZone'
115             start:
116               type: 'yang:date-and-time'
117             end:
118               type: 'yang:date-and-time'
119           container:
120             capacity:
121               uses: {}
122               leaf:
123                 cores:
124                   type: int16
125                   default: '0'
126                 ram:
127                   type: int32
128                   default: '0'
129                   units: MB
130                 instances:
131                   type: int16
132                   default: '0'
133                 networks:
134                   type: int16
135                   default: '0'
136                 ports:
137                   type: int16
138                   default: '0'
139                 routers:
140                   type: int16
141                   default: '0'
142                 subnets:
143                   type: int16
144                   default: '0'
145                 addresses:
146                   type: int32
147                   default: '0'
148                 gigabytes:
149                   type: int32
150                   default: '0'
151                   units: GB
152                 snapshots:
153                   type: int16
154                   default: '0'
155                 volumes:
156                   type: int16
157                   default: '0'
158           leaf-list:
159             elements:
160               type:
161                 instance-identifier:
162                   'ct:instance-type': 'nfvi:ResourceElement'
163                   require-instance: true
164               description: |-
165                 Reference to a list of 'pre-existing' resource elements that are
166                 required for fulfillment of the resource-usage-request.
167
168                 It can contain any instance derived from ResourceElement,
169                 such as ServerInstances or even other
170                 ResourceReservations. If the resource-usage-request is
171                 accepted, the ResourceElement(s) listed here will be placed
172                 into 'protected' mode as to prevent accidental removal.
173
174                 If any of these resource elements become 'unavailable' due to
175                 environmental or administrative activity, a notification will
176                 be issued informing of the issue.
177         query-start-end-window:
178           container:
179             window:
180               description: Matches entries that are within the specified start/end time window
181               leaf:
182                 start:
183                   type: 'yang:date-and-time'
184                 end:
185                   type: 'yang:date-and-time'
186                 scope:
187                   type:
188                     enumeration:
189                       enum:
190                         exclusive:
191                           description: Matches entries that start AND end within the window
192                           value: 0
193                         inclusive:
194                           description: Matches entries that start OR end within the window
195                           value: 1
196                   default: inclusive
197         query-resource-collection:
198           uses: {}
199           leaf-list:
200             without:
201               description: Excludes specified collection identifiers from the result
202               type:
203                 instance-identifier:
204                   'ct:instance-type': ResourceCollection
205           leaf:
206             show-utilization:
207               type: boolean
208               default: 'true'
209           container:
210             elements:
211               leaf-list:
212                 some:
213                   description: Query for ResourceCollection(s) that contain some or more of these element(s)
214                   type:
215                     instance-identifier:
216                       'ct:instance-type': 'nfvi:ResourceElement'
217                 every:
218                   description: Query for ResourceCollection(s) that contain all of these element(s)
219                   type:
220                     instance-identifier:
221                       'ct:instance-type': 'nfvi:ResourceElement'
222             window:
223               description: Matches entries that are within the specified start/end time window
224               leaf:
225                 start:
226                   type: 'yang:date-and-time'
227                 end:
228                   type: 'yang:date-and-time'
229                 scope:
230                   type:
231                     enumeration:
232                       enum:
233                         exclusive:
234                           description: Matches entries that start AND end within the window
235                           value: 0
236                         inclusive:
237                           description: Matches entries that start OR end within the window
238                           value: 1
239                   default: inclusive
240         common-intent-output:
241           leaf:
242             result:
243               type:
244                 enumeration:
245                   enum:
246                     ok:
247                       value: 0
248                     conflict:
249                       value: 1
250                     error:
251                       value: 2
252             message:
253               type: string
254         utilization-output:
255           list:
256             utilization:
257               key: timestamp
258               leaf:
259                 timestamp:
260                   type: 'yang:date-and-time'
261                 count:
262                   type: int16
263               container:
264                 capacity:
265                   uses: {}
266                   leaf:
267                     cores:
268                       type: int16
269                       default: '0'
270                     ram:
271                       type: int32
272                       default: '0'
273                       units: MB
274                     instances:
275                       type: int16
276                       default: '0'
277                     networks:
278                       type: int16
279                       default: '0'
280                     ports:
281                       type: int16
282                       default: '0'
283                     routers:
284                       type: int16
285                       default: '0'
286                     subnets:
287                       type: int16
288                       default: '0'
289                     addresses:
290                       type: int32
291                       default: '0'
292                     gigabytes:
293                       type: int32
294                       default: '0'
295                       units: GB
296                     snapshots:
297                       type: int16
298                       default: '0'
299                     volumes:
300                       type: int16
301                       default: '0'
302       'ct:complex-type':
303         ResourceCollection:
304           'ct:extends': 'nfvi:ResourceContainer'
305           'ct:abstract': 'true'
306           description: |-
307             Describes an abstract ResourceCollection data model, which represents
308             a grouping of capacity and elements available during a given
309             window in time which must be extended by other resource
310             collection related models
311           leaf:
312             start:
313               type: 'yang:date-and-time'
314             end:
315               type: 'yang:date-and-time'
316             active:
317               config: false
318               description: |-
319                 Provides current state of this record whether it is enabled and within
320                 specified start/end time
321               type: boolean
322         ResourcePool:
323           'ct:extends': ResourceCollection
324           description: |-
325             Describes an instance of an active ResourcePool record, which
326             represents total available capacity and elements from a given
327             source.
328           leaf:
329             source:
330               type:
331                 instance-identifier:
332                   'ct:instance-type': 'nfvi:ResourceContainer'
333                   require-instance: true
334               mandatory: true
335           refine:
336             elements:
337               must:
338                 'boolean(/source/elements/*[@id=id])':
339                   error-message: One or more of the ResourceElement(s) does not exist in the provider to be reserved
340         ResourceReservation:
341           'ct:extends': ResourceCollection
342           description: |-
343             Describes an instance of an accepted resource reservation request,
344             created usually as a result of 'create-reservation' request.
345
346             A ResourceReservation is a derived instance of a generic
347             ResourceCollection which has additional parameters to map the
348             pool(s) that were referenced to accept this reservation as well
349             as to track allocations made referencing this reservation.
350
351             Contains the capacities of various resource attributes being
352             reserved along with any resource elements that are needed to be
353             available at the time of allocation(s).
354           reference: 'OPNFV-PROMISE, Section 3.4.1'
355           leaf:
356             created-on:
357               type: 'yang:date-and-time'
358               config: false
359             modified-on:
360               type: 'yang:date-and-time'
361               config: false
362           leaf-list:
363             pools:
364               config: false
365               description: |-
366                 Provides list of one or more pools that were referenced for providing
367                 the requested resources for this reservation.  This is an
368                 important parameter for informing how/where allocation
369                 requests can be issued using this reservation since it is
370                 likely that the total reserved resource capacity/elements are
371                 made availble from multiple sources.
372               type:
373                 instance-identifier:
374                   'ct:instance-type': ResourcePool
375                   require-instance: true
376             allocations:
377               config: false
378               description: |-
379                 Reference to a collection of consumed allocations referencing
380                 this reservation.
381               type:
382                 instance-identifier:
383                   'ct:instance-type': ResourceAllocation
384                   require-instance: true
385           container:
386             remaining:
387               config: false
388               description: |-
389                 Provides visibility into total remaining capacity for this
390                 reservation based on allocations that took effect utilizing
391                 this reservation ID as a reference.
392               uses: {}
393               leaf:
394                 cores:
395                   type: int16
396                   default: '0'
397                 ram:
398                   type: int32
399                   default: '0'
400                   units: MB
401                 instances:
402                   type: int16
403                   default: '0'
404                 networks:
405                   type: int16
406                   default: '0'
407                 ports:
408                   type: int16
409                   default: '0'
410                 routers:
411                   type: int16
412                   default: '0'
413                 subnets:
414                   type: int16
415                   default: '0'
416                 addresses:
417                   type: int32
418                   default: '0'
419                 gigabytes:
420                   type: int32
421                   default: '0'
422                   units: GB
423                 snapshots:
424                   type: int16
425                   default: '0'
426                 volumes:
427                   type: int16
428                   default: '0'
429         ResourceAllocation:
430           'ct:extends': ResourceCollection
431           description: |-
432             A ResourceAllocation record denotes consumption of resources from a
433             referenced ResourcePool.
434
435             It does not reflect an accepted request but is created to
436             represent the actual state about the ResourcePool. It is
437             created once the allocation(s) have successfully taken effect
438             on the 'source' of the ResourcePool.
439
440             The 'priority' state indicates the classification for dealing
441             with resource starvation scenarios. Lower priority allocations
442             will be forcefully terminated to allow for higher priority
443             allocations to be fulfilled.
444
445             Allocations without reference to an existing reservation will
446             receive the lowest priority.
447           reference: 'OPNFV-PROMISE, Section 3.4.3'
448           leaf:
449             reservation:
450               description: Reference to an existing reservation identifier (optional)
451               type:
452                 instance-identifier:
453                   'ct:instance-type': ResourceReservation
454                   require-instance: true
455             pool:
456               description: Reference to an existing resource pool from which allocation is drawn
457               type:
458                 instance-identifier:
459                   'ct:instance-type': ResourcePool
460                   require-instance: true
461             priority:
462               config: false
463               description: Reflects current priority level of the allocation according to classification rules
464               type:
465                 enumeration:
466                   enum:
467                     high:
468                       value: 1
469                     normal:
470                       value: 2
471                     low:
472                       value: 3
473               default: normal
474           container:
475             instance-ref:
476               config: false
477               description: Reference to actual instance identifier of the provider/server for this allocation
478               leaf:
479                 provider:
480                   type:
481                     instance-identifier:
482                       'ct:instance-type': ResourceProvider
483                 server:
484                   type: 'yang:uuid'
485         ResourceFlavor:
486           description: currently NOT an extension of ResourceElement.
487           key: id
488           leaf:
489             id:
490               type: string
491             name:
492               type: string
493             disk:
494               type: uint32
495               units: GB
496               default: '0'
497             ram:
498               type: uint32
499               units: MB
500               default: '0'
501             vcpus:
502               type: uint16
503               default: '0'
504         ResourceProvider:
505           'ct:extends': 'nfvi:ResourceContainer'
506           leaf:
507             token:
508               type: string
509               mandatory: true
510           container:
511             services:
512               config: false
513               container:
514                 compute:
515                   leaf:
516                     endpoint:
517                       type: 'inet:uri'
518                   'ct:instance-list':
519                     flavors:
520                       'ct:instance-type': ResourceFlavor
521           leaf-list:
522             pools:
523               config: false
524               description: Provides list of one or more pools that are referencing this provider.
525               type:
526                 instance-identifier:
527                   'ct:instance-type': ResourcePool
528                   require-instance: true
529       container:
530         promise:
531           uses: {}
532           'ct:instance-list':
533             providers:
534               if-feature: multi-provider
535               description: Aggregate collection of all registered ResourceProvider instances for Promise resource management service
536               'ct:instance-type': ResourceProvider
537               status: unavailable
538             pools:
539               if-feature: reservation-service
540               description: Aggregate collection of all ResourcePool instances
541               'ct:instance-type': ResourcePool
542               status: unavailable
543             reservations:
544               if-feature: reservation-service
545               description: Aggregate collection of all ResourceReservation instances
546               'ct:instance-type': ResourceReservation
547               status: unavailable
548             allocations:
549               description: Aggregate collection of all ResourceAllocation instances
550               'ct:instance-type': ResourceAllocation
551           container:
552             policy:
553               container:
554                 reservation:
555                   leaf:
556                     max-future-start-range:
557                       description: "Enforce reservation request 'start' time is within allowed range from now"
558                       type:
559                         uint16:
560                           range: 0..365
561                       units: days
562                     max-future-end-range:
563                       description: "Enforce reservation request 'end' time is within allowed range from now"
564                       type:
565                         uint16:
566                           range: 0..365
567                       units: days
568                     max-duration:
569                       description: Enforce reservation duration (end-start) does not exceed specified threshold
570                       type: uint16
571                       units: hours
572                       default: '8760'
573                     expiry:
574                       description: |-
575                         Duration in minutes from start when unallocated reserved resources
576                         will be released back into the pool
577                       type: uint32
578                       units: minutes
579             capacity:
580               container:
581                 total:
582                   description: Conceptual container that should be extended
583                   uses: {}
584                   leaf:
585                     cores:
586                       type: int16
587                       default: '0'
588                     ram:
589                       type: int32
590                       default: '0'
591                       units: MB
592                     instances:
593                       type: int16
594                       default: '0'
595                     networks:
596                       type: int16
597                       default: '0'
598                     ports:
599                       type: int16
600                       default: '0'
601                     routers:
602                       type: int16
603                       default: '0'
604                     subnets:
605                       type: int16
606                       default: '0'
607                     addresses:
608                       type: int32
609                       default: '0'
610                     gigabytes:
611                       type: int32
612                       default: '0'
613                       units: GB
614                     snapshots:
615                       type: int16
616                       default: '0'
617                     volumes:
618                       type: int16
619                       default: '0'
620                 reserved:
621                   description: Conceptual container that should be extended
622                   config: false
623                   uses: {}
624                   leaf:
625                     cores:
626                       type: int16
627                       default: '0'
628                     ram:
629                       type: int32
630                       default: '0'
631                       units: MB
632                     instances:
633                       type: int16
634                       default: '0'
635                     networks:
636                       type: int16
637                       default: '0'
638                     ports:
639                       type: int16
640                       default: '0'
641                     routers:
642                       type: int16
643                       default: '0'
644                     subnets:
645                       type: int16
646                       default: '0'
647                     addresses:
648                       type: int32
649                       default: '0'
650                     gigabytes:
651                       type: int32
652                       default: '0'
653                       units: GB
654                     snapshots:
655                       type: int16
656                       default: '0'
657                     volumes:
658                       type: int16
659                       default: '0'
660                 usage:
661                   description: Conceptual container that should be extended
662                   config: false
663                   uses: {}
664                   leaf:
665                     cores:
666                       type: int16
667                       default: '0'
668                     ram:
669                       type: int32
670                       default: '0'
671                       units: MB
672                     instances:
673                       type: int16
674                       default: '0'
675                     networks:
676                       type: int16
677                       default: '0'
678                     ports:
679                       type: int16
680                       default: '0'
681                     routers:
682                       type: int16
683                       default: '0'
684                     subnets:
685                       type: int16
686                       default: '0'
687                     addresses:
688                       type: int32
689                       default: '0'
690                     gigabytes:
691                       type: int32
692                       default: '0'
693                       units: GB
694                     snapshots:
695                       type: int16
696                       default: '0'
697                     volumes:
698                       type: int16
699                       default: '0'
700                 available:
701                   description: Conceptual container that should be extended
702                   config: false
703                   uses: {}
704                   leaf:
705                     cores:
706                       type: int16
707                       default: '0'
708                     ram:
709                       type: int32
710                       default: '0'
711                       units: MB
712                     instances:
713                       type: int16
714                       default: '0'
715                     networks:
716                       type: int16
717                       default: '0'
718                     ports:
719                       type: int16
720                       default: '0'
721                     routers:
722                       type: int16
723                       default: '0'
724                     subnets:
725                       type: int16
726                       default: '0'
727                     addresses:
728                       type: int32
729                       default: '0'
730                     gigabytes:
731                       type: int32
732                       default: '0'
733                       units: GB
734                     snapshots:
735                       type: int16
736                       default: '0'
737                     volumes:
738                       type: int16
739                       default: '0'
740       rpc:
741         create-reservation:
742           if-feature: reservation-service
743           description: Make a request to the reservation system to reserve resources
744           input:
745             uses: {}
746             leaf:
747               zone:
748                 description: Optional identifier to an Availability Zone
749                 type:
750                   instance-identifier:
751                     'ct:instance-type': 'nfvi:AvailabilityZone'
752               start:
753                 type: 'yang:date-and-time'
754               end:
755                 type: 'yang:date-and-time'
756             container:
757               capacity:
758                 uses: {}
759                 leaf:
760                   cores:
761                     type: int16
762                     default: '0'
763                   ram:
764                     type: int32
765                     default: '0'
766                     units: MB
767                   instances:
768                     type: int16
769                     default: '0'
770                   networks:
771                     type: int16
772                     default: '0'
773                   ports:
774                     type: int16
775                     default: '0'
776                   routers:
777                     type: int16
778                     default: '0'
779                   subnets:
780                     type: int16
781                     default: '0'
782                   addresses:
783                     type: int32
784                     default: '0'
785                   gigabytes:
786                     type: int32
787                     default: '0'
788                     units: GB
789                   snapshots:
790                     type: int16
791                     default: '0'
792                   volumes:
793                     type: int16
794                     default: '0'
795             leaf-list:
796               elements:
797                 type:
798                   instance-identifier:
799                     'ct:instance-type': 'nfvi:ResourceElement'
800                     require-instance: true
801                 description: |-
802                   Reference to a list of 'pre-existing' resource elements that are
803                   required for fulfillment of the resource-usage-request.
804
805                   It can contain any instance derived from ResourceElement,
806                   such as ServerInstances or even other
807                   ResourceReservations. If the resource-usage-request is
808                   accepted, the ResourceElement(s) listed here will be placed
809                   into 'protected' mode as to prevent accidental removal.
810
811                   If any of these resource elements become 'unavailable' due to
812                   environmental or administrative activity, a notification will
813                   be issued informing of the issue.
814           output:
815             leaf:
816               reservation-id:
817                 type:
818                   instance-identifier:
819                     'ct:instance-type': ResourceReservation
820               result:
821                 type:
822                   enumeration:
823                     enum:
824                       ok:
825                         value: 0
826                       conflict:
827                         value: 1
828                       error:
829                         value: 2
830               message:
831                 type: string
832           status: unavailable
833         update-reservation:
834           description: Update reservation details for an existing reservation
835           input:
836             leaf:
837               reservation-id:
838                 type:
839                   instance-identifier:
840                     'ct:instance-type': ResourceReservation
841                     require-instance: true
842                 mandatory: true
843               zone:
844                 description: Optional identifier to an Availability Zone
845                 type:
846                   instance-identifier:
847                     'ct:instance-type': 'nfvi:AvailabilityZone'
848               start:
849                 type: 'yang:date-and-time'
850               end:
851                 type: 'yang:date-and-time'
852             uses: {}
853             container:
854               capacity:
855                 uses: {}
856                 leaf:
857                   cores:
858                     type: int16
859                     default: '0'
860                   ram:
861                     type: int32
862                     default: '0'
863                     units: MB
864                   instances:
865                     type: int16
866                     default: '0'
867                   networks:
868                     type: int16
869                     default: '0'
870                   ports:
871                     type: int16
872                     default: '0'
873                   routers:
874                     type: int16
875                     default: '0'
876                   subnets:
877                     type: int16
878                     default: '0'
879                   addresses:
880                     type: int32
881                     default: '0'
882                   gigabytes:
883                     type: int32
884                     default: '0'
885                     units: GB
886                   snapshots:
887                     type: int16
888                     default: '0'
889                   volumes:
890                     type: int16
891                     default: '0'
892             leaf-list:
893               elements:
894                 type:
895                   instance-identifier:
896                     'ct:instance-type': 'nfvi:ResourceElement'
897                     require-instance: true
898                 description: |-
899                   Reference to a list of 'pre-existing' resource elements that are
900                   required for fulfillment of the resource-usage-request.
901
902                   It can contain any instance derived from ResourceElement,
903                   such as ServerInstances or even other
904                   ResourceReservations. If the resource-usage-request is
905                   accepted, the ResourceElement(s) listed here will be placed
906                   into 'protected' mode as to prevent accidental removal.
907
908                   If any of these resource elements become 'unavailable' due to
909                   environmental or administrative activity, a notification will
910                   be issued informing of the issue.
911           output:
912             leaf:
913               result:
914                 type:
915                   enumeration:
916                     enum:
917                       ok:
918                         value: 0
919                       conflict:
920                         value: 1
921                       error:
922                         value: 2
923               message:
924                 type: string
925         cancel-reservation:
926           description: Cancel the reservation and be a good steward
927           input:
928             leaf:
929               reservation-id:
930                 type:
931                   instance-identifier:
932                     'ct:instance-type': ResourceReservation
933                 mandatory: true
934           output:
935             leaf:
936               result:
937                 type:
938                   enumeration:
939                     enum:
940                       ok:
941                         value: 0
942                       conflict:
943                         value: 1
944                       error:
945                         value: 2
946               message:
947                 type: string
948         query-reservation:
949           if-feature: reservation-service
950           description: Query the reservation system to return matching reservation(s)
951           input:
952             leaf:
953               zone:
954                 type:
955                   instance-identifier:
956                     'ct:instance-type': 'nfvi:AvailabilityZone'
957               show-utilization:
958                 type: boolean
959                 default: 'true'
960             uses: {}
961             leaf-list:
962               without:
963                 description: Excludes specified collection identifiers from the result
964                 type:
965                   instance-identifier:
966                     'ct:instance-type': ResourceCollection
967             container:
968               elements:
969                 leaf-list:
970                   some:
971                     description: Query for ResourceCollection(s) that contain some or more of these element(s)
972                     type:
973                       instance-identifier:
974                         'ct:instance-type': 'nfvi:ResourceElement'
975                   every:
976                     description: Query for ResourceCollection(s) that contain all of these element(s)
977                     type:
978                       instance-identifier:
979                         'ct:instance-type': 'nfvi:ResourceElement'
980               window:
981                 description: Matches entries that are within the specified start/end time window
982                 leaf:
983                   start:
984                     type: 'yang:date-and-time'
985                   end:
986                     type: 'yang:date-and-time'
987                   scope:
988                     type:
989                       enumeration:
990                         enum:
991                           exclusive:
992                             description: Matches entries that start AND end within the window
993                             value: 0
994                           inclusive:
995                             description: Matches entries that start OR end within the window
996                             value: 1
997                     default: inclusive
998           output:
999             leaf-list:
1000               reservations:
1001                 type:
1002                   instance-identifier:
1003                     'ct:instance-type': ResourceReservation
1004             list:
1005               utilization:
1006                 key: timestamp
1007                 leaf:
1008                   timestamp:
1009                     type: 'yang:date-and-time'
1010                   count:
1011                     type: int16
1012                 container:
1013                   capacity:
1014                     uses: {}
1015                     leaf:
1016                       cores:
1017                         type: int16
1018                         default: '0'
1019                       ram:
1020                         type: int32
1021                         default: '0'
1022                         units: MB
1023                       instances:
1024                         type: int16
1025                         default: '0'
1026                       networks:
1027                         type: int16
1028                         default: '0'
1029                       ports:
1030                         type: int16
1031                         default: '0'
1032                       routers:
1033                         type: int16
1034                         default: '0'
1035                       subnets:
1036                         type: int16
1037                         default: '0'
1038                       addresses:
1039                         type: int32
1040                         default: '0'
1041                       gigabytes:
1042                         type: int32
1043                         default: '0'
1044                         units: GB
1045                       snapshots:
1046                         type: int16
1047                         default: '0'
1048                       volumes:
1049                         type: int16
1050                         default: '0'
1051           status: unavailable
1052         increase-capacity:
1053           description: Increase total capacity for the reservation system between a window in time
1054           input:
1055             leaf:
1056               source:
1057                 type:
1058                   instance-identifier:
1059                     'ct:instance-type': 'nfvi:ResourceContainer'
1060               start:
1061                 type: 'yang:date-and-time'
1062               end:
1063                 type: 'yang:date-and-time'
1064             container:
1065               capacity:
1066                 uses: {}
1067                 leaf:
1068                   cores:
1069                     type: int16
1070                     default: '0'
1071                   ram:
1072                     type: int32
1073                     default: '0'
1074                     units: MB
1075                   instances:
1076                     type: int16
1077                     default: '0'
1078                   networks:
1079                     type: int16
1080                     default: '0'
1081                   ports:
1082                     type: int16
1083                     default: '0'
1084                   routers:
1085                     type: int16
1086                     default: '0'
1087                   subnets:
1088                     type: int16
1089                     default: '0'
1090                   addresses:
1091                     type: int32
1092                     default: '0'
1093                   gigabytes:
1094                     type: int32
1095                     default: '0'
1096                     units: GB
1097                   snapshots:
1098                     type: int16
1099                     default: '0'
1100                   volumes:
1101                     type: int16
1102                     default: '0'
1103             leaf-list:
1104               elements:
1105                 type:
1106                   instance-identifier:
1107                     'ct:instance-type': 'nfvi:ResourceElement'
1108                     require-instance: true
1109           output:
1110             leaf:
1111               pool-id:
1112                 type:
1113                   instance-identifier:
1114                     'ct:instance-type': ResourcePool
1115               result:
1116                 type:
1117                   enumeration:
1118                     enum:
1119                       ok:
1120                         value: 0
1121                       conflict:
1122                         value: 1
1123                       error:
1124                         value: 2
1125               message:
1126                 type: string
1127         decrease-capacity:
1128           description: Decrease total capacity for the reservation system between a window in time
1129           input:
1130             leaf:
1131               source:
1132                 type:
1133                   instance-identifier:
1134                     'ct:instance-type': 'nfvi:ResourceContainer'
1135               start:
1136                 type: 'yang:date-and-time'
1137               end:
1138                 type: 'yang:date-and-time'
1139             container:
1140               capacity:
1141                 uses: {}
1142                 leaf:
1143                   cores:
1144                     type: int16
1145                     default: '0'
1146                   ram:
1147                     type: int32
1148                     default: '0'
1149                     units: MB
1150                   instances:
1151                     type: int16
1152                     default: '0'
1153                   networks:
1154                     type: int16
1155                     default: '0'
1156                   ports:
1157                     type: int16
1158                     default: '0'
1159                   routers:
1160                     type: int16
1161                     default: '0'
1162                   subnets:
1163                     type: int16
1164                     default: '0'
1165                   addresses:
1166                     type: int32
1167                     default: '0'
1168                   gigabytes:
1169                     type: int32
1170                     default: '0'
1171                     units: GB
1172                   snapshots:
1173                     type: int16
1174                     default: '0'
1175                   volumes:
1176                     type: int16
1177                     default: '0'
1178             leaf-list:
1179               elements:
1180                 type:
1181                   instance-identifier:
1182                     'ct:instance-type': 'nfvi:ResourceElement'
1183                     require-instance: true
1184           output:
1185             leaf:
1186               pool-id:
1187                 type:
1188                   instance-identifier:
1189                     'ct:instance-type': ResourcePool
1190               result:
1191                 type:
1192                   enumeration:
1193                     enum:
1194                       ok:
1195                         value: 0
1196                       conflict:
1197                         value: 1
1198                       error:
1199                         value: 2
1200               message:
1201                 type: string
1202         query-capacity:
1203           description: Check available capacity information about a specified resource collection
1204           input:
1205             leaf:
1206               capacity:
1207                 type:
1208                   enumeration:
1209                     enum:
1210                       total:
1211                         value: 0
1212                       reserved:
1213                         value: 1
1214                       usage:
1215                         value: 2
1216                       available:
1217                         value: 3
1218                 default: available
1219               zone:
1220                 type:
1221                   instance-identifier:
1222                     'ct:instance-type': 'nfvi:AvailabilityZone'
1223               show-utilization:
1224                 type: boolean
1225                 default: 'true'
1226             uses: {}
1227             leaf-list:
1228               without:
1229                 description: Excludes specified collection identifiers from the result
1230                 type:
1231                   instance-identifier:
1232                     'ct:instance-type': ResourceCollection
1233             container:
1234               elements:
1235                 leaf-list:
1236                   some:
1237                     description: Query for ResourceCollection(s) that contain some or more of these element(s)
1238                     type:
1239                       instance-identifier:
1240                         'ct:instance-type': 'nfvi:ResourceElement'
1241                   every:
1242                     description: Query for ResourceCollection(s) that contain all of these element(s)
1243                     type:
1244                       instance-identifier:
1245                         'ct:instance-type': 'nfvi:ResourceElement'
1246               window:
1247                 description: Matches entries that are within the specified start/end time window
1248                 leaf:
1249                   start:
1250                     type: 'yang:date-and-time'
1251                   end:
1252                     type: 'yang:date-and-time'
1253                   scope:
1254                     type:
1255                       enumeration:
1256                         enum:
1257                           exclusive:
1258                             description: Matches entries that start AND end within the window
1259                             value: 0
1260                           inclusive:
1261                             description: Matches entries that start OR end within the window
1262                             value: 1
1263                     default: inclusive
1264           output:
1265             leaf-list:
1266               collections:
1267                 type:
1268                   instance-identifier:
1269                     'ct:instance-type': ResourceCollection
1270             list:
1271               utilization:
1272                 key: timestamp
1273                 leaf:
1274                   timestamp:
1275                     type: 'yang:date-and-time'
1276                   count:
1277                     type: int16
1278                 container:
1279                   capacity:
1280                     uses: {}
1281                     leaf:
1282                       cores:
1283                         type: int16
1284                         default: '0'
1285                       ram:
1286                         type: int32
1287                         default: '0'
1288                         units: MB
1289                       instances:
1290                         type: int16
1291                         default: '0'
1292                       networks:
1293                         type: int16
1294                         default: '0'
1295                       ports:
1296                         type: int16
1297                         default: '0'
1298                       routers:
1299                         type: int16
1300                         default: '0'
1301                       subnets:
1302                         type: int16
1303                         default: '0'
1304                       addresses:
1305                         type: int32
1306                         default: '0'
1307                       gigabytes:
1308                         type: int32
1309                         default: '0'
1310                         units: GB
1311                       snapshots:
1312                         type: int16
1313                         default: '0'
1314                       volumes:
1315                         type: int16
1316                         default: '0'
1317         create-instance:
1318           description: Create an instance of specified resource(s) utilizing capacity from the pool
1319           input:
1320             leaf:
1321               provider-id:
1322                 if-feature: multi-provider
1323                 type:
1324                   instance-identifier:
1325                     'ct:instance-type': ResourceProvider
1326                     require-instance: true
1327                 status: unavailable
1328               name:
1329                 type: string
1330                 mandatory: true
1331               image:
1332                 type:
1333                   union:
1334                     type:
1335                       'yang:uuid': null
1336                       'inet:uri': null
1337                 mandatory: true
1338               flavor:
1339                 type:
1340                   union:
1341                     type:
1342                       'yang:uuid': null
1343                       'inet:uri': null
1344                 mandatory: true
1345               reservation-id:
1346                 type:
1347                   instance-identifier:
1348                     'ct:instance-type': ResourceReservation
1349                     require-instance: true
1350           output:
1351             leaf:
1352               instance-id:
1353                 type:
1354                   instance-identifier:
1355                     'ct:instance-type': ResourceAllocation
1356               result:
1357                 type:
1358                   enumeration:
1359                     enum:
1360                       ok:
1361                         value: 0
1362                       conflict:
1363                         value: 1
1364                       error:
1365                         value: 2
1366               message:
1367                 type: string
1368         destroy-instance:
1369           description: Destroy an instance of resource utilization and release it back to the pool
1370           input:
1371             leaf:
1372               instance-id:
1373                 type:
1374                   instance-identifier:
1375                     'ct:instance-type': ResourceAllocation
1376                     require-instance: true
1377           output:
1378             leaf:
1379               result:
1380                 type:
1381                   enumeration:
1382                     enum:
1383                       ok:
1384                         value: 0
1385                       conflict:
1386                         value: 1
1387                       error:
1388                         value: 2
1389               message:
1390                 type: string
1391         add-provider:
1392           description: Register a new resource provider into reservation system
1393           input:
1394             leaf:
1395               provider-type:
1396                 description: Select a specific resource provider type
1397                 mandatory: true
1398                 type:
1399                   enumeration:
1400                     enum:
1401                       openstack:
1402                         value: 0
1403                       hp:
1404                         value: 1
1405                       rackspace:
1406                         value: 2
1407                       amazon:
1408                         status: planned
1409                         value: 3
1410                       joyent:
1411                         status: planned
1412                         value: 4
1413                       azure:
1414                         status: planned
1415                         value: 5
1416                 default: openstack
1417               strategy:
1418                 type:
1419                   enumeration:
1420                     enum:
1421                       oauth:
1422                         value: 0
1423                       keystone:
1424                         value: 1
1425                 default: keystone
1426               endpoint:
1427                 type: 'inet:uri'
1428                 description: The target endpoint for authentication
1429                 mandatory: true
1430                 default: 'http://localhost:5000/v2.0'
1431               username:
1432                 type: string
1433                 mandatory: true
1434               password:
1435                 type: 'acm:password'
1436                 mandatory: true
1437             uses: {}
1438             container:
1439               tenant:
1440                 leaf:
1441                   id:
1442                     type: string
1443                   name:
1444                     type: string
1445           output:
1446             leaf:
1447               provider-id:
1448                 type:
1449                   instance-identifier:
1450                     'ct:instance-type': ResourceProvider
1451               result:
1452                 type:
1453                   enumeration:
1454                     enum:
1455                       ok:
1456                         value: 0
1457                       conflict:
1458                         value: 1
1459                       error:
1460                         value: 2
1461               message:
1462                 type: string
1463       notification:
1464         reservation-event: null
1465         capacity-event: null
1466         allocation-event: null
1467 dependencies:
1468   access-control-models:
1469     module:
1470       access-control-models:
1471         prefix: acm
1472         namespace: 'urn:opnfv:promise:acm'
1473         import:
1474           complex-types:
1475             prefix: ct
1476           ietf-yang-types:
1477             prefix: yang
1478           ietf-inet-types:
1479             prefix: inet
1480         typedef:
1481           password:
1482             type:
1483               string:
1484                 length: 1..255
1485         grouping:
1486           access-credentials:
1487             leaf:
1488               strategy:
1489                 type:
1490                   enumeration:
1491                     enum:
1492                       oauth:
1493                         value: 0
1494                       keystone:
1495                         value: 1
1496                 default: oauth
1497               endpoint:
1498                 type: 'inet:uri'
1499                 description: The target endpoint for authentication
1500                 mandatory: true
1501               username:
1502                 type: string
1503                 mandatory: true
1504               password:
1505                 type: 'acm:password'
1506                 mandatory: true
1507         'ct:complex-type':
1508           Identity:
1509             'ct:abstract': 'true'
1510             description: Identity represents an administrative access model entity
1511             key: id
1512             leaf:
1513               id:
1514                 type: 'yang:uuid'
1515                 mandatory: true
1516               name:
1517                 type: string
1518                 mandatory: true
1519               description:
1520                 type: string
1521               enabled:
1522                 type: boolean
1523                 default: 'true'
1524           User:
1525             'ct:extends': Identity
1526             leaf:
1527               credential:
1528                 type: string
1529                 mandatory: true
1530               domain:
1531                 type:
1532                   instance-identifier:
1533                     'ct:instance-type': Domain
1534             container:
1535               contact:
1536                 leaf:
1537                   fullName:
1538                     type: string
1539                   email:
1540                     type: string
1541             leaf-list:
1542               groups:
1543                 type:
1544                   instance-identifer:
1545                     'ct:instance-type': Group
1546           Group:
1547             'ct:extends': Identity
1548             leaf-list:
1549               users:
1550                 type:
1551                   instance-identifier:
1552                     'ct:instance-type': User
1553             leaf:
1554               domain:
1555                 type:
1556                   instance-identifier:
1557                     'ct:instance-type': Domain
1558           Domain:
1559             'ct:extends': Identity
1560             description: |-
1561               Domain represent a distinct administrative domain across
1562               collection of users and groups.
1563             'ct:instance-list':
1564               users:
1565                 'ct:instance-type': User
1566               groups:
1567                 'ct:instance-type': Group
1568         rpc:
1569           create-user: null
1570           remove-user: null
1571           create-group: null
1572           remove-group: null
1573   nfv-infrastructure:
1574     module:
1575       nfv-infrastructure:
1576         namespace: 'urn:opnfv:promise:nfv:infrastructure'
1577         prefix: nfvi
1578         import:
1579           access-control-models:
1580             prefix: acm
1581           ietf-inet-types:
1582             prefix: inet
1583           ietf-yang-types:
1584             prefix: yang
1585           complex-types:
1586             prefix: ct
1587         description: |-
1588           NFV Infrastructure Data Models with complex types and typed instance
1589           identifiers representing the various ResourceElements available
1590           in the infrastructure across compute, network, and storage.
1591         revision:
1592           '2015-10-13':
1593             description: Introduce capacity and element collection into NFVI models
1594           '2015-08-07':
1595             description: |-
1596               This YANG module is modeled using 'yangforge' which natively provides
1597               complex types and typed instance identifiers.  This module
1598               provides various collections of resource management data models
1599               for instance based management
1600         identity:
1601           manager:
1602             description: used by specific modules implementing manager role for NFVI
1603         grouping:
1604           compute-capacity:
1605             leaf:
1606               cores:
1607                 type: int16
1608                 default: '0'
1609               ram:
1610                 type: int32
1611                 default: '0'
1612                 units: MB
1613               instances:
1614                 type: int16
1615                 default: '0'
1616           network-capacity:
1617             leaf:
1618               networks:
1619                 type: int16
1620                 default: '0'
1621               ports:
1622                 type: int16
1623                 default: '0'
1624               routers:
1625                 type: int16
1626                 default: '0'
1627               subnets:
1628                 type: int16
1629                 default: '0'
1630               addresses:
1631                 type: int32
1632                 default: '0'
1633           storage-capacity:
1634             leaf:
1635               gigabytes:
1636                 type: int32
1637                 default: '0'
1638                 units: GB
1639               snapshots:
1640                 type: int16
1641                 default: '0'
1642               volumes:
1643                 type: int16
1644                 default: '0'
1645           resource-capacity:
1646             uses: {}
1647             leaf:
1648               cores:
1649                 type: int16
1650                 default: '0'
1651               ram:
1652                 type: int32
1653                 default: '0'
1654                 units: MB
1655               instances:
1656                 type: int16
1657                 default: '0'
1658               networks:
1659                 type: int16
1660                 default: '0'
1661               ports:
1662                 type: int16
1663                 default: '0'
1664               routers:
1665                 type: int16
1666                 default: '0'
1667               subnets:
1668                 type: int16
1669                 default: '0'
1670               addresses:
1671                 type: int32
1672                 default: '0'
1673               gigabytes:
1674                 type: int32
1675                 default: '0'
1676                 units: GB
1677               snapshots:
1678                 type: int16
1679                 default: '0'
1680               volumes:
1681                 type: int16
1682                 default: '0'
1683           resource-collection:
1684             description: |-
1685               Information model capturing parameters for describing a collection of
1686               resource capacity and resource elements
1687             container:
1688               capacity:
1689                 uses: {}
1690                 leaf:
1691                   cores:
1692                     type: int16
1693                     default: '0'
1694                   ram:
1695                     type: int32
1696                     default: '0'
1697                     units: MB
1698                   instances:
1699                     type: int16
1700                     default: '0'
1701                   networks:
1702                     type: int16
1703                     default: '0'
1704                   ports:
1705                     type: int16
1706                     default: '0'
1707                   routers:
1708                     type: int16
1709                     default: '0'
1710                   subnets:
1711                     type: int16
1712                     default: '0'
1713                   addresses:
1714                     type: int32
1715                     default: '0'
1716                   gigabytes:
1717                     type: int32
1718                     default: '0'
1719                     units: GB
1720                   snapshots:
1721                     type: int16
1722                     default: '0'
1723                   volumes:
1724                     type: int16
1725                     default: '0'
1726             leaf-list:
1727               elements:
1728                 type:
1729                   instance-identifier:
1730                     'ct:instance-type': 'nfvi:ResourceElement'
1731                     require-instance: true
1732           resource-stack:
1733             description: |-
1734               Information model describing a NFVI resource stack comprising of
1735               various resource elements across compute, network, and storage
1736             'ct:instance-list':
1737               hosts:
1738                 'ct:instance-type': 'nfvi:PhysicalHost'
1739               hypervisors:
1740                 'ct:instance-type': 'nfvi:Hypervisor'
1741             container:
1742               compute:
1743                 description: Contains compute related resources
1744                 'ct:instance-list':
1745                   servers:
1746                     'ct:instance-type': 'nfvi:ServerInstance'
1747                   images:
1748                     'ct:instance-type': 'nfvi:VirtualMachineImage'
1749                   flavors:
1750                     'ct:instance-type': 'nfvi:ComputeFlavor'
1751               network:
1752                 description: Contains networking related resources
1753                 'ct:instance-list':
1754                   networks:
1755                     'ct:instance-type': 'nfvi:Network'
1756                   subnets:
1757                     'ct:instance-type': 'nfvi:SubNetwork'
1758                   ports:
1759                     'ct:instance-type': 'nfvi:SwitchPort'
1760         'ct:complex-type':
1761           ResourceElement:
1762             'ct:abstract': 'true'
1763             key: id
1764             leaf:
1765               id:
1766                 type: 'yang:uuid'
1767                 mandatory: true
1768               name:
1769                 type: string
1770               enabled:
1771                 type: boolean
1772                 default: 'true'
1773               protected:
1774                 type: boolean
1775                 default: 'false'
1776               owner:
1777                 type:
1778                   instance-identifier:
1779                     'ct:instance-type': 'acm:Identity'
1780               visibility:
1781                 description: "Specify visibility level available from the perspective of 'owner'"
1782                 type:
1783                   enumeration:
1784                     enum:
1785                       public:
1786                         value: 0
1787                       domain:
1788                         value: 1
1789                       project:
1790                         value: 2
1791                       group:
1792                         value: 3
1793                       user:
1794                         value: 4
1795                 default: user
1796             leaf-list:
1797               tags:
1798                 type: string
1799               members:
1800                 description: Optionally share with explicit list of members of AccessIdentity complex-type
1801                 type:
1802                   instance-identifier:
1803                     'ct:instance-type': 'acm:Identity'
1804           ResourceInstance:
1805             'ct:extends': ResourceElement
1806             'ct:abstract': 'true'
1807             leaf:
1808               status:
1809                 type:
1810                   enumeration:
1811                     enum:
1812                       active:
1813                         value: 0
1814                       inactive:
1815                         value: 1
1816                       pending:
1817                         value: 2
1818               progress:
1819                 type:
1820                   uint8:
1821                     range: 0..100
1822                 default: '0'
1823           ResourceContainer:
1824             'ct:extends': ResourceInstance
1825             'ct:abstract': 'true'
1826             description: |-
1827               An abstract resource instance which contains a collection of capacity
1828               and elements.
1829             container:
1830               capacity:
1831                 uses: {}
1832                 leaf:
1833                   cores:
1834                     type: int16
1835                     default: '0'
1836                   ram:
1837                     type: int32
1838                     default: '0'
1839                     units: MB
1840                   instances:
1841                     type: int16
1842                     default: '0'
1843                   networks:
1844                     type: int16
1845                     default: '0'
1846                   ports:
1847                     type: int16
1848                     default: '0'
1849                   routers:
1850                     type: int16
1851                     default: '0'
1852                   subnets:
1853                     type: int16
1854                     default: '0'
1855                   addresses:
1856                     type: int32
1857                     default: '0'
1858                   gigabytes:
1859                     type: int32
1860                     default: '0'
1861                     units: GB
1862                   snapshots:
1863                     type: int16
1864                     default: '0'
1865                   volumes:
1866                     type: int16
1867                     default: '0'
1868             leaf-list:
1869               elements:
1870                 type:
1871                   instance-identifier:
1872                     'ct:instance-type': 'nfvi:ResourceElement'
1873                     require-instance: true
1874           AvailabilityZone:
1875             'ct:extends': ResourceElement
1876           PhysicalHost:
1877             'ct:extends': ResourceElement
1878             leaf:
1879               type:
1880                 type: string
1881               version:
1882                 type: string
1883               cpu:
1884                 type: uint8
1885               workload:
1886                 type: uint8
1887                 default: '0'
1888               uptime:
1889                 type: string
1890             container:
1891               ram:
1892                 leaf:
1893                   total:
1894                     type: uint32
1895                     units: MB
1896                   used:
1897                     type: uint32
1898                     units: MB
1899                   free:
1900                     type: uint32
1901                     units: MB
1902               disk:
1903                 leaf:
1904                   total:
1905                     type: uint32
1906                     units: GB
1907                   used:
1908                     type: uint32
1909                     units: GB
1910                   free:
1911                     type: uint32
1912                     units: GB
1913             leaf-list:
1914               hypervisors:
1915                 type:
1916                   instance-identifier:
1917                     'ct:instance-type': Hypervisor
1918           Hypervisor:
1919             'ct:extends': PhysicalHost
1920             leaf:
1921               host:
1922                 type:
1923                   instance-identifier:
1924                     'ct:instance-type': PhysicalHost
1925                 mandatory: true
1926             container:
1927               vcpu:
1928                 leaf:
1929                   total:
1930                     type: uint16
1931                   used:
1932                     type: uint16
1933                   free:
1934                     type: uint16
1935             leaf-list:
1936               servers:
1937                 type:
1938                   instance-identifier:
1939                     'ct:instance-type': ServerInstance
1940           ComputeElement:
1941             'ct:extends': ResourceElement
1942             'ct:abstract': 'true'
1943             container:
1944               constraint:
1945                 leaf:
1946                   disk:
1947                     type: uint32
1948                     units: GB
1949                     default: '0'
1950                   ram:
1951                     type: uint32
1952                     units: MB
1953                     default: '0'
1954                   vcpu:
1955                     type: uint16
1956                     default: '0'
1957             leaf-list:
1958               instances:
1959                 description: State info about instances currently using this resource element
1960                 type:
1961                   instance-identifier:
1962                     'ct:instance-type': ResourceInstance
1963                 config: false
1964           VirtualMachineImage:
1965             'ct:extends': ComputeElement
1966             container:
1967               data:
1968                 leaf:
1969                   checksum:
1970                     type: string
1971                     mandatory: true
1972                   size:
1973                     type: uint32
1974                     units: Bytes
1975                     mandatory: true
1976                   content:
1977                     description: "should be a 'private' property so only direct access retrieves content"
1978                     type: binary
1979                 container:
1980                   format:
1981                     leaf:
1982                       container:
1983                         type:
1984                           enumeration:
1985                             enum:
1986                               ami:
1987                                 value: 0
1988                               ari:
1989                                 value: 1
1990                               aki:
1991                                 value: 2
1992                               bare:
1993                                 value: 3
1994                               ovf:
1995                                 value: 4
1996                         default: bare
1997                       disk:
1998                         type:
1999                           enumeration:
2000                             enum:
2001                               ami:
2002                                 value: 0
2003                               ari:
2004                                 value: 1
2005                               aki:
2006                                 value: 2
2007                               vhd:
2008                                 value: 3
2009                               vmdk:
2010                                 value: 4
2011                               raw:
2012                                 value: 5
2013                               qcow2:
2014                                 value: 6
2015                               vdi:
2016                                 value: 7
2017                               iso:
2018                                 value: 8
2019           ComputeFlavor:
2020             'ct:extends': ResourceElement
2021             leaf:
2022               disk:
2023                 type: uint32
2024                 units: GB
2025                 default: '0'
2026               ram:
2027                 type: uint32
2028                 units: MB
2029                 default: '0'
2030               vcpus:
2031                 type: uint16
2032                 default: '0'
2033           ServerInstance:
2034             'ct:extends': ResourceInstance
2035             leaf:
2036               flavor:
2037                 type:
2038                   instance-identifier:
2039                     'ct:instance-type': ComputeFlavor
2040                 mandatory: true
2041               image:
2042                 type:
2043                   instance-identifier:
2044                     'ct:instance-type': VirtualMachineImage
2045                 mandatory: true
2046               host:
2047                 type:
2048                   instance-identifier:
2049                     'ct:instance-type': PhysicalHost
2050             leaf-list:
2051               connections:
2052                 description: |-
2053                   References to collection of NetworkingElement class objects such as
2054                   Network, Subnet, Port, Router that this ServerInstance is
2055                   connected with.
2056                 type:
2057                   instance-identifier:
2058                     'ct:instance-type': NetworkElement
2059           NetworkElement:
2060             'ct:extends': ResourceElement
2061             'ct:abstract': 'true'
2062           Network:
2063             'ct:extends': NetworkElement
2064             leaf-list:
2065               subnets:
2066                 type:
2067                   instance-identifier:
2068                     'ct:instance-type': SubNetwork
2069           SubNetwork:
2070             'ct:extends': NetworkElement
2071             leaf:
2072               network:
2073                 type:
2074                   instance-identifier:
2075                     'ct:instance-type': Network
2076             leaf-list:
2077               nameservers:
2078                 type: string
2079             container:
2080               dhcp:
2081                 leaf:
2082                   enabled:
2083                     type: boolean
2084                 list:
2085                   pools:
2086                     leaf:
2087                       start:
2088                         type: 'inet:ip-address'
2089                       end:
2090                         type: 'inet:ip-address'
2091           SwitchPort:
2092             'ct:extends': NetworkElement
2093             leaf:
2094               subnet:
2095                 type:
2096                   instance-identifier:
2097                     'ct:instance-type': SubNetwork
2098 extension:
2099   module:
2100     argument: name
2101     include: 0..n
2102     prefix: 0..1
2103     anyxml: 0..n
2104     augment: 0..n
2105     choice: 0..n
2106     contact: 0..1
2107     container: 0..n
2108     description: 0..1
2109     deviation: 0..n
2110     extension: 0..n
2111     feature: 0..n
2112     grouping: 0..n
2113     identity: 0..n
2114     import: 0..n
2115     leaf: 0..n
2116     leaf-list: 0..n
2117     list: 0..n
2118     namespace: 0..1
2119     notification: 0..n
2120     organization: 0..1
2121     reference: 0..1
2122     revision: 0..n
2123     rpc: 0..n
2124     typedef: 0..n
2125     uses: 0..n
2126     yang-version: 0..1
2127     preprocess: !<tag:yaml.org,2002:js/function> |-
2128       function (arg, params, ctx) {
2129         var changes, match, ref, synth, target;
2130         synth = this.require('data-synth');
2131         ref = params.augment;
2132         for (target in ref) {
2133           changes = ref[target];
2134           match = this.locate(ctx, target);
2135           if (match == null) {
2136             continue;
2137           }
2138           synth.copy(match, changes);
2139         }
2140         return delete this.source[params.prefix];
2141       }
2142     construct: !<tag:yaml.org,2002:js/function> |-
2143       function (arg, params, children, ctx, self) {
2144         return (self.origin.construct.apply(this, arguments)).merge({
2145           models: this.resolve('complex-type')
2146         });
2147       }
2148     complex-type: 0..n
2149     instance: 0..n
2150     instance-list: 0..n
2151     origin:
2152       argument: name
2153       include: 0..n
2154       prefix: 0..1
2155       anyxml: 0..n
2156       augment: 0..n
2157       choice: 0..n
2158       contact: 0..1
2159       container: 0..n
2160       description: 0..1
2161       deviation: 0..n
2162       extension: 0..n
2163       feature: 0..n
2164       grouping: 0..n
2165       identity: 0..n
2166       import: 0..n
2167       leaf: 0..n
2168       leaf-list: 0..n
2169       list: 0..n
2170       namespace: 0..1
2171       notification: 0..n
2172       organization: 0..1
2173       reference: 0..1
2174       revision: 0..n
2175       rpc: 0..n
2176       typedef: 0..n
2177       uses: 0..n
2178       yang-version: 0..1
2179       preprocess: !<tag:yaml.org,2002:js/function> |-
2180         function (arg, params, ctx) {
2181           var changes, match, ref, synth, target;
2182           synth = this.require('data-synth');
2183           ref = params.augment;
2184           for (target in ref) {
2185             changes = ref[target];
2186             match = this.locate(ctx, target);
2187             if (match == null) {
2188               continue;
2189             }
2190             synth.copy(match, changes);
2191           }
2192           return delete this.source[params.prefix];
2193         }
2194       construct: !<tag:yaml.org,2002:js/function> |-
2195         function (arg, params, children) {
2196           var k, m, modules, ref, synth, v;
2197           synth = this.require('data-synth');
2198           modules = {};
2199           ref = params["import"];
2200           for (k in ref) {
2201             v = ref[k];
2202             modules[k] = children[k];
2203             delete children[k];
2204           }
2205           m = (synth.Store(params, function() {
2206             return this.set({
2207               name: arg,
2208               modules: modules
2209             });
2210           })).bind(children);
2211           this.define('module', arg, m);
2212           return m;
2213         }
2214   prefix:
2215     argument: value
2216     preprocess: !<tag:yaml.org,2002:js/function> |-
2217       function (arg, params, ctx) {
2218         return this.source[arg] = this.source;
2219       }
2220   include:
2221     argument: module
2222     preprocess: !<tag:yaml.org,2002:js/function> |-
2223       function (arg, params, ctx) {
2224         var k, m, ref, ref1, ref2, results, v;
2225         m = this.preprocess(this.resolve('dependencies', arg));
2226         ref = m.extension;
2227         for (k in ref) {
2228           v = ref[k];
2229           this.define('extension', k, v);
2230         }
2231         ref1 = m.typedef;
2232         for (k in ref1) {
2233           v = ref1[k];
2234           this.define('typedef', k, v);
2235         }
2236         ref2 = m.schema;
2237         results = [];
2238         for (k in ref2) {
2239           v = ref2[k];
2240           results.push(ctx[k] = v);
2241         }
2242         return results;
2243       }
2244     revision-date: 0..1
2245   augment:
2246     anyxml: 0..n
2247     case: 0..n
2248     choice: 0..n
2249     container: 0..n
2250     description: 0..1
2251     if-feature: 0..n
2252     leaf: 0..n
2253     leaf-list: 0..n
2254     list: 0..n
2255     reference: 0..1
2256     status: 0..1
2257     uses: 0..n
2258     when: 0..1
2259     argument: target-node
2260   belongs-to:
2261     prefix: 1
2262     preprocess: !<tag:yaml.org,2002:js/function> |-
2263       function (arg, params, ctx) {
2264         return this.source[params.prefix] = this.source;
2265       }
2266     argument: module
2267   bit:
2268     description: 0..1
2269     reference: 0..1
2270     status: 0..1
2271     position: 0..1
2272     argument: name
2273   case:
2274     anyxml: 0..n
2275     choice: 0..n
2276     container: 0..n
2277     description: 0..1
2278     if-feature: 0..n
2279     leaf: 0..n
2280     leaf-list: 0..n
2281     list: 0..n
2282     reference: 0..1
2283     status: 0..1
2284     uses: 0..n
2285     when: 0..1
2286     argument: name
2287   choice:
2288     anyxml: 0..n
2289     case: 0..n
2290     config: 0..1
2291     container: 0..n
2292     default: 0..1
2293     description: 0..1
2294     if-feature: 0..n
2295     leaf: 0..n
2296     leaf-list: 0..n
2297     list: 0..n
2298     mandatory: 0..1
2299     reference: 0..1
2300     status: 0..1
2301     when: 0..1
2302     argument: condition
2303   config:
2304     preprocess: !<tag:yaml.org,2002:js/function> |-
2305       function (arg, p, ctx) {
2306         return ctx.config = arg === true || arg === 'true';
2307       }
2308     argument: value
2309   container:
2310     anyxml: 0..n
2311     choice: 0..n
2312     config: 0..1
2313     container: 0..n
2314     description: 0..1
2315     grouping: 0..n
2316     if-feature: 0..n
2317     leaf: 0..n
2318     leaf-list: 0..n
2319     list: 0..n
2320     must: 0..n
2321     presence: 0..1
2322     reference: 0..1
2323     status: 0..1
2324     typedef: 0..n
2325     uses: 0..n
2326     when: 0..1
2327     construct: !<tag:yaml.org,2002:js/function> |-
2328       function (arg, params, children) {
2329         var synth;
2330         synth = this.require('data-synth');
2331         return (synth.Object(params)).bind(children);
2332       }
2333     argument: name
2334     instance: 0..n
2335     instance-list: 0..n
2336     origin:
2337       anyxml: 0..n
2338       choice: 0..n
2339       config: 0..1
2340       container: 0..n
2341       description: 0..1
2342       grouping: 0..n
2343       if-feature: 0..n
2344       leaf: 0..n
2345       leaf-list: 0..n
2346       list: 0..n
2347       must: 0..n
2348       presence: 0..1
2349       reference: 0..1
2350       status: 0..1
2351       typedef: 0..n
2352       uses: 0..n
2353       when: 0..1
2354       construct: !<tag:yaml.org,2002:js/function> |-
2355         function (arg, params, children) {
2356           var synth;
2357           synth = this.require('data-synth');
2358           return (synth.Object(params)).bind(children);
2359         }
2360       argument: name
2361   deviate:
2362     config: 0..1
2363     default: 0..1
2364     mandatory: 0..1
2365     max-elements: 0..1
2366     min-elements: 0..1
2367     must: 0..n
2368     type: 0..1
2369     unique: 0..1
2370     units: 0..1
2371     argument: value
2372   deviation:
2373     description: 0..1
2374     deviate: 1..n
2375     reference: 0..1
2376     argument: target-node
2377   enum:
2378     description: 0..1
2379     reference: 0..1
2380     status: 0..1
2381     value: 0..1
2382     preprocess: !<tag:yaml.org,2002:js/function> |-
2383       function (arg, params, ctx) {
2384         if (params.value == null) {
2385           if (this.enumValue == null) {
2386             this.enumValue = 0;
2387           }
2388           params.value = this.enumValue++;
2389         } else {
2390           params.value = Number(params.value);
2391           this.enumValue = params.value + 1;
2392         }
2393         return ctx["enum"][arg] = params;
2394       }
2395     argument: name
2396   feature:
2397     description: 0..1
2398     if-feature: 0..n
2399     reference: 0..1
2400     status: 0..1
2401     preprocess: !<tag:yaml.org,2002:js/function> |-
2402       function (arg, params, ctx) {
2403         if (params.status === 'unavailable') {
2404           console.warn("feature " + arg + " is unavailable");
2405           if (typeof ctx.feature === 'object') {
2406             return delete ctx.feature[arg];
2407           } else {
2408             return delete ctx.feature;
2409           }
2410         }
2411       }
2412     construct: !<tag:yaml.org,2002:js/function> |-
2413       function (arg, params, children) {
2414         var feature;
2415         feature = this.resolve('feature', arg);
2416         return null;
2417       }
2418     argument: name
2419   grouping:
2420     anyxml: 0..n
2421     choice: 0..n
2422     container: 0..n
2423     description: 0..1
2424     grouping: 0..n
2425     leaf: 0..n
2426     leaf-list: 0..n
2427     list: 0..n
2428     reference: 0..1
2429     status: 0..1
2430     typedef: 0..n
2431     uses: 0..n
2432     preprocess: !<tag:yaml.org,2002:js/function> |-
2433       function (arg, params) {
2434         return this.define('grouping', arg, params);
2435       }
2436     argument: name
2437     instance: 0..n
2438     instance-list: 0..n
2439     origin:
2440       anyxml: 0..n
2441       choice: 0..n
2442       container: 0..n
2443       description: 0..1
2444       grouping: 0..n
2445       leaf: 0..n
2446       leaf-list: 0..n
2447       list: 0..n
2448       reference: 0..1
2449       status: 0..1
2450       typedef: 0..n
2451       uses: 0..n
2452       preprocess: !<tag:yaml.org,2002:js/function> |-
2453         function (arg, params) {
2454           return this.define('grouping', arg, params);
2455         }
2456       argument: name
2457   identity:
2458     base: 0..1
2459     description: 0..1
2460     reference: 0..1
2461     status: 0..1
2462     preprocess: !<tag:yaml.org,2002:js/function> |-
2463       function (arg, params) {
2464         return this.define('identity', arg, params);
2465       }
2466     argument: name
2467   if-feature:
2468     preprocess: !<tag:yaml.org,2002:js/function> |-
2469       function (arg, params, ctx) {
2470         if ((this.resolve('feature', arg)) == null) {
2471           return ctx.status = 'unavailable';
2472         }
2473       }
2474     argument: name
2475   import:
2476     prefix: 1
2477     revision-date: 0..1
2478     preprocess: !<tag:yaml.org,2002:js/function> |-
2479       function (arg, params, ctx) {
2480         var copy, k, m, original, ref, ref1, rev, schema, source, synth, v;
2481         synth = this.require('data-synth');
2482         schema = this.resolve('dependencies', arg, false);
2483         if (schema == null) {
2484           console.warn("no explicit dependency for " + arg + " defined, searching local filesystem");
2485           schema = this.parse("!yang " + arg + ".yang", this.source);
2486           if (schema != null) {
2487             this.define('dependencies', arg, schema);
2488             source = this.source.parent;
2489             while ((source.parent != null) && source.parent.name !== 'yangforge') {
2490               source = source.parent;
2491             }
2492             if (source.dependencies == null) {
2493               source.dependencies = {};
2494             }
2495             source.dependencies[arg] = schema;
2496           }
2497         }
2498         m = this.preprocess(schema);
2499         if (m == null) {
2500           throw this.error("unable to resolve '" + arg + "' in dependencies", 'import');
2501         }
2502         rev = params['revision-date'];
2503         if ((rev != null) && !(rev in m.revision)) {
2504           throw this.error("requested " + rev + " not available in " + arg, 'import');
2505         }
2506         ref = m.extension;
2507         for (k in ref) {
2508           v = ref[k];
2509           if (!(v.override === true)) {
2510             continue;
2511           }
2512           original = this.resolve('extension', k);
2513           copy = synth.copy({}, v);
2514           copy.origin = synth.copy({}, (ref1 = original.origin) != null ? ref1 : original);
2515           delete copy.override;
2516           this.define('extension', k, copy);
2517         }
2518         return this.source[params.prefix] = m;
2519       }
2520     construct: !<tag:yaml.org,2002:js/function> |-
2521       function (arg, params, children, ctx) {
2522         return this.compile(this.source[params.prefix], this.source);
2523       }
2524     argument: module
2525   input:
2526     anyxml: 0..n
2527     choice: 0..n
2528     container: 0..n
2529     grouping: 0..n
2530     leaf: 0..n
2531     leaf-list: 0..n
2532     list: 0..n
2533     typedef: 0..n
2534     uses: 0..n
2535     construct: !<tag:yaml.org,2002:js/function> |-
2536       function (arg, params, children) {
2537         var synth;
2538         synth = this.require('data-synth');
2539         return (synth.Object(params)).bind(children);
2540       }
2541     instance: 0..n
2542     instance-list: 0..n
2543     origin:
2544       anyxml: 0..n
2545       choice: 0..n
2546       container: 0..n
2547       grouping: 0..n
2548       leaf: 0..n
2549       leaf-list: 0..n
2550       list: 0..n
2551       typedef: 0..n
2552       uses: 0..n
2553       construct: !<tag:yaml.org,2002:js/function> |-
2554         function (arg, params, children) {
2555           var synth;
2556           synth = this.require('data-synth');
2557           return (synth.Object(params)).bind(children);
2558         }
2559   leaf:
2560     config: 0..1
2561     default: 0..1
2562     description: 0..1
2563     if-feature: 0..n
2564     mandatory: 0..1
2565     must: 0..n
2566     reference: 0..1
2567     status: 0..1
2568     type: 0..1
2569     units: 0..1
2570     when: 0..1
2571     construct: !<tag:yaml.org,2002:js/function> |-
2572       function (arg, params, children, ctx, self) {
2573         var synth;
2574         synth = this.require('data-synth');
2575         if (params.type['instance-identifier'] != null) {
2576           return synth.BelongsTo(params, function() {
2577             return this.set({
2578               model: children.type
2579             });
2580           });
2581         } else {
2582           return self.origin.construct.apply(this, arguments);
2583         }
2584       }
2585     argument: name
2586     origin:
2587       config: 0..1
2588       default: 0..1
2589       description: 0..1
2590       if-feature: 0..n
2591       mandatory: 0..1
2592       must: 0..n
2593       reference: 0..1
2594       status: 0..1
2595       type: 0..1
2596       units: 0..1
2597       when: 0..1
2598       construct: !<tag:yaml.org,2002:js/function> |-
2599         function (arg, params, children) {
2600           var synth;
2601           synth = this.require('data-synth');
2602           return synth.Property(params, function() {
2603             if (children.type != null) {
2604               return this.set({
2605                 type: children.type
2606               });
2607             }
2608           });
2609         }
2610       argument: name
2611   leaf-list:
2612     config: 0..1
2613     description: 0..1
2614     if-feature: 0..n
2615     max-elements: 0..1
2616     min-elements: 0..1
2617     must: 0..n
2618     ordered-by: 0..1
2619     reference: 0..1
2620     status: 0..1
2621     type: 0..1
2622     units: 0..1
2623     when: 0..1
2624     construct: !<tag:yaml.org,2002:js/function> |-
2625       function (arg, params, children, ctx, self) {
2626         var synth;
2627         synth = this.require('data-synth');
2628         if (params.type['instance-identifier'] != null) {
2629           return synth.HasMany(params, function() {
2630             return this.set({
2631               model: children.type
2632             });
2633           });
2634         } else {
2635           return self.origin.construct.apply(this, arguments);
2636         }
2637       }
2638     argument: name
2639     origin:
2640       config: 0..1
2641       description: 0..1
2642       if-feature: 0..n
2643       max-elements: 0..1
2644       min-elements: 0..1
2645       must: 0..n
2646       ordered-by: 0..1
2647       reference: 0..1
2648       status: 0..1
2649       type: 0..1
2650       units: 0..1
2651       when: 0..1
2652       construct: !<tag:yaml.org,2002:js/function> |-
2653         function (arg, params, children) {
2654           var synth;
2655           synth = this.require('data-synth');
2656           return synth.List(params, function() {
2657             if (children.type != null) {
2658               return this.set({
2659                 type: children.type
2660               });
2661             }
2662           });
2663         }
2664       argument: name
2665   list:
2666     anyxml: 0..n
2667     choice: 0..n
2668     config: 0..1
2669     container: 0..n
2670     description: 0..1
2671     grouping: 0..n
2672     if-feature: 0..n
2673     key: 0..1
2674     leaf: 0..n
2675     leaf-list: 0..n
2676     list: 0..n
2677     max-elements: 0..1
2678     min-elements: 0..1
2679     must: 0..n
2680     ordered-by: 0..1
2681     reference: 0..1
2682     status: 0..1
2683     typedef: 0..n
2684     unique: 0..1
2685     uses: 0..n
2686     when: 0..1
2687     construct: !<tag:yaml.org,2002:js/function> |-
2688       function (arg, params, children) {
2689         var item, synth;
2690         synth = this.require('data-synth');
2691         item = (synth.Object(null)).bind(children);
2692         return (synth.List(params)).set({
2693           type: item
2694         });
2695       }
2696     argument: name
2697   mandatory:
2698     preprocess: !<tag:yaml.org,2002:js/function> |-
2699       function (arg, p, ctx) {
2700         return ctx.mandatory = arg === true || arg === 'true';
2701       }
2702     argument: value
2703   max-elements:
2704     preprocess: !<tag:yaml.org,2002:js/function> |-
2705       function (arg, params, ctx) {
2706         if (arg !== 'unbounded') {
2707           return ctx['max-elements'] = Number(arg);
2708         }
2709       }
2710     argument: value
2711   min-elements:
2712     preprocess: !<tag:yaml.org,2002:js/function> |-
2713       function (arg, params, ctx) {
2714         return ctx['min-elements'] = Number(arg);
2715       }
2716     argument: value
2717   must:
2718     description: 0..1
2719     error-app-tag: 0..1
2720     error-message: 0..1
2721     reference: 0..1
2722     argument: condition
2723   notification:
2724     anyxml: 0..n
2725     choice: 0..n
2726     container: 0..n
2727     description: 0..1
2728     grouping: 0..n
2729     if-feature: 0..n
2730     leaf: 0..n
2731     leaf-list: 0..n
2732     list: 0..n
2733     reference: 0..1
2734     status: 0..1
2735     typedef: 0..n
2736     uses: 0..n
2737     preprocess: !<tag:yaml.org,2002:js/function> |-
2738       function (arg, params) {
2739         return this.define('notification', arg, params);
2740       }
2741     argument: event
2742   output:
2743     anyxml: 0..n
2744     choice: 0..n
2745     container: 0..n
2746     grouping: 0..n
2747     leaf: 0..n
2748     leaf-list: 0..n
2749     list: 0..n
2750     typedef: 0..n
2751     uses: 0..n
2752     construct: !<tag:yaml.org,2002:js/function> |-
2753       function (arg, params, children) {
2754         var synth;
2755         synth = this.require('data-synth');
2756         return (synth.Object(params)).bind(children);
2757       }
2758     instance: 0..n
2759     instance-list: 0..n
2760     origin:
2761       anyxml: 0..n
2762       choice: 0..n
2763       container: 0..n
2764       grouping: 0..n
2765       leaf: 0..n
2766       leaf-list: 0..n
2767       list: 0..n
2768       typedef: 0..n
2769       uses: 0..n
2770       construct: !<tag:yaml.org,2002:js/function> |-
2771         function (arg, params, children) {
2772           var synth;
2773           synth = this.require('data-synth');
2774           return (synth.Object(params)).bind(children);
2775         }
2776   path:
2777     preprocess: !<tag:yaml.org,2002:js/function> |-
2778       function (arg, params, ctx) {
2779         return ctx.path = arg.replace(/[_]/g, '.');
2780       }
2781     argument: value
2782   pattern:
2783     construct: !<tag:yaml.org,2002:js/function> |-
2784       function (arg, params, children, ctx) {
2785         if (ctx.patterns == null) {
2786           ctx.patterns = [];
2787         }
2788         return ctx.patterns.push(new RegExp(arg));
2789       }
2790     argument: value
2791   refine:
2792     default: 0..1
2793     description: 0..1
2794     reference: 0..1
2795     config: 0..1
2796     mandatory: 0..1
2797     presence: 0..1
2798     must: 0..n
2799     min-elements: 0..1
2800     max-elements: 0..1
2801     units: 0..1
2802     argument: target-node
2803   require-instance:
2804     preprocess: !<tag:yaml.org,2002:js/function> |-
2805       function (arg, params, ctx) {
2806         return ctx['require-instance'] = arg === true || arg === 'true';
2807       }
2808     argument: value
2809   revision:
2810     description: 0..1
2811     reference: 0..1
2812     preprocess: !<tag:yaml.org,2002:js/function> |-
2813       function (arg, params, ctx) {
2814         return this.define('revision', arg, params);
2815       }
2816     argument: date
2817   rpc:
2818     description: 0..1
2819     grouping: 0..n
2820     if-feature: 0..n
2821     input: 0..1
2822     output: 0..1
2823     reference: 0..1
2824     status: 0..1
2825     typedef: 0..n
2826     construct: !<tag:yaml.org,2002:js/function> |-
2827       function (arg, params, children) {
2828         var func, method, ref, ref1, request, response, synth;
2829         synth = this.require('data-synth');
2830         func = this.resolve('rpc', arg, false);
2831         if (func == null) {
2832           func = function(input, output, done) {
2833             return done("No control logic found for '" + arg + "' rpc operation");
2834           };
2835         }
2836         request = (ref = children.input) != null ? ref : synth.Meta;
2837         response = (ref1 = children.output) != null ? ref1 : synth.Meta;
2838         method = function(data, resolve, reject) {
2839           var e, error, input, output;
2840           if (typeof console.debug === "function") {
2841             console.debug("executing rpc " + arg + "...");
2842           }
2843           try {
2844             input = new request(data, this);
2845             output = new response(null, this);
2846           } catch (error) {
2847             e = error;
2848             return reject(e);
2849           }
2850           return func.call(this, input, output, function(e) {
2851             if (e == null) {
2852               return resolve(output);
2853             } else {
2854               return reject(e);
2855             }
2856           });
2857         };
2858         method.params = params;
2859         method.input = request;
2860         method.output = response;
2861         return method;
2862       }
2863     argument: name
2864   submodule:
2865     argument: name
2866     anyxml: 0..n
2867     augment: 0..n
2868     belongs-to: 0..1
2869     choice: 0..n
2870     contact: 0..1
2871     container: 0..n
2872     description: 0..1
2873     deviation: 0..n
2874     extension: 0..n
2875     feature: 0..n
2876     grouping: 0..n
2877     identity: 0..n
2878     import: 0..n
2879     include: 0..n
2880     leaf: 0..n
2881     leaf-list: 0..n
2882     list: 0..n
2883     notification: 0..n
2884     organization: 0..1
2885     reference: 0..1
2886     revision: 0..n
2887     rpc: 0..n
2888     typedef: 0..n
2889     uses: 0..n
2890     yang-version: 0..1
2891     preprocess: !<tag:yaml.org,2002:js/function> |-
2892       function (arg, params, ctx) {
2893         var k, v;
2894         for (k in params) {
2895           v = params[k];
2896           ctx[k] = v;
2897         }
2898         return delete ctx.submodule;
2899       }
2900     complex-type: 0..n
2901     instance: 0..n
2902     instance-list: 0..n
2903     origin:
2904       argument: name
2905       anyxml: 0..n
2906       augment: 0..n
2907       belongs-to: 0..1
2908       choice: 0..n
2909       contact: 0..1
2910       container: 0..n
2911       description: 0..1
2912       deviation: 0..n
2913       extension: 0..n
2914       feature: 0..n
2915       grouping: 0..n
2916       identity: 0..n
2917       import: 0..n
2918       include: 0..n
2919       leaf: 0..n
2920       leaf-list: 0..n
2921       list: 0..n
2922       notification: 0..n
2923       organization: 0..1
2924       reference: 0..1
2925       revision: 0..n
2926       rpc: 0..n
2927       typedef: 0..n
2928       uses: 0..n
2929       yang-version: 0..1
2930       preprocess: !<tag:yaml.org,2002:js/function> |-
2931         function (arg, params, ctx) {
2932           var k, v;
2933           for (k in params) {
2934             v = params[k];
2935             ctx[k] = v;
2936           }
2937           return delete ctx.submodule;
2938         }
2939   status:
2940     preprocess: !<tag:yaml.org,2002:js/function> |-
2941       function (arg, params, ctx) {
2942         return ctx.status != null ? ctx.status : ctx.status = arg;
2943       }
2944     argument: value
2945   type:
2946     base: 0..1
2947     bit: 0..n
2948     enum: 0..n
2949     fraction-digits: 0..1
2950     length: 0..1
2951     path: 0..1
2952     pattern: 0..n
2953     range: 0..1
2954     require-instance: 0..1
2955     type: 0..n
2956     preprocess: !<tag:yaml.org,2002:js/function> |-
2957       function (arg, params, ctx) {
2958         return delete this.enumValue;
2959       }
2960     construct: !<tag:yaml.org,2002:js/function> |-
2961       function (arg, params, children, ctx, self) {
2962         if (children.ctype != null) {
2963           ctx.type = children.ctype;
2964           return null;
2965         } else {
2966           return self.origin.construct.apply(this, arguments);
2967         }
2968       }
2969     argument: name
2970     instance-type: 0..1
2971     origin:
2972       base: 0..1
2973       bit: 0..n
2974       enum: 0..n
2975       fraction-digits: 0..1
2976       length: 0..1
2977       path: 0..1
2978       pattern: 0..n
2979       range: 0..1
2980       require-instance: 0..1
2981       type: 0..n
2982       preprocess: !<tag:yaml.org,2002:js/function> |-
2983         function (arg, params, ctx) {
2984           return delete this.enumValue;
2985         }
2986       construct: !<tag:yaml.org,2002:js/function> |-
2987         function (arg, params, children, ctx) {
2988           var key, mparams, ref, ref1, synth, typedef, value;
2989           synth = this.require('data-synth');
2990           typedef = this.resolve('typedef', arg);
2991           if (typedef == null) {
2992             throw this.error("unable to resolve typedef for " + arg);
2993           }
2994           switch (false) {
2995             case typedef.construct == null:
2996               ctx.type = typedef.construct(params, this, arguments.callee);
2997               break;
2998             case typeof typedef.type !== 'object':
2999               ref = typedef.type;
3000               for (key in ref) {
3001                 value = ref[key];
3002                 mparams = synth.copy({}, value);
3003                 synth.copy(mparams, params);
3004                 arguments.callee.call(this, key, mparams, children, ctx);
3005               }
3006               break;
3007             case typeof typedef.type !== 'string':
3008               arguments.callee.call(this, typedef.type, params, children, ctx);
3009           }
3010           if ((ref1 = ctx.type) != null) {
3011             ref1.toString = function() {
3012               return arg;
3013             };
3014           }
3015           return null;
3016         }
3017       argument: name
3018   typedef:
3019     default: 0..1
3020     description: 0..1
3021     units: 0..1
3022     type: 0..1
3023     reference: 0..1
3024     preprocess: !<tag:yaml.org,2002:js/function> |-
3025       function (arg, params) {
3026         return this.define('typedef', arg, params);
3027       }
3028     argument: name
3029   uses:
3030     augment: 0..n
3031     description: 0..1
3032     if-feature: 0..n
3033     refine: 0..n
3034     reference: 0..1
3035     status: 0..1
3036     when: 0..1
3037     preprocess: !<tag:yaml.org,2002:js/function> |-
3038       function (arg, params, ctx) {
3039         var changes, grouping, k, match, ref, ref1, synth, target, v;
3040         synth = this.require('data-synth');
3041         grouping = synth.copy({}, this.resolve('grouping', arg));
3042         delete grouping.description;
3043         delete grouping.reference;
3044         synth.copy(ctx, grouping);
3045         ref = params.refine;
3046         for (target in ref) {
3047           changes = ref[target];
3048           match = this.locate(ctx, target);
3049           if (match == null) {
3050             continue;
3051           }
3052           for (k in changes) {
3053             v = changes[k];
3054             match[k] = v;
3055           }
3056         }
3057         ref1 = params.augment;
3058         for (target in ref1) {
3059           changes = ref1[target];
3060           match = this.locate(ctx, target);
3061           if (match == null) {
3062             continue;
3063           }
3064           synth.copy(match, changes);
3065         }
3066         if (typeof ctx.uses === 'object') {
3067           return delete ctx.uses[arg];
3068         } else {
3069           return delete ctx.uses;
3070         }
3071       }
3072     argument: name
3073   when:
3074     description: 0..1
3075     reference: 0..1
3076     argument: condition
3077   anyxml: {}
3078   base:
3079     argument: name
3080   contact:
3081     argument:
3082       text:
3083         yin-element: 'true'
3084   default:
3085     argument: value
3086   description:
3087     argument:
3088       text:
3089         yin-element: 'true'
3090   error-app-tag:
3091     argument: value
3092   error-message:
3093     argument:
3094       value:
3095         yin-element: 'true'
3096   fraction-digits:
3097     argument: value
3098   key:
3099     argument: value
3100   length:
3101     argument: value
3102   namespace:
3103     argument: uri
3104   ordered-by:
3105     argument: value
3106   organization:
3107     argument:
3108       text:
3109         yin-element: 'true'
3110   position:
3111     argument: value
3112   presence:
3113     argument: value
3114   range:
3115     argument: value
3116   reference:
3117     argument:
3118       text:
3119         yin-element: 'true'
3120   revision-date:
3121     argument: date
3122   unique:
3123     argument: tag
3124   units:
3125     argument: value
3126   value:
3127     argument: value
3128   yang-version:
3129     argument: value
3130   yin-element:
3131     argument: value
3132 feature: !<tag:yaml.org,2002:js/undefined> ''
3133 keywords:
3134   - opnfv
3135   - promise
3136   - vim
3137   - nfvi
3138   - infrastructure
3139   - openstack
3140   - nbi
3141   - yangforge
3142   - resource
3143   - reservation
3144   - capacity
3145   - allocation
3146 rpc:
3147   create-reservation: !<tag:yaml.org,2002:js/function> |-
3148     function (input, output, done) {
3149           var reservation, reservations;
3150           reservation = this.create('ResourceReservation');
3151           reservations = this.access('promise.reservations');
3152           return reservation.invoke('update', input.get()).then(function(res) {
3153             return res.save().then(function() {
3154               reservations.push(res);
3155               output.set({
3156                 result: 'ok',
3157                 message: 'reservation request accepted'
3158               });
3159               output.set('reservation-id', res.id);
3160               return done();
3161             })["catch"](function(err) {
3162               output.set({
3163                 result: 'error',
3164                 message: err
3165               });
3166               return done();
3167             });
3168           })["catch"](function(err) {
3169             output.set({
3170               result: 'conflict',
3171               message: err
3172             });
3173             return done();
3174           });
3175         }
3176   query-reservation: !<tag:yaml.org,2002:js/function> |-
3177     function (input, output, done) {
3178           var query;
3179           query = input.get();
3180           query.capacity = 'reserved';
3181           return this.invoke('query-capacity', query).then(function(res) {
3182             output.set('reservations', res.get('collections'));
3183             output.set('utilization', res.get('utilization'));
3184             return done();
3185           })["catch"](function(e) {
3186             return done(e);
3187           });
3188         }
3189   update-reservation: !<tag:yaml.org,2002:js/function> |-
3190     function (input, output, done) {
3191           var reservation;
3192           if ((input.get('reservation-id')) == null) {
3193             output.set({
3194               result: 'error',
3195               message: "must provide 'reservation-id' parameter"
3196             });
3197             return done();
3198           }
3199           reservation = this.find('ResourceReservation', input.get('reservation-id'));
3200           if (reservation == null) {
3201             output.set({
3202               result: 'error',
3203               message: 'no reservation found for specified identifier'
3204             });
3205             return done();
3206           }
3207           return reservation.invoke('update', input.get()).then(function(res) {
3208             return res.save().then(function() {
3209               output.set({
3210                 result: 'ok',
3211                 message: 'reservation update successful'
3212               });
3213               return done();
3214             })["catch"](function(err) {
3215               output.set({
3216                 result: 'error',
3217                 message: err
3218               });
3219               return done();
3220             });
3221           })["catch"](function(err) {
3222             output.set({
3223               result: 'conflict',
3224               message: err
3225             });
3226             return done();
3227           });
3228         }
3229   cancel-reservation: !<tag:yaml.org,2002:js/function> |-
3230     function (input, output, done) {
3231           var reservation;
3232           reservation = this.find('ResourceReservation', input.get('reservation-id'));
3233           if (reservation == null) {
3234             output.set({
3235               result: 'error',
3236               message: 'no reservation found for specified identifier'
3237             });
3238             return done();
3239           }
3240           return reservation.destroy().then((function(_this) {
3241             return function() {
3242               (_this.access('promise.reservations')).remove(reservation.id);
3243               output.set('result', 'ok');
3244               output.set('message', 'reservation canceled');
3245               return done();
3246             };
3247           })(this))["catch"](function(e) {
3248             output.set('result', 'error');
3249             output.set('message', e);
3250             return done();
3251           });
3252         }
3253   query-capacity: !<tag:yaml.org,2002:js/function> |-
3254     function (input, output, done) {
3255           var collections, deltas, entry, k, last, matches, metric, timestamp, usages, v, window;
3256           window = input.get('window');
3257           metric = input.get('capacity');
3258           collections = (function() {
3259             switch (metric) {
3260               case 'total':
3261                 return ['ResourcePool'];
3262               case 'reserved':
3263                 return ['ResourceReservation'];
3264               case 'usage':
3265                 return ['ResourceAllocation'];
3266               case 'available':
3267                 return ['ResourcePool', 'ResourceReservation', 'ResourceAllocation'];
3268             }
3269           })();
3270           matches = collections.reduce(((function(_this) {
3271             return function(a, name) {
3272               var res;
3273               res = _this.find(name, {
3274                 start: function(value) {
3275                   return (window.end == null) || (new Date(value)) <= (new Date(window.end));
3276                 },
3277                 end: function(value) {
3278                   return (window.start == null) || (new Date(value)) >= (new Date(window.start));
3279                 },
3280                 enabled: true
3281               });
3282               return a.concat.apply(a, res);
3283             };
3284           })(this)), []);
3285           if (window.scope === 'exclusive') {
3286             matches = matches.where({
3287               start: function(value) {
3288                 return (window.start == null) || (new Date(value)) >= (new Date(window.start));
3289               },
3290               end: function(value) {
3291                 return (window.end == null) || (new Date(value)) <= (new Date(window.end));
3292               }
3293             });
3294           }
3295           matches = matches.without({
3296             id: input.get('without')
3297           });
3298           if (metric === 'available') {
3299             matches = matches.without({
3300               reservation: function(v) {
3301                 return v != null;
3302               }
3303             });
3304           }
3305           output.set('collections', matches);
3306           if ((input.get('show-utilization')) !== true) {
3307             return done();
3308           }
3309           deltas = matches.reduce((function(a, entry) {
3310             var b, base, base1, ekey, k, ref1, ref2, skey, v;
3311             b = entry.get();
3312             if (b.end == null) {
3313               b.end = 'infiniteT';
3314             }
3315             ref1 = [(b.start.split('T'))[0], (b.end.split('T'))[0]], skey = ref1[0], ekey = ref1[1];
3316             if (a[skey] == null) {
3317               a[skey] = {
3318                 count: 0,
3319                 capacity: {}
3320               };
3321             }
3322             if (a[ekey] == null) {
3323               a[ekey] = {
3324                 count: 0,
3325                 capacity: {}
3326               };
3327             }
3328             a[skey].count += 1;
3329             a[ekey].count -= 1;
3330             ref2 = b.capacity;
3331             for (k in ref2) {
3332               v = ref2[k];
3333               if (!(v != null)) {
3334                 continue;
3335               }
3336               if ((base = a[skey].capacity)[k] == null) {
3337                 base[k] = 0;
3338               }
3339               if ((base1 = a[ekey].capacity)[k] == null) {
3340                 base1[k] = 0;
3341               }
3342               if (entry.name === 'ResourcePool') {
3343                 a[skey].capacity[k] += v;
3344                 a[ekey].capacity[k] -= v;
3345               } else {
3346                 a[skey].capacity[k] -= v;
3347                 a[ekey].capacity[k] += v;
3348               }
3349             }
3350             return a;
3351           }), {});
3352           last = {
3353             count: 0,
3354             capacity: {}
3355           };
3356           usages = (function() {
3357             var i, len, ref1, ref2, ref3, results;
3358             ref1 = Object.keys(deltas).sort();
3359             results = [];
3360             for (i = 0, len = ref1.length; i < len; i++) {
3361               timestamp = ref1[i];
3362               if (!(timestamp !== 'infinite')) {
3363                 continue;
3364               }
3365               entry = deltas[timestamp];
3366               entry.timestamp = (new Date(timestamp)).toJSON();
3367               entry.count += last.count;
3368               ref2 = entry.capacity;
3369               for (k in ref2) {
3370                 v = ref2[k];
3371                 entry.capacity[k] += (ref3 = last.capacity[k]) != null ? ref3 : 0;
3372               }
3373               last = entry;
3374               results.push(entry);
3375             }
3376             return results;
3377           })();
3378           output.set('utilization', usages);
3379           return done();
3380         }
3381   increase-capacity: !<tag:yaml.org,2002:js/function> |-
3382     function (input, output, done) {
3383           var pool;
3384           pool = this.create('ResourcePool', input.get());
3385           return pool.save().then((function(_this) {
3386             return function(res) {
3387               (_this.access('promise.pools')).push(res);
3388               output.set({
3389                 result: 'ok',
3390                 message: 'capacity increase successful'
3391               });
3392               output.set('pool-id', res.id);
3393               return done();
3394             };
3395           })(this))["catch"](function(e) {
3396             output.set({
3397               result: 'error',
3398               message: e
3399             });
3400             return done();
3401           });
3402         }
3403   decrease-capacity: !<tag:yaml.org,2002:js/function> |-
3404     function (input, output, done) {
3405           var k, pool, ref1, request, v;
3406           request = input.get();
3407           ref1 = request.capacity;
3408           for (k in ref1) {
3409             v = ref1[k];
3410             request.capacity[k] = -v;
3411           }
3412           pool = this.create('ResourcePool', request);
3413           return pool.save().then((function(_this) {
3414             return function(res) {
3415               (_this.access('promise.pools')).push(res);
3416               output.set({
3417                 result: 'ok',
3418                 message: 'capacity decrease successful'
3419               });
3420               output.set('pool-id', res.id);
3421               return done();
3422             };
3423           })(this))["catch"](function(e) {
3424             output.set({
3425               result: 'error',
3426               message: e
3427             });
3428             return done();
3429           });
3430         }
3431   create-instance: !<tag:yaml.org,2002:js/function> |-
3432     function (input, output, done) {
3433           var available, flavor, k, pid, provider, required, reservation, rid, v;
3434           pid = input.get('provider-id');
3435           if (pid != null) {
3436             provider = this.find('ResourceProvider', pid);
3437             if (provider == null) {
3438               output.set({
3439                 result: 'error',
3440                 message: "no matching provider found for specified identifier: " + pid
3441               });
3442               return done();
3443             }
3444           } else {
3445             provider = (this.find('ResourceProvider'))[0];
3446             if (provider == null) {
3447               output.set({
3448                 result: 'error',
3449                 message: "no available provider found for create-instance"
3450               });
3451               return done();
3452             }
3453           }
3454           flavor = provider.access("services.compute.flavors." + (input.get('flavor')));
3455           if (flavor == null) {
3456             output.set({
3457               result: 'error',
3458               message: "no such flavor found for specified identifier: " + pid
3459             });
3460             return done();
3461           }
3462           required = {
3463             instances: 1,
3464             cores: flavor.get('vcpus'),
3465             ram: flavor.get('ram'),
3466             gigabytes: flavor.get('disk')
3467           };
3468           rid = input.get('reservation-id');
3469           if (rid != null) {
3470             reservation = this.find('ResourceReservation', rid);
3471             if (reservation == null) {
3472               output.set({
3473                 result: 'error',
3474                 message: 'no valid reservation found for specified identifier'
3475               });
3476               return done();
3477             }
3478             if ((reservation.get('active')) !== true) {
3479               output.set({
3480                 result: 'error',
3481                 message: "reservation is currently not active"
3482               });
3483               return done();
3484             }
3485             available = reservation.get('remaining');
3486           } else {
3487             available = this.get('promise.capacity.available');
3488           }
3489           for (k in required) {
3490             v = required[k];
3491             if ((v != null) && !!v) {
3492               if (!(available[k] >= v)) {
3493                 output.set({
3494                   result: 'conflict',
3495                   message: "required " + k + "=" + v + " exceeds available " + available[k]
3496                 });
3497                 return done();
3498               }
3499             }
3500           }
3501           return this.create('ResourceAllocation', {
3502             reservation: rid,
3503             capacity: required
3504           }).save().then((function(_this) {
3505             return function(instance) {
3506               var request, url;
3507               url = provider.get('services.compute.endpoint');
3508               request = _this.parent.require('superagent');
3509               request.post(url + "/servers").send({
3510                 server: {
3511                   name: input.get('name'),
3512                   imageRef: input.get('image'),
3513                   flavorRef: input.get('flavor')
3514                 }
3515               }).set('X-Auth-Token', provider.get('token')).set('Accept', 'application/json').end(function(err, res) {
3516                 if ((err != null) || !res.ok) {
3517                   instance.destroy();
3518                   console.error(err);
3519                   return done(res.error);
3520                 }
3521                 instance.set('instance-ref', {
3522                   provider: provider,
3523                   server: res.body.server.id
3524                 });
3525                 (_this.access('promise.allocations')).push(instance);
3526                 output.set({
3527                   result: 'ok',
3528                   message: 'create-instance request accepted'
3529                 });
3530                 output.set('instance-id', instance.id);
3531                 return done();
3532               });
3533               return instance;
3534             };
3535           })(this))["catch"](function(err) {
3536             output.set({
3537               result: 'error',
3538               mesage: err
3539             });
3540             return done();
3541           });
3542         }
3543   destroy-instance: !<tag:yaml.org,2002:js/function> |-
3544     function (input, output, done) {
3545           var instance;
3546           instance = this.find('ResourceAllocation', input.get('instance-id'));
3547           if (instance == null) {
3548             output.set({
3549               result: 'error',
3550               message: 'no allocation found for specified identifier'
3551             });
3552             return done();
3553           }
3554           return instance.destroy().then((function(_this) {
3555             return function() {
3556               var provider, ref, request, url;
3557               (_this.access('promise.allocations')).remove(instance.id);
3558               ref = instance.get('instance-ref');
3559               provider = _this.access("promise.providers." + ref.provider);
3560               url = provider.get('services.compute.endpoint');
3561               request = _this.parent.require('superagent');
3562               request["delete"](url + "/servers/" + ref.server).set('X-Auth-Token', provider.get('token')).set('Accept', 'application/json').end(function(err, res) {
3563                 if ((err != null) || !res.ok) {
3564                   console.error(err);
3565                   return done(res.error);
3566                 }
3567                 output.set('result', 'ok');
3568                 output.set('message', 'instance destroyed and resource released back to pool');
3569                 return done();
3570               });
3571               return instance;
3572             };
3573           })(this))["catch"](function(e) {
3574             output.set('result', 'error');
3575             output.set('message', e);
3576             return done();
3577           });
3578         }
3579   add-provider: !<tag:yaml.org,2002:js/function> "function (input, output, done) {\n      var app, payload, providers, request, url;\n      app = this.parent;\n      request = app.require('superagent');\n      payload = (function() {\n        switch (input.get('provider-type')) {\n          case 'openstack':\n            return {\n              auth: {\n                tenantId: input.get('tenant.id'),\n                tenantName: input.get('tenant.name'),\n                passwordCredentials: input.get('username', 'password')\n              }\n            };\n        }\n      })();\n      if (payload == null) {\n        return done('Sorry, only openstack supported at this time');\n      }\n      url = input.get('endpoint');\n      switch (input.get('strategy')) {\n        case 'keystone':\n        case 'oauth':\n          if (!/\\/tokens$/.test(url)) {\n            url += '/tokens';\n          }\n      }\n      providers = this.access('promise.providers');\n      return request.post(url).send(payload).set('Accept', 'application/json').end((function(_this) {\n        return function(err, res) {\n          var access, provider, ref1, ref2, ref3;\n          if ((err != null) || !res.ok) {\n            return done(res.error);\n          }\n          access = res.body.access;\n          provider = _this.create('ResourceProvider', {\n            token: access != null ? (ref1 = access.token) != null ? ref1.id : void 0 : void 0,\n            name: access != null ? (ref2 = access.token) != null ? (ref3 = ref2.tenant) != null ? ref3.name : void 0 : void 0 : void 0\n          });\n          return provider.invoke('update', access.serviceCatalog).then(function(res) {\n            return res.save().then(function() {\n              providers.push(res);\n              output.set('result', 'ok');\n              output.set('provider-id', res.id);\n              return done();\n            })[\"catch\"](function(err) {\n              output.set('error', {\n                message: err\n              });\n              return done();\n            });\n          })[\"catch\"](function(err) {\n            output.set('error', {\n              message: err\n            });\n            return done();\n          });\n        };\n      })(this));\n    }"
3580 typedef: !<tag:yaml.org,2002:js/undefined> ''
3581 complex-type:
3582   ResourceElement:
3583     id: !<tag:yaml.org,2002:js/function> |-
3584       function (prev) {
3585         return prev.set('default', function() {
3586           return this.uuid();
3587         });
3588       }
3589   ResourceCollection:
3590     id:
3591       - !<tag:yaml.org,2002:js/function> |-
3592         function (prev) {
3593           return prev.set('default', function() {
3594             return this.uuid();
3595           });
3596         }
3597     start:
3598       - !<tag:yaml.org,2002:js/function> |-
3599         function (prev) {
3600           return prev.set('default', function() {
3601             return (new Date).toJSON();
3602           });
3603         }
3604     active:
3605       - !<tag:yaml.org,2002:js/function> |-
3606         function (prev) {
3607           return this.computed((function() {
3608             var end, now, start;
3609             now = new Date;
3610             start = new Date(this.get('start'));
3611             end = (function() {
3612               switch (false) {
3613                 case (this.get('end')) == null:
3614                   return new Date(this.get('end'));
3615                 default:
3616                   return now;
3617               }
3618             }).call(this);
3619             return (this.get('enabled')) && ((start <= now && now <= end));
3620           }), {
3621             type: prev
3622           });
3623         }
3624   ResourceReservation:
3625     id:
3626       - !<tag:yaml.org,2002:js/function> |-
3627         function (prev) {
3628           return prev.set('default', function() {
3629             return this.uuid();
3630           });
3631         }
3632     start:
3633       - !<tag:yaml.org,2002:js/function> |-
3634         function (prev) {
3635           return prev.set('default', function() {
3636             return (new Date).toJSON();
3637           });
3638         }
3639     active:
3640       - !<tag:yaml.org,2002:js/function> |-
3641         function (prev) {
3642           return this.computed((function() {
3643             var end, now, start;
3644             now = new Date;
3645             start = new Date(this.get('start'));
3646             end = (function() {
3647               switch (false) {
3648                 case (this.get('end')) == null:
3649                   return new Date(this.get('end'));
3650                 default:
3651                   return now;
3652               }
3653             }).call(this);
3654             return (this.get('enabled')) && ((start <= now && now <= end));
3655           }), {
3656             type: prev
3657           });
3658         }
3659     end:
3660       - !<tag:yaml.org,2002:js/function> |-
3661         function (prev) {
3662           return prev.set('default', function() {
3663             var end, max;
3664             end = new Date(this.get('start'));
3665             max = this.parent.get('promise.policy.reservation.max-duration');
3666             if (max == null) {
3667               return;
3668             }
3669             end.setTime(end.getTime() + (max * 60 * 60 * 1000));
3670             return end.toJSON();
3671           });
3672         }
3673     allocations:
3674       - !<tag:yaml.org,2002:js/function> |-
3675         function (prev) {
3676           return this.computed((function() {
3677             var res;
3678             res = this.store.find('ResourceAllocation', {
3679               reservation: this.id
3680             });
3681             return res.map(function(x) {
3682               return x.get('id');
3683             });
3684           }), {
3685             type: 'array'
3686           });
3687         }
3688     remaining:
3689       - !<tag:yaml.org,2002:js/function> |-
3690         function (prev) {
3691           return this.computed((function() {
3692             var entry, i, k, len, records, total, usage, v;
3693             total = this.get('capacity');
3694             records = this.store.find('ResourceAllocation', {
3695               id: this.get('allocations'),
3696               active: true
3697             });
3698             for (i = 0, len = records.length; i < len; i++) {
3699               entry = records[i];
3700               usage = entry.get('capacity');
3701               for (k in usage) {
3702                 v = usage[k];
3703                 total[k] -= v;
3704               }
3705             }
3706             return total;
3707           }), {
3708             type: prev
3709           });
3710         }
3711     validate:
3712       - !<tag:yaml.org,2002:js/function> |-
3713         function (prev) {
3714           return function(value, resolve, reject) {
3715             var end, hasCapacity, k, now, ref, start, v;
3716             if (value == null) {
3717               value = {};
3718             }
3719             ref = value.capacity;
3720             for (k in ref) {
3721               v = ref[k];
3722               if ((v != null) && !!v) {
3723                 hasCapacity = true;
3724               }
3725             }
3726             if ((!hasCapacity) && value.elements.length === 0) {
3727               return reject("unable to validate reservation record without anything being reserved");
3728             }
3729             now = new Date;
3730             if (value.start != null) {
3731               start = new Date(value.start);
3732             }
3733             if (value.end != null) {
3734               end = new Date(value.end);
3735             }
3736             if ((end != null) && end < now) {
3737               return reject("requested end time " + value.end + " cannot be in the past");
3738             }
3739             if ((start != null) && (end != null) && start > end) {
3740               retun(reject("requested start time must be earlier than end time"));
3741             }
3742             return resolve(this);
3743           };
3744         }
3745     update:
3746       - !<tag:yaml.org,2002:js/function> |-
3747         function (prev) {
3748           return function(req, resolve, reject) {
3749             if (req.start == null) {
3750               req.start = this.get('start');
3751             }
3752             if (req.end == null) {
3753               req.end = this.get('end');
3754             }
3755             return this.parent.invoke('query-capacity', {
3756               start: req.start,
3757               end: req.end,
3758               capacity: 'available',
3759               without: this.id
3760             }).then((function(_this) {
3761               return function(res) {
3762                 var available, collections, end, entries, i, k, pools, ref, ref1, start, t1, t2, v, x;
3763                 collections = res.get('collections');
3764                 if (!(collections.length > 0)) {
3765                   return reject('no resource capacity available during requested start/end time');
3766                 }
3767                 pools = collections.filter(function(e) {
3768                   return /^ResourcePool/.test(e);
3769                 });
3770                 entries = res.get('utilization');
3771                 start = new Date(req.start);
3772                 end = new Date(req.end);
3773                 for (x = i = 0, ref = entries.length - 1; 0 <= ref ? i <= ref : i >= ref; x = 0 <= ref ? ++i : --i) {
3774                   t1 = new Date(entries[x].timestamp);
3775                   if (!(t1 < end)) {
3776                     break;
3777                   }
3778                   if (x < entries.length - 1) {
3779                     t2 = new Date(entries[x + 1].timestamp);
3780                     if (!(t2 > start)) {
3781                       continue;
3782                     }
3783                   }
3784                   available = entries[x].capacity;
3785                   ref1 = req.capacity;
3786                   for (k in ref1) {
3787                     v = ref1[k];
3788                     if ((v != null) && !!v) {
3789                       if (!(available[k] >= v)) {
3790                         return reject("requested " + k + "=" + v + " exceeds available " + available[k] + " between " + t1 + " and " + t2);
3791                       }
3792                     }
3793                   }
3794                 }
3795                 _this.set(req);
3796                 _this.set('pools', pools);
3797                 return resolve(_this);
3798               };
3799             })(this))["catch"](function(err) {
3800               return reject(err);
3801             });
3802           };
3803         }
3804     save:
3805       - !<tag:yaml.org,2002:js/function> |-
3806         function (prev) {
3807           return function(resolve, reject) {
3808             return this.invoke('validate', this.get()).then(function(res) {
3809               var now;
3810               now = (new Date).toJSON();
3811               if ((res.get('created-on')) == null) {
3812                 res.set('created-on', now);
3813               }
3814               res.set('modified-on', now);
3815               return resolve(res);
3816             })["catch"](function(e) {
3817               return reject(e);
3818             });
3819           };
3820         }
3821   ResourceAllocation:
3822     id:
3823       - !<tag:yaml.org,2002:js/function> |-
3824         function (prev) {
3825           return prev.set('default', function() {
3826             return this.uuid();
3827           });
3828         }
3829     start:
3830       - !<tag:yaml.org,2002:js/function> |-
3831         function (prev) {
3832           return prev.set('default', function() {
3833             return (new Date).toJSON();
3834           });
3835         }
3836     active:
3837       - !<tag:yaml.org,2002:js/function> |-
3838         function (prev) {
3839           return this.computed((function() {
3840             var end, now, start;
3841             now = new Date;
3842             start = new Date(this.get('start'));
3843             end = (function() {
3844               switch (false) {
3845                 case (this.get('end')) == null:
3846                   return new Date(this.get('end'));
3847                 default:
3848                   return now;
3849               }
3850             }).call(this);
3851             return (this.get('enabled')) && ((start <= now && now <= end));
3852           }), {
3853             type: prev
3854           });
3855         }
3856     priority:
3857       - !<tag:yaml.org,2002:js/function> |-
3858         function (prev) {
3859           return this.computed((function() {
3860             switch (false) {
3861               case !((this.get('reservation')) == null):
3862                 return 3;
3863               case !!(this.get('active')):
3864                 return 2;
3865               default:
3866                 return 1;
3867             }
3868           }), {
3869             type: prev
3870           });
3871         }
3872   ResourcePool:
3873     id:
3874       - !<tag:yaml.org,2002:js/function> |-
3875         function (prev) {
3876           return prev.set('default', function() {
3877             return this.uuid();
3878           });
3879         }
3880     start:
3881       - !<tag:yaml.org,2002:js/function> |-
3882         function (prev) {
3883           return prev.set('default', function() {
3884             return (new Date).toJSON();
3885           });
3886         }
3887     active:
3888       - !<tag:yaml.org,2002:js/function> |-
3889         function (prev) {
3890           return this.computed((function() {
3891             var end, now, start;
3892             now = new Date;
3893             start = new Date(this.get('start'));
3894             end = (function() {
3895               switch (false) {
3896                 case (this.get('end')) == null:
3897                   return new Date(this.get('end'));
3898                 default:
3899                   return now;
3900               }
3901             }).call(this);
3902             return (this.get('enabled')) && ((start <= now && now <= end));
3903           }), {
3904             type: prev
3905           });
3906         }
3907     save:
3908       - !<tag:yaml.org,2002:js/function> |-
3909         function (prev) {
3910           return function(resolve, reject) {
3911             var hasCapacity, k, ref, v, value;
3912             value = this.get();
3913             ref = value.capacity;
3914             for (k in ref) {
3915               v = ref[k];
3916               if ((v != null) && !!v) {
3917                 hasCapacity = true;
3918               }
3919             }
3920             if ((!hasCapacity) && value.elements.length === 0) {
3921               return reject("unable to save pool record without any capacity values");
3922             }
3923             return resolve(this);
3924           };
3925         }
3926   ResourceProvider:
3927     id:
3928       - !<tag:yaml.org,2002:js/function> |-
3929         function (prev) {
3930           return prev.set('default', function() {
3931             return this.uuid();
3932           });
3933         }
3934     token:
3935       - !<tag:yaml.org,2002:js/function> |-
3936         function (prev) {
3937           return prev.set('private', true);
3938         }
3939     pools:
3940       - !<tag:yaml.org,2002:js/function> |-
3941         function (prev) {
3942           return this.computed((function() {
3943             return (this.store.find('ResourcePool', {
3944               source: this.get('name')
3945             })).map(function(x) {
3946               return x.get('id');
3947             });
3948           }), {
3949             type: 'array'
3950           });
3951         }
3952     update:
3953       - !<tag:yaml.org,2002:js/function> |-
3954         function (prev) {
3955           return function(services, resolve, reject) {
3956             var request;
3957             if (services == null) {
3958               services = [];
3959             }
3960             if (!services.length) {
3961               return reject("unable to update provider without list of services");
3962             }
3963             request = this.store.parent.require('superagent');
3964             services.forEach((function(_this) {
3965               return function(service) {
3966                 var url;
3967                 switch (service.type) {
3968                   case 'compute':
3969                     url = service.endpoints[0].publicURL;
3970                     _this.set('services.compute.endpoint', url);
3971                     request.get(url + "/limits").set('X-Auth-Token', _this.get('token')).set('Accept', 'application/json').end(function(err, res) {
3972                       var capacity, ref;
3973                       if ((err != null) || !res.ok) {
3974                         console.warn("request to discover capacity limits failed");
3975                         return;
3976                       }
3977                       capacity = (ref = res.body.limits) != null ? ref.absolute : void 0;
3978                       return (_this.access('capacity')).set({
3979                         cores: capacity.maxTotalCores,
3980                         ram: capacity.maxTotalRAMSize,
3981                         instances: capacity.maxTotalInstances,
3982                         addresses: capacity.maxTotalFloatingIps
3983                       });
3984                     });
3985                     return request.get(url + "/flavors/detail").set('X-Auth-Token', _this.get('token')).set('Accept', 'application/json').end(function(err, res) {
3986                       var er, error, flavors, ref;
3987                       if ((err != null) || !res.ok) {
3988                         console.warn("request to discover compute flavors failed");
3989                         return;
3990                       }
3991                       flavors = res.body.flavors;
3992                       try {
3993                         flavors = flavors.map(function(x) {
3994                           return {
3995                             ResourceFlavor: x
3996                           };
3997                         });
3998                         return (ref = _this.access('services.compute.flavors')).push.apply(ref, flavors);
3999                       } catch (error) {
4000                         er = error;
4001                         return console.warn("failed to update flavors into the provider due to validation errors");
4002                       }
4003                     });
4004                 }
4005               };
4006             })(this));
4007             return resolve(this);
4008           };
4009         }
4010   ResourceFlavor: !<tag:yaml.org,2002:js/undefined> ''
4011 pkgdir: /home/plee/hack/opnfv-promise
4012 module:
4013   opnfv-promise:
4014     promise.capacity.total:
4015       - !<tag:yaml.org,2002:js/function> |-
4016         function (prev) {
4017           return this.computed((function() {
4018             var combine;
4019             combine = function(a, b) {
4020               var k, ref, v;
4021               ref = b.capacity;
4022               for (k in ref) {
4023                 v = ref[k];
4024                 if (!(v != null)) {
4025                   continue;
4026                 }
4027                 if (a[k] == null) {
4028                   a[k] = 0;
4029                 }
4030                 a[k] += v;
4031               }
4032               return a;
4033             };
4034             return (this.parent.get('pools')).filter(function(entry) {
4035               return entry.active === true;
4036             }).reduce(combine, {});
4037           }), {
4038             type: prev
4039           });
4040         }
4041     promise.capacity.reserved:
4042       - !<tag:yaml.org,2002:js/function> |-
4043         function (prev) {
4044           return this.computed((function() {
4045             var combine;
4046             combine = function(a, b) {
4047               var k, ref, v;
4048               ref = b.remaining;
4049               for (k in ref) {
4050                 v = ref[k];
4051                 if (!(v != null)) {
4052                   continue;
4053                 }
4054                 if (a[k] == null) {
4055                   a[k] = 0;
4056                 }
4057                 a[k] += v;
4058               }
4059               return a;
4060             };
4061             return (this.parent.get('reservations')).filter(function(entry) {
4062               return entry.active === true;
4063             }).reduce(combine, {});
4064           }), {
4065             type: prev
4066           });
4067         }
4068     promise.capacity.usage:
4069       - !<tag:yaml.org,2002:js/function> |-
4070         function (prev) {
4071           return this.computed((function() {
4072             var combine;
4073             combine = function(a, b) {
4074               var k, ref, v;
4075               ref = b.capacity;
4076               for (k in ref) {
4077                 v = ref[k];
4078                 if (!(v != null)) {
4079                   continue;
4080                 }
4081                 if (a[k] == null) {
4082                   a[k] = 0;
4083                 }
4084                 a[k] += v;
4085               }
4086               return a;
4087             };
4088             return (this.parent.get('allocations')).filter(function(entry) {
4089               return entry.active === true;
4090             }).reduce(combine, {});
4091           }), {
4092             type: prev
4093           });
4094         }
4095     promise.capacity.available:
4096       - !<tag:yaml.org,2002:js/function> |-
4097         function (prev) {
4098           return this.computed((function() {
4099             var k, reserved, total, usage, v;
4100             total = this.get('total');
4101             reserved = this.get('reserved');
4102             usage = this.get('usage');
4103             for (k in total) {
4104               v = total[k];
4105               if (!(v != null)) {
4106                 continue;
4107               }
4108               if (reserved[k] != null) {
4109                 total[k] -= reserved[k];
4110               }
4111               if (usage[k] != null) {
4112                 total[k] -= usage[k];
4113               }
4114             }
4115             return total;
4116           }), {
4117             type: prev
4118           });
4119         }
4120 config: !<tag:yaml.org,2002:js/undefined> ''