@Override public LocationSpec<?> newLocationSpecFromString(String spec, Map<?,?> locationFlags, LocationRegistry registry) { ConfigBag config = extractConfig(locationFlags, spec, registry); @SuppressWarnings("unchecked") Map<String,?> globalProperties = registry.getProperties(); String namedLocation = (String) locationFlags.get(LocationInternal.NAMED_SPEC_NAME.getName()); if (registry != null) { LocationPropertiesFromBrooklynProperties.setLocalTempDir(globalProperties, config); } return LocationSpec.create(getLocationType()) .configure(config.getAllConfig()) .configure(LocationConfigUtils.finalAndOriginalSpecs(spec, locationFlags, globalProperties, namedLocation)); }
/** * Finds the properties that apply to location, stripping off the prefixes. * * Order of preference (in ascending order) is: * <ol> * <li>brooklyn.location.* * <li>brooklyn.location.provider.* * <li>brooklyn.location.named.namedlocation.* * </ol> * <p> * Converts deprecated hyphenated properties to the non-deprecated camelCase format. */ public Map<String, Object> getLocationProperties(String provider, String namedLocation, Map<String, ?> properties) { ConfigBag result = ConfigBag.newInstance(); if (!Strings.isNullOrEmpty(provider)) result.put(LocationConfigKeys.CLOUD_PROVIDER, provider); // named properties are preferred over providerOrApi properties result.putAll(transformDeprecated(getGenericLocationSingleWordProperties(properties))); if (!Strings.isNullOrEmpty(provider)) result.putAll(transformDeprecated(getScopedLocationProperties(provider, properties))); if (!Strings.isNullOrEmpty(namedLocation)) result.putAll(transformDeprecated(getNamedLocationProperties(namedLocation, properties))); setLocalTempDir(properties, result); return result.getAllConfigRaw(); }
@Override public LocationSpec<?> newLocationSpecFromString(String spec, Map<?, ?> locationFlags, LocationRegistry registry) { ConfigBag config = extractConfig(locationFlags, spec, registry); @SuppressWarnings("rawtypes") Map globalProperties = registry.getProperties(); String namedLocation = (String) locationFlags.get(LocationInternal.NAMED_SPEC_NAME.getName()); if (registry != null) { LocationPropertiesFromBrooklynProperties.setLocalTempDir(globalProperties, config); } if (config.getStringKey("target") == null) { throw new IllegalArgumentException("target must be specified in single-machine spec"); } String target = config.getStringKey("target").toString(); config.remove("target"); Maybe<LocationSpec<?>> testResolve = managementContext.getLocationRegistry().getLocationSpec(target); if (!testResolve.isPresent()) { throw new IllegalArgumentException("Invalid target location '" + target + "' for location '"+SINGLE+"': "+ Exceptions.collapseText( Maybe.getException(testResolve) ), Maybe.getException(testResolve)); } return LocationSpec.create(SingleMachineProvisioningLocation.class) .configure("location", target) .configure("locationFlags", config.getAllConfig()) .configure(LocationConfigUtils.finalAndOriginalSpecs(spec, locationFlags, globalProperties, namedLocation)); }