Source:
<code>protected boolean canDoAction() { if (getVmTemplate() == null) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST); } if (getVmTemplate().isDisabled()) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_IS_DISABLED); } if (!buildAndCheckDestStorageDomains()) { return false; } storageToDisksMap = ImagesHandler.buildStorageToDiskMap(getImagesToCheckDestinationStorageDomains(), diskInfoDestinationMap); if (!canDoAddVmCommand()) { return false; } String vmName = getParameters().getVm().getName(); if (vmName == null || vmName.isEmpty()) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_NAME_MAY_NOT_BE_EMPTY); } if (!isVmNameValidLength(getParameters().getVm())) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_NAME_LENGTH_IS_TOO_LONG); } if (getParameters().getVmPayload() != null) { if (!checkPayload(getParameters().getVmPayload(), getParameters().getVmStaticData().getIsoPath())) { return false; } getParameters().getVmPayload().setContent(Base64.encodeBase64String( getParameters().getVmPayload().getContent().getBytes())); } if (!VmHandler.isUsbPolicyLegal(getParameters().getVm().getUsbPolicy(), getParameters().getVm().getOs(), getVdsGroup(), getReturnValue().getCanDoActionMessages())) { return false; } <START> VM vmFromParams = getParameters().getVm(); <END> if (!isCpuPinningValid(vmFromParams.getCpuPinning(), vmFromParams.getStaticData())) { return false; } if (getParameters().getVm().isUseHostCpuFlags() && getParameters().getVm().getMigrationSupport() == MigrationSupport.MIGRATABLE) { return failCanDoAction(VdcBllMessages.VM_HOSTCPU_MUST_BE_PINNED_TO_HOST); } if (!checkCpuSockets()){ return false; } return true; }</code><technical_language>i nice if this parameter defined in beginning of method instead of getParameters().getVm() (could in another patch, making some sense in this method so..)</technical_language>

Target:
protected boolean canDoAction() { if (getVmTemplate() == null) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST); } if (getVmTemplate().isDisabled()) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_IS_DISABLED); } if (!buildAndCheckDestStorageDomains()) { return false; } storageToDisksMap = ImagesHandler.buildStorageToDiskMap(getImagesToCheckDestinationStorageDomains(), diskInfoDestinationMap); if (!canDoAddVmCommand()) { return false; } VM vmFromParams = getParameters().getVm(); if (StringUtils.isEmpty(vmFromParams.getName())) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_NAME_MAY_NOT_BE_EMPTY); } if (!isVmNameValidLength(vmFromParams)) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_NAME_LENGTH_IS_TOO_LONG); } if (getParameters().getVmPayload() != null) { if (!checkPayload(getParameters().getVmPayload(), getParameters().getVmStaticData().getIsoPath())) { return false; } getParameters().getVmPayload().setContent(Base64.encodeBase64String( getParameters().getVmPayload().getContent().getBytes())); } if (!VmHandler.isUsbPolicyLegal(vmFromParams.getUsbPolicy(), vmFromParams.getOs(), getVdsGroup(), getReturnValue().getCanDoActionMessages())) { return false; } if (!isCpuPinningValid(vmFromParams.getCpuPinning(), vmFromParams.getStaticData())) { return false; } if (vmFromParams.isUseHostCpuFlags() && vmFromParams.getMigrationSupport() == MigrationSupport.MIGRATABLE) { return failCanDoAction(VdcBllMessages.VM_HOSTCPU_MUST_BE_PINNED_TO_HOST); } if (!checkCpuSockets()){ return false; } return true; }