@Override public Response start(Action action) { RunVmParams params; VdcActionType actionType; if (action.isSetVm()) { VM vm = action.getVm(); validateEnums(VM.class, vm); actionType = VdcActionType.RunVmOnce; params = createRunVmOnceParams(vm); } else { actionType = VdcActionType.RunVm; params = new RunVmParams(guid); } if (action.isSetPause() && action.isPause()) { params.setRunAndPause(true); } boolean useSysprep = action.isSetUseSysprep() && action.isUseSysprep(); boolean useCloudInit = action.isSetUseCloudInit() && action.isUseCloudInit(); if (useSysprep && useCloudInit) { Fault fault = new Fault(); fault.setReason(localize(Messages.CANT_USE_SYSPREP_AND_CLOUD_INIT_SIMULTANEOUSLY)); return Response.status(Response.Status.CONFLICT).entity(fault).build(); } if (useSysprep) { params.setInitializationType(InitializationType.Sysprep); } else if (useCloudInit) { params.setInitializationType(InitializationType.CloudInit); } else { params.setInitializationType(InitializationType.None); } return doAction(actionType, params, action); }
protected Fault fault(String reason, String detail) { Fault fault = new Fault(); fault.setReason(reason); fault.setDetail(detail); return fault; }