| 1 | /** |
| 2 | * Licensed to jclouds, Inc. (jclouds) under one or more |
| 3 | * contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. jclouds licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. 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, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | package org.jclouds.vcloud.domain; |
| 20 | |
| 21 | import static com.google.common.base.Preconditions.checkNotNull; |
| 22 | |
| 23 | /** |
| 24 | * Objects such as vAppTemplate, vApp, and Vm have a status attribute whose value indicates the |
| 25 | * state of the object. Status for an object, such as a vAppTemplate or vApp, whose Children (Vm |
| 26 | * objects) each have a status of their own, is computed from the status of the Children. |
| 27 | * |
| 28 | * <h2>NOTE</h2> |
| 29 | * <p/> |
| 30 | * The deployment status of an object is indicated by the value of its deployed attribute. |
| 31 | * |
| 32 | * @since vcloud api 0.8 |
| 33 | * |
| 34 | * @author Adrian Cole |
| 35 | */ |
| 36 | public enum Status { |
| 37 | /** |
| 38 | * The {@link VAppTemplate}, {@link VApp}, or {@link Vm} could not be created. |
| 39 | * |
| 40 | * @since vcloud api 1.0 |
| 41 | */ |
| 42 | ERROR, |
| 43 | /** |
| 44 | * The {@link VAppTemplate}, {@link VApp}, or {@link Vm} is unresolved. |
| 45 | * |
| 46 | * @since vcloud api 0.8 |
| 47 | */ |
| 48 | UNRESOLVED, |
| 49 | /** |
| 50 | * The {@link VAppTemplate}, {@link VApp}, or {@link Vm} is resolved. |
| 51 | * |
| 52 | * @since vcloud api 0.8 |
| 53 | */ |
| 54 | RESOLVED, |
| 55 | /** |
| 56 | * The object is deployed. |
| 57 | * <p/> |
| 58 | * note that the documentation does not reference use of this. |
| 59 | * |
| 60 | * @since vcloud api 1.0 |
| 61 | */ |
| 62 | DEPLOYED, |
| 63 | /** |
| 64 | * The {@link VApp} or {@link Vm} is suspended. |
| 65 | * |
| 66 | * @since vcloud api 0.8 |
| 67 | */ |
| 68 | SUSPENDED, |
| 69 | /** |
| 70 | * The {@link VApp} or {@link Vm} is powered on |
| 71 | * |
| 72 | * @since vcloud api 0.8 |
| 73 | */ |
| 74 | ON, |
| 75 | /** |
| 76 | * The {@link VApp} or {@link Vm} waiting for user input. |
| 77 | * |
| 78 | * @since vcloud api 1.0 |
| 79 | */ |
| 80 | WAITING_FOR_INPUT, |
| 81 | /** |
| 82 | * The {@link VAppTemplate}, {@link VApp}, or {@link Vm} is in an unknown state. |
| 83 | * |
| 84 | * @since vcloud api 1.0 |
| 85 | */ |
| 86 | UNKNOWN, |
| 87 | /** |
| 88 | * The {@link VAppTemplate}, {@link VApp}, or {@link Vm} is in an unrecognized state. |
| 89 | * |
| 90 | * @since vcloud api 1.0 |
| 91 | */ |
| 92 | UNRECOGNIZED, |
| 93 | /** |
| 94 | * The {@link VAppTemplate}, {@link VApp}, or {@link Vm} is off. |
| 95 | * |
| 96 | * @since vcloud api 0.8 |
| 97 | */ |
| 98 | OFF, |
| 99 | /** |
| 100 | * The {@link VApp} or {@link Vm} is in an inconsistent state. |
| 101 | * |
| 102 | * @since vcloud api 1.0 |
| 103 | */ |
| 104 | INCONSISTENT, |
| 105 | /** |
| 106 | * The {@link VAppTemplate} or {@link VApp} have children do not all have the same status. |
| 107 | * |
| 108 | * @since vcloud api 1.0 |
| 109 | */ |
| 110 | MIXED, |
| 111 | /** |
| 112 | * The {@link VAppTemplate} Upload initiated, OVF descriptor pending |
| 113 | * |
| 114 | * @since vcloud api 1.0 |
| 115 | */ |
| 116 | PENDING_DESCRIPTOR, |
| 117 | /** |
| 118 | * The {@link VAppTemplate} Upload initiated, copying contents |
| 119 | * |
| 120 | * @since vcloud api 1.0 |
| 121 | */ |
| 122 | COPYING, |
| 123 | /** |
| 124 | * The {@link VAppTemplate} Upload initiated, disk contents pending |
| 125 | * |
| 126 | * @since vcloud api 1.0 |
| 127 | */ |
| 128 | PENDING_CONTENTS, |
| 129 | /** |
| 130 | * The {@link VAppTemplate} Upload has been quarantined |
| 131 | * |
| 132 | * @since vcloud api 1.0 |
| 133 | */ |
| 134 | QUARANTINED, |
| 135 | /** |
| 136 | * The {@link VAppTemplate} Upload quarantine period has expired |
| 137 | * |
| 138 | * @since vcloud api 1.0 |
| 139 | */ |
| 140 | QUARANTINE_EXPIRED; |
| 141 | |
| 142 | public String value() { |
| 143 | switch (this) { |
| 144 | case UNRESOLVED: |
| 145 | return "0"; |
| 146 | case RESOLVED: |
| 147 | return "1"; |
| 148 | case DEPLOYED: |
| 149 | return "2"; |
| 150 | case SUSPENDED: |
| 151 | return "3"; |
| 152 | case ON: |
| 153 | return "4"; |
| 154 | case WAITING_FOR_INPUT: |
| 155 | return "5"; |
| 156 | case UNKNOWN: |
| 157 | return "6"; |
| 158 | case UNRECOGNIZED: |
| 159 | return "7"; |
| 160 | case OFF: |
| 161 | return "8"; |
| 162 | case INCONSISTENT: |
| 163 | return "9"; |
| 164 | case MIXED: |
| 165 | return "10"; |
| 166 | case PENDING_DESCRIPTOR: |
| 167 | return "11"; |
| 168 | case COPYING: |
| 169 | return "12"; |
| 170 | case PENDING_CONTENTS: |
| 171 | return "13"; |
| 172 | case QUARANTINED: |
| 173 | return "14"; |
| 174 | case QUARANTINE_EXPIRED: |
| 175 | return "15"; |
| 176 | default: |
| 177 | return "7"; |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | public static Status fromValue(String status) { |
| 182 | try { |
| 183 | return fromValue(Integer.parseInt(checkNotNull(status, "status"))); |
| 184 | } catch (IllegalArgumentException e) { |
| 185 | return UNRECOGNIZED; |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | public static Status fromValue(int v) { |
| 190 | switch (v) { |
| 191 | case 0: |
| 192 | return UNRESOLVED; |
| 193 | case 1: |
| 194 | return RESOLVED; |
| 195 | case 2: |
| 196 | return DEPLOYED; |
| 197 | case 3: |
| 198 | return SUSPENDED; |
| 199 | case 4: |
| 200 | return ON; |
| 201 | case 5: |
| 202 | return WAITING_FOR_INPUT; |
| 203 | case 6: |
| 204 | return UNKNOWN; |
| 205 | case 7: |
| 206 | return UNRECOGNIZED; |
| 207 | case 8: |
| 208 | return OFF; |
| 209 | case 9: |
| 210 | return INCONSISTENT; |
| 211 | case 10: |
| 212 | return MIXED; |
| 213 | case 11: |
| 214 | return PENDING_DESCRIPTOR; |
| 215 | case 12: |
| 216 | return COPYING; |
| 217 | case 13: |
| 218 | return PENDING_CONTENTS; |
| 219 | case 14: |
| 220 | return QUARANTINED; |
| 221 | case 15: |
| 222 | return QUARANTINE_EXPIRED; |
| 223 | default: |
| 224 | return UNRECOGNIZED; |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | } |