Java Code Examples for org.apache.brooklyn.util.core.config.ConfigBag#get()

The following examples show how to use org.apache.brooklyn.util.core.config.ConfigBag#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InternalFactory.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance (e.g. of entity, location, enricher or policy.
 * Checks if special instructions on the spec, if supplied;
 * else if new-style class, calls no-arg constructor (ignoring spec); 
 * else if old-style, uses flags if avail as args or as spec and passes to constructor.
 */
protected <T> T construct(Class<? extends T> clazz, AbstractBrooklynObjectSpec<?,?> optionalSpec, Map<String,?> optionalOldStyleConstructorFlags) {
    try {
        if (optionalSpec!=null) {
            ConfigBag bag = ConfigBag.newInstance(optionalSpec.getConfig());
            Class<? extends SpecialBrooklynObjectConstructor> special = bag.get(SpecialBrooklynObjectConstructor.Config.SPECIAL_CONSTRUCTOR);
            if (special!=null) {
                // special construction requested; beta and very limited scope; see SpecialBrooklynObjectConstructor 
                return constructWithSpecial(special, clazz, optionalSpec);
            }
        }
        
        if (isNewStyle(clazz)) {
            return constructNewStyle(clazz);
        } else {
            MutableMap<String,Object> constructorFlags = MutableMap.of();
            if (optionalOldStyleConstructorFlags!=null) constructorFlags.add(optionalOldStyleConstructorFlags);
            else constructorFlags.add(optionalSpec.getFlags());
            
            return constructOldStyle(clazz, MutableMap.copyOf(constructorFlags));
        }
    } catch (Exception e) {
        throw Exceptions.propagate(e);
     }
 }
 
Example 2
Source File: SetHighAvailabilityModeEffectorBody.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Override
public ManagementNodeState call(ConfigBag parameters) {
    HighAvailabilityMode mode = parameters.get(MODE);
    Preconditions.checkNotNull(mode, MODE.getName() + " parameter is required");

    EntityHttpClient httpClient = ((BrooklynNode)entity()).http();
    HttpToolResponse resp = httpClient.post("/v1/server/ha/state", 
            ImmutableMap.of("Brooklyn-Allow-Non-Master-Access", "true"),
            ImmutableMap.of("mode", mode.toString()));

    if (resp.getResponseCode() == HttpStatus.SC_OK) {
        Function<HttpToolResponse, ManagementNodeState> parseRespone = Functionals.chain(
                Functionals.chain(HttpValueFunctions.jsonContents(), JsonFunctions.cast(String.class)),
                Enums.fromStringFunction(ManagementNodeState.class));
        return parseRespone.apply(resp);
    } else {
        throw new IllegalStateException("Unexpected response code: " + resp.getResponseCode() + "\n" + resp.getContentAsString());
    }
}
 
Example 3
Source File: JcloudsLocation.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
protected ConnectivityResolverOptions.Builder getConnectivityOptionsBuilder(ConfigBag setup, boolean isWindows) {
    boolean waitForSshable = !"false".equalsIgnoreCase(setup.get(JcloudsLocationConfig.WAIT_FOR_SSHABLE));
    boolean waitForWinRmable = !"false".equalsIgnoreCase(setup.get(JcloudsLocationConfig.WAIT_FOR_WINRM_AVAILABLE));
    boolean waitForConnectable = isWindows ? waitForWinRmable : waitForSshable;

    boolean usePortForwarding = setup.get(JcloudsLocationConfig.USE_PORT_FORWARDING);
    boolean skipJcloudsSshing = usePortForwarding ||
            Boolean.FALSE.equals(setup.get(JcloudsLocationConfig.USE_JCLOUDS_SSH_INIT));

    ConnectivityResolverOptions.Builder builder = ConnectivityResolverOptions.builder()
            .waitForConnectable(waitForConnectable)
            .usePortForwarding(usePortForwarding)
            .skipJcloudsSshing(skipJcloudsSshing);

    String pollForFirstReachable = setup.get(JcloudsLocationConfig.POLL_FOR_FIRST_REACHABLE_ADDRESS);
    boolean pollEnabled = !"false".equalsIgnoreCase(pollForFirstReachable);

    if (pollEnabled) {
        Predicate<? super HostAndPort> reachableAddressesPredicate = getReachableAddressesPredicate(setup);
        Duration pollTimeout = "true".equals(pollForFirstReachable)
                               ? Duration.FIVE_MINUTES
                               : Duration.of(pollForFirstReachable);
        builder.pollForReachableAddresses(reachableAddressesPredicate, pollTimeout, true);
    }
    return builder;
}
 
