Skip to content
This repository has been archived by the owner on Mar 25, 2018. It is now read-only.

replace org.jclouds.googlecompute.GoogleComputeConstants.GOOGLE_PROJECT with getImageApi #4

Open
codefromthecrypt opened this issue Mar 10, 2013 · 8 comments

Comments

@codefromthecrypt
Copy link
Contributor

When a user specifies the wrong email address for their account, an authorization error occurs relating to project.

$ java -jar target/compute-basics-jar-with-dependencies.jar google-compute [email protected] "`cat $HOME/google-compute.pem`" mygroup add
>> initializing {id=google-compute, name=Google Compute Engine Api, views=[org.jclouds.compute.ComputeServiceContext], endpointName=https endpoint, identityName=Email associated with the Goole API client_id, credentialName=Optional.of(Private key literal associated with the Google API client_id), documentation=https://developers.google.com/compute/docs, api=interface org.jclouds.googlecompute.GoogleComputeApi, asyncApi=interface org.jclouds.googlecompute.GoogleComputeAsyncApi}
>> adding node to group mygroup
error: Guice provision errors:

1) Error in custom provider, org.jclouds.http.HttpResponseException: org.jclouds.http.HttpResponseException: command: POST https://accounts.google.com/o/oauth2/token HTTP/1.1 failed with response: HTTP/1.1 400 Bad Request; content: [{
  "error" : "invalid_grant"
}] connecting to GET https://www.googleapis.com/compute/v1beta13/projects/adrian.f.cole/zones HTTP/1.1
  at org.jclouds.compute.config.BaseComputeServiceContextModule.provideTemplateOptionallyFromProperties(BaseComputeServiceContextModule.java:184)
  while locating org.jclouds.compute.domain.TemplateBuilder annotated with @com.google.inject.name.Named(value=DEFAULT)

1 error

A savvy person would know that the email is wrong, and I should have re-read the README before blindly hunting. Even if it was my fault, crud in GoogleComputeConstants is distracting, particularly GOOGLE_PROJECT which shows up in grep.

Rather than having curious hard-coded constants, wouldn't it be better to make a special method that says what it does. I understand from @dralves that this is the project for public resources. So far as I can tell, this constant is only used in the compute service adapter for public images.e

Why not just make a method for that and remove the constant, such as we do in aws for the default zone?

   @Delegate
   @Path("/projects/google")
   ImageApi getImageApi(); // or getPublicImageApi
@codefromthecrypt
Copy link
Contributor Author

cc @mattstep

@dralves
Copy link
Contributor

dralves commented Mar 10, 2013

Hi Adrian:

a few things:

  • GOOGLE_PROJECT does not refer to the project name (which is not hardcoded as I'll explain next). This constant refers to the "public" project under which certain public resources are, such as public images.
  • If you're using "[email protected]" as the account identity then it's the wrong one. refer to the README to find out how to get the right one (something along the lines of [email protected] i think). The project name is extracted from the identity (it's the part before the @)
  • I never even used the jclouds project (I was using "jclouds-gce").
  • please make sure you credentials work by running the oauth live test first (multiple people have tried it)

@codefromthecrypt
Copy link
Contributor Author

ok, once you mention what this magic constant does, I'll update the issue accordingly.

@dralves
Copy link
Contributor

dralves commented Mar 10, 2013

as I said it refers to the name of the project under which GCE keeps the "public" resources. It should be documented for dev's sake but there's no reason an user should need or even have to know about it.

@codefromthecrypt
Copy link
Contributor Author

ok, I agree that this should be better documented, or better yet. removed.

If one enters the incorrect email address, the error relates to the http path including project and that this property is constant is passed as a method arg for project. This is so very unnecessarily confusing.

I'm changing the issue to remove this confusion now and will ping back.

@codefromthecrypt
Copy link
Contributor Author

ok. changed the issue. you are correct that my google id works, so I'll mention this issue isn't a blocker

@dralves
Copy link
Contributor

dralves commented Mar 11, 2013

So this issue only refers to:

  • changing the name of the constant to something like PUBLIC_PROJECT_ID
  • documenting it

@codefromthecrypt
Copy link
Contributor Author

No it refers to deleting the constant and instead expose a no arg method
for ImageApi

On Sunday, March 10, 2013, David Ribeiro Alves wrote:

So this issue only refers to:

  • changing the name of the constant to something like PUBLIC_PROJECT_ID
  • documenting it


Reply to this email directly or view it on GitHubhttps://github.com/jclouds/jclouds-labs/issues/4#issuecomment-14693367
.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants