> + public VersionAwareRegionToEndpoint(@Region Supplier<Map<String,
> Supplier<URI>>> regionToEndpointSupplier) {
> + this.regionToEndpointSupplier = checkNotNull(regionToEndpointSupplier,
> "regionToEndpointSupplier");
> + }
> +
> + @Override
> + public URI apply(@Nullable Object from) {
> + checkArgument(from != null && from instanceof String, "you must
> specify a region, as a String argument");
> + Map<String, Supplier<URI>> regionToEndpoint =
> regionToEndpointSupplier.get();
> + checkState(!regionToEndpoint.isEmpty(), "no region name to endpoint
> mappings configured!");
> + checkArgument(regionToEndpoint.containsKey(from),
> + "requested location %s, which is not in the configured
> locations: %s", from, regionToEndpoint);
> + String uri = regionToEndpoint.get(from).get().toString();
> +
> + /**
> + * A quick fix to ensure Neutron works with endpoint definitions that
> are not version-agnostic.
> + */
An alternative way to implement this is to figure out how to handle version
inconsistencies and version negotiation in a consistent way for all the
services, including the cases when there are noticeable differences between
devstack and provider implementations. This can probably be based, to an
extent, on the version negotiation currently in use for glance, or similar.
For now, however, this will allow devstack-tested code to work with provider
code. The endpoint URI will contain a /v2.0 in one case, and in the other, it
will not.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/169/files#r20164670