Example 4
Source File: AddChildrenEffector.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
public Body(Effector<?> eff, ConfigBag params) {
    this.effector = eff;
    String newBlueprint = null;
    Object yaml = params.get(BLUEPRINT_YAML);
    if (yaml instanceof Map) {
        newBlueprint = toJson((Map<?,?>)yaml);
    } else if (yaml instanceof String) {
        newBlueprint = (String) yaml;
    } else if (yaml!=null) {
        throw new IllegalArgumentException(this+" requires map or string in "+BLUEPRINT_YAML+"; not "+yaml.getClass()+" ("+yaml+")");
    }
    String blueprintType = params.get(BLUEPRINT_TYPE);
    if (blueprintType!=null) {
        if (newBlueprint!=null) {
            throw new IllegalArgumentException(this+" cannot take both "+BLUEPRINT_TYPE+" and "+BLUEPRINT_YAML);
        }
        newBlueprint = "services: [ { type: "+blueprintType+" } ]";
    }
    if (newBlueprint==null) {
        throw new IllegalArgumentException(this+" requires either "+BLUEPRINT_TYPE+" or "+BLUEPRINT_YAML);
    }
    blueprintBase = newBlueprint;
    autostart = params.get(AUTO_START);
}
 
Example 5
Source File: LocationConfigUtils.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
private static String getKeyDataFromDataKeyOrFileKey(ConfigBag config, ConfigKey<String> dataKey, ConfigKey<String> fileKey) {
    boolean unused = config.isUnused(dataKey);
    String data = config.get(dataKey);
    if (Strings.isNonBlank(data) && !unused) {
        return data.trim();
    }
    
    String file = config.get(fileKey);
    if (groovyTruth(file)) {
        List<String> files = Arrays.asList(file.split(File.pathSeparator));
        List<String> filesTidied = tidyFilePaths(files);
        String fileData = getFileContents(filesTidied);
        if (fileData == null) {
            log.warn("Invalid file" + (files.size() > 1 ? "s" : "") + " for " + fileKey + " (given " + files + 
                    (files.equals(filesTidied) ? "" : "; converted to " + filesTidied) + ") " +
                    "may fail provisioning " + config.getDescription());
        } else if (groovyTruth(data)) {
            if (!fileData.trim().equals(data.trim()))
                log.warn(dataKey.getName()+" and "+fileKey.getName()+" both specified; preferring the former");
        } else {
            data = fileData;
            config.put(dataKey, data);
            config.get(dataKey);
        }
    }
    
    return data;
}
 
Example 6
Source File: ConfigKeys.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
public static ConfigKey<?> newInstance(ConfigBag keyDefs) {
    String typeName = Strings.toString(keyDefs.getStringKey("type"));
    if (Strings.isNonBlank(typeName)) {
        // TODO dynamic typing - see TYPE key commented out above; also see AddSensor.getType for type lookup
        log.warn("Setting 'type' is not currently supported for dynamic config keys; ignoring in definition of "+keyDefs);
    }
    
    Class<Object> type = Object.class;
    String name = keyDefs.get(NAME);
    String description = keyDefs.get(DESCRIPTION);
    Object defaultValue = keyDefs.get(DEFAULT_VALUE);
    return newConfigKey(type, name, description, defaultValue);
}
 
