Source:
<code>private void validate(APIUpdateVmInstanceMsg msg) { new SQLBatch() { @Override protected void scripts() { VmInstanceVO vo = Q.New(VmInstanceVO.class).eq(VmInstanceVO_.uuid, msg.getVmInstanceUuid()).find(); Integer cpuSum = msg.getCpuNum(); Long memorySize = msg.getMemorySize(); if ((cpuSum == null && memorySize == null)) { return; } VmInstanceState vmState = Q.New(VmInstanceVO.class).select(VmInstanceVO_.state).eq(VmInstanceVO_.uuid, msg.getVmInstanceUuid()).findValue(); if (!VmGlobalConfig.NUMA.value(Boolean.class) && !VmInstanceState.Stopped.equals(vmState)) { throw new ApiMessageInterceptionException(argerr( <START> "cannot do cpu or memory update because numa not allowed when vm not in the state of %s", vmState <END> )); } if (!VmInstanceState.Stopped.equals(vo.getState()) && !VmInstanceState.Running.equals(vo.getState())) { throw new OperationFailureException(operr("The state of vm[uuid:%s] is %s. Only these state[%s] is allowed to update cpu or memory.", vo.getUuid(), vo.getState(), StringUtils.join(list(VmInstanceState.Running, VmInstanceState.Stopped), ","))); } if (VmInstanceState.Stopped.equals(vmState)) { return; } if (msg.getCpuNum() != null && msg.getCpuNum() < vo.getCpuNum()) { throw new ApiMessageInterceptionException(argerr( "can't not decrease cpu of vm[:uuid] when it is running", vo.getUuid() )); } if (msg.getMemorySize() != null && msg.getMemorySize() < vo.getMemorySize()) { throw new ApiMessageInterceptionException(argerr( "can't not decrease memory size of vm[:uuid] when it is running", vo.getUuid() )); } } }.execute(); }</code><technical_language>"cannot do cpu memory update numa allowed vm in state of %s" --> "the VM do online cpu/memory update is of NUMA architecture. Please stop VM do cpu/memory update again"</technical_language>

Target:
private void validate(APIUpdateVmInstanceMsg msg) { new SQLBatch() { @Override protected void scripts() { VmInstanceVO vo = Q.New(VmInstanceVO.class).eq(VmInstanceVO_.uuid, msg.getVmInstanceUuid()).find(); Integer cpuSum = msg.getCpuNum(); Long memorySize = msg.getMemorySize(); if ((cpuSum == null && memorySize == null)) { return; } VmInstanceState vmState = Q.New(VmInstanceVO.class).select(VmInstanceVO_.state).eq(VmInstanceVO_.uuid, msg.getVmInstanceUuid()).findValue(); if (!VmGlobalConfig.NUMA.value(Boolean.class) && !VmInstanceState.Stopped.equals(vmState)) { throw new ApiMessageInterceptionException(argerr( "the VM cannot do online cpu/memory update because it is not of NUMA architecture. Please stop the VM then do the cpu/memory update again" )); } if (!VmInstanceState.Stopped.equals(vo.getState()) && !VmInstanceState.Running.equals(vo.getState())) { throw new OperationFailureException(operr("The state of vm[uuid:%s] is %s. Only these state[%s] is allowed to update cpu or memory.", vo.getUuid(), vo.getState(), StringUtils.join(list(VmInstanceState.Running, VmInstanceState.Stopped), ","))); } if (VmInstanceState.Stopped.equals(vmState)) { return; } if (msg.getCpuNum() != null && msg.getCpuNum() < vo.getCpuNum()) { throw new ApiMessageInterceptionException(argerr( "can't not decrease cpu of vm[:uuid] when it is running", vo.getUuid() )); } if (msg.getMemorySize() != null && msg.getMemorySize() < vo.getMemorySize()) { throw new ApiMessageInterceptionException(argerr( "can't not decrease memory size of vm[:uuid] when it is running", vo.getUuid() )); } } }.execute(); }