Fix CS-15835

Using the disk offering associated with volume to determine the storage type
Reviewed-by: Nitin
This commit is contained in:
Koushik Das 2012-08-06 18:51:35 +05:30
parent 4146b4273d
commit f772c9aa99
1 changed files with 1 additions and 18 deletions

View File

@ -1124,24 +1124,6 @@ public class ApiResponseHelper implements ResponseGenerator {
populateOwner(volResponse, volume);
String storageType;
try {
if (volume.getPoolId() == null) {
if (volume.getState() == Volume.State.Allocated || volume.getState() == Volume.State.UploadOp) {
/* set it as shared, so the UI can attach it to VM */
storageType = "shared";
} else {
storageType = "unknown";
}
} else {
storageType = ApiDBUtils.volumeIsOnSharedStorage(volume.getId()) ? ServiceOffering.StorageType.shared.toString() : ServiceOffering.StorageType.local.toString();
}
} catch (InvalidParameterValueException e) {
s_logger.error(e.getMessage(), e);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Volume " + volume.getName() + " does not have a valid ID");
}
volResponse.setStorageType(storageType);
if (volume.getVolumeType().equals(Volume.Type.ROOT)) {
volResponse.setServiceOfferingId(volume.getDiskOfferingId());
} else {
@ -1156,6 +1138,7 @@ public class ApiResponseHelper implements ResponseGenerator {
volResponse.setDiskOfferingName(diskOffering.getName());
volResponse.setDiskOfferingDisplayText(diskOffering.getDisplayText());
}
volResponse.setStorageType(diskOffering.getUseLocalStorage() ? ServiceOffering.StorageType.local.toString() : ServiceOffering.StorageType.shared.toString());
Long poolId = volume.getPoolId();
String poolName = (poolId == null) ? "none" : ApiDBUtils.findStoragePoolById(poolId).getName();