You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jclouds.apache.org by Zack Shoylev <no...@github.com> on 2015/02/04 21:21:44 UTC
[jclouds] fix jclouds live tests failing when a keypair is missing
(#667)
If the keypair is missing, create one.
In some configurations this can be common (cloudbees, windows)
You can view, comment on, or merge this pull request online at:
https://github.com/jclouds/jclouds/pull/667
-- Commit Summary --
* fix jclouds live tests failing when a keypair is missing.
-- File Changes --
M compute/src/test/java/org/jclouds/compute/ComputeTestUtils.java (16)
M project/pom.xml (6)
-- Patch Links --
https://github.com/jclouds/jclouds/pull/667.patch
https://github.com/jclouds/jclouds/pull/667.diff
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/667
Re: [jclouds] fix jclouds live tests failing when a keypair is
missing (#667)
Posted by Zack Shoylev <no...@github.com>.
> @@ -62,7 +64,19 @@
> public static void checkSecretKeyFile(String secretKeyFile) {
> checkNotNull(emptyToNull(secretKeyFile), "System property: [test.ssh.keyfile] set to an empty string");
> if (!new File(secretKeyFile).exists()) {
> - throw new IllegalStateException("secretKeyFile not found at: " + secretKeyFile);
> + // Create file if missing
> + try {
> + JSch jsch = new JSch();
> + KeyPair kPair = KeyPair.genKeyPair(jsch, KeyPair.RSA);
> + kPair.writePrivateKey(secretKeyFile);
> + kPair.writePublicKey(secretKeyFile + ".pub", "jclouds generated key pair");
> + System.out.println("jclouds generated finger print: " + kPair.getFingerPrint());
This println is probably not necessary?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/667/files#r24118200
Re: [jclouds] fix jclouds live tests failing when a keypair is
missing (#667)
Posted by Zack Shoylev <no...@github.com>.
Alright, all looks good with the live tests. About to squash/merge.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/667#issuecomment-73148072
Re: [jclouds] fix jclouds live tests failing when a keypair is
missing (#667)
Posted by Zack Shoylev <no...@github.com>.
merged
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/667#issuecomment-73153937
Re: [jclouds] fix jclouds live tests failing when a keypair is
missing (#667)
Posted by Zack Shoylev <no...@github.com>.
The error without this fix:
https://jclouds.ci.cloudbees.com/view/live%20tests/job/computeservice-rackspace/4/console
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/667#issuecomment-72933294
Re: [jclouds] fix jclouds live tests failing when a keypair is
missing (#667)
Posted by Zack Shoylev <no...@github.com>.
> @@ -62,7 +64,18 @@
> public static void checkSecretKeyFile(String secretKeyFile) {
> checkNotNull(emptyToNull(secretKeyFile), "System property: [test.ssh.keyfile] set to an empty string");
> if (!new File(secretKeyFile).exists()) {
> - throw new IllegalStateException("secretKeyFile not found at: " + secretKeyFile);
> + // Create file if missing
> + try {
> + JSch jsch = new JSch();
> + KeyPair kPair = KeyPair.genKeyPair(jsch, KeyPair.RSA, 4096);
> + kPair.writePrivateKey(secretKeyFile);
> + kPair.writePublicKey(secretKeyFile + ".pub", "jclouds generated key pair");
> + kPair.dispose();
I notice we generate a 2048 key... Any issues upping that to 4k?
Also, yes, great point - it's possible to pass the keypair directly, but I am not sure the files are used after during testing or not. Still checking.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/667/files#r24193992
Re: [jclouds] fix jclouds live tests failing when a keypair is
missing (#667)
Posted by Ignasi Barrera <no...@github.com>.
> @@ -62,7 +64,18 @@
> public static void checkSecretKeyFile(String secretKeyFile) {
> checkNotNull(emptyToNull(secretKeyFile), "System property: [test.ssh.keyfile] set to an empty string");
> if (!new File(secretKeyFile).exists()) {
> - throw new IllegalStateException("secretKeyFile not found at: " + secretKeyFile);
> + // Create file if missing
> + try {
> + JSch jsch = new JSch();
> + KeyPair kPair = KeyPair.genKeyPair(jsch, KeyPair.RSA, 4096);
> + kPair.writePrivateKey(secretKeyFile);
> + kPair.writePublicKey(secretKeyFile + ".pub", "jclouds generated key pair");
> + kPair.dispose();
You should be able to do the same without adding a new dependency:
```java
Map<String, String> keypair = SshKeys.generate();
Files.write(keypair.get("private"), new File(secretkeyFile), Charsets.UTF_8);
Files.write(keypair.get("public"), new File(secretkeyFile + ".pub"), Charsets.UTF_8);
```
But given that this method just assigns the `Map<String, String>` variable, parhaps you don't even need to persist it to disk. Could you test if it works if you just return the result of the `SshKeys.generate()` call? If not, we can persist the generated keys, but it would be better if we can avoid doing that.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/667/files#r24151401
Re: [jclouds] fix jclouds live tests failing when a keypair is
missing (#667)
Posted by Zack Shoylev <no...@github.com>.
> @@ -365,6 +365,12 @@
> <artifactId>assertj-guava</artifactId>
> <scope>test</scope>
> </dependency>
> + <dependency>
> + <groupId>com.jcraft</groupId>
> + <artifactId>jsch</artifactId>
> + <version>0.1.51</version>
> + <scope>test</scope>
> + </dependency>
Note: this adds a test dependency in the jclouds project pom (the one that is used as a parent project). The test dependency might be used in multiple providers/apis live tests...
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/667/files#r24118453
Re: [jclouds] fix jclouds live tests failing when a keypair is
missing (#667)
Posted by Zack Shoylev <no...@github.com>.
Hmm, I will have to rerun tests... messed up my testing environment
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/667#issuecomment-73133414
Re: [jclouds] fix jclouds live tests failing when a keypair is
missing (#667)
Posted by Zack Shoylev <no...@github.com>.
> @@ -62,7 +64,19 @@
> public static void checkSecretKeyFile(String secretKeyFile) {
> checkNotNull(emptyToNull(secretKeyFile), "System property: [test.ssh.keyfile] set to an empty string");
> if (!new File(secretKeyFile).exists()) {
> - throw new IllegalStateException("secretKeyFile not found at: " + secretKeyFile);
> + // Create file if missing
> + try {
> + JSch jsch = new JSch();
> + KeyPair kPair = KeyPair.genKeyPair(jsch, KeyPair.RSA);
The default key size is 1k. I will test with 4k and update if it works.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/667/files#r24118156
Re: [jclouds] fix jclouds live tests failing when a keypair is
missing (#667)
Posted by Zack Shoylev <no...@github.com>.
Passed live tests using the on-demand generated keypair, so this is much better now! Thanks @nacx
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/667#issuecomment-73132914