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:
Anshul Gangwar 2014-04-01 13:38:54 +05:30 committed by Devdeep Singh
parent 06c0486d0b
commit 24820d20d3
4 changed files with 23 additions and 6 deletions

View File

@ -30,8 +30,6 @@ import java.util.concurrent.ExecutionException;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import com.cloud.vm.UserVmVO;
import com.cloud.vm.dao.UserVmDao;
import org.apache.log4j.Logger;
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.StateMachine2;
import com.cloud.vm.DiskProfile;
import com.cloud.vm.UserVmVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachine.State;
import com.cloud.vm.VirtualMachineProfile;
import com.cloud.vm.VirtualMachineProfileImpl;
import com.cloud.vm.dao.UserVmDao;
public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrationService, Configurable {
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) {
return ImageFormat.RAW;
} else if (hyperType == HypervisorType.Hyperv) {
return ImageFormat.VHD;
return ImageFormat.VHDX;
} else {
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,
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()
+ " is not compatible with the vm hypervisor type");
}

View File

@ -1175,7 +1175,7 @@ namespace HypervResource
VolumeObjectTO volume = VolumeObjectTO.ParseJson(cmd.data);
PrimaryDataStoreTO primary = volume.primaryDataStore;
ulong volumeSize = volume.size;
string volumeName = volume.uuid + ".vhd";
string volumeName = volume.uuid + ".vhdx";
string volumePath = null;
if (primary.isLocal)

View File

@ -1777,7 +1777,7 @@ namespace HypervResource
// Is there a template we can use to fill in the settings?
var newVirtHDSettings = VirtualHardDiskSettingData.CreateInstance();
newVirtHDSettings.LateBoundObject["Type"] = 3; // Dynamic
newVirtHDSettings.LateBoundObject["Format"] = 2; // VHD
newVirtHDSettings.LateBoundObject["Format"] = 3; // VHDX
newVirtHDSettings.LateBoundObject["Path"] = Path;
newVirtHDSettings.LateBoundObject["MaxInternalSize"] = MaxInternalSize;
newVirtHDSettings.LateBoundObject["BlockSize"] = 0; // Use defaults

View File

@ -396,6 +396,10 @@
id: 'VHD',
description: 'VHD'
});
items.push({
id: 'VHDX',
description: 'VHDX'
});
}
args.response.success({
data: items