CLOUDSTACK-3336 AWSAPI - createVolume API with custom size should prefer a non-tagged custom sized disk offering first over a tagged offering
Changes: For createVolume API with custom size the awsapi component chooses the custom size disk offering present on CloudStack, sice CS createVolume API needs an offering Id. But if there are multiple custom size disk offerings, and some of the offerings have tags, awsapi should try to choose a non-tagged custom offering first. There is a reason for people to tag a disk offering and using that on every user API call may not be preferable. If all disk offerings are tagged however, awsapi will choose one of them. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/6c9383bd Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/6c9383bd Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/6c9383bd Branch: refs/heads/vmsync Commit: 6c9383bd76500e38f6737db814bc2d7aae131a2c Parents: f9de646 Author: Prachi Damle <pra...@cloud.com> Authored: Tue Jul 2 15:18:49 2013 -0700 Committer: Prachi Damle <pra...@cloud.com> Committed: Tue Jul 2 15:18:49 2013 -0700 ---------------------------------------------------------------------- .../src/com/cloud/bridge/service/core/ec2/EC2Engine.java | 11 ++++++++++- .../com/cloud/stack/models/CloudStackDiskOffering.java | 9 +++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6c9383bd/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java index 15ed908..715c83e 100644 --- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java @@ -1184,14 +1184,23 @@ public class EC2Engine extends ManagerBase { String snapshotId = request.getSnapshotId(); Long size = request.getSize(); String diskOfferingId = null; + String taggedDiskOffering = null; if (snapshotId == null) { List<CloudStackDiskOffering> disks = getApi().listDiskOfferings(null, null, null, null); for (CloudStackDiskOffering offer : disks) { if (offer.isCustomized()) { - diskOfferingId = offer.getId(); + if (offer.getTags() == null) { + diskOfferingId = offer.getId(); + break; + } else { + taggedDiskOffering = offer.getId(); + } } } + if (diskOfferingId == null) { + diskOfferingId = taggedDiskOffering; + } if (diskOfferingId == null) throw new EC2ServiceException(ServerError.InternalError, "No Customize Disk Offering Found"); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6c9383bd/awsapi/src/com/cloud/stack/models/CloudStackDiskOffering.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/stack/models/CloudStackDiskOffering.java b/awsapi/src/com/cloud/stack/models/CloudStackDiskOffering.java index 308941c..6e1b98e 100644 --- a/awsapi/src/com/cloud/stack/models/CloudStackDiskOffering.java +++ b/awsapi/src/com/cloud/stack/models/CloudStackDiskOffering.java @@ -32,6 +32,8 @@ public class CloudStackDiskOffering { private String created; @SerializedName(ApiConstants.IS_CUSTOMIZED) private boolean isCustomized; + @SerializedName(ApiConstants.TAGS) + private String tags; /** * @@ -80,4 +82,11 @@ public class CloudStackDiskOffering { public boolean isCustomized() { return isCustomized; } + + /** + * @return the tags + */ + public String getTags() { + return tags; + } }