/** * Gets all properties that start with the given {@code fullPrefix}, stripping off * the prefix in the returned map. */ protected Map<String, Object> getMatchingProperties(String fullPrefix, Map<String, ?> properties) { return ConfigUtils.filterForPrefixAndStrip(properties, fullPrefix).asMapWithStringKeys(); }
/** * Gets all properties that start with the given {@code fullPrefix}, stripping off * the prefix in the returned map. * * Returns only those properties whose key suffix is a single word (i.e. contains no dots). * We do this special (sub-optimal!) filtering because we want sub-scoped things * (e.g. could want brooklyn.location.privateKeyFile, but not brooklyn.location.named.*). */ protected Map<String, Object> getMatchingSingleWordProperties(String fullPrefix, Map<String, ?> properties) { BrooklynProperties filteredProperties = ConfigUtils.filterForPrefixAndStrip(properties, fullPrefix); return ConfigUtils.filterFor(filteredProperties, Predicates.not(Predicates.containsPattern("\\."))).asMapWithStringKeys(); }
public static final Set<ConfigKey<?>> getAllSupportedProperties() { Set<String> configsOnClass = Sets.newLinkedHashSet( Iterables.transform(ConfigUtils.getStaticKeysOnClass(JcloudsLocation.class), new Function<HasConfigKey<?>,String>() { @Override @Nullable public String apply(@Nullable HasConfigKey<?> input) { return input.getConfigKey().getName(); } })); Set<ConfigKey<?>> configKeysInList = ImmutableSet.<ConfigKey<?>>builder() .addAll(SUPPORTED_TEMPLATE_BUILDER_PROPERTIES.keySet()) .addAll(SUPPORTED_TEMPLATE_OPTIONS_PROPERTIES.keySet()) .build(); Set<String> configsInList = Sets.newLinkedHashSet( Iterables.transform(configKeysInList, new Function<ConfigKey<?>,String>() { @Override @Nullable public String apply(@Nullable ConfigKey<?> input) { return input.getName(); } })); SetView<String> extrasInList = Sets.difference(configsInList, configsOnClass); // notInList is normal if (!extrasInList.isEmpty()) LOG.warn("JcloudsLocation supported properties differs from config defined on class: " + extrasInList); return Collections.unmodifiableSet(configKeysInList); }
@Override protected String constructDefaultLoggingPrefix(ConfigBag execFlags) { String hostname = getAddress().getHostName(); Integer port = execFlags.peek(SshTool.PROP_PORT); if (port == null) port = getConfig(ConfigUtils.prefixedKey(SshTool.BROOKLYN_CONFIG_KEY_PREFIX, SshTool.PROP_PORT)); if (port == null) port = getConfig(ConfigUtils.prefixedKey(SSHCONFIG_PREFIX, SshTool.PROP_PORT)); return (user != null ? user+"@" : "") + hostname + (port != null ? ":"+port : ""); } @Override
/** extracts the values for the main brooklyn.ssh.config.* config keys (i.e. those declared in ConfigKeys) * as declared on the entity, and inserts them in a map using the unprefixed state, for ssh. */ /* currently this is computed for each call, which may be wasteful, but it is reliable in the face of config changes. * we could cache the Map. note that we do _not_ cache (or even own) the SshTool; * the SshTool is created or re-used by the SshMachineLocation making use of these properties */ protected Map<String, Object> getSshFlags() { Map<String, Object> result = Maps.newLinkedHashMap(); StringConfigMap globalConfig = ((EntityInternal)getEntity()).getManagementContext().getConfig(); Map<ConfigKey<?>, Object> mgmtConfig = globalConfig.getAllConfig(); Map<ConfigKey<?>, Object> entityConfig = ((EntityInternal)getEntity()).getAllConfig(); Map<ConfigKey<?>, Object> allConfig = MutableMap.<ConfigKey<?>, Object>builder().putAll(mgmtConfig).putAll(entityConfig).build(); for (ConfigKey<?> key : allConfig.keySet()) { if (key.getName().startsWith(SshTool.BROOKLYN_CONFIG_KEY_PREFIX)) { // have to use raw config to test whether the config is set Object val = ((EntityInternal)getEntity()).getConfigMap().getRawConfig(key); if (val!=null) { val = getEntity().getConfig(key); } else { val = globalConfig.getRawConfig(key); if (val!=null) val = globalConfig.getConfig(key); } if (val!=null) { result.put(ConfigUtils.unprefixedKey(SshTool.BROOKLYN_CONFIG_KEY_PREFIX, key).getName(), val); } } } return result; }
protected Map<String, Object> getNamedLocationProperties(String locationName, Map<String, ?> properties) { checkArgument(!Strings.isNullOrEmpty(locationName), "locationName should not be blank"); String prefix = String.format("brooklyn.location.named.%s.", locationName); return ConfigUtils.filterForPrefixAndStrip(properties, prefix).asMapWithStringKeys(); }
protected Map<String, Object> getNamedJcloudsProperties(String locationName, Map<String, ?> properties) { if(locationName == null) return Maps.newHashMap(); String prefix = String.format("brooklyn.location.named.%s.", locationName); return ConfigUtils.filterForPrefixAndStrip(properties, prefix).asMapWithStringKeys(); }
/** * Gets all properties that start with {@code "brooklyn.location."+scopeSuffix+"."}, stripping off * the prefix in the returned map. */ protected Map<String, Object> getScopedLocationProperties(String scopeSuffix, Map<String, ?> properties) { checkArgument(!scopeSuffix.startsWith("."), "scopeSuffix \"%s\" should not start with \".\"", scopeSuffix); checkArgument(!scopeSuffix.endsWith("."), "scopeSuffix \"%s\" should not end with \".\"", scopeSuffix); String prefix = String.format("brooklyn.location.%s.", scopeSuffix); return ConfigUtils.filterForPrefixAndStrip(properties, prefix).asMapWithStringKeys(); }
Map<String, Object> config = ConfigUtils.filterForPrefixAndStrip(namedLocationProps.asMapWithStringKeys(), k+"."); definedLocations.put(id, new BasicLocationDefinition(id, name, spec, config)); count++;