listVirtualMachine api: return "Not created" as a root volume type when volume's storage pool id is NULL

This commit is contained in:
alena 2010-11-05 16:03:37 -07:00
parent c0e2986766
commit e2aa4738ec

View File

@ -429,8 +429,12 @@ public class ApiResponseHelper {
VolumeVO rootVolume = ApiDBUtils.findRootVolume(userVm.getId());
if (rootVolume != null) {
userVmResponse.setRootDeviceId(rootVolume.getDeviceId());
StoragePoolVO storagePool = ApiDBUtils.findStoragePoolById(rootVolume.getPoolId());
userVmResponse.setRootDeviceType(storagePool.getPoolType().toString());
String rootDeviceType = "Not created";
if (rootVolume.getPoolId() != null){
StoragePoolVO storagePool = ApiDBUtils.findStoragePoolById(rootVolume.getPoolId());
rootDeviceType = storagePool.getPoolType().toString();
}
userVmResponse.setRootDeviceType(rootDeviceType);
}
//stats calculation