Example 7
Source File: DefaultAzureArmNetworkCreatorTest.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
@Test
public void testVanillaWhereExistingNetworkButNoSubnet() throws Exception {
    //Setup config bag
    ConfigBag configBag = ConfigBag.newInstance();
    configBag.put(CLOUD_REGION_ID, TEST_LOCATION);

    //Setup mocks
    when(subnetApi.get(TEST_SUBNET_NAME)).thenReturn(null).thenReturn(subnet); //null first time, subnet next
    when(virtualNetworkApi.get(TEST_NETWORK_NAME)).thenReturn(virtualNetwork);
    when(resourceGroupApi.get(TEST_RESOURCE_GROUP)).thenReturn(resourceGroup);
    when(subnet.properties().provisioningState()).thenReturn("Updating").thenReturn("Succeeded");

    //Test
    DefaultAzureArmNetworkCreator.createDefaultNetworkAndAddToTemplateOptionsIfRequired(computeService, configBag);

    //verify
    verify(subnetApi).createOrUpdate(eq(TEST_SUBNET_NAME), any());
    verify(subnetApi, atLeast(2)).get(TEST_SUBNET_NAME);
    verify(subnet).id();

    verify(resourceGroupApi).get(TEST_RESOURCE_GROUP);
    verify(resourceGroupApi, never()).create(any(), any(), any());

    verify(virtualNetworkApi, never()).createOrUpdate(any(), any(), any(), any());

    //verify templateOptions updated to include defaults
    Map<String, Object> templateOptions = configBag.get(TEMPLATE_OPTIONS);
    Map<String, Object> ipOptions = (Map<String, Object>) ((List)templateOptions.get("ipOptions")).iterator().next();
    assertEquals(ipOptions.get("subnet"), TEST_SUBNET_ID);
    assertEquals(ipOptions.get("allocateNewPublicIp"), true);
}
 
Example 8
Source File: DockerJcloudsLocation.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
@Override
protected MachineLocation obtainOnce(ConfigBag setup) throws NoMachinesAvailableException {
    // Use the provider name that jclouds expects; rely on resolver to have validated this.
    setup.configure(JcloudsLocation.CLOUD_PROVIDER, "docker");

    // Inject default image, if absent
    String imageId = setup.get(JcloudsLocation.IMAGE_ID);
    String imageNameRegex = setup.get(JcloudsLocation.IMAGE_NAME_REGEX);
    String imageDescriptionRegex = setup.get(JcloudsLocation.IMAGE_DESCRIPTION_REGEX);
    String defaultImageDescriptionRegex = setup.get(DEFAULT_IMAGE_DESCRIPTION_REGEX);
    OsFamily osFamily = setup.get(OS_FAMILY);
    String osVersionRegex = setup.get(OS_VERSION_REGEX);

    if (Strings.isBlank(imageId) && Strings.isBlank(imageNameRegex) && Strings.isBlank(imageDescriptionRegex)) {
        if (osFamily != null || osVersionRegex != null) {
            for (ImageMetadata imageMetadata : DEFAULT_IMAGES) {
                if (imageMetadata.matches(osFamily, osVersionRegex)) {
                    String imageDescription = imageMetadata.getImageDescription();
                    LOG.debug("Setting default image regex to {}, for obtain call in {}; removing osFamily={} and osVersionRegex={}",
                            new Object[]{imageDescription, this, osFamily, osVersionRegex});
                    setup.configure(JcloudsLocation.IMAGE_DESCRIPTION_REGEX, imageDescription);
                    setup.configure(OS_FAMILY, null);
                    setup.configure(OS_VERSION_REGEX, null);
                    break;
                }
            }
        } else if (Strings.isNonBlank(defaultImageDescriptionRegex)) {
            LOG.debug("Setting default image regex to {}, for obtain call in {}", defaultImageDescriptionRegex, this);
            setup.configure(JcloudsLocation.IMAGE_DESCRIPTION_REGEX, defaultImageDescriptionRegex);
        }
    }

    return super.obtainOnce(setup);
}
 
Example 9
Source File: BrooklynNodeImpl.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
private StopMode getStopProcessModeParam() {
    ConfigBag parameters = BrooklynTaskTags.getCurrentEffectorParameters();
    if (parameters != null) {
        return parameters.get(StopSoftwareParameters.STOP_PROCESS_MODE);
    } else {
        return StopSoftwareParameters.STOP_PROCESS_MODE.getDefaultValue();
    }
}
 
