Skip to content

Commit

Permalink
Issue 1037: consolidate keystone endpoints to end with /v2.0/ + chang…
Browse files Browse the repository at this point in the history
…e hpcloud to default to user/pass auth
  • Loading branch information
Adrian Cole committed Jul 29, 2012
1 parent ba56e2d commit 735da0a
Show file tree
Hide file tree
Showing 31 changed files with 94 additions and 124 deletions.
2 changes: 1 addition & 1 deletion apis/openstack-keystone/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<properties>
<!-- keystone endpoint -->
<test.openstack-keystone.endpoint>http://localhost:5000</test.openstack-keystone.endpoint>
<test.openstack-keystone.endpoint>http://localhost:5000/v${jclouds.api-version}/</test.openstack-keystone.endpoint>
<!-- keystone version -->
<test.openstack-keystone.api-version>2.0</test.openstack-keystone.api-version>
<test.openstack-keystone.build-version></test.openstack-keystone.build-version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
* />
* @author Adrian Cole
*/
@Path("/v2.0")
public interface AuthenticationAsyncApi {

/**
Expand Down Expand Up @@ -76,8 +75,6 @@ ListenableFuture<Access> authenticateWithTenantIdAndCredentials(@Nullable @Paylo
@Consumes(MediaType.APPLICATION_JSON)
@Path("/tokens")
@MapBinder(BindAuthToJsonPayload.class)
// TODO: is tenantName permanent? or should we switch to tenantId at some point. seems most tools
// still use tenantName
ListenableFuture<Access> authenticateWithTenantNameAndCredentials(@Nullable @PayloadParam("tenantName") String tenantName,
ApiAccessKeyCredentials apiAccessKeyCredentials);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneParserModule;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneRestClientModule;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneRestClientModule.KeystoneAdminURLModule;
import org.jclouds.openstack.v2_0.ServiceType;
Expand Down Expand Up @@ -69,10 +68,8 @@ protected KeystoneApiMetadata(Builder builder) {

public static Properties defaultProperties() {
Properties properties = BaseRestApiMetadata.defaultProperties();
// TODO: this doesn't actually do anything yet.
properties.setProperty(KeystoneProperties.VERSION, "2.0");
properties.setProperty(CREDENTIAL_TYPE, CredentialTypes.PASSWORD_CREDENTIALS);
properties.put(SERVICE_TYPE, ServiceType.IDENTITY);
properties.setProperty(SERVICE_TYPE, ServiceType.IDENTITY);
return properties;
}

Expand All @@ -82,11 +79,12 @@ protected Builder(Class<?> api, Class<?> asyncApi) {
super(api, asyncApi);
id("openstack-keystone")
.name("OpenStack Keystone Essex+ API")
.identityName("tenantId:user")
.credentialName("password")
.identityName("${tenantName}:${userName} or ${userName}, if your keystone supports a default tenant")
.credentialName("${password}")
.endpointName("KeyStone base url ending in /v${jclouds.api-version}/")
.documentation(URI.create("http://api.openstack.org/"))
.version("2.0")
.defaultEndpoint("http://localhost:5000")
.defaultEndpoint("http://localhost:5000/v${jclouds.api-version}/")
.defaultProperties(KeystoneApiMetadata.defaultProperties())
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
.add(KeystoneAuthenticationModule.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;

import org.jclouds.Constants;
import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata;
import org.jclouds.openstack.keystone.v2_0.features.ServiceAsyncApi;
import org.jclouds.openstack.keystone.v2_0.features.TenantAsyncApi;
Expand Down Expand Up @@ -53,7 +51,6 @@ public interface KeystoneAsyncApi {
@GET
@SelectJson("version")
@Consumes(MediaType.APPLICATION_JSON)
@Path("/v{" + Constants.PROPERTY_API_VERSION + "}/")
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<ApiMetadata> getApiMetadata();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ public interface KeystoneProperties {
*/
public static final String REQUIRES_TENANT = "jclouds.keystone.requires-tenant";

/**
* version of the keystone service
*/
public static final String VERSION = "jclouds.keystone.version";

/**
* type of the keystone service. ex. {@code compute}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,36 @@

import java.net.URI;
import java.util.Map;
import java.util.NoSuchElementException;

import javax.inject.Named;
import javax.inject.Singleton;

import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError;
import org.jclouds.openstack.keystone.v2_0.KeystoneAsyncApi;
import org.jclouds.location.Provider;
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
import org.jclouds.openstack.keystone.v2_0.features.ServiceAsyncApi;
import org.jclouds.openstack.keystone.v2_0.KeystoneAsyncApi;
import org.jclouds.openstack.keystone.v2_0.features.ServiceApi;
import org.jclouds.openstack.keystone.v2_0.features.TenantAsyncApi;
import org.jclouds.openstack.keystone.v2_0.features.ServiceAsyncApi;
import org.jclouds.openstack.keystone.v2_0.features.TenantApi;
import org.jclouds.openstack.keystone.v2_0.features.TokenAsyncApi;
import org.jclouds.openstack.keystone.v2_0.features.TenantAsyncApi;
import org.jclouds.openstack.keystone.v2_0.features.TokenApi;
import org.jclouds.openstack.keystone.v2_0.features.UserAsyncApi;
import org.jclouds.openstack.keystone.v2_0.features.TokenAsyncApi;
import org.jclouds.openstack.keystone.v2_0.features.UserApi;
import org.jclouds.openstack.keystone.v2_0.features.UserAsyncApi;
import org.jclouds.openstack.keystone.v2_0.functions.PresentWhenAdminURLExistsForIdentityService;
import org.jclouds.openstack.keystone.v2_0.handlers.KeystoneErrorHandler;
import org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToAdminURIFromAccessForTypeAndVersion;
import org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToAdminURISupplier;
import org.jclouds.openstack.v2_0.ServiceType;
import org.jclouds.openstack.v2_0.services.Identity;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.annotations.ApiVersion;
import org.jclouds.rest.config.RestClientModule;
import org.jclouds.rest.functions.ImplicitOptionalConverter;
import org.jclouds.util.Suppliers2;

import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap;
Expand Down Expand Up @@ -90,13 +93,22 @@ protected void configure() {
RegionIdToAdminURIFromAccessForTypeAndVersion.class).build(RegionIdToAdminURISupplier.Factory.class));
}

// return any identity url.
/**
* in some cases, there is no {@link ServiceType#IDENTITY} entry in the service catalog. In
* other cases, there's no adminURL entry present. Fallback to the provider in this case.
*/
@Provides
@Singleton
@Identity
protected Supplier<URI> provideStorageUrl(RegionIdToAdminURISupplier.Factory factory,
@Named(KeystoneProperties.VERSION) String version) {
return getLastValueInMap(factory.createForApiTypeAndVersion(ServiceType.IDENTITY, version));
protected Supplier<URI> provideStorageUrl(final RegionIdToAdminURISupplier.Factory factory,
@ApiVersion final String version, @Provider final Supplier<URI> providerURI) {
Supplier<URI> identityServiceForVersion = getLastValueInMap(factory.createForApiTypeAndVersion(
ServiceType.IDENTITY, version));
Supplier<URI> whenIdentityServiceIsntListedFallbackToProviderURI = Suppliers2.onThrowable(
identityServiceForVersion, NoSuchElementException.class, providerURI);
Supplier<URI> whenIdentityServiceHasNoAdminURLFallbackToProviderURI = Suppliers2.or(
whenIdentityServiceIsntListedFallbackToProviderURI, providerURI);
return whenIdentityServiceHasNoAdminURLFallbackToProviderURI;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;

import org.jclouds.Constants;
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
import org.jclouds.rest.annotations.ExceptionParser;
Expand All @@ -46,7 +45,6 @@
* />
* @author Adam Lowe
*/
@Path("/v{" + Constants.PROPERTY_API_VERSION + "}")
@SkipEncoding( { '/', '=' })
public interface ServiceAsyncApi {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.net.URI;
import java.util.Map;
import java.util.NoSuchElementException;

import org.jclouds.javax.annotation.Nullable;

Expand All @@ -16,15 +17,16 @@
public interface RegionIdToAdminURISupplier extends Supplier<Map<String, Supplier<URI>>> {
static interface Factory {
/**
*
*
* @param apiType
* type of the api, according to the provider. ex. {@code compute} {@code
* object-store}
* type of the api, according to the provider. ex. {@code compute}
* {@code object-store}
* @param apiVersion
* version of the api, or null
* @return regions mapped to default uri
* @throws NoSuchElementException if the {@code apiType} is not present in the catalog
*/
RegionIdToAdminURISupplier createForApiTypeAndVersion(@Assisted("apiType") String apiType,
@Nullable @Assisted("apiVersion") String apiVersion);
@Nullable @Assisted("apiVersion") String apiVersion) throws NoSuchElementException;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class TokenApiLiveTest extends BaseKeystoneApiLiveTest {
@BeforeMethod
public void grabToken() {
AuthenticateRequest ar = keystoneContext.getUtils().getInjector().getInstance(AuthenticateRequest.class);
HttpRequest test = ar.filter(HttpRequest.builder().method("GET").endpoint(endpoint).build());
HttpRequest test = ar.filter(HttpRequest.builder().method("GET").endpoint(context.getProviderMetadata().getEndpoint()).build());
token = Iterables.getOnlyElement(test.getHeaders().get("X-Auth-Token"));
}

Expand Down
2 changes: 1 addition & 1 deletion apis/openstack-nova/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<properties>
<!-- keystone endpoint -->
<test.openstack-nova.endpoint>http://localhost:5000</test.openstack-nova.endpoint>
<test.openstack-nova.endpoint>http://localhost:5000/v2.0/</test.openstack-nova.endpoint>
<!-- keystone version -->
<test.openstack-nova.api-version>1.1</test.openstack-nova.api-version>
<test.openstack-nova.build-version></test.openstack-nova.build-version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE;
import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE;
import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.VERSION;
import static org.jclouds.openstack.nova.v2_0.config.NovaProperties.AUTO_ALLOCATE_FLOATING_IPS;
import static org.jclouds.openstack.nova.v2_0.config.NovaProperties.AUTO_GENERATE_KEYPAIRS;
import static org.jclouds.openstack.nova.v2_0.config.NovaProperties.TIMEOUT_SECURITYGROUP_PRESENT;
Expand Down Expand Up @@ -79,9 +78,6 @@ public static Properties defaultProperties() {
properties.setProperty(SERVICE_TYPE, ServiceType.COMPUTE);
properties.setProperty(CREDENTIAL_TYPE, CredentialTypes.PASSWORD_CREDENTIALS);

// TODO: this doesn't actually do anything yet.
properties.setProperty(VERSION, "2.0");

properties.setProperty(AUTO_ALLOCATE_FLOATING_IPS, "false");
properties.setProperty(AUTO_GENERATE_KEYPAIRS, "false");
properties.setProperty(TIMEOUT_SECURITYGROUP_PRESENT, "500");
Expand All @@ -94,11 +90,12 @@ protected Builder() {
super(NovaApi.class, NovaAsyncApi.class);
id("openstack-nova")
.name("OpenStack Nova Diablo+ API")
.identityName("tenantName:user or user")
.credentialName("password")
.identityName("${tenantName}:${userName} or ${userName}, if your keystone supports a default tenant")
.credentialName("${password}")
.endpointName("KeyStone base url ending in /v2.0/")
.documentation(URI.create("http://api.openstack.org/"))
.version("1.1")
.defaultEndpoint("http://localhost:5000")
.defaultEndpoint("http://localhost:5000/v2.0/")
.defaultProperties(NovaApiMetadata.defaultProperties())
.view(TypeToken.of(ComputeServiceContext.class))
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
Expand Down
4 changes: 2 additions & 2 deletions apis/rackspace-cloudidentity/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@

<properties>
<!-- keystone endpoint -->
<test.rackspace-cloudidentity.endpoint>https://identity.api.rackspacecloud.com</test.rackspace-cloudidentity.endpoint>
<test.rackspace-cloudidentity.endpoint>https://identity.api.rackspacecloud.com/v${jclouds.api-version}/</test.rackspace-cloudidentity.endpoint>
<!-- keystone version -->
<test.rackspace-cloudidentity.api-version>2.0</test.rackspace-cloudidentity.api-version>
<test.rackspace-cloudidentity.build-version></test.rackspace-cloudidentity.build-version>
<test.rackspace-cloudidentity.identity>413274:${test.rackspace-us.identity}</test.rackspace-cloudidentity.identity>
<test.rackspace-cloudidentity.identity>${test.rackspace-us.identity}</test.rackspace-cloudidentity.identity>
<test.rackspace-cloudidentity.credential>${test.rackspace-us.credential}</test.rackspace-cloudidentity.credential>
<test.jclouds.keystone.credential-type>RAX-KSKEY:apiKeyCredentials</test.jclouds.keystone.credential-type>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
import java.util.Properties;

import org.jclouds.apis.ApiMetadata;
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
import org.jclouds.openstack.keystone.v2_0.KeystoneApiMetadata;
import org.jclouds.openstack.keystone.v2_0.KeystoneAsyncApi;
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneParserModule;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneRestClientModule;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneRestClientModule.KeystoneAdminURLModule;
Expand Down Expand Up @@ -73,7 +73,6 @@ protected CloudIdentityApiMetadata(Builder builder) {
public static Properties defaultProperties() {
Properties properties = KeystoneApiMetadata.defaultProperties();
properties.setProperty(CREDENTIAL_TYPE, CloudIdentityCredentialTypes.API_KEY_CREDENTIALS);

return properties;
}

Expand All @@ -82,9 +81,10 @@ protected Builder(){
super(KeystoneApi.class, KeystoneAsyncApi.class);
id("rackspace-cloudidentity")
.name("Rackspace Cloud Identity Service")
.defaultEndpoint("https://identity.api.rackspacecloud.com")
.identityName("username")
.credentialName("API Key")
.identityName("${userName}")
.credentialName("${apiKey}")
.defaultEndpoint("https://identity.api.rackspacecloud.com/v${jclouds.api-version}/")
.endpointName("identity service url ending in /v${jclouds.api-version}/")
.defaultProperties(CloudIdentityApiMetadata.defaultProperties())
.context(CONTEXT_TOKEN)
.documentation(URI.create("http://docs.rackspace.com/auth/api/v2.0/auth-api-devguide/"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
* />
* @author Adrian Cole
*/
@Path("/v2.0")
public interface CloudIdentityAuthenticationAsyncApi extends AuthenticationAsyncApi {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.jclouds.apis.ApiMetadata;
import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
import org.jclouds.openstack.services.ServiceType;
import org.jclouds.openstack.swift.blobstore.config.SwiftBlobStoreContextModule;
import org.jclouds.openstack.swift.config.SwiftKeystoneRestClientModule;
Expand Down Expand Up @@ -72,22 +71,24 @@ protected SwiftKeystoneApiMetadata(Builder builder) {
public static Properties defaultProperties() {
Properties properties = SwiftApiMetadata.defaultProperties();
properties.setProperty(SERVICE_TYPE, ServiceType.OBJECT_STORE);
// TODO: this doesn't actually do anything yet.
properties.setProperty(KeystoneProperties.VERSION, "2.0");
properties.setProperty(CREDENTIAL_TYPE, CredentialTypes.API_ACCESS_KEY_CREDENTIALS);
properties.setProperty(CREDENTIAL_TYPE, CredentialTypes.PASSWORD_CREDENTIALS);
properties.remove(PROPERTY_REGIONS);
return properties;
}

public static class Builder extends SwiftApiMetadata.Builder {
protected Builder() {
super(SwiftKeystoneClient.class, SwiftKeystoneAsyncClient.class);
this(SwiftKeystoneClient.class, SwiftKeystoneAsyncClient.class);
}

protected Builder(Class<?> syncClient, Class<?> asyncClient) {
super(syncClient, asyncClient);
id("swift-keystone")
.name("OpenStack Swift with Keystone authentication")
.identityName("tenantName:user or user")
.credentialName("password")
.defaultEndpoint("http://localhost:5000")
.endpointName("keystone url")
.identityName("${tenantName}:${userName} or ${userName}, if your keystone supports a default tenant")
.credentialName("${password}")
.endpointName("KeyStone base url ending in /v2.0/")
.defaultEndpoint("http://localhost:5000/v2.0/")
.context(CONTEXT_TOKEN)
.defaultProperties(SwiftKeystoneApiMetadata.defaultProperties())
.defaultModules(ImmutableSet.<Class<? extends Module>>of(KeystoneStorageEndpointModule.class, KeystoneAuthenticationModule.RegionModule.class,
Expand Down
2 changes: 1 addition & 1 deletion labs/openstack-glance/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<properties>
<!-- keystone endpoint -->
<test.openstack-glance.endpoint>http://localhost:5000</test.openstack-glance.endpoint>
<test.openstack-glance.endpoint>http://localhost:5000/v2.0/</test.openstack-glance.endpoint>
<!-- keystone version -->
<test.openstack-glance.api-version>1.0</test.openstack-glance.api-version>
<test.openstack-glance.build-version></test.openstack-glance.build-version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.RegionModule;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
import org.jclouds.openstack.v2_0.ServiceType;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
Expand Down Expand Up @@ -69,9 +68,6 @@ public static Properties defaultProperties() {
Properties properties = BaseRestApiMetadata.defaultProperties();
properties.setProperty(SERVICE_TYPE, ServiceType.IMAGE);
properties.setProperty(CREDENTIAL_TYPE, CredentialTypes.PASSWORD_CREDENTIALS);

// TODO: this doesn't actually do anything yet.
properties.setProperty(KeystoneProperties.VERSION, "2.0");
return properties;
}

Expand All @@ -81,11 +77,12 @@ protected Builder() {
super(GlanceApi.class, GlanceAsyncApi.class);
id("openstack-glance")
.name("OpenStack Glance API")
.identityName("tenantName:user or user")
.credentialName("password")
.identityName("${tenantName}:${userName} or ${userName}, if your keystone supports a default tenant")
.credentialName("${password}")
.endpointName("KeyStone base url ending in /v2.0/")
.documentation(URI.create("http://glance.openstack.org/glanceapi.html"))
.version("1.0")
.defaultEndpoint("http://localhost:5000")
.defaultEndpoint("http://localhost:5000/v2.0/")
.defaultProperties(GlanceApiMetadata.defaultProperties())
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
.add(KeystoneAuthenticationModule.class)
Expand Down
Loading

0 comments on commit 735da0a

Please sign in to comment.