View Javadoc

1   /**
2    *
3    * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4    *
5    * ====================================================================
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   * ====================================================================
18   */
19  package org.jclouds.vcloud.domain;
20  
21  import static com.google.common.base.Preconditions.checkNotNull;
22  
23  import com.google.common.base.CaseFormat;
24  
25  /**
26   * The AllocationModel element defines how resources are allocated in a vDC.
27   */
28  public enum AllocationModel {
29     /**
30      * Resources are committed to a vDC only when vApps are created in it
31      */
32     ALLOCATION_VAPP,
33     /**
34      * Only a percentage of the resources you allocate are committed to the organization vDC.
35      */
36     ALLOCATION_POOL,
37     /**
38      * All the resources you allocate are committed as a pool to the organization vDC. vApps in vDCs
39      * that support this allocation model can specify values for resource and limit.
40      */
41     RESERVATION_POOL,
42     /**
43      * The VCloud API returned a model unsupported in the version 1.0 spec.
44      */
45     UNRECOGNIZED;
46  
47     public String value() {
48        switch (this) {
49           case ALLOCATION_VAPP:
50              return "AllocationVApp";
51           case ALLOCATION_POOL:
52              return "AllocationPool";
53           case RESERVATION_POOL:
54              return "ReservationPool";
55           default:
56              return "UnrecognizedModel";
57        }
58     }
59  
60     @Override
61     public String toString() {
62        return value();
63     }
64  
65     public static AllocationModel fromValue(String model) {
66        try {
67           return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(model, "model")));
68        } catch (IllegalArgumentException e) {
69           return UNRECOGNIZED;
70        }
71     }
72  }