mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug CS-14957: Return hypervisor type for uploaded volume
This commit is contained in:
parent
0e22eed41f
commit
07cbec95fa
@ -92,6 +92,7 @@ import com.cloud.storage.VMTemplateHostVO;
|
||||
import com.cloud.storage.VMTemplateSwiftVO;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.VolumeHostVO;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Volume.Type;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.dao.DiskOfferingDao;
|
||||
@ -560,6 +561,10 @@ public class ApiDBUtils {
|
||||
public static HypervisorType getVolumeHyperType(long volumeId) {
|
||||
return _volumeDao.getHypervisorType(volumeId);
|
||||
}
|
||||
|
||||
public static HypervisorType getHypervisorTypeFromFormat(ImageFormat format){
|
||||
return _storageMgr.getHypervisorTypeFromFormat(format);
|
||||
}
|
||||
|
||||
public static List<VMTemplateHostVO> listTemplateHostBy(long templateId, Long zoneId, boolean readyOnly) {
|
||||
if (zoneId != null) {
|
||||
|
||||
@ -1025,6 +1025,9 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
com.cloud.storage.VolumeHostVO volumeHostRef = ApiDBUtils.findVolumeHostRef(volume.getId(), volume.getDataCenterId());
|
||||
volResponse.setSize(volumeHostRef.getSize());
|
||||
volResponse.setCreated(volumeHostRef.getCreated());
|
||||
Account caller = UserContext.current().getCaller();
|
||||
if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN)
|
||||
volResponse.setHypervisor(ApiDBUtils.getHypervisorTypeFromFormat(volumeHostRef.getFormat()).toString());
|
||||
if (volumeHostRef.getDownloadState() != Status.DOWNLOADED) {
|
||||
String volumeStatus = "Processing";
|
||||
if (volumeHostRef.getDownloadState() == VMTemplateHostVO.Status.DOWNLOAD_IN_PROGRESS) {
|
||||
@ -1096,8 +1099,8 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
|
||||
// return hypervisor for ROOT and Resource domain only
|
||||
Account caller = UserContext.current().getCaller();
|
||||
if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
|
||||
volResponse.setHypervisor(ApiDBUtils.getVolumeHyperType(volume.getId()).toString());
|
||||
if ((caller.getType() == Account.ACCOUNT_TYPE_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) && volume.getState() != Volume.State.UploadOp) {
|
||||
volResponse.setHypervisor(ApiDBUtils.getVolumeHyperType(volume.getId()).toString());
|
||||
}
|
||||
|
||||
volResponse.setAttached(volume.getAttached());
|
||||
|
||||
@ -28,6 +28,7 @@ import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Volume.Event;
|
||||
import com.cloud.storage.Volume.Type;
|
||||
import com.cloud.user.Account;
|
||||
@ -228,4 +229,6 @@ public interface StorageManager extends StorageService, Manager {
|
||||
HypervisorType hyperType) throws NoTransitionException;
|
||||
|
||||
String getSupportedImageFormatForCluster(Long clusterId);
|
||||
|
||||
HypervisorType getHypervisorTypeFromFormat(ImageFormat format);
|
||||
}
|
||||
|
||||
@ -3824,4 +3824,24 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public HypervisorType getHypervisorTypeFromFormat(ImageFormat format) {
|
||||
|
||||
if(format == null) {
|
||||
return HypervisorType.None;
|
||||
}
|
||||
|
||||
if (format == ImageFormat.VHD) {
|
||||
return HypervisorType.XenServer;
|
||||
} else if (format == ImageFormat.OVA) {
|
||||
return HypervisorType.VMware;
|
||||
} else if (format == ImageFormat.QCOW2) {
|
||||
return HypervisorType.KVM;
|
||||
} else if (format == ImageFormat.RAW) {
|
||||
return HypervisorType.Ovm;
|
||||
} else {
|
||||
return HypervisorType.None;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user