diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Snapshot.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Snapshot.java index d83651f5b0..feafd8f686 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Snapshot.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Snapshot.java @@ -50,7 +50,7 @@ public class Snapshot implements Comparable { private State state; private long volumeId; private String volumeName; - private Volume.VolumeType volumeType; + private Volume.Type volumeType; /** * @param id ID of the snapshot @@ -159,7 +159,7 @@ public class Snapshot implements Comparable { /** * @param volumeType type of the disk volume */ - public Builder volumeType(Volume.VolumeType volumeType) { + public Builder volumeType(Volume.Type volumeType) { this.volumeType = volumeType; return this; } @@ -236,10 +236,10 @@ public class Snapshot implements Comparable { @SerializedName("volumename") private String volumeName; @SerializedName("volumetype") - private Volume.VolumeType volumeType; + private Volume.Type volumeType; public Snapshot(long id, String account, Date created, String domain, long domainId, Interval interval, long jobId, - String jobStatus, String name, Type snapshotType, State state, long volumeId, String volumeName, Volume.VolumeType volumeType) { + String jobStatus, String name, Type snapshotType, State state, long volumeId, String volumeName, Volume.Type volumeType) { this.id = id; this.account = account; this.created = created; @@ -356,7 +356,7 @@ public class Snapshot implements Comparable { /** * @return type of the disk volume */ - public Volume.VolumeType getVolumeType() { + public Volume.Type getVolumeType() { return volumeType; } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Volume.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Volume.java index 200a4b74d0..15dac620ec 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Volume.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Volume.java @@ -66,7 +66,7 @@ public class Volume implements Comparable { private State state; private String storage; private String storageType; - private VolumeType type; + private Type type; private long virtualMachineId; private String vmDisplayName; private String vmName; @@ -194,7 +194,7 @@ public class Volume implements Comparable { return this; } - public Builder type(VolumeType type) { + public Builder type(Type type) { this.type = type; return this; } @@ -275,7 +275,7 @@ public class Volume implements Comparable { @SerializedName("storagetype") // MAYDO: this should perhaps be an enum; only value I have seen is "shared" private String storageType; - private VolumeType type; + private Type type; @SerializedName("virtualmachineid") private long virtualMachineId; @SerializedName("vmdisplayname") @@ -294,7 +294,7 @@ public class Volume implements Comparable { String domain, long domainId, String hypervisor, boolean extractable, long jobId, String jobStatus, String name, String serviceOfferingDisplayText, long serviceOfferingId, String serviceOfferingName, long size, long snapshotId, State state, String storage, - String storageType, VolumeType type, long virtualMachineId, String vmDisplayName, String vmName, + String storageType, Type type, long virtualMachineId, String vmDisplayName, String vmName, VirtualMachine.State vmState, long zoneId, String zoneName) { this.id = id; this.account = account; @@ -425,7 +425,7 @@ public class Volume implements Comparable { return storageType; } - public VolumeType getType() { + public Type getType() { return type; } @@ -626,33 +626,33 @@ public class Volume implements Comparable { } } - public enum VolumeType { + public enum Type { ROOT(0), DATADISK(1), UNRECOGNIZED(Integer.MAX_VALUE); private int code; - private static final Map INDEX = Maps.uniqueIndex(ImmutableSet.copyOf(VolumeType.values()), - new Function() { + private static final Map INDEX = Maps.uniqueIndex(ImmutableSet.copyOf(Type.values()), + new Function() { @Override - public Integer apply(VolumeType input) { + public Integer apply(Type input) { return input.code; } }); - VolumeType(int code) { + Type(int code) { this.code = code; } @Override public String toString() { - return name(); + return name().toLowerCase(); } - public static VolumeType fromValue(String resourceType) { + public static Type fromValue(String resourceType) { Integer code = new Integer(checkNotNull(resourceType, "resourcetype")); return INDEX.containsKey(code) ? INDEX.get(code) : UNRECOGNIZED; } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListVolumesOptions.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListVolumesOptions.java index 8ed8e09266..59e8f05841 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListVolumesOptions.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListVolumesOptions.java @@ -19,6 +19,7 @@ package org.jclouds.cloudstack.options; import com.google.common.collect.ImmutableSet; +import org.jclouds.cloudstack.domain.Volume; /** * Options used to control what volume @@ -84,8 +85,8 @@ public class ListVolumesOptions extends AccountInDomainOptions { /** * @param type the type of the disk volume */ - public ListVolumesOptions type(String type) { - this.queryParameters.replaceValues("type", ImmutableSet.of(type + "")); + public ListVolumesOptions type(Volume.Type type) { + this.queryParameters.replaceValues("type", ImmutableSet.of(type .toString())); return this; } @@ -178,7 +179,7 @@ public class ListVolumesOptions extends AccountInDomainOptions { /** * @see ListVolumesOptions#type */ - public static ListVolumesOptions type(String type) { + public static ListVolumesOptions type(Volume.Type type) { ListVolumesOptions options = new ListVolumesOptions(); return options.type(type); } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VolumeClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VolumeClientLiveTest.java index c7d0ee0722..b35d40b617 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VolumeClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VolumeClientLiveTest.java @@ -237,7 +237,7 @@ public class VolumeClientLiveTest extends BaseCloudStackClientLiveTest { static void checkVolume(final Volume volume) { assertNotNull(volume.getId()); assertNotNull(volume.getName()); - assertNotSame(Volume.VolumeType.UNRECOGNIZED, volume.getType()); + assertNotSame(Volume.Type.UNRECOGNIZED, volume.getType()); } Volume findVolumeWithId(final long id) {