mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
CLOUDSTACK-6288: Changing default ImageFormat to vhdx for hyper-v and allowing registration of vhdx format templates.
Signed-off-by: Devdeep Singh <devdeep@gmail.com>
This commit is contained in:
parent
06c0486d0b
commit
24820d20d3
@ -30,8 +30,6 @@ import java.util.concurrent.ExecutionException;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.naming.ConfigurationException;
|
import javax.naming.ConfigurationException;
|
||||||
|
|
||||||
import com.cloud.vm.UserVmVO;
|
|
||||||
import com.cloud.vm.dao.UserVmDao;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
|
import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
|
||||||
@ -113,10 +111,12 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
|||||||
import com.cloud.utils.fsm.NoTransitionException;
|
import com.cloud.utils.fsm.NoTransitionException;
|
||||||
import com.cloud.utils.fsm.StateMachine2;
|
import com.cloud.utils.fsm.StateMachine2;
|
||||||
import com.cloud.vm.DiskProfile;
|
import com.cloud.vm.DiskProfile;
|
||||||
|
import com.cloud.vm.UserVmVO;
|
||||||
import com.cloud.vm.VirtualMachine;
|
import com.cloud.vm.VirtualMachine;
|
||||||
import com.cloud.vm.VirtualMachine.State;
|
import com.cloud.vm.VirtualMachine.State;
|
||||||
import com.cloud.vm.VirtualMachineProfile;
|
import com.cloud.vm.VirtualMachineProfile;
|
||||||
import com.cloud.vm.VirtualMachineProfileImpl;
|
import com.cloud.vm.VirtualMachineProfileImpl;
|
||||||
|
import com.cloud.vm.dao.UserVmDao;
|
||||||
|
|
||||||
public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrationService, Configurable {
|
public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrationService, Configurable {
|
||||||
private static final Logger s_logger = Logger.getLogger(VolumeOrchestrator.class);
|
private static final Logger s_logger = Logger.getLogger(VolumeOrchestrator.class);
|
||||||
@ -687,16 +687,29 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
|||||||
} else if (hyperType == HypervisorType.Ovm) {
|
} else if (hyperType == HypervisorType.Ovm) {
|
||||||
return ImageFormat.RAW;
|
return ImageFormat.RAW;
|
||||||
} else if (hyperType == HypervisorType.Hyperv) {
|
} else if (hyperType == HypervisorType.Hyperv) {
|
||||||
return ImageFormat.VHD;
|
return ImageFormat.VHDX;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isSupportedImageFormatForCluster(VolumeInfo volume, HypervisorType rootDiskHyperType) {
|
||||||
|
ImageFormat volumeFormat = volume.getFormat();
|
||||||
|
if (rootDiskHyperType == HypervisorType.Hyperv) {
|
||||||
|
if (volumeFormat.equals(ImageFormat.VHDX) || volumeFormat.equals(ImageFormat.VHD)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return volume.getFormat().equals(getSupportedImageFormatForCluster(rootDiskHyperType));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private VolumeInfo copyVolume(StoragePool rootDiskPool, VolumeInfo volume, VirtualMachine vm, VirtualMachineTemplate rootDiskTmplt, DataCenter dcVO, Pod pod,
|
private VolumeInfo copyVolume(StoragePool rootDiskPool, VolumeInfo volume, VirtualMachine vm, VirtualMachineTemplate rootDiskTmplt, DataCenter dcVO, Pod pod,
|
||||||
DiskOffering diskVO, ServiceOffering svo, HypervisorType rootDiskHyperType) throws NoTransitionException {
|
DiskOffering diskVO, ServiceOffering svo, HypervisorType rootDiskHyperType) throws NoTransitionException {
|
||||||
|
|
||||||
if (!volume.getFormat().equals(getSupportedImageFormatForCluster(rootDiskHyperType))) {
|
if (!isSupportedImageFormatForCluster(volume, rootDiskHyperType)) {
|
||||||
throw new InvalidParameterValueException("Failed to attach volume to VM since volumes format " + volume.getFormat().getFileExtension()
|
throw new InvalidParameterValueException("Failed to attach volume to VM since volumes format " + volume.getFormat().getFileExtension()
|
||||||
+ " is not compatible with the vm hypervisor type");
|
+ " is not compatible with the vm hypervisor type");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1175,7 +1175,7 @@ namespace HypervResource
|
|||||||
VolumeObjectTO volume = VolumeObjectTO.ParseJson(cmd.data);
|
VolumeObjectTO volume = VolumeObjectTO.ParseJson(cmd.data);
|
||||||
PrimaryDataStoreTO primary = volume.primaryDataStore;
|
PrimaryDataStoreTO primary = volume.primaryDataStore;
|
||||||
ulong volumeSize = volume.size;
|
ulong volumeSize = volume.size;
|
||||||
string volumeName = volume.uuid + ".vhd";
|
string volumeName = volume.uuid + ".vhdx";
|
||||||
string volumePath = null;
|
string volumePath = null;
|
||||||
|
|
||||||
if (primary.isLocal)
|
if (primary.isLocal)
|
||||||
|
|||||||
@ -1777,7 +1777,7 @@ namespace HypervResource
|
|||||||
// Is there a template we can use to fill in the settings?
|
// Is there a template we can use to fill in the settings?
|
||||||
var newVirtHDSettings = VirtualHardDiskSettingData.CreateInstance();
|
var newVirtHDSettings = VirtualHardDiskSettingData.CreateInstance();
|
||||||
newVirtHDSettings.LateBoundObject["Type"] = 3; // Dynamic
|
newVirtHDSettings.LateBoundObject["Type"] = 3; // Dynamic
|
||||||
newVirtHDSettings.LateBoundObject["Format"] = 2; // VHD
|
newVirtHDSettings.LateBoundObject["Format"] = 3; // VHDX
|
||||||
newVirtHDSettings.LateBoundObject["Path"] = Path;
|
newVirtHDSettings.LateBoundObject["Path"] = Path;
|
||||||
newVirtHDSettings.LateBoundObject["MaxInternalSize"] = MaxInternalSize;
|
newVirtHDSettings.LateBoundObject["MaxInternalSize"] = MaxInternalSize;
|
||||||
newVirtHDSettings.LateBoundObject["BlockSize"] = 0; // Use defaults
|
newVirtHDSettings.LateBoundObject["BlockSize"] = 0; // Use defaults
|
||||||
|
|||||||
@ -396,6 +396,10 @@
|
|||||||
id: 'VHD',
|
id: 'VHD',
|
||||||
description: 'VHD'
|
description: 'VHD'
|
||||||
});
|
});
|
||||||
|
items.push({
|
||||||
|
id: 'VHDX',
|
||||||
|
description: 'VHDX'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
args.response.success({
|
args.response.success({
|
||||||
data: items
|
data: items
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user