Skip to content

Commit 23f536a

Browse files
shwstpprdhslove
authored andcommitted
server: fix diskoffering details in vm response (apache#8135)
Fixes apache#8120
1 parent 5ccdf67 commit 23f536a

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

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
@@ -166,11 +166,11 @@ public class UserVmResponse extends BaseResponseWithTagInformation implements Co
166166
private String serviceOfferingName;
167167

168168
@SerializedName(ApiConstants.DISK_OFFERING_ID)
169-
@Param(description = "the ID of the disk offering of the virtual machine", since = "4.4")
169+
@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")
170170
private String diskOfferingId;
171171

172172
@SerializedName("diskofferingname")
173-
@Param(description = "the name of the disk offering of the virtual machine", since = "4.4")
173+
@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")
174174
private String diskOfferingName;
175175

176176
@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
@@ -29,6 +29,7 @@
2929
import javax.inject.Inject;
3030

3131
import com.cloud.vm.VirtualMachine;
32+
import com.cloud.storage.Volume;
3233
import org.apache.cloudstack.affinity.AffinityGroupResponse;
3334
import org.apache.cloudstack.annotation.AnnotationService;
3435
import org.apache.cloudstack.annotation.dao.AnnotationDao;
@@ -45,6 +46,7 @@
4546
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
4647
import org.apache.cloudstack.query.QueryService;
4748
import org.apache.commons.lang3.BooleanUtils;
49+
import org.apache.commons.lang3.StringUtils;
4850
import org.apache.log4j.Logger;
4951
import org.springframework.stereotype.Component;
5052

@@ -602,6 +604,11 @@ public UserVmResponse setUserVmResponse(ResponseView view, UserVmResponse userVm
602604
userVmData.addAffinityGroup(resp);
603605
}
604606

607+
if (StringUtils.isEmpty(userVmData.getDiskOfferingId()) && !Volume.Type.ROOT.equals(uvo.getVolumeType())) {
608+
userVmData.setDiskOfferingId(uvo.getDiskOfferingUuid());
609+
userVmData.setDiskOfferingName(uvo.getDiskOfferingName());
610+
}
611+
605612
return userVmData;
606613
}
607614

0 commit comments

Comments
 (0)