Skip to content

Commit 6c9383b

Browse files
author
Prachi Damle
committed
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.
1 parent f9de646 commit 6c9383b

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1184,14 +1184,23 @@ public EC2Volume createVolume( EC2CreateVolume request ) {
11841184
String snapshotId = request.getSnapshotId();
11851185
Long size = request.getSize();
11861186
String diskOfferingId = null;
1187+
String taggedDiskOffering = null;
11871188

11881189
if (snapshotId == null) {
11891190
List<CloudStackDiskOffering> disks = getApi().listDiskOfferings(null, null, null, null);
11901191
for (CloudStackDiskOffering offer : disks) {
11911192
if (offer.isCustomized()) {
1192-
diskOfferingId = offer.getId();
1193+
if (offer.getTags() == null) {
1194+
diskOfferingId = offer.getId();
1195+
break;
1196+
} else {
1197+
taggedDiskOffering = offer.getId();
1198+
}
11931199
}
11941200
}
1201+
if (diskOfferingId == null) {
1202+
diskOfferingId = taggedDiskOffering;
1203+
}
11951204
if (diskOfferingId == null) throw new EC2ServiceException(ServerError.InternalError, "No Customize Disk Offering Found");
11961205
}
11971206

awsapi/src/com/cloud/stack/models/CloudStackDiskOffering.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public class CloudStackDiskOffering {
3232
private String created;
3333
@SerializedName(ApiConstants.IS_CUSTOMIZED)
3434
private boolean isCustomized;
35+
@SerializedName(ApiConstants.TAGS)
36+
private String tags;
3537

3638
/**
3739
*
@@ -80,4 +82,11 @@ public String getCreated() {
8082
public boolean isCustomized() {
8183
return isCustomized;
8284
}
85+
86+
/**
87+
* @return the tags
88+
*/
89+
public String getTags() {
90+
return tags;
91+
}
8392
}

0 commit comments

Comments
 (0)