private CommandContext getCommandContext() { CommandContext commandContext = ExecutionHandler.createDefaultContextForTasks(enclosingCommand.getContext()); commandContext.getExecutionContext().setShouldEndJob(isLastTaskHandler()); return commandContext; }
private static CommandContext modifyContextForIntenralJob( CommandContext returnedContext, EngineLock lock) { return returnedContext .withExecutionContext(createMonitoredExecutionContext()) .withLock(lock) .withoutCompensationContext(); }
private AddVmCommand<AddVmParameters> createCommand(VM vm) { AddVmParameters param = new AddVmParameters(vm); AddVmCommand<AddVmParameters> cmd = new AddVmCommand<AddVmParameters>( param, CommandContext.createContext(param.getSessionId())) { @Override protected void initUser() { // Stub for testing } @Override protected void initTemplateDisks() { // Stub for testing } @Override protected void initStoragePoolId() { // stub for testing } @Override public VmTemplate getVmTemplate() { return createVmTemplate(); } }; cmd = spy(cmd); mockDaos(cmd); mockBackend(cmd); doReturn(new Cluster()).when(cmd).getCluster(); generateStorageToDisksMap(cmd); initDestSDs(cmd); storageDomainValidator = mock(StorageDomainValidator.class); doReturn(ValidationResult.VALID).when(storageDomainValidator).isDomainWithinThresholds(); doReturn(storageDomainValidator) .when(cmd) .createStorageDomainValidator(any(StorageDomain.class)); return cmd; }
protected AddVmFromTemplateCommand<AddVmParameters> createVmFromTemplateCommand(VM vm) { AddVmParameters param = new AddVmParameters(); param.setVm(vm); AddVmFromTemplateCommand<AddVmParameters> concrete = new AddVmFromTemplateCommand<AddVmParameters>( param, CommandContext.createContext(param.getSessionId())) { @Override protected void initUser() { // Stub for testing } @Override protected void initTemplateDisks() { // Stub for testing } @Override protected void initStoragePoolId() { // Stub for testing } @Override public VmTemplate getVmTemplate() { return createVmTemplate(); } }; AddVmFromTemplateCommand<AddVmParameters> result = spy(concrete); doReturn(true).when(result).checkNumberOfMonitors(); doReturn(createVmTemplate()).when(result).getVmTemplate(); doReturn(true).when(result).validateCustomProperties(any(VmStatic.class), anyList()); mockDaos(result); mockBackend(result); initCommandMethods(result); result.poolPerDc = this.macPoolPerDc; result.postConstruct(); return result; }
public static void setExecutionContextForTasks( CommandContext commandContext, ExecutionContext executionContext, EngineLock lock) { commandContext .withExecutionContext(createDefaultContextForTasksImpl(executionContext)) .withLock(lock); }
/** * Creates a default execution context for an inner command which creates VDSM tasks so the tasks * will be monitored under the parent {@code StepEnum.EXECUTING} step. If the parent command is an * internal command, its parent task step is passed to its internal command. * * @param parentExecutionContext The context of the parent command * @param lock The lock which should be released at child command * @return A context by which the internal command should be monitored. */ public static CommandContext createDefaultContextForTasks( CommandContext commandContext, EngineLock lock) { CommandContext result = commandContext.clone().withLock(lock).withoutCompensationContext(); return result.withExecutionContext( createDefaultContextForTasksImpl(result.getExecutionContext())); }
public static CommandContext createInternalJobContext( CommandContext commandContext, EngineLock lock) { return modifyContextForIntenralJob(commandContext.clone(), lock); }