server: fix diskoffering details in vm response (#8135)

Fixes #8120
This commit is contained in:
Abhishek Kumar 2023-12-09 11:43:52 +05:30 committed by GitHub
parent ea569ffaad
commit a11fc43788
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -159,11 +159,11 @@ public class UserVmResponse extends BaseResponseWithTagInformation implements Co
private String serviceOfferingName;
@SerializedName(ApiConstants.DISK_OFFERING_ID)
@Param(description = "the ID of the disk offering of the virtual machine", since = "4.4")
@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")
private String diskOfferingId;
@SerializedName("diskofferingname")
@Param(description = "the name of the disk offering of the virtual machine", since = "4.4")
@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")
private String diskOfferingName;
@SerializedName(ApiConstants.BACKUP_OFFERING_ID)

View File

@ -27,6 +27,7 @@ import java.util.stream.Collectors;
import javax.inject.Inject;
import com.cloud.storage.Volume;
import org.apache.cloudstack.affinity.AffinityGroupResponse;
import org.apache.cloudstack.annotation.AnnotationService;
import org.apache.cloudstack.annotation.dao.AnnotationDao;
@ -42,6 +43,7 @@ import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.query.QueryService;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
@ -550,6 +552,11 @@ public class UserVmJoinDaoImpl extends GenericDaoBaseWithTagInformation<UserVmJo
userVmData.addAffinityGroup(resp);
}
if (StringUtils.isEmpty(userVmData.getDiskOfferingId()) && !Volume.Type.ROOT.equals(uvo.getVolumeType())) {
userVmData.setDiskOfferingId(uvo.getDiskOfferingUuid());
userVmData.setDiskOfferingName(uvo.getDiskOfferingName());
}
return userVmData;
}