private static Map<String, Object> getSshFlags(Location location) { Set<ConfigKey<?>> sshConfig = MutableSet.of(); StringConfigMap mgmtConfig = null; sshConfig.addAll(location.config().findKeysPresent(ConfigPredicates.nameStartsWith(SshTool.BROOKLYN_CONFIG_KEY_PREFIX))); if (location instanceof AbstractLocation) { ManagementContext mgmt = ((AbstractLocation)location).getManagementContext(); if (mgmt!=null) { mgmtConfig = mgmt.getConfig(); sshConfig.addAll(mgmtConfig.findKeysPresent(ConfigPredicates.nameStartsWith(SshTool.BROOKLYN_CONFIG_KEY_PREFIX))); } } Map<String, Object> result = Maps.newLinkedHashMap(); for (ConfigKey<?> key : sshConfig) { Maybe<Object> v = ((LocationInternal)location).config().getRaw(key); if (v.isAbsent() && mgmtConfig!=null) v = Maybe.of( (Object) mgmtConfig.getConfig(key) ); result.put(ConfigUtils.unprefixedKey(SshTool.BROOKLYN_CONFIG_KEY_PREFIX, key).getName(), v.get()); } return result; }
sshConfig.addAll(optionalLocation.config().findKeysPresent(ConfigPredicates.nameStartsWith(SshTool.BROOKLYN_CONFIG_KEY_PREFIX)));
/** * Looks up {@link ConfigKey configuration} with the entity value taking precedence over the * location, and returning a default value (normally {@literal null}) if neither is present. */ public <T> T lookup(final ConfigKey<T> config, Entity entity, ConfigBag setup, T defaultValue) { boolean entityConfigPresent = !entity.config().findKeysPresent(new Predicate<ConfigKey<?>>() { @Override public boolean apply(@Nullable ConfigKey<?> configKey) { return config.equals(configKey); } }).isEmpty(); boolean setupBagConfigPresent = setup.containsKey(config); if (entityConfigPresent) { return entity.config().get(config); } else if (setupBagConfigPresent) { return setup.get(config); } return defaultValue; }