private CommandContext getCommandContext() {
    CommandContext commandContext =
        ExecutionHandler.createDefaultContextForTasks(enclosingCommand.getContext());
    commandContext.getExecutionContext().setShouldEndJob(isLastTaskHandler());

    return commandContext;
  }
 /**
  * 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()));
 }