| 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 java.net.URI; |
| 22 | |
| 23 | import org.jclouds.vcloud.VCloudMediaType; |
| 24 | |
| 25 | /** |
| 26 | * The GuestCustomization of a Vm contains customization parameters for the guest operating system |
| 27 | * of the virtual machine. |
| 28 | */ |
| 29 | public class GuestCustomizationSection { |
| 30 | protected final String type; |
| 31 | protected final URI href; |
| 32 | protected String info; |
| 33 | protected Boolean enabled; |
| 34 | protected Boolean changeSid; |
| 35 | protected String virtualMachineId; |
| 36 | protected Boolean joinDomainEnabled; |
| 37 | protected Boolean useOrgSettings; |
| 38 | protected String domainName; |
| 39 | protected String domainUserName; |
| 40 | protected String domainUserPassword; |
| 41 | protected Boolean adminPasswordEnabled; |
| 42 | protected Boolean adminPasswordAuto; |
| 43 | protected String adminPassword; |
| 44 | protected Boolean resetPasswordRequired; |
| 45 | protected String customizationScript; |
| 46 | protected String computerName; |
| 47 | protected final ReferenceType edit; |
| 48 | |
| 49 | public GuestCustomizationSection(URI href) { |
| 50 | this.href = href; |
| 51 | this.type = VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML; |
| 52 | this.info = "Specifies Guest OS Customization Settings"; |
| 53 | this.edit = null; |
| 54 | } |
| 55 | |
| 56 | public GuestCustomizationSection(String type, URI href, String info, Boolean enabled, Boolean changeSid, |
| 57 | String virtualMachineId, Boolean joinDomainEnabled, Boolean useOrgSettings, String domainName, |
| 58 | String domainUserName, String domainUserPassword, Boolean adminPasswordEnabled, Boolean adminPasswordAuto, |
| 59 | String adminPassword, Boolean resetPasswordRequired, String customizationScript, String computerName, |
| 60 | ReferenceType edit) { |
| 61 | this.type = type; |
| 62 | this.href = href; |
| 63 | this.info = info; |
| 64 | this.enabled = enabled; |
| 65 | this.changeSid = changeSid; |
| 66 | this.virtualMachineId = virtualMachineId; |
| 67 | this.joinDomainEnabled = joinDomainEnabled; |
| 68 | this.useOrgSettings = useOrgSettings; |
| 69 | this.domainName = domainName; |
| 70 | this.domainUserName = domainUserName; |
| 71 | this.domainUserPassword = domainUserPassword; |
| 72 | this.adminPasswordEnabled = adminPasswordEnabled; |
| 73 | this.adminPasswordAuto = adminPasswordAuto; |
| 74 | this.adminPassword = adminPassword; |
| 75 | this.resetPasswordRequired = resetPasswordRequired; |
| 76 | this.customizationScript = customizationScript; |
| 77 | this.computerName = computerName; |
| 78 | this.edit = edit; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * |
| 83 | * @return media type of this section |
| 84 | */ |
| 85 | public String getType() { |
| 86 | return type; |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * |
| 91 | * @return URL to access this section |
| 92 | */ |
| 93 | public URI getHref() { |
| 94 | return href; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * |
| 99 | * @return |
| 100 | */ |
| 101 | public String getInfo() { |
| 102 | return info; |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * |
| 107 | * @return if true, to enable guest customization at power on |
| 108 | */ |
| 109 | public Boolean isEnabled() { |
| 110 | return enabled; |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * |
| 115 | * @return if true, customization will run sysprep to change the Windows SID for this virtual |
| 116 | * machine |
| 117 | */ |
| 118 | public Boolean shouldChangeSid() { |
| 119 | return changeSid; |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * |
| 124 | * @return unique identifier for this virtual machine |
| 125 | */ |
| 126 | public String getVirtualMachineId() { |
| 127 | return virtualMachineId; |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * |
| 132 | * @return if true, this virtual machine can join a Windows domain |
| 133 | */ |
| 134 | public Boolean isJoinDomainEnabled() { |
| 135 | return joinDomainEnabled; |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * |
| 140 | * @return if true, this virtual machine uses the containing organization?s default values for |
| 141 | * Windows domain name, domain user name, and domain user password |
| 142 | */ |
| 143 | public Boolean useOrgSettings() { |
| 144 | return useOrgSettings; |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * |
| 149 | * @return if UseOrgSettings is false, specifies the Windows domain to join |
| 150 | */ |
| 151 | public String getDomainName() { |
| 152 | return domainName; |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * |
| 157 | * @return if UseOrgSettings is false, specifies the Windows domain user name |
| 158 | */ |
| 159 | public String getDomainUserName() { |
| 160 | return domainUserName; |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * |
| 165 | * @return if UseOrgSettings is false, specifies the Windows domain user?s password |
| 166 | */ |
| 167 | public String getDomainUserPassword() { |
| 168 | return domainUserPassword; |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * |
| 173 | * @return true if the guest OS allows use of a local administrator password |
| 174 | */ |
| 175 | public Boolean isAdminPasswordEnabled() { |
| 176 | return adminPasswordEnabled; |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * |
| 181 | * @return true if the local administrator password should be automatically generated |
| 182 | */ |
| 183 | public Boolean isAdminPasswordAuto() { |
| 184 | return adminPasswordAuto; |
| 185 | } |
| 186 | |
| 187 | /** |
| 188 | * |
| 189 | * @return local administrator password for this virtual machine |
| 190 | */ |
| 191 | public String getAdminPassword() { |
| 192 | return adminPassword; |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * |
| 197 | * @return if true, the local administrator must reset his password on first use |
| 198 | */ |
| 199 | public Boolean isResetPasswordRequired() { |
| 200 | return resetPasswordRequired; |
| 201 | } |
| 202 | |
| 203 | /** |
| 204 | * |
| 205 | * @return the customization script to run |
| 206 | */ |
| 207 | public String getCustomizationScript() { |
| 208 | return customizationScript; |
| 209 | } |
| 210 | |
| 211 | /** |
| 212 | * |
| 213 | * @return name of this virtual machine in DNS or Windows domain |
| 214 | */ |
| 215 | public String getComputerName() { |
| 216 | return computerName; |
| 217 | } |
| 218 | |
| 219 | /** |
| 220 | * |
| 221 | * @return edit link |
| 222 | */ |
| 223 | public ReferenceType getEdit() { |
| 224 | return edit; |
| 225 | } |
| 226 | |
| 227 | @Override |
| 228 | public String toString() { |
| 229 | return "[href=" + getHref() + ", type=" + getType() + ", info=" + getInfo() + ", enabled=" + isEnabled() + "]"; |
| 230 | } |
| 231 | |
| 232 | @Override |
| 233 | public int hashCode() { |
| 234 | int prime = 31; |
| 235 | int result = 1; |
| 236 | result = prime * result + ((adminPassword == null) ? 0 : adminPassword.hashCode()); |
| 237 | result = prime * result + ((adminPasswordAuto == null) ? 0 : adminPasswordAuto.hashCode()); |
| 238 | result = prime * result + ((adminPasswordEnabled == null) ? 0 : adminPasswordEnabled.hashCode()); |
| 239 | result = prime * result + ((changeSid == null) ? 0 : changeSid.hashCode()); |
| 240 | result = prime * result + ((computerName == null) ? 0 : computerName.hashCode()); |
| 241 | result = prime * result + ((customizationScript == null) ? 0 : customizationScript.hashCode()); |
| 242 | result = prime * result + ((domainName == null) ? 0 : domainName.hashCode()); |
| 243 | result = prime * result + ((domainUserName == null) ? 0 : domainUserName.hashCode()); |
| 244 | result = prime * result + ((domainUserPassword == null) ? 0 : domainUserPassword.hashCode()); |
| 245 | result = prime * result + ((edit == null) ? 0 : edit.hashCode()); |
| 246 | result = prime * result + ((enabled == null) ? 0 : enabled.hashCode()); |
| 247 | result = prime * result + ((href == null) ? 0 : href.hashCode()); |
| 248 | result = prime * result + ((info == null) ? 0 : info.hashCode()); |
| 249 | result = prime * result + ((joinDomainEnabled == null) ? 0 : joinDomainEnabled.hashCode()); |
| 250 | result = prime * result + ((resetPasswordRequired == null) ? 0 : resetPasswordRequired.hashCode()); |
| 251 | result = prime * result + ((type == null) ? 0 : type.hashCode()); |
| 252 | result = prime * result + ((useOrgSettings == null) ? 0 : useOrgSettings.hashCode()); |
| 253 | result = prime * result + ((virtualMachineId == null) ? 0 : virtualMachineId.hashCode()); |
| 254 | return result; |
| 255 | } |
| 256 | |
| 257 | @Override |
| 258 | public boolean equals(Object obj) { |
| 259 | if (this == obj) |
| 260 | return true; |
| 261 | if (obj == null) |
| 262 | return false; |
| 263 | if (getClass() != obj.getClass()) |
| 264 | return false; |
| 265 | GuestCustomizationSection other = (GuestCustomizationSection) obj; |
| 266 | if (adminPassword == null) { |
| 267 | if (other.adminPassword != null) |
| 268 | return false; |
| 269 | } else if (!adminPassword.equals(other.adminPassword)) |
| 270 | return false; |
| 271 | if (adminPasswordAuto == null) { |
| 272 | if (other.adminPasswordAuto != null) |
| 273 | return false; |
| 274 | } else if (!adminPasswordAuto.equals(other.adminPasswordAuto)) |
| 275 | return false; |
| 276 | if (adminPasswordEnabled == null) { |
| 277 | if (other.adminPasswordEnabled != null) |
| 278 | return false; |
| 279 | } else if (!adminPasswordEnabled.equals(other.adminPasswordEnabled)) |
| 280 | return false; |
| 281 | if (changeSid == null) { |
| 282 | if (other.changeSid != null) |
| 283 | return false; |
| 284 | } else if (!changeSid.equals(other.changeSid)) |
| 285 | return false; |
| 286 | if (computerName == null) { |
| 287 | if (other.computerName != null) |
| 288 | return false; |
| 289 | } else if (!computerName.equals(other.computerName)) |
| 290 | return false; |
| 291 | if (customizationScript == null) { |
| 292 | if (other.customizationScript != null) |
| 293 | return false; |
| 294 | } else if (!customizationScript.equals(other.customizationScript)) |
| 295 | return false; |
| 296 | if (domainName == null) { |
| 297 | if (other.domainName != null) |
| 298 | return false; |
| 299 | } else if (!domainName.equals(other.domainName)) |
| 300 | return false; |
| 301 | if (domainUserName == null) { |
| 302 | if (other.domainUserName != null) |
| 303 | return false; |
| 304 | } else if (!domainUserName.equals(other.domainUserName)) |
| 305 | return false; |
| 306 | if (domainUserPassword == null) { |
| 307 | if (other.domainUserPassword != null) |
| 308 | return false; |
| 309 | } else if (!domainUserPassword.equals(other.domainUserPassword)) |
| 310 | return false; |
| 311 | if (edit == null) { |
| 312 | if (other.edit != null) |
| 313 | return false; |
| 314 | } else if (!edit.equals(other.edit)) |
| 315 | return false; |
| 316 | if (enabled == null) { |
| 317 | if (other.enabled != null) |
| 318 | return false; |
| 319 | } else if (!enabled.equals(other.enabled)) |
| 320 | return false; |
| 321 | if (href == null) { |
| 322 | if (other.href != null) |
| 323 | return false; |
| 324 | } else if (!href.equals(other.href)) |
| 325 | return false; |
| 326 | if (info == null) { |
| 327 | if (other.info != null) |
| 328 | return false; |
| 329 | } else if (!info.equals(other.info)) |
| 330 | return false; |
| 331 | if (joinDomainEnabled == null) { |
| 332 | if (other.joinDomainEnabled != null) |
| 333 | return false; |
| 334 | } else if (!joinDomainEnabled.equals(other.joinDomainEnabled)) |
| 335 | return false; |
| 336 | if (resetPasswordRequired == null) { |
| 337 | if (other.resetPasswordRequired != null) |
| 338 | return false; |
| 339 | } else if (!resetPasswordRequired.equals(other.resetPasswordRequired)) |
| 340 | return false; |
| 341 | if (type == null) { |
| 342 | if (other.type != null) |
| 343 | return false; |
| 344 | } else if (!type.equals(other.type)) |
| 345 | return false; |
| 346 | if (useOrgSettings == null) { |
| 347 | if (other.useOrgSettings != null) |
| 348 | return false; |
| 349 | } else if (!useOrgSettings.equals(other.useOrgSettings)) |
| 350 | return false; |
| 351 | if (virtualMachineId == null) { |
| 352 | if (other.virtualMachineId != null) |
| 353 | return false; |
| 354 | } else if (!virtualMachineId.equals(other.virtualMachineId)) |
| 355 | return false; |
| 356 | return true; |
| 357 | } |
| 358 | |
| 359 | public void setEnabled(Boolean enabled) { |
| 360 | this.enabled = enabled; |
| 361 | } |
| 362 | |
| 363 | public Boolean getChangeSid() { |
| 364 | return changeSid; |
| 365 | } |
| 366 | |
| 367 | public void setChangeSid(Boolean changeSid) { |
| 368 | this.changeSid = changeSid; |
| 369 | } |
| 370 | |
| 371 | public Boolean getJoinDomainEnabled() { |
| 372 | return joinDomainEnabled; |
| 373 | } |
| 374 | |
| 375 | public void setJoinDomainEnabled(Boolean joinDomainEnabled) { |
| 376 | this.joinDomainEnabled = joinDomainEnabled; |
| 377 | } |
| 378 | |
| 379 | public Boolean shouldUseOrgSettings() { |
| 380 | return useOrgSettings; |
| 381 | } |
| 382 | |
| 383 | public void setUseOrgSettings(Boolean useOrgSettings) { |
| 384 | this.useOrgSettings = useOrgSettings; |
| 385 | } |
| 386 | |
| 387 | public Boolean getAdminPasswordEnabled() { |
| 388 | return adminPasswordEnabled; |
| 389 | } |
| 390 | |
| 391 | public void setAdminPasswordEnabled(Boolean adminPasswordEnabled) { |
| 392 | this.adminPasswordEnabled = adminPasswordEnabled; |
| 393 | } |
| 394 | |
| 395 | public Boolean getAdminPasswordAuto() { |
| 396 | return adminPasswordAuto; |
| 397 | } |
| 398 | |
| 399 | public void setAdminPasswordAuto(Boolean adminPasswordAuto) { |
| 400 | this.adminPasswordAuto = adminPasswordAuto; |
| 401 | } |
| 402 | |
| 403 | public Boolean getResetPasswordRequired() { |
| 404 | return resetPasswordRequired; |
| 405 | } |
| 406 | |
| 407 | public void setResetPasswordRequired(Boolean resetPasswordRequired) { |
| 408 | this.resetPasswordRequired = resetPasswordRequired; |
| 409 | } |
| 410 | |
| 411 | public void setInfo(String info) { |
| 412 | this.info = info; |
| 413 | } |
| 414 | |
| 415 | public void setVirtualMachineId(String virtualMachineId) { |
| 416 | this.virtualMachineId = virtualMachineId; |
| 417 | } |
| 418 | |
| 419 | public void setDomainName(String domainName) { |
| 420 | this.domainName = domainName; |
| 421 | } |
| 422 | |
| 423 | public void setDomainUserName(String domainUserName) { |
| 424 | this.domainUserName = domainUserName; |
| 425 | } |
| 426 | |
| 427 | public void setDomainUserPassword(String domainUserPassword) { |
| 428 | this.domainUserPassword = domainUserPassword; |
| 429 | } |
| 430 | |
| 431 | public void setAdminPassword(String adminPassword) { |
| 432 | this.adminPassword = adminPassword; |
| 433 | } |
| 434 | |
| 435 | public void setCustomizationScript(String customizationScript) { |
| 436 | this.customizationScript = customizationScript; |
| 437 | } |
| 438 | |
| 439 | public void setComputerName(String computerName) { |
| 440 | this.computerName = computerName; |
| 441 | } |
| 442 | } |