Skip to content

Commit a11fc43

Browse files
authored
server: fix diskoffering details in vm response (#8135)
Fixes #8120
1 parent ea569ff commit a11fc43

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

api/src/main/java/org/apache/cloudstack/api/response/UserVmResponse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ public class UserVmResponse extends BaseResponseWithTagInformation implements Co
159159
private String serviceOfferingName;
160160

161161
@SerializedName(ApiConstants.DISK_OFFERING_ID)
162-
@Param(description = "the ID of the disk offering of the virtual machine", since = "4.4")
162+
@Param(description = "the ID of the disk offering of the virtual machine. This parameter should not be used for retrieving disk offering details of DATA volumes. Use listVolumes API instead", since = "4.4")
163163
private String diskOfferingId;
164164

165165
@SerializedName("diskofferingname")
166-
@Param(description = "the name of the disk offering of the virtual machine", since = "4.4")
166+
@Param(description = "the name of the disk offering of the virtual machine. This parameter should not be used for retrieving disk offering details of DATA volumes. Use listVolumes API instead", since = "4.4")
167167
private String diskOfferingName;
168168

169169
@SerializedName(ApiConstants.BACKUP_OFFERING_ID)

server/src/main/java/com/cloud/api/query/dao/UserVmJoinDaoImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import javax.inject.Inject;
2929

30+
import com.cloud.storage.Volume;
3031
import org.apache.cloudstack.affinity.AffinityGroupResponse;
3132
import org.apache.cloudstack.annotation.AnnotationService;
3233
import org.apache.cloudstack.annotation.dao.AnnotationDao;
@@ -42,6 +43,7 @@
4243
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
4344
import org.apache.cloudstack.query.QueryService;
4445
import org.apache.commons.lang3.BooleanUtils;
46+
import org.apache.commons.lang3.StringUtils;
4547
import org.apache.log4j.Logger;
4648
import org.springframework.stereotype.Component;
4749

@@ -550,6 +552,11 @@ public UserVmResponse setUserVmResponse(ResponseView view, UserVmResponse userVm
550552
userVmData.addAffinityGroup(resp);
551553
}
552554

555+
if (StringUtils.isEmpty(userVmData.getDiskOfferingId()) && !Volume.Type.ROOT.equals(uvo.getVolumeType())) {
556+
userVmData.setDiskOfferingId(uvo.getDiskOfferingUuid());
557+
userVmData.setDiskOfferingName(uvo.getDiskOfferingName());
558+
}
559+
553560
return userVmData;
554561
}
555562

0 commit comments

Comments
 (0)