Updated Branches: refs/heads/1.6.x 16c58db3a -> 399a97e48
backport of JCLOUDS-362 fix (jclouds-labs-google cec667a8aed54ebd0c976758181ca7e9899008cf) Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/e0839de2 Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/e0839de2 Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/e0839de2 Branch: refs/heads/1.6.x Commit: e0839de2eb072a9c89f0284214df422f202fafd5 Parents: 16c58db Author: Alex Heneveld <[email protected]> Authored: Thu Nov 28 14:56:33 2013 +0000 Committer: Andrew Phillips <[email protected]> Committed: Mon Dec 9 16:38:25 2013 -0500 ---------------------------------------------------------------------- .../config/GoogleComputeEngineHttpApiModule.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/e0839de2/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineHttpApiModule.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineHttpApiModule.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineHttpApiModule.java index 214c932..bbf5c71 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineHttpApiModule.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineHttpApiModule.java @@ -16,7 +16,6 @@ */ package org.jclouds.googlecomputeengine.config; -import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Suppliers.compose; import static com.google.inject.name.Names.named; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; @@ -98,9 +97,20 @@ public class GoogleComputeEngineHttpApiModule extends HttpApiModule<GoogleComput return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, compose(new Function<Credentials, String>() { public String apply(Credentials in) { - checkState(in.identity.indexOf("@") != 1, - "identity should be in [email protected] format"); - Project project = api.getProjectApi().get(Iterables.get(Splitter.on("@").split(in.identity), 0)); + // ID should be of the form [email protected] + // OR (increasingly often) [email protected] + // where project_id is the NUMBER; + // HERE we also accept simply "project" as the identity, if no "@" is present; + // this is used in tests, but not sure if it is valid in the wild. + String projectName = in.identity; + if (projectName.indexOf("@") != -1) { + projectName = Iterables.get(Splitter.on("@").split(projectName), 0); + if (projectName.indexOf("-") != -1) { + // if ID is of the form [email protected] + projectName = Iterables.get(Splitter.on("-").split(projectName), 0); + } + } + Project project = api.getProjectApi().get(projectName); return project.getName(); } }, creds), seconds, TimeUnit.SECONDS);