Example 10
Source File: Winrm4jTool.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
private <T> T getRequiredConfig(ConfigBag bag, ConfigKey<T> key) {
    T result = bag.get(key);
    if (result == null) {
        throw new IllegalArgumentException("Missing config "+key+" in "+Sanitizer.sanitize(bag));
    }
    return result;
}
 
Example 11
Source File: BrooklynNodeImpl.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
@Override
public Void call(ConfigBag parameters) {
    Duration timeout = parameters.get(TIMEOUT);

    ConfigBag stopParameters = ConfigBag.newInstanceCopying(parameters);
    stopParameters.put(ShutdownEffector.STOP_APPS_FIRST, Boolean.FALSE);
    stopParameters.putIfAbsent(ShutdownEffector.SHUTDOWN_TIMEOUT, timeout);
    stopParameters.putIfAbsent(ShutdownEffector.REQUEST_TIMEOUT, timeout);
    DynamicTasks.queue(Effectors.invocation(entity(), STOP, stopParameters)).asTask().getUnchecked();
    return null;
}
 
Example 12
Source File: KubernetesLocation.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
protected String findImageName(Entity entity, ConfigBag setup) {
    String result = entity.config().get(DockerContainer.IMAGE_NAME);
    if (Strings.isNonBlank(result)) return result;

    result = setup.get(IMAGE);
    if (Strings.isNonBlank(result)) return result;

    String osFamily = setup.get(OS_FAMILY);
    String osVersion = setup.get(OS_VERSION_REGEX);
    Optional<String> imageName = new ImageChooser().chooseImage(osFamily, osVersion);
    if (imageName.isPresent()) return imageName.get();

    throw new IllegalStateException("No matching image found for " + entity
            + " (no explicit image name, osFamily=" + osFamily + "; osVersion=" + osVersion + ")");
}
 
Example 13
Source File: CreatePasswordSensor.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
public CreatePasswordSensor(ConfigBag params) {
    super(params);
    passwordLength = params.get(PASSWORD_LENGTH);
    acceptableChars = params.get(ACCEPTABLE_CHARS);
    characterGroups = params.get(CHARACTER_GROUPS);
}
 
Example 14
Source File: AddSensor.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
public AddSensor(final ConfigBag params) {
    this.name = Preconditions.checkNotNull(params.get(SENSOR_NAME), "Name must be supplied when defining a sensor");
    this.period = params.get(SENSOR_PERIOD);
    this.type = params.get(SENSOR_TYPE);
    this.params = params;
}
 
Example 15
Source File: WindowsPerformanceCounterSensors.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
public WindowsPerformanceCounterSensors(ConfigBag params) {
    sensors = params.get(PERFORMANCE_COUNTERS);
    period = params.get(PERIOD);
}
 
Example 16
Source File: DockerJcloudsLocation.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
@Override
public Template buildTemplate(ComputeService computeService, ConfigBag config, Collection<JcloudsLocationCustomizer> customizers) {
    String loginUser = config.get(JcloudsLocation.LOGIN_USER);
    String loginPassword = config.get(JcloudsLocation.LOGIN_USER_PASSWORD);
    String loginKeyFile = config.get(JcloudsLocation.LOGIN_USER_PRIVATE_KEY_FILE);
    String loginKeyData = config.get(JcloudsLocation.LOGIN_USER_PRIVATE_KEY_DATA);

    Template template = super.buildTemplate(computeService, config, customizers);
    DockerTemplateOptions templateOptions = (DockerTemplateOptions) template.getOptions();
    Image image = template.getImage();
    List<String> env = MutableList.copyOf(templateOptions.getEnv());

    // Inject login credentials, if required
    Boolean injectLoginCredentials = config.get(INJECT_LOGIN_CREDENTIAL);
    if (injectLoginCredentials == null) {
        String imageDescription = image.getDescription();
        for (String regex : IMAGE_DESCRIPTION_REGEXES_REQUIRING_INJECTED_LOGIN_CREDS) {
            if (imageDescription != null && imageDescription.matches(regex)) {
                injectLoginCredentials = true;
                break;
            }
        }
    }
    if (Strings.isBlank(loginUser) && Strings.isBlank(loginPassword) && Strings.isBlank(loginKeyFile) && Strings.isBlank(loginKeyData)) {
        if (Boolean.TRUE.equals(injectLoginCredentials)) {
            loginUser = "root";
            loginPassword = Identifiers.makeRandomPassword(12);
            templateOptions.overrideLoginUser(loginUser);
            templateOptions.overrideLoginPassword(loginPassword);

            env.add("BROOKLYN_ROOT_PASSWORD=" + loginPassword);
        }
    }

    Entity context = validateCallerContext(config);
    Map<String, Object> containerEnv = MutableMap.copyOf(context.config().get(DockerContainer.CONTAINER_ENVIRONMENT));
    for (Map.Entry<String, String> entry : Maps.transformValues(containerEnv, Functions.toStringFunction()).entrySet()) {
        env.add(String.format("%s=%s", entry.getKey(), entry.getValue()));
    }
    templateOptions.env(env);

    return template;
}
 
