Source:
<code>public DiskProfile importVolume(Type type, String name, DiskOffering offering, Long size, Long minIops, Long maxIops, VirtualMachine vm, VirtualMachineTemplate template, Account owner, Long deviceId, Long poolId, String path, String chainInfo) { if (size == null) { size = offering.getDiskSize(); } else { size = (size * 1024 * 1024 * 1024); } minIops = minIops != null ? minIops : offering.getMinIops(); maxIops = maxIops != null ? maxIops : offering.getMaxIops(); VolumeVO vol = new VolumeVO(type, name, vm.getDataCenterId(), owner.getDomainId(), owner.getId(), offering.getId(), offering.getProvisioningType(), size, minIops, maxIops, null); if (vm != null) { vol.setInstanceId(vm.getId()); } if (deviceId != null) { vol.setDeviceId(deviceId); } else if (type.equals(Type.ROOT)) { vol.setDeviceId(0l); } else { vol.setDeviceId(1l); } if (template != null) { if (template.getFormat() == ImageFormat.ISO) { vol.setIsoId(template.getId()); <START> } else if (template.getTemplateType().equals(Storage.TemplateType.DATADISK)) { <END> vol.setTemplateId(template.getId()); } if (type == Type.ROOT) { vol.setTemplateId(template.getId()); } } if (vm.getType() == VirtualMachine.Type.User) { UserVmVO userVm = _userVmDao.findById(vm.getId()); vol.setDisplayVolume(userVm.isDisplayVm()); } vol.setFormat(getSupportedImageFormatForCluster(vm.getHypervisorType())); vol.setPoolId(poolId); vol.setPath(path); vol.setChainInfo(chainInfo); vol.setState(Volume.State.Ready); vol = _volsDao.persist(vol); return toDiskProfile(vol, offering); }</code><technical_language>I suggest } else if (Storage.TemplateType.DATADISK.equals(template.getTemplateType())) { a defense template.getTemplateType() null</technical_language>

Target:
public DiskProfile importVolume(Type type, String name, DiskOffering offering, Long size, Long minIops, Long maxIops, VirtualMachine vm, VirtualMachineTemplate template, Account owner, Long deviceId, Long poolId, String path, String chainInfo) { if (size == null) { size = offering.getDiskSize(); } else { size = (size * 1024 * 1024 * 1024); } minIops = minIops != null ? minIops : offering.getMinIops(); maxIops = maxIops != null ? maxIops : offering.getMaxIops(); VolumeVO vol = new VolumeVO(type, name, vm.getDataCenterId(), owner.getDomainId(), owner.getId(), offering.getId(), offering.getProvisioningType(), size, minIops, maxIops, null); if (vm != null) { vol.setInstanceId(vm.getId()); } if (deviceId != null) { vol.setDeviceId(deviceId); } else if (type.equals(Type.ROOT)) { vol.setDeviceId(0l); } else { vol.setDeviceId(1l); } if (template != null) { if (ImageFormat.ISO.equals(template.getFormat())) { vol.setIsoId(template.getId()); } else if (Storage.TemplateType.DATADISK.equals(template.getTemplateType())) { vol.setTemplateId(template.getId()); } if (type == Type.ROOT) { vol.setTemplateId(template.getId()); } } if (VirtualMachine.Type.User.equals(vm.getType())) { UserVmVO userVm = _userVmDao.findById(vm.getId()); vol.setDisplayVolume(userVm.isDisplayVm()); } vol.setFormat(getSupportedImageFormatForCluster(vm.getHypervisorType())); vol.setPoolId(poolId); vol.setPath(path); vol.setChainInfo(chainInfo); vol.setState(Volume.State.Ready); vol = _volsDao.persist(vol); return toDiskProfile(vol, offering); }