You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jclouds.apache.org by najtmar <no...@github.com> on 2014/08/11 17:41:17 UTC

[jclouds-examples] Make CreateServer allow a user to execute jobs via SSH. (#59)

You can merge this Pull Request by running:

  git pull https://github.com/najtmar/jclouds-examples master

Or you can view, comment on it, or merge it online at:

  https://github.com/jclouds/jclouds-examples/pull/59

-- Commit Summary --

  * Make CreateServer allow a user to execute jobs via SSH.

-- File Changes --

    M google/src/main/java/org/jclouds/examples/google/computeengine/CreateServer.java (110)

-- Patch Links --

https://github.com/jclouds/jclouds-examples/pull/59.patch
https://github.com/jclouds/jclouds-examples/pull/59.diff

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/59

Re: [jclouds-examples] Make CreateServer allow a user to execute jobs via SSH. (#59)

Posted by Andrew Phillips <no...@github.com>.
+1 - looks good to me! Could you squash'n'rebase? Then we should be good to merge!

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/59#issuecomment-51921515

Re: [jclouds-examples] Make CreateServer allow a user to execute jobs via SSH. (#59)

Posted by Andrew Phillips <no...@github.com>.
> Checkstyle recommended me to do this. Reverted.

If Checkstyle recommended it, please put it back - we try to stick to Checkstyle generally.

Thanks for the other updates, @najtmar. With this last change, looks good to me!

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/59#issuecomment-51908785

Re: [jclouds-examples] Make CreateServer allow a user to execute jobs via SSH. (#59)

Posted by Andrew Phillips <no...@github.com>.
Closed #59.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/59#event-151916757

Re: [jclouds-examples] Make CreateServer allow a user to execute jobs via SSH. (#59)

Posted by Andrew Phillips <no...@github.com>.
> @@ -52,35 +60,55 @@
>     /**
>      * To get a service account and its private key see [TODO: write some
>      * documentation on the website and put a link to it]
> -    * 
> -    * The first argument (args[0]) must be your service account email address
> -    * The second argument (args[1]) must a path to your service account
> -    *     private key PEM file (without a password).
> +    *
> +    * The first argument (args[0]) is your service account email address
> +    *    (https://developers.google.com/console/help/new/#serviceaccounts).
> +    * The second argument (args[1]) is a path to your service account private key PEM file without a password
> +    *    (https://developers.google.com/console/help/new/#serviceaccounts).
> +    * The third argument (args[2]) is your Google user name.
> +    * The fourth argument (args[3]) is a path to the file containing your SSH public key
> +    *    (https://developers.google.com/compute/docs/instances#sshkeys).
> +    * The fifth argument (args[4]) is a path to the file containing your SSH private key
> +    *    (https://developers.google.com/compute/docs/instances#sshkeys).

Are these the credentials to be used to log in to the target machine? Do we need to add a comment saying something like "your private key will not be transmitted anywhere"?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/59/files#r16062167

Re: [jclouds-examples] Make CreateServer allow a user to execute jobs via SSH. (#59)

Posted by najtmar <no...@github.com>.
> @@ -52,35 +60,55 @@
>     /**
>      * To get a service account and its private key see [TODO: write some
>      * documentation on the website and put a link to it]
> -    * 
> -    * The first argument (args[0]) must be your service account email address
> -    * The second argument (args[1]) must a path to your service account
> -    *     private key PEM file (without a password).
> +    *
> +    * The first argument (args[0]) is your service account email address
> +    *    (https://developers.google.com/console/help/new/#serviceaccounts).
> +    * The second argument (args[1]) is a path to your service account private key PEM file without a password
> +    *    (https://developers.google.com/console/help/new/#serviceaccounts).

I made multiple attempts to make it work, and I only succeeded with this one. But I would be happy to make the example simpler if I knew how to do it.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/59/files#r16103563

Re: [jclouds-examples] Make CreateServer allow a user to execute jobs via SSH. (#59)

Posted by Andrew Phillips <no...@github.com>.
> @@ -179,7 +215,7 @@ private Image getImage() {
>     /**
>      * Always close your service when you're done with it.
>      */
> -   public void close() throws IOException {
> +   public final void close() throws IOException {

Is this change needed?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/59/files#r16062296

Re: [jclouds-examples] Make CreateServer allow a user to execute jobs via SSH. (#59)

Posted by najtmar <no...@github.com>.
> @@ -108,8 +137,15 @@ private void createServer() throws RunNodesException, TimeoutException {
>              .locationId(ZONE)
>              .hardwareId(getHardware().getId())
>              .imageId(getImage().getId())
> -            .build();
> -      
> +                                       .build();

That was accidental. Fixed.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/59/files#r16103312

Re: [jclouds-examples] Make CreateServer allow a user to execute jobs via SSH. (#59)

Posted by Ignasi Barrera <no...@github.com>.
> @@ -108,8 +137,15 @@ private void createServer() throws RunNodesException, TimeoutException {
>              .locationId(ZONE)
>              .hardwareId(getHardware().getId())
>              .imageId(getImage().getId())
> -            .build();
> -      
> +                                       .build();
> +      // Authorize googleUserName to use the instance with their SSH key.
> +      template.getOptions().as(GoogleComputeEngineTemplateOptions.class)

Is the cast needed? If we're only using portable options here, then better remove the `as` call.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/59/files#r16063407

Re: [jclouds-examples] Make CreateServer allow a user to execute jobs via SSH. (#59)

Posted by najtmar <no...@github.com>.
> @@ -108,8 +137,15 @@ private void createServer() throws RunNodesException, TimeoutException {
>              .locationId(ZONE)
>              .hardwareId(getHardware().getId())
>              .imageId(getImage().getId())
> -            .build();
> -      
> +                                       .build();
> +      // Authorize googleUserName to use the instance with their SSH key.
> +      template.getOptions().as(GoogleComputeEngineTemplateOptions.class)

Cast removed.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/59/files#r16103568

Re: [jclouds-examples] Make CreateServer allow a user to execute jobs via SSH. (#59)

Posted by Ignasi Barrera <no...@github.com>.
> @@ -52,35 +60,55 @@
>     /**
>      * To get a service account and its private key see [TODO: write some
>      * documentation on the website and put a link to it]
> -    * 
> -    * The first argument (args[0]) must be your service account email address
> -    * The second argument (args[1]) must a path to your service account
> -    *     private key PEM file (without a password).
> +    *
> +    * The first argument (args[0]) is your service account email address
> +    *    (https://developers.google.com/console/help/new/#serviceaccounts).
> +    * The second argument (args[1]) is a path to your service account private key PEM file without a password
> +    *    (https://developers.google.com/console/help/new/#serviceaccounts).

Just a note FTR. jclouds will fallback to authenticate with the SSH agent, so it should work with password protected keys if they're already loaded by the agent.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/59/files#r16063313

Re: [jclouds-examples] Make CreateServer allow a user to execute jobs via SSH. (#59)

Posted by Andrew Phillips <no...@github.com>.
> @@ -108,8 +137,15 @@ private void createServer() throws RunNodesException, TimeoutException {
>              .locationId(ZONE)
>              .hardwareId(getHardware().getId())
>              .imageId(getImage().getId())
> -            .build();
> -      
> +                                       .build();

[minor] Is this indent change intentional?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/59/files#r16062263

Re: [jclouds-examples] Make CreateServer allow a user to execute jobs via SSH. (#59)

Posted by Andrew Phillips <no...@github.com>.
Committed to [master](https://git-wip-us.apache.org/repos/asf?p=jclouds-examples.git;a=commit;h=e682ee8bf9762e350c64ee37694759a5996b71fb). Thanks, @najtmar!

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/59#issuecomment-51928991

Re: [jclouds-examples] Make CreateServer allow a user to execute jobs via SSH. (#59)

Posted by najtmar <no...@github.com>.
> @@ -179,7 +215,7 @@ private Image getImage() {
>     /**
>      * Always close your service when you're done with it.
>      */
> -   public void close() throws IOException {
> +   public final void close() throws IOException {

Following the suggestion, the change has been reapplied.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/59/files#r16115515

Re: [jclouds-examples] Make CreateServer allow a user to execute jobs via SSH. (#59)

Posted by najtmar <no...@github.com>.
> @@ -52,35 +60,55 @@
>     /**
>      * To get a service account and its private key see [TODO: write some
>      * documentation on the website and put a link to it]
> -    * 
> -    * The first argument (args[0]) must be your service account email address
> -    * The second argument (args[1]) must a path to your service account
> -    *     private key PEM file (without a password).
> +    *
> +    * The first argument (args[0]) is your service account email address
> +    *    (https://developers.google.com/console/help/new/#serviceaccounts).
> +    * The second argument (args[1]) is a path to your service account private key PEM file without a password
> +    *    (https://developers.google.com/console/help/new/#serviceaccounts).
> +    * The third argument (args[2]) is your Google user name.
> +    * The fourth argument (args[3]) is a path to the file containing your SSH public key
> +    *    (https://developers.google.com/compute/docs/instances#sshkeys).
> +    * The fifth argument (args[4]) is a path to the file containing your SSH private key
> +    *    (https://developers.google.com/compute/docs/instances#sshkeys).

Added clarifying comments and a disclaimer that private keys are not transmitted anywhere.

The experience I gained when writing this example (and the way I understand the documentation) tell me that we need the PEM file for server-to-server interaction and the SSH keys to perform actions on machines.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/59/files#r16103288

Re: [jclouds-examples] Make CreateServer allow a user to execute jobs via SSH. (#59)

Posted by najtmar <no...@github.com>.
> @@ -179,7 +215,7 @@ private Image getImage() {
>     /**
>      * Always close your service when you're done with it.
>      */
> -   public void close() throws IOException {
> +   public final void close() throws IOException {

Checkstyle recommended me to do this. Reverted.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/59/files#r16103350