Example 17
Source File: MaxConcurrencySensor.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
public MaxConcurrencySensor(ConfigBag params) {
    this.sensorName = params.get(SENSOR_NAME);
    this.maxConcurrency = params.getStringKey(MAX_CONCURRENCY.getName());
}
 
Example 18
Source File: BrooklynNodeUpgradeEffectorBody.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
@Override
public Void call(ConfigBag parametersO) {
    if (!isPersistenceModeEnabled(entity())) {
        // would could try a `forcePersistNow`, but that's sloppy; 
        // for now, require HA/persistence for upgrading
        DynamicTasks.queue( Tasks.warning("Check persistence", 
            new IllegalStateException("Persistence does not appear to be enabled at this cluster. "
            + "In-place node upgrade will not succeed unless a custom launch script enables it.")) );
    }

    final ConfigBag parameters = ConfigBag.newInstanceCopying(parametersO);

    /*
     * all parameters are passed to children, apart from EXTRA_CONFIG
     * whose value (as a map) is so passed; it provides an easy way to set extra config in the gui.
     * (IOW a key-value mapping can be passed either inside EXTRA_CONFIG or as a sibling to EXTRA_CONFIG)  
     */
    if (parameters.containsKey(EXTRA_CONFIG)) {
        Map<String, Object> extra = parameters.get(EXTRA_CONFIG);
        parameters.remove(EXTRA_CONFIG);
        parameters.putAll(extra);
    }
    log.debug(this+" upgrading, using "+parameters);
    
    final String bkName;
    boolean doDryRunFirst = parameters.get(DO_DRY_RUN_FIRST);
    if(doDryRunFirst) {
        bkName = dryRunUpdate(parameters);
    } else {
        bkName = "direct-"+Identifiers.makeRandomId(4);
    }
    
    // Stop running instance
    DynamicTasks.queue(Tasks.builder().displayName("shutdown node")
            .add(Effectors.invocation(entity(), BrooklynNode.STOP_NODE_BUT_LEAVE_APPS, ImmutableMap.of(StopSoftwareParameters.STOP_MACHINE_MODE, StopMode.NEVER)))
            .build());

    // backup old files
    DynamicTasks.queue(Tasks.builder().displayName("backup old version").body(new Runnable() {
        @Override
        public void run() {
            String runDir = entity().getAttribute(SoftwareProcess.RUN_DIR);
            String bkDir = Urls.mergePaths(runDir, "..", Urls.getBasename(runDir)+"-backups", bkName);
            log.debug(this+" storing backup of previous version in "+bkDir);
            DynamicTasks.queue(SshEffectorTasks.ssh(
                "cd "+runDir,
                "mkdir -p "+bkDir,
                "mv * "+bkDir
                // By removing the run dir of the entity we force it to go through
                // the customize step again on start and re-generate local-brooklyn.properties.
                ).summary("move files"));
        }
    }).build());
    
    // Reconfigure entity
    DynamicTasks.queue(Tasks.builder().displayName("reconfigure").body(new Runnable() {
        @Override
        public void run() {
            DynamicTasks.waitForLast();
            entity().sensors().set(SoftwareProcess.INSTALL_DIR, (String)null);
            entity().config().set(SoftwareProcess.INSTALL_UNIQUE_LABEL, (String)null);
            entity().config().putAll(parameters.getAllConfig());
            entity().sensors().set(BrooklynNode.DOWNLOAD_URL, entity().getConfig(DOWNLOAD_URL));

            // Setting SUGGESTED_VERSION will result in an new empty INSTALL_FOLDER, but clear it
            // just in case the user specified already installed version.
            ((BrooklynNodeDriver)((DriverDependentEntity<?>)entity()).getDriver()).clearInstallDir();
        }
    }).build());
    
    // Start this entity, running the new version.
    // This will download and install the new dist (if not already done by the dry run node).
    DynamicTasks.queue(Effectors.invocation(entity(), BrooklynNode.START, ConfigBag.EMPTY));

    return null;
}
 
