Issue 358: changed to enum.UNRECOGNIZED for all values that could arrive from a server

This commit is contained in:
Adrian Cole 2010-09-18 10:04:43 -07:00
parent 3d5bfa7422
commit e94ee94cd4
65 changed files with 403 additions and 262 deletions

View File

@ -21,14 +21,18 @@ package org.jclouds.atmosonline.saas.domain;
public enum FileType { public enum FileType {
DIRECTORY, REGULAR; DIRECTORY, REGULAR, UNRECOGNIZED;
public String value() { public String value() {
return name().toLowerCase(); return name().toLowerCase();
} }
public static FileType fromValue(String v) { public static FileType fromValue(String v) {
return valueOf(v.toUpperCase()); try {
return valueOf(v.toUpperCase());
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }

View File

@ -29,7 +29,7 @@ import com.google.common.base.CaseFormat;
* @author Adrian Cole * @author Adrian Cole
*/ */
public enum StandardUnit { public enum StandardUnit {
SECONDS, PERCENT, BYTES, BITS, COUNT, BITS_PER_SECOND, COUNT_PER_SECOND, NONE; SECONDS, PERCENT, BYTES, BITS, COUNT, BITS_PER_SECOND, COUNT_PER_SECOND, NONE, UNRECOGNIZED;
public String value() { public String value() {
return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name().replace("_PER_", "/"))); return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name().replace("_PER_", "/")));
@ -41,7 +41,11 @@ public enum StandardUnit {
} }
public static StandardUnit fromValue(String state) { public static StandardUnit fromValue(String state) {
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state").replace("/", try {
"_PER_"))); return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state").replace(
"/", "_PER_")));
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }

View File

@ -76,7 +76,8 @@ public class RunningInstanceToNodeMetadata implements Function<RunningInstance,
.put(InstanceState.PENDING, NodeState.PENDING).put(InstanceState.RUNNING, NodeState.RUNNING).put( .put(InstanceState.PENDING, NodeState.PENDING).put(InstanceState.RUNNING, NodeState.RUNNING).put(
InstanceState.SHUTTING_DOWN, NodeState.PENDING) InstanceState.SHUTTING_DOWN, NodeState.PENDING)
.put(InstanceState.TERMINATED, NodeState.TERMINATED).put(InstanceState.STOPPING, NodeState.PENDING).put( .put(InstanceState.TERMINATED, NodeState.TERMINATED).put(InstanceState.STOPPING, NodeState.PENDING).put(
InstanceState.STOPPED, NodeState.SUSPENDED).build(); InstanceState.STOPPED, NodeState.SUSPENDED)
.put(InstanceState.UNRECOGNIZED, NodeState.UNRECOGNIZED).build();
private final EC2Client client; private final EC2Client client;
private final Map<RegionAndName, KeyPair> credentialsMap; private final Map<RegionAndName, KeyPair> credentialsMap;

View File

