Source:
<code>protected void init() { T parameters = getParameters(); if (parameters.getVmStaticData() != null) { Guid templateIdToUse = getParameters().getVmStaticData().getVmtGuid(); if (parameters.getVmStaticData().isUseLatestVersion()) { VmTemplate latest = getVmTemplateDao().getTemplateWithLatestVersionInChain(templateIdToUse); if (latest != null) { if (!templateIdToUse.equals(latest.getId())) { getParameters().setDiskInfoDestinationMap(new HashMap<Guid, DiskImage>()); } setVmTemplate(latest); templateIdToUse = latest.getId(); getParameters().getVmStaticData().setVmtGuid(templateIdToUse); } } setVmTemplateId(templateIdToUse); <START> if (parameters.isSoundDeviceEnabled() == null) { <END> parameters.setSoundDeviceEnabled(parameters.getVmStaticData().getVmType() == VmType.Desktop); } if (parameters.isConsoleEnabled() == null) { parameters.setConsoleEnabled(false); } vmDevicesSourceId = (getInstanceTypeId() != null) ? getInstanceTypeId() : parameters.getVmStaticData().getVmtGuid(); imageTypeId = parameters.getVmStaticData().getImageTypeId(); vmInterfacesSourceId = parameters.getVmStaticData().getVmtGuid(); vmDisksSource = getVmTemplate(); } parameters.setEntityInfo(new EntityInfo(VdcObjectType.VM, getVmId())); updateVmObject(); initTemplateDisks(); initStoragePoolId(); diskInfoDestinationMap = getParameters().getDiskInfoDestinationMap(); if (diskInfoDestinationMap == null) { diskInfoDestinationMap = new HashMap<>(); } VmHandler.updateDefaultTimeZone(parameters.getVmStaticData()); if (getParameters().getVmStaticData() != null && getParameters().getVmStaticData().getMigrationSupport() == null) { setDefaultMigrationPolicy(); } }</code><technical_language>need this code smarter, if user create vm api, sound card, engine choose add fail, be... fail... similar issue engine picking spice if display is missing, spice is supported ppc: <LINK_0> calling new isSoundDeviceEnabled() method good need check cluster is null</technical_language>

Target:
protected void init() { T parameters = getParameters(); if (parameters.getVmStaticData() != null) { Guid templateIdToUse = getParameters().getVmStaticData().getVmtGuid(); if (parameters.getVmStaticData().isUseLatestVersion()) { VmTemplate latest = getVmTemplateDao().getTemplateWithLatestVersionInChain(templateIdToUse); if (latest != null) { if (!templateIdToUse.equals(latest.getId())) { getParameters().setDiskInfoDestinationMap(new HashMap<Guid, DiskImage>()); } setVmTemplate(latest); templateIdToUse = latest.getId(); getParameters().getVmStaticData().setVmtGuid(templateIdToUse); } } setVmTemplateId(templateIdToUse); if (shouldOverrideSoundDevice()) { parameters.setSoundDeviceEnabled(true); } if (parameters.isConsoleEnabled() == null) { parameters.setConsoleEnabled(false); } vmDevicesSourceId = (getInstanceTypeId() != null) ? getInstanceTypeId() : parameters.getVmStaticData().getVmtGuid(); imageTypeId = parameters.getVmStaticData().getImageTypeId(); vmInterfacesSourceId = parameters.getVmStaticData().getVmtGuid(); vmDisksSource = getVmTemplate(); } parameters.setEntityInfo(new EntityInfo(VdcObjectType.VM, getVmId())); updateVmObject(); initTemplateDisks(); initStoragePoolId(); diskInfoDestinationMap = getParameters().getDiskInfoDestinationMap(); if (diskInfoDestinationMap == null) { diskInfoDestinationMap = new HashMap<>(); } VmHandler.updateDefaultTimeZone(parameters.getVmStaticData()); if (getParameters().getVmStaticData() != null && getParameters().getVmStaticData().getMigrationSupport() == null) { setDefaultMigrationPolicy(); } }