Example 19
Source File: ConfigKeyDeprecationTest.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
public MyEntityInitializer(ConfigBag params) {
    this.key1 = params.get(KEY_1);
}
 
Example 20
Source File: ExecWithLoggingHelpers.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
public int execWithLogging(Map<String,?> props, final String summaryForLogging, final List<String> commands,
        final Map<String,?> env, String expectedCommandHeaders, final ExecRunner execCommand) {
    if (commandLogger!=null && commandLogger.isDebugEnabled()) {
        String allcmds = (Strings.isBlank(expectedCommandHeaders) ? "" : expectedCommandHeaders + " ; ") + Strings.join(commands, " ; ");
        commandLogger.debug("{}, initiating "+shortName.toLowerCase()+" on machine {}{}: {}",
                new Object[] {summaryForLogging, getTargetName(),
                env!=null && !env.isEmpty() ? " (env "+Sanitizer.sanitize(env)+")": "", allcmds});
    }

    if (commands.isEmpty()) {
        if (commandLogger!=null && commandLogger.isDebugEnabled())
            commandLogger.debug("{}, on machine {}, ending: no commands to run", summaryForLogging, getTargetName());
        return 0;
    }

    final ConfigBag execFlags = new ConfigBag().putAll(props);
    // some props get overridden in execFlags, so remove them from the tool flags
    final ConfigBag toolFlags = new ConfigBag().putAll(props).removeAll(
            LOG_PREFIX, STDOUT, STDERR, ShellTool.PROP_NO_EXTRA_OUTPUT);

    execFlags.configure(ShellTool.PROP_SUMMARY, summaryForLogging);
    
    preExecChecks();
    
    String logPrefix = execFlags.get(LOG_PREFIX);
    if (logPrefix==null) logPrefix = constructDefaultLoggingPrefix(execFlags);

    if (!execFlags.get(NO_STDOUT_LOGGING)) {
        String stdoutLogPrefix = "["+(logPrefix != null ? logPrefix+":stdout" : "stdout")+"] ";
        OutputStream outO = LoggingOutputStream.builder()
                .outputStream(execFlags.get(STDOUT))
                .logger(commandLogger)
                .logPrefix(stdoutLogPrefix)
                .build();

        execFlags.put(STDOUT, outO);
    }

    if (!execFlags.get(NO_STDERR_LOGGING)) {
        String stderrLogPrefix = "["+(logPrefix != null ? logPrefix+":stderr" : "stderr")+"] ";
        OutputStream outE = LoggingOutputStream.builder()
                .outputStream(execFlags.get(STDERR))
                .logger(commandLogger)
                .logPrefix(stderrLogPrefix)
                .build();
        execFlags.put(STDERR, outE);
    }

    Tasks.setBlockingDetails(shortName+" executing, "+summaryForLogging);
    try {
        return execWithTool(MutableMap.copyOf(toolFlags.getAllConfig()), new Function<ShellTool, Integer>() {
            @Override
            public Integer apply(ShellTool tool) {
                int result = execCommand.exec(tool, MutableMap.copyOf(execFlags.getAllConfig()), commands, env);
                if (commandLogger!=null && commandLogger.isDebugEnabled()) 
                    commandLogger.debug("{}, on machine {}, completed: return status {}",
                            new Object[] {summaryForLogging, getTargetName(), result});
                return result;
            }});

    } finally {
        Tasks.setBlockingDetails(null);
    }
}