@ -32,7 +32,7 @@ import java.util.Date;
*/ */
public class Attachment implements Comparable<Attachment> { public class Attachment implements Comparable<Attachment> {
public static enum Status { public static enum Status {
ATTACHING, ATTACHED, DETACHING, DETACHED, BUSY; ATTACHING, ATTACHED, DETACHING, DETACHED, BUSY, UNRECOGNIZED;
public String value() { public String value() {
return name().toLowerCase(); return name().toLowerCase();
} }
@ -43,7 +43,11 @@ public class Attachment implements Comparable<Attachment> {
} }
public static Status fromValue(String status) { public static Status fromValue(String status) {
return valueOf(checkNotNull(status, "status").toUpperCase()); try {
return valueOf(checkNotNull(status, "status").toUpperCase());
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }
@ -54,8 +58,7 @@ public class Attachment implements Comparable<Attachment> {
private final Status status; private final Status status;
private final Date attachTime; private final Date attachTime;
public Attachment(String region, String volumeId, String instanceId, String device, public Attachment(String region, String volumeId, String instanceId, String device, Status status, Date attachTime) {
Status status, Date attachTime) {
this.region = checkNotNull(region, "region"); this.region = checkNotNull(region, "region");
this.volumeId = volumeId; this.volumeId = volumeId;
this.instanceId = instanceId; this.instanceId = instanceId;
@ -164,9 +167,8 @@ public class Attachment implements Comparable<Attachment> {
@Override @Override
public String toString() { public String toString() {
return "Attachment [region=" + region + ", volumeId=" + volumeId + ", instanceId=" return "Attachment [region=" + region + ", volumeId=" + volumeId + ", instanceId=" + instanceId + ", device="
+ instanceId + ", device=" + device + ", attachTime=" + attachTime + ", status=" + device + ", attachTime=" + attachTime + ", status=" + status + "]";
+ status + "]";
} }
@Override @Override

View File

@ -59,22 +59,18 @@ public class Image implements Comparable<Image> {
private final RootDeviceType rootDeviceType; private final RootDeviceType rootDeviceType;
@Nullable @Nullable
private final String rootDeviceName; private final String rootDeviceName;
private final Map<String, EbsBlockDevice> ebsBlockDevices = Maps private final Map<String, EbsBlockDevice> ebsBlockDevices = Maps.newHashMap();
.newHashMap();
private final String virtualizationType; private final String virtualizationType;
public String getVirtualizationType() { public String getVirtualizationType() {
return virtualizationType; return virtualizationType;
} }
public Image(String region, Architecture architecture, public Image(String region, Architecture architecture, @Nullable String name, @Nullable String description,
@Nullable String name, @Nullable String description, String imageId, String imageId, String imageLocation, String imageOwnerId, ImageState imageState, ImageType imageType,
String imageLocation, String imageOwnerId, ImageState imageState, boolean isPublic, Iterable<String> productCodes, @Nullable String kernelId, @Nullable String platform,
ImageType imageType, boolean isPublic, Iterable<String> productCodes, @Nullable String ramdiskId, RootDeviceType rootDeviceType, @Nullable String rootDeviceName,
@Nullable String kernelId, @Nullable String platform, Map<String, EbsBlockDevice> ebsBlockDevices, String virtualizationType) {
@Nullable String ramdiskId, RootDeviceType rootDeviceType,
@Nullable String rootDeviceName,
Map<String, EbsBlockDevice> ebsBlockDevices, String virtualizationType) {
this.region = checkNotNull(region, "region"); this.region = checkNotNull(region, "region");
this.architecture = checkNotNull(architecture, "architecture"); this.architecture = checkNotNull(architecture, "architecture");
this.imageId = checkNotNull(imageId, "imageId"); this.imageId = checkNotNull(imageId, "imageId");
@ -88,14 +84,11 @@ public class Image implements Comparable<Image> {
this.isPublic = isPublic; this.isPublic = isPublic;
this.kernelId = kernelId; this.kernelId = kernelId;
this.platform = platform; this.platform = platform;
Iterables.addAll(this.productCodes, checkNotNull(productCodes, Iterables.addAll(this.productCodes, checkNotNull(productCodes, "productCodes"));
"productCodes"));
this.ramdiskId = ramdiskId; this.ramdiskId = ramdiskId;
this.rootDeviceType = checkNotNull(rootDeviceType, "rootDeviceType"); this.rootDeviceType = checkNotNull(rootDeviceType, "rootDeviceType");
this.ebsBlockDevices.putAll(checkNotNull(ebsBlockDevices, this.ebsBlockDevices.putAll(checkNotNull(ebsBlockDevices, "ebsBlockDevices"));
"ebsBlockDevices")); this.virtualizationType = checkNotNull(virtualizationType, "virtualizationType");
this.virtualizationType = checkNotNull(virtualizationType,
"virtualizationType");
} }
/** The serialVersionUID */ /** The serialVersionUID */
@ -109,36 +102,48 @@ public class Image implements Comparable<Image> {
/** /**
* the image is deregistered and no longer available for launching * the image is deregistered and no longer available for launching
*/ */
DEREGISTERED; DEREGISTERED, UNRECOGNIZED;
public String value() { public String value() {
return name().toLowerCase(); return name().toLowerCase();
} }
public static ImageState fromValue(String v) { public static ImageState fromValue(String v) {
return valueOf(v.toUpperCase()); try {
return valueOf(v.toUpperCase());
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }
public static enum Architecture { public static enum Architecture {
I386, X86_64; I386, X86_64, UNRECOGNIZED;
public String value() { public String value() {
return name().toLowerCase(); return name().toLowerCase();
} }
public static Architecture fromValue(String v) { public static Architecture fromValue(String v) {
return valueOf(v.toUpperCase()); try {
return valueOf(v.toUpperCase());
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }
public static enum ImageType { public static enum ImageType {
MACHINE, KERNEL, RAMDISK; MACHINE, KERNEL, RAMDISK, UNRECOGNIZED;
public String value() { public String value() {
return name().toLowerCase(); return name().toLowerCase();
} }
public static ImageType fromValue(String v) { public static ImageType fromValue(String v) {
return valueOf(v.toUpperCase()); try {
return valueOf(v.toUpperCase());
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }
@ -149,8 +154,7 @@ public class Image implements Comparable<Image> {
private final long volumeSize; private final long volumeSize;
private final boolean deleteOnTermination; private final boolean deleteOnTermination;
public EbsBlockDevice(@Nullable String snapshotId, long volumeSize, public EbsBlockDevice(@Nullable String snapshotId, long volumeSize, boolean deleteOnTermination) {
boolean deleteOnTermination) {
this.snapshotId = snapshotId; this.snapshotId = snapshotId;
this.volumeSize = volumeSize; this.volumeSize = volumeSize;
this.deleteOnTermination = deleteOnTermination; this.deleteOnTermination = deleteOnTermination;
@ -173,8 +177,7 @@ public class Image implements Comparable<Image> {
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result + (deleteOnTermination ? 1231 : 1237); result = prime * result + (deleteOnTermination ? 1231 : 1237);
result = prime * result result = prime * result + ((snapshotId == null) ? 0 : snapshotId.hashCode());
+ ((snapshotId == null) ? 0 : snapshotId.hashCode());
result = prime * result + (int) (volumeSize ^ (volumeSize >>> 32)); result = prime * result + (int) (volumeSize ^ (volumeSize >>> 32));
return result; return result;
} }
@ -202,9 +205,8 @@ public class Image implements Comparable<Image> {
@Override @Override
public String toString() { public String toString() {
return "EbsBlockDevice [deleteOnTermination=" + deleteOnTermination return "EbsBlockDevice [deleteOnTermination=" + deleteOnTermination + ", snapshotId=" + snapshotId
+ ", snapshotId=" + snapshotId + ", volumeSize=" + volumeSize + ", volumeSize=" + volumeSize + "]";
+ "]";
} }
} }
@ -246,10 +248,9 @@ public class Image implements Comparable<Image> {
} }
/** /**
* Current state of the AMI. If the operation returns available, the image is * Current state of the AMI. If the operation returns available, the image is successfully
* successfully registered and avail able for launching. If the operation * registered and avail able for launching. If the operation returns deregistered, the image is
* returns deregistered, the image is deregistered and no longer available * deregistered and no longer available for launching.
* for launching.
*/ */
public ImageState getImageState() { public ImageState getImageState() {
return imageState; return imageState;
@ -263,16 +264,15 @@ public class Image implements Comparable<Image> {
} }
/** /**
* Returns true if this image has public launch permissions. Returns false if * Returns true if this image has public launch permissions. Returns false if it only has
* it only has implicit and explicit launch permissions. * implicit and explicit launch permissions.
*/ */
public boolean isPublic() { public boolean isPublic() {
return isPublic; return isPublic;
} }
/** /**
* The kernel associated with the image, if any. Only applicable for machine * The kernel associated with the image, if any. Only applicable for machine images.
* images.
*/ */
public String getKernelId() { public String getKernelId() {
return kernelId; return kernelId;
@ -293,8 +293,7 @@ public class Image implements Comparable<Image> {
} }
/** /**
* The RAM disk associated with the image, if any. Only applicable for * The RAM disk associated with the image, if any. Only applicable for machine images.
* machine images.
*/ */
public String getRamdiskId() { public String getRamdiskId() {
return ramdiskId; return ramdiskId;
@ -309,8 +308,8 @@ public class Image implements Comparable<Image> {
/** /**
* *
* @return The root device type used by the AMI. The AMI can use an Amazon * @return The root device type used by the AMI. The AMI can use an Amazon EBS or instance store
* EBS or instance store root device. * root device.
*/ */
public RootDeviceType getRootDeviceType() { public RootDeviceType getRootDeviceType() {
return rootDeviceType; return rootDeviceType;
@ -336,37 +335,24 @@ public class Image implements Comparable<Image> {
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result result = prime * result + ((architecture == null) ? 0 : architecture.hashCode());
+ ((architecture == null) ? 0 : architecture.hashCode()); result = prime * result + ((description == null) ? 0 : description.hashCode());
result = prime * result result = prime * result + ((ebsBlockDevices == null) ? 0 : ebsBlockDevices.hashCode());
+ ((description == null) ? 0 : description.hashCode());
result = prime * result
+ ((ebsBlockDevices == null) ? 0 : ebsBlockDevices.hashCode());
result = prime * result + ((imageId == null) ? 0 : imageId.hashCode()); result = prime * result + ((imageId == null) ? 0 : imageId.hashCode());
result = prime * result result = prime * result + ((imageLocation == null) ? 0 : imageLocation.hashCode());
+ ((imageLocation == null) ? 0 : imageLocation.hashCode()); result = prime * result + ((imageOwnerId == null) ? 0 : imageOwnerId.hashCode());
result = prime * result result = prime * result + ((imageState == null) ? 0 : imageState.hashCode());
+ ((imageOwnerId == null) ? 0 : imageOwnerId.hashCode()); result = prime * result + ((imageType == null) ? 0 : imageType.hashCode());
result = prime * result
+ ((imageState == null) ? 0 : imageState.hashCode());
result = prime * result
+ ((imageType == null) ? 0 : imageType.hashCode());
result = prime * result + (isPublic ? 1231 : 1237); result = prime * result + (isPublic ? 1231 : 1237);
result = prime * result + ((kernelId == null) ? 0 : kernelId.hashCode()); result = prime * result + ((kernelId == null) ? 0 : kernelId.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((platform == null) ? 0 : platform.hashCode()); result = prime * result + ((platform == null) ? 0 : platform.hashCode());
result = prime * result result = prime * result + ((productCodes == null) ? 0 : productCodes.hashCode());
+ ((productCodes == null) ? 0 : productCodes.hashCode()); result = prime * result + ((ramdiskId == null) ? 0 : ramdiskId.hashCode());
result = prime * result
+ ((ramdiskId == null) ? 0 : ramdiskId.hashCode());
result = prime * result + ((region == null) ? 0 : region.hashCode()); result = prime * result + ((region == null) ? 0 : region.hashCode());
result = prime * result result = prime * result + ((rootDeviceName == null) ? 0 : rootDeviceName.hashCode());
+ ((rootDeviceName == null) ? 0 : rootDeviceName.hashCode()); result = prime * result + ((rootDeviceType == null) ? 0 : rootDeviceType.hashCode());
result = prime * result result = prime * result + ((virtualizationType == null) ? 0 : virtualizationType.hashCode());
+ ((rootDeviceType == null) ? 0 : rootDeviceType.hashCode());
result = prime
* result
+ ((virtualizationType == null) ? 0 : virtualizationType.hashCode());
return result; return result;
} }
@ -471,16 +457,13 @@ public class Image implements Comparable<Image> {
@Override @Override
public String toString() { public String toString() {
return "Image [architecture=" + architecture + ", description=" return "Image [architecture=" + architecture + ", description=" + description + ", ebsBlockDevices="
+ description + ", ebsBlockDevices=" + ebsBlockDevices + ebsBlockDevices + ", imageId=" + imageId + ", imageLocation=" + imageLocation + ", imageOwnerId="
+ ", imageId=" + imageId + ", imageLocation=" + imageLocation + imageOwnerId + ", imageState=" + imageState + ", imageType=" + imageType + ", isPublic=" + isPublic
+ ", imageOwnerId=" + imageOwnerId + ", imageState=" + imageState + ", kernelId=" + kernelId + ", name=" + name + ", platform=" + platform + ", productCodes="
+ ", imageType=" + imageType + ", isPublic=" + isPublic + productCodes + ", ramdiskId=" + ramdiskId + ", region=" + region + ", rootDeviceName="
+ ", kernelId=" + kernelId + ", name=" + name + ", platform=" + rootDeviceName + ", rootDeviceType=" + rootDeviceType + ", virtualizationType=" + virtualizationType
+ platform + ", productCodes=" + productCodes + ", ramdiskId=" + "]";
+ ramdiskId + ", region=" + region + ", rootDeviceName="
+ rootDeviceName + ", rootDeviceType=" + rootDeviceType
+ ", virtualizationType=" + virtualizationType + "]";
} }
} }

View File

@ -58,7 +58,7 @@ public enum ImageAttribute {
/** /**
* the mapping that defines native device names to use when exposing virtual devices. * the mapping that defines native device names to use when exposing virtual devices.
*/ */
BLOCK_DEVICE_MAPPING; BLOCK_DEVICE_MAPPING, UNRECOGNIZED;
public String value() { public String value() {
switch (this) { switch (this) {
case PRODUCT_CODES: case PRODUCT_CODES:
@ -97,7 +97,7 @@ public enum ImageAttribute {
else if ("blockDeviceMapping".equals(attribute)) else if ("blockDeviceMapping".equals(attribute))
return BLOCK_DEVICE_MAPPING; return BLOCK_DEVICE_MAPPING;
else else
throw new IllegalArgumentException("unmapped attribute: " + attribute); return UNRECOGNIZED;
} }
} }

View File

@ -62,7 +62,7 @@ public enum InstanceState {
/** /**
* the instance is stopped * the instance is stopped
*/ */
STOPPED; STOPPED, UNRECOGNIZED;
public String value() { public String value() {
return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name())); return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name()));
@ -74,8 +74,11 @@ public enum InstanceState {
} }
public static InstanceState fromValue(String state) { public static InstanceState fromValue(String state) {
return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, try {
"state"))); return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state")));
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
public static InstanceState fromValue(int v) { public static InstanceState fromValue(int v) {
@ -93,7 +96,7 @@ public enum InstanceState {
case 80: case 80:
return STOPPED; return STOPPED;
default: default:
throw new IllegalArgumentException("invalid state:" + v); return UNRECOGNIZED;
} }
} }
} }

View File

@ -27,7 +27,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/ */
public enum IpProtocol { public enum IpProtocol {
TCP, UDP, ICMP; TCP, UDP, ICMP, UNRECOGNIZED;
public String value() { public String value() {
return name().toLowerCase(); return name().toLowerCase();
@ -39,7 +39,11 @@ public enum IpProtocol {
} }
public static IpProtocol fromValue(String protocol) { public static IpProtocol fromValue(String protocol) {
return valueOf(checkNotNull(protocol, "protocol").toUpperCase()); try {
return valueOf(checkNotNull(protocol, "protocol").toUpperCase());
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }

View File

@ -35,7 +35,7 @@ import org.jclouds.aws.ec2.services.MonitoringClient;
*/ */
public enum MonitoringState { public enum MonitoringState {
PENDING, ENABLED, DISABLING, DISABLED; PENDING, ENABLED, DISABLING, DISABLED, UNRECOGNIZED;
public String value() { public String value() {
return name().toLowerCase(); return name().toLowerCase();
@ -54,6 +54,10 @@ public enum MonitoringState {
return DISABLED; return DISABLED;
if ("true".endsWith(state)) if ("true".endsWith(state))
return ENABLED; return ENABLED;
return valueOf(checkNotNull(state, "state").toUpperCase()); try {
return valueOf(checkNotNull(state, "state").toUpperCase());
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }

View File

@ -41,7 +41,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/ */
public class PlacementGroup implements Comparable<PlacementGroup> { public class PlacementGroup implements Comparable<PlacementGroup> {
public static enum State { public static enum State {
PENDING, AVAILABLE, DELETING, DELETED; PENDING, AVAILABLE, DELETING, DELETED, UNRECOGNIZED;
public String value() { public String value() {
return name().toLowerCase(); return name().toLowerCase();
} }
@ -52,7 +52,11 @@ public class PlacementGroup implements Comparable<PlacementGroup> {
} }
public static State fromValue(String state) { public static State fromValue(String state) {
return valueOf(checkNotNull(state, "state").toUpperCase()); try {
return valueOf(checkNotNull(state, "state").toUpperCase());
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }
@ -146,8 +150,7 @@ public class PlacementGroup implements Comparable<PlacementGroup> {
@Override @Override
public String toString() { public String toString() {
return "[name=" + name + ", region=" + region + ", state=" + state + ", strategy=" + strategy return "[name=" + name + ", region=" + region + ", state=" + state + ", strategy=" + strategy + "]";
+ "]";
} }
} }

View File

@ -31,7 +31,7 @@ public enum RootDeviceType {
INSTANCE_STORE, INSTANCE_STORE,
EBS; EBS, UNRECOGNIZED;
public String value() { public String value() {
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name()); return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name());
@ -42,6 +42,10 @@ public enum RootDeviceType {
} }
public static RootDeviceType fromValue(String v) { public static RootDeviceType fromValue(String v) {
return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, v)); try {
return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, v));
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }

View File

@ -31,7 +31,7 @@ import java.util.Date;
*/ */
public class Snapshot implements Comparable<Snapshot> { public class Snapshot implements Comparable<Snapshot> {
public static enum Status { public static enum Status {
PENDING, COMPLETED, ERROR; PENDING, COMPLETED, ERROR, UNRECOGNIZED;
public String value() { public String value() {
return name().toLowerCase(); return name().toLowerCase();
} }
@ -42,7 +42,11 @@ public class Snapshot implements Comparable<Snapshot> {
} }
public static Status fromValue(String status) { public static Status fromValue(String status) {
return valueOf(checkNotNull(status, "status").toUpperCase()); try {
return valueOf(checkNotNull(status, "status").toUpperCase());
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }
@ -57,8 +61,8 @@ public class Snapshot implements Comparable<Snapshot> {
private final String description; private final String description;
private final String ownerAlias; private final String ownerAlias;
public Snapshot(String region, String id, String volumeId, int volumeSize, Status status, public Snapshot(String region, String id, String volumeId, int volumeSize, Status status, Date startTime,
Date startTime, int progress, String ownerId, String description, String ownerAlias) { int progress, String ownerId, String description, String ownerAlias) {
this.region = checkNotNull(region, "region"); this.region = checkNotNull(region, "region");
this.id = id; this.id = id;
this.volumeId = volumeId; this.volumeId = volumeId;
@ -135,8 +139,8 @@ public class Snapshot implements Comparable<Snapshot> {
} }
/** /**
* The AWS identity alias (e.g., "amazon", "redhat", "self", etc.) or AWS identity ID that owns the * The AWS identity alias (e.g., "amazon", "redhat", "self", etc.) or AWS identity ID that owns
* AMI. * the AMI.
*/ */
public String getOwnerAlias() { public String getOwnerAlias() {
return ownerAlias; return ownerAlias;
@ -217,10 +221,9 @@ public class Snapshot implements Comparable<Snapshot> {
@Override @Override
public String toString() { public String toString() {
return "Snapshot [description=" + description + ", id=" + id + ", ownerAlias=" + ownerAlias return "Snapshot [description=" + description + ", id=" + id + ", ownerAlias=" + ownerAlias + ", ownerId="
+ ", ownerId=" + ownerId + ", progress=" + progress + ", startTime=" + startTime + ownerId + ", progress=" + progress + ", startTime=" + startTime + ", status=" + status + ", volumeId="
+ ", status=" + status + ", volumeId=" + volumeId + ", volumeSize=" + volumeSize + volumeId + ", volumeSize=" + volumeSize + "]";
+ "]";
} }
@Override @Override

View File

@ -46,7 +46,7 @@ public class Volume implements Comparable<Volume> {
* @author Adrian Cole * @author Adrian Cole
*/ */
public static enum InstanceInitiatedShutdownBehavior { public static enum InstanceInitiatedShutdownBehavior {
STOP, TERMINATE; STOP, TERMINATE, UNRECOGNIZED;
public String value() { public String value() {
return name().toLowerCase(); return name().toLowerCase();
} }
@ -57,12 +57,16 @@ public class Volume implements Comparable<Volume> {
} }
public static InstanceInitiatedShutdownBehavior fromValue(String status) { public static InstanceInitiatedShutdownBehavior fromValue(String status) {
return valueOf(checkNotNull(status, "status").toUpperCase()); try {
return valueOf(checkNotNull(status, "status").toUpperCase());
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }
public static enum Status { public static enum Status {
CREATING, AVAILABLE, IN_USE, DELETING; CREATING, AVAILABLE, IN_USE, DELETING, UNRECOGNIZED;
public String value() { public String value() {
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name()); return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name());
} }
@ -73,8 +77,11 @@ public class Volume implements Comparable<Volume> {
} }
public static Status fromValue(String status) { public static Status fromValue(String status) {
return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull( try {
status, "status"))); return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(status, "status")));
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }
@ -88,9 +95,8 @@ public class Volume implements Comparable<Volume> {
private final Date createTime; private final Date createTime;
private final Set<Attachment> attachments = Sets.newLinkedHashSet(); private final Set<Attachment> attachments = Sets.newLinkedHashSet();
public Volume(String region, String id, int size, String snapshotId, public Volume(String region, String id, int size, String snapshotId, String availabilityZone, Volume.Status status,
String availabilityZone, Volume.Status status, Date createTime, Date createTime, Iterable<Attachment> attachments) {
Iterable<Attachment> attachments) {
this.region = checkNotNull(region, "region"); this.region = checkNotNull(region, "region");
this.id = id; this.id = id;
this.size = size; this.size = size;
@ -208,8 +214,8 @@ public class Volume implements Comparable<Volume> {
@Override @Override
public String toString() { public String toString() {
return "Volume [attachments=" + attachments + ", availabilityZone=" + availabilityZone return "Volume [attachments=" + attachments + ", availabilityZone=" + availabilityZone + ", createTime="
+ ", createTime=" + createTime + ", id=" + id + ", region=" + region + ", size=" + createTime + ", id=" + id + ", region=" + region + ", size=" + size + ", snapshotId=" + snapshotId
+ size + ", snapshotId=" + snapshotId + ", status=" + status + "]"; + ", status=" + status + "]";
} }
} }

View File

@ -61,13 +61,17 @@ import com.google.common.base.CaseFormat;
* "http://docs.amazonwebservices.com/AmazonS3/latest/index.html?RESTrequestPaymentGET.html" /> * "http://docs.amazonwebservices.com/AmazonS3/latest/index.html?RESTrequestPaymentGET.html" />
*/ */
public enum Payer { public enum Payer {
REQUESTER, BUCKET_OWNER; REQUESTER, BUCKET_OWNER, UNRECOGNIZED;
public String value() { public String value() {
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
} }
public static Payer fromValue(String payer) { public static Payer fromValue(String payer) {
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, payer)); try {
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, payer));
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }

View File

@ -56,7 +56,7 @@ public class LocationConstraintHandler extends ParseSax.HandlerWithResult<String
return Region.US_WEST_1; return Region.US_WEST_1;
else if (v.equals(Region.AP_SOUTHEAST_1)) else if (v.equals(Region.AP_SOUTHEAST_1))
return Region.AP_SOUTHEAST_1; return Region.AP_SOUTHEAST_1;
throw new IllegalStateException("unimplemented location: " + v); return v;
} }
public void characters(char ch[], int start, int length) { public void characters(char ch[], int start, int length) {

View File

@ -217,7 +217,7 @@ public class ImageParserTest extends BaseEC2HandlerTest {
assertEquals(image.getOperatingSystem().getArch(), "paravirtual"); assertEquals(image.getOperatingSystem().getArch(), "paravirtual");
assertEquals(image.getOperatingSystem().getDescription(), assertEquals(image.getOperatingSystem().getDescription(),
"vostok-builds/vostok-0.95-5622/vostok-0.95-5622.manifest.xml"); "vostok-builds/vostok-0.95-5622/vostok-0.95-5622.manifest.xml");
assertEquals(image.getOperatingSystem().getFamily(), OsFamily.UNKNOWN); assertEquals(image.getOperatingSystem().getFamily(), OsFamily.UNRECOGNIZED);
assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "133804938231", "rootDeviceType", assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "133804938231", "rootDeviceType",
"instance-store")); "instance-store"));
assertEquals(image.getVersion(), "5622"); assertEquals(image.getVersion(), "5622");

View File

@ -27,7 +27,7 @@ import com.google.common.base.CaseFormat;
* @author Adrian Cole * @author Adrian Cole
*/ */
public enum BlobType { public enum BlobType {
BLOCK_BLOB, PAGE_BLOB; BLOCK_BLOB, PAGE_BLOB, UNRECOGNIZED;
public String value() { public String value() {
return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name())); return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()));
@ -39,7 +39,10 @@ public enum BlobType {
} }
public static BlobType fromValue(String type) { public static BlobType fromValue(String type) {
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, try {
"type"))); return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type")));
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }

View File

@ -27,7 +27,7 @@ import com.google.common.base.CaseFormat;
* @author Adrian Cole * @author Adrian Cole
*/ */
public enum LeaseStatus { public enum LeaseStatus {
LOCKED, UNLOCKED; LOCKED, UNLOCKED, UNRECOGNIZED;
public String value() { public String value() {
return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name())); return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()));
@ -39,7 +39,10 @@ public enum LeaseStatus {
} }
public static LeaseStatus fromValue(String type) { public static LeaseStatus fromValue(String type) {
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, try {
"type"))); return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type")));
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }

View File

@ -287,10 +287,10 @@ See http://code.google.com/p/jclouds for details."
[#^NodeMetadata node] [#^NodeMetadata node]
(state-predicate node ERROR)) (state-predicate node ERROR))
(defn unknown-state? (defn unrecognized-state?
"Predicate for the node being in an unknown state." "Predicate for the node being in an unrecognized state."
[#^NodeMetadata node] [#^NodeMetadata node]
(state-predicate node UNKNOWN)) (state-predicate node UNRECOGNIZED))
(defn public-ips (defn public-ips
"Returns the node's public ips" "Returns the node's public ips"

View File

@ -46,8 +46,8 @@ public enum NodeState {
*/ */
ERROR, ERROR,
/** /**
* The state of the node is unknown. * The state of the node is unrecognized.
*/ */
UNKNOWN; UNRECOGNIZED;
} }

View File

@ -30,7 +30,7 @@ import com.google.common.base.CaseFormat;
* @author Adrian Cole * @author Adrian Cole
*/ */
public enum OsFamily { public enum OsFamily {
UNKNOWN, AIX, ARCH, CENTOS, DARWIN, DEBIAN, ESX, FEDORA, FREEBSD, GENTOO, HPUX, LINUX, UNRECOGNIZED, AIX, ARCH, CENTOS, DARWIN, DEBIAN, ESX, FEDORA, FREEBSD, GENTOO, HPUX, LINUX,
/** /**
* @see <a href="http://aws.amazon.com/amazon-linux-ami/">amazon linux ami</a> * @see <a href="http://aws.amazon.com/amazon-linux-ami/">amazon linux ami</a>
*/ */
@ -53,7 +53,7 @@ public enum OsFamily {
try { try {
return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(osFamily, "osFamily"))); return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(osFamily, "osFamily")));
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
return UNKNOWN; return UNRECOGNIZED;
} }
} }
} }

View File

@ -28,8 +28,7 @@ import com.google.common.annotations.Beta;
* Operating system based on DMTF CIM model. * Operating system based on DMTF CIM model.
* *
* @author Adrian Cole * @author Adrian Cole
* @see <a href="http://dmtf.org/standards/cim/cim_schema_v2260">DMTF CIM * @see <a href="http://dmtf.org/standards/cim/cim_schema_v2260">DMTF CIM model</a>
* model</a>
*/ */
@Beta @Beta
public class CIMOperatingSystem extends OperatingSystem { public class CIMOperatingSystem extends OperatingSystem {
@ -38,7 +37,7 @@ public class CIMOperatingSystem extends OperatingSystem {
/** /**
* Other * Other
*/ */
OTHER(1, "Other", OsFamily.UNKNOWN, false), OTHER(1, "Other", OsFamily.UNRECOGNIZED, false),
/** /**
* MACOS * MACOS
*/ */
@ -66,7 +65,7 @@ public class CIMOperatingSystem extends OperatingSystem {
/** /**
* Not Applicable * Not Applicable
*/ */
NOT_APPLICABLE(66, "Not Applicable", OsFamily.UNKNOWN, false), NOT_APPLICABLE(66, "Not Applicable", OsFamily.UNRECOGNIZED, false),
/** /**
* Microsoft Windows Server 2003 * Microsoft Windows Server 2003
*/ */
@ -174,7 +173,7 @@ public class CIMOperatingSystem extends OperatingSystem {
/** /**
* Other 64-Bit * Other 64-Bit
*/ */
OTHER_64(102, "Other 64-Bit", OsFamily.UNKNOWN, true), OTHER_64(102, "Other 64-Bit", OsFamily.UNRECOGNIZED, true),
/** /**
* Microsoft Windows Server 2008 R2 * Microsoft Windows Server 2008 R2
*/ */
@ -202,7 +201,8 @@ public class CIMOperatingSystem extends OperatingSystem {
/** /**
* Oracle Enterprise Linux 64-bit * Oracle Enterprise Linux 64-bit
*/ */
ORACLE_ENTERPRISE_LINUX_64(109, "Oracle Enterprise Linux 64-bit", OsFamily.OEL, true); ORACLE_ENTERPRISE_LINUX_64(109, "Oracle Enterprise Linux 64-bit", OsFamily.OEL, true), UNRECOGNIZED(
Integer.MAX_VALUE, "UNRECOGNIZED", null, true);
private final int code; private final int code;
@ -238,7 +238,7 @@ public class CIMOperatingSystem extends OperatingSystem {
if (type.code == code) if (type.code == code)
return type; return type;
} }
return OTHER; return UNRECOGNIZED;
} }
} }
@ -253,6 +253,7 @@ public class CIMOperatingSystem extends OperatingSystem {
super(osType.getFamily(), osType.getValue(), version, arch, description, osType.is64Bit()); super(osType.getFamily(), osType.getValue(), version, arch, description, osType.is64Bit());
this.osType = osType; this.osType = osType;
} }
/** /**
* CIM OSType of the image * CIM OSType of the image
*/ */
@ -288,6 +289,6 @@ public class CIMOperatingSystem extends OperatingSystem {
@Override @Override
public String toString() { public String toString() {
return "[osType=" + osType + ", version=" + getVersion() + ", arch=" + getArch() + ", description=" return "[osType=" + osType + ", version=" + getVersion() + ", arch=" + getArch() + ", description="
+ getDescription() + "]"; + getDescription() + "]";
} }
} }

View File

@ -114,6 +114,7 @@ public class GoGridComputeServiceContextModule extends BaseComputeServiceContext
.put(ServerState.STOPPING, NodeState.PENDING)// .put(ServerState.STOPPING, NodeState.PENDING)//
.put(ServerState.RESTARTING, NodeState.PENDING)// .put(ServerState.RESTARTING, NodeState.PENDING)//
.put(ServerState.SAVING, NodeState.PENDING)// .put(ServerState.SAVING, NodeState.PENDING)//
.put(ServerState.UNRECOGNIZED, NodeState.UNRECOGNIZED)//
.put(ServerState.RESTORING, NodeState.PENDING)// .put(ServerState.RESTORING, NodeState.PENDING)//
.put(ServerState.UPDATING, NodeState.PENDING).build(); .put(ServerState.UPDATING, NodeState.PENDING).build();

View File

@ -27,13 +27,17 @@ import static com.google.common.base.Preconditions.checkNotNull;
* @author Oleksiy Yarmula * @author Oleksiy Yarmula
*/ */
public enum IpState { public enum IpState {
UNASSIGNED, ASSIGNED; UNASSIGNED, ASSIGNED, UNRECOGNIZED;
public String toString() { public String toString() {
return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name())); return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()));
} }
public static IpState fromValue(String state) { public static IpState fromValue(String state) {
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state"))); try {
} return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state")));
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
}
} }

View File

@ -31,7 +31,7 @@ public enum JobState {
"Change request has succeeded."), FAILED("Failed", "Change request has failed."), CANCELED( "Change request has succeeded."), FAILED("Failed", "Change request has failed."), CANCELED(
"Canceled", "Change request has been canceled."), FATAL("Fatal", "Canceled", "Change request has been canceled."), FATAL("Fatal",
"Change request had Fatal or Unrecoverable Failure"), CREATED("Created", "Change request had Fatal or Unrecoverable Failure"), CREATED("Created",
"Change request is created but not queued yet"), UNKNOWN("Unknown", "Change request is created but not queued yet"), UNRECOGNIZED("Unknown",
"The state is unknown to JClouds"); "The state is unknown to JClouds");
String name; String name;
@ -52,7 +52,7 @@ public enum JobState {
if (jobState.name.equals(checkNotNull(state))) if (jobState.name.equals(checkNotNull(state)))
return jobState; return jobState;
} }
return UNKNOWN; return UNRECOGNIZED;
} }
} }

View File

@ -27,13 +27,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
public enum LoadBalancerOs { public enum LoadBalancerOs {
F5, F5,
UNKNOWN; UNRECOGNIZED;
public static LoadBalancerOs fromValue(String value) { public static LoadBalancerOs fromValue(String value) {
try { try {
return valueOf(checkNotNull(value)); return valueOf(checkNotNull(value));
} catch(IllegalArgumentException e) { } catch(IllegalArgumentException e) {
return UNKNOWN; return UNRECOGNIZED;
} }
} }

View File

@ -26,7 +26,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/ */
public enum LoadBalancerPersistenceType { public enum LoadBalancerPersistenceType {
NONE("None"), SSL_STICKY("SSL Sticky"), SOURCE_ADDRESS("Source Address"), UNKNOWN("Unknown"); NONE("None"), SSL_STICKY("SSL Sticky"), SOURCE_ADDRESS("Source Address"), UNRECOGNIZED("Unknown");
String type; String type;
@ -44,6 +44,6 @@ public enum LoadBalancerPersistenceType {
if (persistenceType.type.equals(checkNotNull(type))) if (persistenceType.type.equals(checkNotNull(type)))
return persistenceType; return persistenceType;
} }
return UNKNOWN; return UNRECOGNIZED;
} }
} }

View File

@ -31,7 +31,7 @@ public enum LoadBalancerState {
ON, ON,
OFF, OFF,
UNAVAILABLE, UNAVAILABLE,
UNKNOWN; UNRECOGNIZED;
public String value() { public String value() {
return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name())); return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()));
@ -46,7 +46,7 @@ public enum LoadBalancerState {
try { try {
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state"))); return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state")));
} catch(IllegalArgumentException e) { } catch(IllegalArgumentException e) {
return UNKNOWN; return UNRECOGNIZED;
} }
} }

View File

@ -28,7 +28,7 @@ public enum LoadBalancerType {
ROUND_ROBIN("Round Robin"), ROUND_ROBIN("Round Robin"),
LEAST_CONNECTED("Least Connect"), LEAST_CONNECTED("Least Connect"),
UNKNOWN("Unknown"); UNRECOGNIZED("Unknown");
String type; String type;
LoadBalancerType(String type) { LoadBalancerType(String type) {
@ -44,7 +44,7 @@ public enum LoadBalancerType {
for(LoadBalancerType persistenceType : values()) { for(LoadBalancerType persistenceType : values()) {
if(persistenceType.type.equals(checkNotNull(type))) return persistenceType; if(persistenceType.type.equals(checkNotNull(type))) return persistenceType;
} }
return UNKNOWN; return UNRECOGNIZED;
} }
} }

View File

@ -34,7 +34,7 @@ public enum ObjectType {
STORAGE_DNS, STORAGE_DNS,
SERVER_IMAGE, SERVER_IMAGE,
DEDICATED_SERVER, DEDICATED_SERVER,
UNKNOWN; UNRECOGNIZED;
public String value() { public String value() {
return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name())); return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()));
@ -50,7 +50,7 @@ public enum ObjectType {
try { try {
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type"))); return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type")));
} catch(IllegalArgumentException e) { } catch(IllegalArgumentException e) {
return UNKNOWN; return UNRECOGNIZED;
} }
} }

View File

@ -28,7 +28,7 @@ public enum ServerImageState {
AVAILABLE("Available"), AVAILABLE("Available"),
SAVING("Saving"), SAVING("Saving"),
UNKNOWN("Unknown"); UNRECOGNIZED("Unknown");
String type; String type;
ServerImageState(String type) { ServerImageState(String type) {
@ -44,6 +44,6 @@ public enum ServerImageState {
for(ServerImageState serverImageState : values()) { for(ServerImageState serverImageState : values()) {
if(serverImageState.type.equals(checkNotNull(type))) return serverImageState; if(serverImageState.type.equals(checkNotNull(type))) return serverImageState;
} }
return UNKNOWN; return UNRECOGNIZED;
} }
} }

View File

@ -28,7 +28,7 @@ public enum ServerImageType {
WEB_APPLICATION_SERVER("Web Server"), WEB_APPLICATION_SERVER("Web Server"),
DATABASE_SERVER("Database Server"), DATABASE_SERVER("Database Server"),
UNKNOWN("Unknown"); UNRECOGNIZED("Unknown");
String type; String type;
ServerImageType(String type) { ServerImageType(String type) {
@ -44,6 +44,6 @@ public enum ServerImageType {
for(ServerImageType serverImageType : values()) { for(ServerImageType serverImageType : values()) {
if(serverImageType.type.equals(checkNotNull(type))) return serverImageType; if(serverImageType.type.equals(checkNotNull(type))) return serverImageType;
} }
return UNKNOWN; return UNRECOGNIZED;
} }
} }

View File

@ -28,7 +28,7 @@ import com.google.common.base.CaseFormat;
*/ */
public enum ServerState { public enum ServerState {
ON, STARTING, OFF, STOPPING, RESTARTING, SAVING, RESTORING, UPDATING; ON, STARTING, OFF, STOPPING, RESTARTING, SAVING, RESTORING, UPDATING, UNRECOGNIZED;
public String value() { public String value() {
return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name())); return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()));
@ -40,6 +40,10 @@ public enum ServerState {
} }
public static ServerState fromValue(String state) { public static ServerState fromValue(String state) {
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state"))); try {
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state")));
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }

View File

@ -125,7 +125,7 @@ public class CloudServersComputeServiceContextModule extends BaseComputeServiceC
.put(ServerStatus.SHARE_IP, NodeState.PENDING)// .put(ServerStatus.SHARE_IP, NodeState.PENDING)//
.put(ServerStatus.REBOOT, NodeState.PENDING)// .put(ServerStatus.REBOOT, NodeState.PENDING)//
.put(ServerStatus.HARD_REBOOT, NodeState.PENDING)// .put(ServerStatus.HARD_REBOOT, NodeState.PENDING)//
.put(ServerStatus.UNKNOWN, NodeState.UNKNOWN).build(); .put(ServerStatus.UNRECOGNIZED, NodeState.UNRECOGNIZED).build();
@Singleton @Singleton
@Provides @Provides

View File

@ -21,26 +21,18 @@ package org.jclouds.rackspace.cloudservers.domain;
public enum DailyBackup { public enum DailyBackup {
DISABLED, DISABLED, H_0000_0200, H_0200_0400, H_0400_0600, H_0600_0800, H_0800_1000, H_1000_1200, H_1200_1400, H_1400_1600, H_1600_1800, H_1800_2000, H_2000_2200, H_2200_0000, UNRECOGNIZED;
H_0000_0200,
H_0200_0400,
H_0400_0600,
H_0600_0800,
H_0800_1000,
H_1000_1200,
H_1200_1400,
H_1400_1600,
H_1600_1800,
H_1800_2000,
H_2000_2200,
H_2200_0000;
public String value() { public String value() {
return name(); return name();
} }
public static DailyBackup fromValue(String v) { public static DailyBackup fromValue(String v) {
return valueOf(v); try {
} return valueOf(v);
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
}
} }

View File

@ -29,14 +29,18 @@ package org.jclouds.rackspace.cloudservers.domain;
*/ */
public enum ImageStatus { public enum ImageStatus {
UNKNOWN, ACTIVE, SAVING, PREPARING, QUEUED, FAILED; UNRECOGNIZED, ACTIVE, SAVING, PREPARING, QUEUED, FAILED;
public String value() { public String value() {
return name(); return name();
} }
public static ImageStatus fromValue(String v) { public static ImageStatus fromValue(String v) {
return valueOf(v); try {
return valueOf(v);
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }

View File

@ -21,14 +21,18 @@ package org.jclouds.rackspace.cloudservers.domain;
public enum RateLimitUnit { public enum RateLimitUnit {
MINUTE, HOUR, DAY; MINUTE, HOUR, DAY, UNRECOGNIZED;
public String value() { public String value() {
return name(); return name();
} }
public static RateLimitUnit fromValue(String v) { public static RateLimitUnit fromValue(String v) {
return valueOf(v); try {
return valueOf(v);
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }

View File

@ -29,21 +29,27 @@ package org.jclouds.rackspace.cloudservers.domain;
* available. The 'ACTIVE' label is really misleading in the fact that it just means the system * available. The 'ACTIVE' label is really misleading in the fact that it just means the system
* doesn't have any activity going on related to it's configuration. * doesn't have any activity going on related to it's configuration.
* <p/> * <p/>
* Processes such as ssh will not be available until 5-10 seconds following the phase ACTIVE * Processes such as ssh will not be available until 5-10 seconds following the phase ACTIVE
* <ul><li>[Web Hosting #119335]</li></ul> * <ul>
* <li>[Web Hosting #119335]</li>
* </ul>
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public enum ServerStatus { public enum ServerStatus {
ACTIVE, SUSPENDED, DELETED, QUEUE_RESIZE, PREP_RESIZE, RESIZE, VERIFY_RESIZE, QUEUE_MOVE, PREP_MOVE, MOVE, VERIFY_MOVE, RESCUE, ERROR, BUILD, RESTORING, PASSWORD, REBUILD, DELETE_IP, SHARE_IP_NO_CONFIG, SHARE_IP, REBOOT, HARD_REBOOT, UNKNOWN; ACTIVE, SUSPENDED, DELETED, QUEUE_RESIZE, PREP_RESIZE, RESIZE, VERIFY_RESIZE, QUEUE_MOVE, PREP_MOVE, MOVE, VERIFY_MOVE, RESCUE, ERROR, BUILD, RESTORING, PASSWORD, REBUILD, DELETE_IP, SHARE_IP_NO_CONFIG, SHARE_IP, REBOOT, HARD_REBOOT, UNRECOGNIZED;
public String value() { public String value() {
return name(); return name();
} }
public static ServerStatus fromValue(String v) { public static ServerStatus fromValue(String v) {
return valueOf(v); try {
return valueOf(v);
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }

View File

@ -21,14 +21,18 @@ package org.jclouds.rackspace.cloudservers.domain;
public enum VersionStatus { public enum VersionStatus {
BETA, CURRENT, DEPRECATED; BETA, CURRENT, DEPRECATED, UNRECOGNIZED;
public String value() { public String value() {
return name(); return name();
} }
public static VersionStatus fromValue(String v) { public static VersionStatus fromValue(String v) {
return valueOf(v); try {
return valueOf(v);
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }

View File

@ -21,14 +21,18 @@ package org.jclouds.rackspace.cloudservers.domain;
public enum WeeklyBackup { public enum WeeklyBackup {
DISABLED, SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY; DISABLED, SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, UNRECOGNIZED;
public String value() { public String value() {
return name(); return name();
} }
public static WeeklyBackup fromValue(String v) { public static WeeklyBackup fromValue(String v) {
return valueOf(v); try {
return valueOf(v);
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }

View File

@ -31,10 +31,10 @@ import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.LoadBalancerService; import org.jclouds.compute.LoadBalancerService;
import org.jclouds.compute.config.BaseComputeServiceContextModule; import org.jclouds.compute.config.BaseComputeServiceContextModule;
import org.jclouds.compute.config.ComputeServiceTimeoutsModule; import org.jclouds.compute.config.ComputeServiceTimeoutsModule;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.compute.internal.ComputeServiceContextImpl; import org.jclouds.compute.internal.ComputeServiceContextImpl;
import org.jclouds.compute.strategy.AddNodeWithTagStrategy; import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
@ -53,9 +53,9 @@ import org.jclouds.rimuhosting.miro.compute.strategy.RimuHostingDestroyNodeStrat
import org.jclouds.rimuhosting.miro.compute.strategy.RimuHostingGetNodeMetadataStrategy; import org.jclouds.rimuhosting.miro.compute.strategy.RimuHostingGetNodeMetadataStrategy;
import org.jclouds.rimuhosting.miro.compute.strategy.RimuHostingListNodesStrategy; import org.jclouds.rimuhosting.miro.compute.strategy.RimuHostingListNodesStrategy;
import org.jclouds.rimuhosting.miro.compute.strategy.RimuHostingRebootNodeStrategy; import org.jclouds.rimuhosting.miro.compute.strategy.RimuHostingRebootNodeStrategy;
import org.jclouds.rimuhosting.miro.compute.suppliers.RimuHostingHardwareSupplier;
import org.jclouds.rimuhosting.miro.compute.suppliers.RimuHostingImageSupplier; import org.jclouds.rimuhosting.miro.compute.suppliers.RimuHostingImageSupplier;
import org.jclouds.rimuhosting.miro.compute.suppliers.RimuHostingLocationSupplier; import org.jclouds.rimuhosting.miro.compute.suppliers.RimuHostingLocationSupplier;
import org.jclouds.rimuhosting.miro.compute.suppliers.RimuHostingHardwareSupplier;
import org.jclouds.rimuhosting.miro.domain.Server; import org.jclouds.rimuhosting.miro.domain.Server;
import org.jclouds.rimuhosting.miro.domain.internal.RunningState; import org.jclouds.rimuhosting.miro.domain.internal.RunningState;
@ -116,6 +116,7 @@ public class RimuHostingComputeServiceContextModule extends BaseComputeServiceCo
.put(RunningState.NOTRUNNING, NodeState.SUSPENDED)// .put(RunningState.NOTRUNNING, NodeState.SUSPENDED)//
.put(RunningState.POWERCYCLING, NodeState.PENDING)// .put(RunningState.POWERCYCLING, NodeState.PENDING)//
.put(RunningState.RESTARTING, NodeState.PENDING)// .put(RunningState.RESTARTING, NodeState.PENDING)//
.put(RunningState.UNRECOGNIZED, NodeState.UNRECOGNIZED)//
.build(); .build();
@Singleton @Singleton

View File

@ -19,11 +19,21 @@
package org.jclouds.rimuhosting.miro.domain.internal; package org.jclouds.rimuhosting.miro.domain.internal;
/** /**
* States an instance can be in. * States an instance can be in.
* *
* @author Ivan Meredith * @author Ivan Meredith
*/ */
public enum RunningState { public enum RunningState {
RUNNING, NOTRUNNING, RESTARTING, POWERCYCLING RUNNING, NOTRUNNING, RESTARTING, POWERCYCLING, UNRECOGNIZED;
public static RunningState fromValue(String v) {
try {
return valueOf(v);
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
}
} }

View File

@ -30,10 +30,10 @@ import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.LoadBalancerService; import org.jclouds.compute.LoadBalancerService;
import org.jclouds.compute.config.BaseComputeServiceContextModule; import org.jclouds.compute.config.BaseComputeServiceContextModule;
import org.jclouds.compute.config.ComputeServiceTimeoutsModule; import org.jclouds.compute.config.ComputeServiceTimeoutsModule;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.compute.internal.BaseComputeService; import org.jclouds.compute.internal.BaseComputeService;
import org.jclouds.compute.internal.ComputeServiceContextImpl; import org.jclouds.compute.internal.ComputeServiceContextImpl;
@ -56,8 +56,8 @@ import org.jclouds.slicehost.compute.strategy.SlicehostDestroyNodeStrategy;
import org.jclouds.slicehost.compute.strategy.SlicehostGetNodeMetadataStrategy; import org.jclouds.slicehost.compute.strategy.SlicehostGetNodeMetadataStrategy;
import org.jclouds.slicehost.compute.strategy.SlicehostListNodesStrategy; import org.jclouds.slicehost.compute.strategy.SlicehostListNodesStrategy;
import org.jclouds.slicehost.compute.strategy.SlicehostRebootNodeStrategy; import org.jclouds.slicehost.compute.strategy.SlicehostRebootNodeStrategy;
import org.jclouds.slicehost.compute.suppliers.SlicehostImageSupplier;
import org.jclouds.slicehost.compute.suppliers.SlicehostHardwareSupplier; import org.jclouds.slicehost.compute.suppliers.SlicehostHardwareSupplier;
import org.jclouds.slicehost.compute.suppliers.SlicehostImageSupplier;
import org.jclouds.slicehost.domain.Slice; import org.jclouds.slicehost.domain.Slice;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
@ -109,6 +109,7 @@ public class SlicehostComputeServiceContextModule extends BaseComputeServiceCont
.put(Slice.Status.REBOOT, NodeState.PENDING)// .put(Slice.Status.REBOOT, NodeState.PENDING)//
.put(Slice.Status.HARD_REBOOT, NodeState.PENDING)// .put(Slice.Status.HARD_REBOOT, NodeState.PENDING)//
.put(Slice.Status.TERMINATED, NodeState.TERMINATED)// .put(Slice.Status.TERMINATED, NodeState.TERMINATED)//
.put(Slice.Status.UNRECOGNIZED, NodeState.UNRECOGNIZED)//
.build(); .build();
@Singleton @Singleton

View File

@ -28,8 +28,8 @@ import javax.annotation.Nullable;
import com.google.common.base.CaseFormat; import com.google.common.base.CaseFormat;
/** /**
* A slice is a virtual machine instance in the Slicehost system. Flavor and * A slice is a virtual machine instance in the Slicehost system. Flavor and image are requisite
* image are requisite elements when creating a slice. * elements when creating a slice.
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@ -40,7 +40,7 @@ public class Slice {
*/ */
public enum Status { public enum Status {
ACTIVE, BUILD, REBOOT, HARD_REBOOT, TERMINATED; ACTIVE, BUILD, REBOOT, HARD_REBOOT, TERMINATED, UNRECOGNIZED;
public String value() { public String value() {
return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_UNDERSCORE, name())); return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_UNDERSCORE, name()));
@ -52,7 +52,11 @@ public class Slice {
} }
public static Status fromValue(String state) { public static Status fromValue(String state) {
return valueOf(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state"))); try {
return valueOf(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state")));
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }
@ -73,8 +77,8 @@ public class Slice {
private final String rootPassword; private final String rootPassword;
public Slice(int id, String name, int flavorId, @Nullable Integer imageId, @Nullable Integer backupId, public Slice(int id, String name, int flavorId, @Nullable Integer imageId, @Nullable Integer backupId,
Status status, @Nullable Integer progress, float bandwidthIn, float bandwidthOut, Set<String> addresses, Status status, @Nullable Integer progress, float bandwidthIn, float bandwidthOut, Set<String> addresses,
@Nullable String rootPassword) { @Nullable String rootPassword) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.flavorId = flavorId; this.flavorId = flavorId;
@ -145,8 +149,7 @@ public class Slice {
} }
/** /**
* @return an array of strings representing the Slice's IPs, including * @return an array of strings representing the Slice's IPs, including private IPs
* private IPs
*/ */
public Set<String> getAddresses() { public Set<String> getAddresses() {
return addresses; return addresses;
@ -242,9 +245,9 @@ public class Slice {
@Override @Override
public String toString() { public String toString() {
return "[id=" + id + ", name=" + name + ", flavorId=" + flavorId + ", imageId=" + imageId + ", backupId=" return "[id=" + id + ", name=" + name + ", flavorId=" + flavorId + ", imageId=" + imageId + ", backupId="
+ backupId + ", status=" + status + ", progress=" + progress + ", bandwidthIn=" + bandwidthIn + backupId + ", status=" + status + ", progress=" + progress + ", bandwidthIn=" + bandwidthIn
+ ", bandwidthOut=" + bandwidthOut + ", addresses=" + addresses + ", rootPassword=" + ", bandwidthOut=" + bandwidthOut + ", addresses=" + addresses + ", rootPassword="
+ (rootPassword != null) + "]"; + (rootPassword != null) + "]";
} }
} }

View File

@ -27,9 +27,9 @@ import javax.inject.Singleton;
import org.jclouds.compute.LoadBalancerService; import org.jclouds.compute.LoadBalancerService;
import org.jclouds.compute.config.BaseComputeServiceContextModule; import org.jclouds.compute.config.BaseComputeServiceContextModule;
import org.jclouds.compute.config.ComputeServiceTimeoutsModule; import org.jclouds.compute.config.ComputeServiceTimeoutsModule;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy; import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy;
import org.jclouds.compute.strategy.impl.EncodeTagIntoNameRunNodesAndAddToSetStrategy; import org.jclouds.compute.strategy.impl.EncodeTagIntoNameRunNodesAndAddToSetStrategy;
import org.jclouds.domain.Location; import org.jclouds.domain.Location;
@ -56,9 +56,9 @@ public abstract class CommonVCloudComputeServiceContextModule extends BaseComput
@VisibleForTesting @VisibleForTesting
static final Map<Status, NodeState> vAppStatusToNodeState = ImmutableMap.<Status, NodeState> builder().put( static final Map<Status, NodeState> vAppStatusToNodeState = ImmutableMap.<Status, NodeState> builder().put(
Status.OFF, NodeState.SUSPENDED).put(Status.ON, NodeState.RUNNING).put(Status.RESOLVED, NodeState.PENDING) Status.OFF, NodeState.SUSPENDED).put(Status.ON, NodeState.RUNNING).put(Status.RESOLVED, NodeState.PENDING)
.put(Status.ERROR, NodeState.ERROR).put(Status.UNRECOGNIZED, NodeState.UNKNOWN).put(Status.DEPLOYED, .put(Status.ERROR, NodeState.ERROR).put(Status.UNRECOGNIZED, NodeState.UNRECOGNIZED).put(Status.DEPLOYED,
NodeState.PENDING).put(Status.INCONSISTENT, NodeState.PENDING).put(Status.UNKNOWN, NodeState.PENDING).put(Status.INCONSISTENT, NodeState.PENDING).put(Status.UNKNOWN,
NodeState.UNKNOWN).put(Status.MIXED, NodeState.PENDING).put(Status.WAITING_FOR_INPUT, NodeState.UNRECOGNIZED).put(Status.MIXED, NodeState.PENDING).put(Status.WAITING_FOR_INPUT,
NodeState.PENDING).put(Status.SUSPENDED, NodeState.SUSPENDED).put(Status.UNRESOLVED, NodeState.PENDING).put(Status.SUSPENDED, NodeState.SUSPENDED).put(Status.UNRESOLVED,
NodeState.PENDING).build(); NodeState.PENDING).build();

View File

@ -43,7 +43,7 @@ public enum AllocationModel {
/** /**
* The VCloud API returned a model unsupported in the version 1.0 spec. * The VCloud API returned a model unsupported in the version 1.0 spec.
*/ */
UNRECOGNIZED_MODEL; UNRECOGNIZED;
public String value() { public String value() {
switch (this) { switch (this) {
@ -64,6 +64,10 @@ public enum AllocationModel {
} }
public static AllocationModel fromValue(String model) { public static AllocationModel fromValue(String model) {
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(model, "model"))); try {
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(model, "model")));
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }

View File

@ -35,7 +35,7 @@ public enum MappingMode {
/** /**
* the external IP address is assigned automatically * the external IP address is assigned automatically
*/ */
AUTOMATIC; AUTOMATIC, UNRECOGNIZED;
public String value() { public String value() {
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()); return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name());
@ -47,7 +47,11 @@ public enum MappingMode {
} }
public static MappingMode fromValue(String mode) { public static MappingMode fromValue(String mode) {
return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(mode, "mode"))); try {
return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(mode, "mode")));
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }

View File

@ -175,12 +175,16 @@ public enum Status {
case QUARANTINE_EXPIRED: case QUARANTINE_EXPIRED:
return "15"; return "15";
default: default:
throw new IllegalArgumentException("invalid status:" + this); return "7";
} }
} }
public static Status fromValue(String status) { public static Status fromValue(String status) {
return fromValue(Integer.parseInt(checkNotNull(status, "status"))); try {
return fromValue(Integer.parseInt(checkNotNull(status, "status")));
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
public static Status fromValue(int v) { public static Status fromValue(int v) {
@ -218,7 +222,7 @@ public enum Status {
case 15: case 15:
return QUARANTINE_EXPIRED; return QUARANTINE_EXPIRED;
default: default:
throw new IllegalArgumentException("invalid status:" + v); return UNRECOGNIZED;
} }
} }

View File

@ -93,7 +93,9 @@ public interface VAppTemplate extends ReferenceType {
/** /**
* description of the predefined vApp internal networks in this template * description of the predefined vApp internal networks in this template
* *
* @return null if the vAppTemplate is still copying
* @since vcloud api 1.0 * @since vcloud api 1.0
*/ */
@Nullable
VCloudNetworkSection getNetworkSection(); VCloudNetworkSection getNetworkSection();
} }

View File

@ -26,7 +26,7 @@ package org.jclouds.vcloud.domain;
*/ */
public enum VDCStatus { public enum VDCStatus {
CREATION_FAILED, NOT_READY, READY, UNKNOWN, UNRECOGNIZED_STATUS; CREATION_FAILED, NOT_READY, READY, UNKNOWN, UNRECOGNIZED;
public int value() { public int value() {
switch (this) { switch (this) {
@ -54,7 +54,7 @@ public enum VDCStatus {
case 2: case 2:
return UNKNOWN; return UNKNOWN;
default: default:
return UNRECOGNIZED_STATUS; return UNRECOGNIZED;
} }
} }
} }

View File

@ -54,11 +54,13 @@ public class VAppTemplateImpl extends ReferenceTypeImpl implements VAppTemplate
private final boolean ovfDescriptorUploaded; private final boolean ovfDescriptorUploaded;
private final String vAppScopedLocalId; private final String vAppScopedLocalId;
private final Set<Vm> children = Sets.newLinkedHashSet(); private final Set<Vm> children = Sets.newLinkedHashSet();
@Nullable
private final VCloudNetworkSection networkSection; private final VCloudNetworkSection networkSection;
public VAppTemplateImpl(String name, String type, URI id, Status status, ReferenceType vdc, public VAppTemplateImpl(String name, String type, URI id, Status status, ReferenceType vdc,
@Nullable String description, Iterable<Task> tasks, boolean ovfDescriptorUploaded, @Nullable String description, Iterable<Task> tasks, boolean ovfDescriptorUploaded,
@Nullable String vAppScopedLocalId, Iterable<? extends Vm> children, VCloudNetworkSection networkSection) { @Nullable String vAppScopedLocalId, Iterable<? extends Vm> children,
@Nullable VCloudNetworkSection networkSection) {
super(name, type, id); super(name, type, id);
this.status = checkNotNull(status, "status"); this.status = checkNotNull(status, "status");
this.vdc = vdc;// TODO: once <1.0 is killed check not null this.vdc = vdc;// TODO: once <1.0 is killed check not null
@ -67,7 +69,7 @@ public class VAppTemplateImpl extends ReferenceTypeImpl implements VAppTemplate
this.vAppScopedLocalId = vAppScopedLocalId; this.vAppScopedLocalId = vAppScopedLocalId;
this.ovfDescriptorUploaded = ovfDescriptorUploaded; this.ovfDescriptorUploaded = ovfDescriptorUploaded;
Iterables.addAll(this.children, checkNotNull(children, "children")); Iterables.addAll(this.children, checkNotNull(children, "children"));
this.networkSection = checkNotNull(networkSection, "networkSection"); this.networkSection = networkSection; // can be null when copying
} }
/** /**

View File

@ -51,7 +51,7 @@ public enum FenceMode {
* *
* @since vcloud api 0.8 * @since vcloud api 0.8
*/ */
NAT_ROUTED; NAT_ROUTED, UNRECOGNIZED;
public String value() { public String value() {
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()); return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name());
@ -63,7 +63,11 @@ public enum FenceMode {
} }
public static FenceMode fromValue(String fenceMode) { public static FenceMode fromValue(String fenceMode) {
return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(fenceMode, "fenceMode"))); try {
return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(fenceMode, "fenceMode")));
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }

View File

@ -35,7 +35,7 @@ public enum FirewallPolicy {
/** /**
* allow packets of this type to pass through the firewall * allow packets of this type to pass through the firewall
*/ */
ALLOW; ALLOW, UNRECOGNIZED;
public String value() { public String value() {
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()); return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name());
@ -50,7 +50,7 @@ public enum FirewallPolicy {
try { try {
return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(policy, "policy"))); return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(policy, "policy")));
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
return DROP; return UNRECOGNIZED;
} }
} }

View File

@ -35,7 +35,7 @@ public enum NatPolicy {
/** /**
* only inbound packets of this type pass through the firewall * only inbound packets of this type pass through the firewall
*/ */
ALLOW_TRAFFIC_IN; ALLOW_TRAFFIC_IN, UNRECOGNIZED;
public String value() { public String value() {
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()); return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name());
@ -50,7 +50,7 @@ public enum NatPolicy {
try { try {
return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(policy, "policy"))); return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(policy, "policy")));
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
return ALLOW_TRAFFIC_IN; return UNRECOGNIZED;
} }
} }

View File

@ -43,7 +43,7 @@ public enum NatType {
* *
* @since vcloud api 0.9 * @since vcloud api 0.9
*/ */
PORT_FORWARDING; PORT_FORWARDING, UNRECOGNIZED;
public String value() { public String value() {
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()); return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name());
@ -55,6 +55,10 @@ public enum NatType {
} }
public static NatType fromValue(String natType) { public static NatType fromValue(String natType) {
return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(natType, "natType"))); try {
return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(natType, "natType")));
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }

View File

@ -33,7 +33,7 @@ import org.jclouds.vcloud.VCloudExpressAsyncClient;
* *
*/ */
public enum ResourceType { public enum ResourceType {
OTHER, PROCESSOR, MEMORY, IDE_CONTROLLER, SCSI_CONTROLLER, ETHERNET_ADAPTER, FLOPPY_DRIVE, CD_DRIVE, DVD_DRIVE, DISK_DRIVE, USB_CONTROLLER; OTHER, PROCESSOR, MEMORY, IDE_CONTROLLER, SCSI_CONTROLLER, ETHERNET_ADAPTER, FLOPPY_DRIVE, CD_DRIVE, DVD_DRIVE, DISK_DRIVE, USB_CONTROLLER, UNRECOGNIZED;
public String value() { public String value() {
switch (this) { switch (this) {
@ -65,7 +65,11 @@ public enum ResourceType {
} }
public static ResourceType fromValue(String type) { public static ResourceType fromValue(String type) {
return fromValue(Integer.parseInt(checkNotNull(type, "type"))); try {
return fromValue(Integer.parseInt(checkNotNull(type, "type")));
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
public static ResourceType fromValue(int v) { public static ResourceType fromValue(int v) {
@ -93,7 +97,7 @@ public enum ResourceType {
case 23: case 23:
return USB_CONTROLLER; return USB_CONTROLLER;
default: default:
throw new IllegalArgumentException("invalid type:" + v); return UNRECOGNIZED;
} }
} }
} }

View File

@ -22,10 +22,10 @@ package org.jclouds.vcloud.util;
import java.net.URI; import java.net.URI;
import java.util.Map; import java.util.Map;
import org.jclouds.vcloud.domain.Error;
import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.internal.ErrorImpl;
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
import org.jclouds.vcloud.domain.internal.TaskImpl.ErrorImpl;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
@ -57,7 +57,11 @@ public class Utils {
return newReferenceType(attributes, null); return newReferenceType(attributes, null);
} }
public static Task.Error newError(Map<String, String> attributes) { /**
* note that vCloud 0.9+ the error isn't attributes, it is a nested object. see
* {@link ErrorHandler}
*/
public static Error newError(Map<String, String> attributes) {
String minorErrorCode = attributes.get("minorErrorCode"); String minorErrorCode = attributes.get("minorErrorCode");
String vendorSpecificErrorCode = attributes.get("vendorSpecificErrorCode"); String vendorSpecificErrorCode = attributes.get("vendorSpecificErrorCode");
int errorCode; int errorCode;

View File

@ -110,7 +110,9 @@ public class VAppTemplateHandler extends ParseSax.HandlerWithResult<VAppTemplate
public void endElement(String uri, String name, String qName) { public void endElement(String uri, String name, String qName) {
if (qName.endsWith("Children")) { if (qName.endsWith("Children")) {
inChildren = false; inChildren = false;
this.children.add(vmHandler.getResult()); Vm vm = vmHandler.getResult();
if (vm != null)
this.children.add(vmHandler.getResult());
} else if (qName.endsWith("Tasks")) { } else if (qName.endsWith("Tasks")) {
inTasks = false; inTasks = false;
this.tasks.add(taskHandler.getResult()); this.tasks.add(taskHandler.getResult());

View File

@ -61,7 +61,7 @@ public class VDCHandler extends ParseSax.HandlerWithResult<VDC> {
protected ReferenceType org; protected ReferenceType org;
protected String description; protected String description;
protected List<Task> tasks = Lists.newArrayList(); protected List<Task> tasks = Lists.newArrayList();
protected AllocationModel allocationModel = AllocationModel.UNRECOGNIZED_MODEL; protected AllocationModel allocationModel = AllocationModel.UNRECOGNIZED;
protected Capacity storageCapacity; protected Capacity storageCapacity;
protected Capacity cpuCapacity; protected Capacity cpuCapacity;

View File

@ -86,8 +86,8 @@ public class VmHandler extends ParseSax.HandlerWithResult<Vm> {
private boolean inGuestCustomization; private boolean inGuestCustomization;
public Vm getResult() { public Vm getResult() {
return new VmImpl(vm.getName(), vm.getType(), vm.getHref(), status, vdc, description, tasks, hardware, os, return vm == null ? null : new VmImpl(vm.getName(), vm.getType(), vm.getHref(), status, vdc, description, tasks,
networkConnectionSection, guestCustomization, vAppScopedLocalId); hardware, os, networkConnectionSection, guestCustomization, vAppScopedLocalId);
} }
@Override @Override

View File

@ -24,15 +24,18 @@ import static org.testng.Assert.assertEquals;
import java.io.InputStream; import java.io.InputStream;
import java.net.URI; import java.net.URI;
import org.jclouds.date.DateService;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ParseSax.Factory; import org.jclouds.http.functions.ParseSax.Factory;
import org.jclouds.http.functions.config.SaxParserModule; import org.jclouds.http.functions.config.SaxParserModule;
import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.GuestCustomizationSection; import org.jclouds.vcloud.domain.GuestCustomizationSection;
import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.Status;
import org.jclouds.vcloud.domain.TaskStatus;
import org.jclouds.vcloud.domain.VAppTemplate; import org.jclouds.vcloud.domain.VAppTemplate;
import org.jclouds.vcloud.domain.Vm; import org.jclouds.vcloud.domain.Vm;
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
import org.jclouds.vcloud.domain.internal.TaskImpl;
import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection; import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection;
import org.jclouds.vcloud.domain.ovf.network.Network; import org.jclouds.vcloud.domain.ovf.network.Network;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -50,6 +53,7 @@ import com.google.inject.Injector;
*/ */
@Test(groups = "unit", testName = "vcloud.VAppTemplateHandlerTest") @Test(groups = "unit", testName = "vcloud.VAppTemplateHandlerTest")
public class VAppTemplateHandlerTest { public class VAppTemplateHandlerTest {
public void testUbuntuTemplate() { public void testUbuntuTemplate() {
InputStream is = getClass().getResourceAsStream("/vAppTemplate.xml"); InputStream is = getClass().getResourceAsStream("/vAppTemplate.xml");
Injector injector = Guice.createInjector(new SaxParserModule()); Injector injector = Guice.createInjector(new SaxParserModule());
@ -115,4 +119,34 @@ public class VAppTemplateHandlerTest {
} }
public void testCopyingTemplate() {
InputStream is = getClass().getResourceAsStream("/vAppTemplate-copying.xml");
Injector injector = Guice.createInjector(new SaxParserModule());
Factory factory = injector.getInstance(ParseSax.Factory.class);
DateService dateService = injector.getInstance(DateService.class);
VAppTemplate result = factory.create(injector.getInstance(VAppTemplateHandler.class)).parse(is);
assertEquals(result.getName(), "Ubuntu10.04_v2");
assertEquals(result.getHref(), URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-699683881"));
assertEquals(result.getType(), "application/vnd.vmware.vcloud.vAppTemplate+xml");
assertEquals(result.getStatus(), Status.UNRESOLVED);
assertEquals(result.getVDC(), new ReferenceTypeImpl(null, VCloudMediaType.VDC_XML, URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/105186609")));
assertEquals(result.getDescription(), null);
assertEquals(result.getTasks(), ImmutableList.of(new TaskImpl(URI
.create("https://vcenterprise.bluelock.com/api/v1.0/task/q62gxhi32xgd9yrqvr"),
"Copying Virtual Application Template Ubuntu10.04_v2(699683881)", TaskStatus.RUNNING, dateService
.iso8601DateParse("2010-09-17T23:20:46.039-04:00"), dateService
.iso8601DateParse("9999-12-31T23:59:59.999-05:00"), dateService
.iso8601DateParse("2010-12-16T23:20:46.039-05:00"), new ReferenceTypeImpl("Ubuntu10.04_v2",
"application/vnd.vmware.vcloud.vAppTemplate+xml",
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-699683881")),
null)));
assertEquals(result.getVAppScopedLocalId(), null);
assert result.isOvfDescriptorUploaded();
assertEquals(result.getChildren(), ImmutableList.of());
assertEquals(result.getNetworkSection(), null);
}
} }

View File

@ -31,7 +31,7 @@ import com.google.common.base.CaseFormat;
public class IpAddress implements Comparable<IpAddress> { public class IpAddress implements Comparable<IpAddress> {
public static enum Status { public static enum Status {
AVAILABLE, ASSIGNED; AVAILABLE, ASSIGNED, UNRECOGNIZED;
public String value() { public String value() {
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
} }
@ -42,8 +42,11 @@ public class IpAddress implements Comparable<IpAddress> {
} }
public static Status fromValue(String status) { public static Status fromValue(String status) {
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(status, try {
"status"))); return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(status, "status")));
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }

View File

@ -706,7 +706,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
ImmutableMap.<String, org.jclouds.vcloud.domain.VDC> of("vdc", new TerremarkVDCImpl("vdc", null, URI ImmutableMap.<String, org.jclouds.vcloud.domain.VDC> of("vdc", new TerremarkVDCImpl("vdc", null, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), VDCStatus.READY, null, "description", .create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), VDCStatus.READY, null, "description",
ImmutableSet.<Task> of(), AllocationModel.UNRECOGNIZED_MODEL, new Capacity("MB", 0, 0, 0, 0), ImmutableSet.<Task> of(), AllocationModel.UNRECOGNIZED, new Capacity("MB", 0, 0, 0, 0),
new Capacity("MB", 0, 0, 0, 0), new Capacity("MB", 0, 0, 0, 0), new Capacity("MB", 0, 0, 0, 0), new Capacity("MB", 0, 0, 0, 0),
ImmutableMap.<String, ReferenceType> of("vapp", new ReferenceTypeImpl("vapp", ImmutableMap.<String, ReferenceType> of("vapp", new ReferenceTypeImpl("vapp",
"application/vnd.vmware.vcloud.vApp+xml", URI "application/vnd.vmware.vcloud.vApp+xml", URI

View File

@ -84,7 +84,7 @@ public class TerremarkECloudComputeServiceLiveTest extends VCloudExpressComputeS
@Override @Override
protected void checkOsMatchesTemplate(NodeMetadata node) { protected void checkOsMatchesTemplate(NodeMetadata node) {
if (node.getOperatingSystem() != null) if (node.getOperatingSystem() != null)
assertEquals(node.getOperatingSystem().getFamily(), OsFamily.UNKNOWN); assertEquals(node.getOperatingSystem().getFamily(), OsFamily.UNRECOGNIZED);
} }
@Override @Override

View File

@ -84,7 +84,7 @@ public class TerremarkVCloudExpressComputeServiceLiveTest extends VCloudExpressC
@Override @Override
protected void checkOsMatchesTemplate(NodeMetadata node) { protected void checkOsMatchesTemplate(NodeMetadata node) {
if (node.getOperatingSystem() != null) if (node.getOperatingSystem() != null)
assertEquals(node.getOperatingSystem().getFamily(), OsFamily.UNKNOWN); assertEquals(node.getOperatingSystem().getFamily(), OsFamily.UNRECOGNIZED);
} }
@Override @Override