Skip to content

Instantly share code, notes, and snippets.

@nacx
Last active January 3, 2016 22:19
Show Gist options
  • Select an option

  • Save nacx/8528108 to your computer and use it in GitHub Desktop.

Select an option

Save nacx/8528108 to your computer and use it in GitHub Desktop.
jclouds basic compute failure
Exception in thread "main" org.jclouds.compute.RunNodesException: error running 1 node group(jcloudstest) location(IAD) image(d45ed9c5-d6fc-4c9d-89ea-1b3ae1c83999) size(2) options({loginPrivateKeyPresent=true, scriptPresent=true, publicKeyPresent=true, autoAssignFloatingIp=false})
Execution failures:
0 error[s]
Node failures:
1) IllegalArgumentException on node IAD/5d4ac520-5dc7-480d-9ba1-4f6e92c6cae4:
java.lang.IllegalArgumentException: DER length more than 4 bytes: 72
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:120)
at org.jclouds.crypto.ASN1Codec.readLength(ASN1Codec.java:163)
at org.jclouds.crypto.ASN1Codec.create(ASN1Codec.java:152)
at org.jclouds.crypto.ASN1Codec.createASN1Sequence(ASN1Codec.java:86)
at org.jclouds.crypto.ASN1Codec.decodeRSAPrivateKey(ASN1Codec.java:66)
at org.jclouds.crypto.Pems$DecodeRSAPrivateCrtKeySpec.parseResult(Pems.java:242)
at org.jclouds.crypto.Pems$DecodeRSAPrivateCrtKeySpec.parseResult(Pems.java:237)
at org.jclouds.crypto.Pems$PemProcessor.getResult(Pems.java:102)
at com.google.common.io.ByteStreams.readBytes(ByteStreams.java:776)
at com.google.common.io.ByteStreams.readBytes(ByteStreams.java:749)
at org.jclouds.crypto.Pems.fromPem(Pems.java:199)
at org.jclouds.crypto.Pems.privateKeySpec(Pems.java:218)
at org.jclouds.crypto.Pems.privateKeySpec(Pems.java:256)
at org.jclouds.ssh.SshKeys.fingerprintPrivateKey(SshKeys.java:212)
at org.jclouds.sshj.SshjSshClient.<init>(SshjSshClient.java:156)
at org.jclouds.sshj.config.SshjSshClientModule$Factory.create(SshjSshClientModule.java:61)
at org.jclouds.compute.functions.CreateSshClientOncePortIsListeningOnNode.apply(CreateSshClientOncePortIsListeningOnNode.java:72)
at org.jclouds.compute.functions.CreateSshClientOncePortIsListeningOnNode.apply(CreateSshClientOncePortIsListeningOnNode.java:44)
at org.jclouds.compute.callables.SudoAwareInitManager.init(SudoAwareInitManager.java:71)
at org.jclouds.compute.callables.RunScriptOnNodeAsInitScriptUsingSsh.init(RunScriptOnNodeAsInitScriptUsingSsh.java:68)
at org.jclouds.compute.callables.RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete.init(RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete.java:81)
at org.jclouds.compute.callables.RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete.init(RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete.java:42)
at org.jclouds.compute.strategy.InitializeRunScriptOnNodeOrPlaceInBadMap.call(InitializeRunScriptOnNodeOrPlaceInBadMap.java:65)
at org.jclouds.compute.strategy.InitializeRunScriptOnNodeOrPlaceInBadMap.call(InitializeRunScriptOnNodeOrPlaceInBadMap.java:38)
at org.jclouds.compute.strategy.CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.call(CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.java:123)
at org.jclouds.compute.strategy.CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.apply(CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.java:146)
at org.jclouds.compute.strategy.CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.apply(CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.java:53)
at com.google.common.util.concurrent.Futures$1.apply(Futures.java:711)
at com.google.common.util.concurrent.Futures$ChainingListenableFuture.run(Futures.java:849)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
1 error[s]
at org.jclouds.compute.internal.BaseComputeService.createNodesInGroup(BaseComputeService.java:227)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.inject.internal.DelegatingInvocationHandler.invoke(DelegatingInvocationHandler.java:37)
at com.sun.proxy.$Proxy59.createNodesInGroup(Unknown Source)
at com.abiquo.deployer.rackspace.RackspaceCompute.main(RackspaceCompute.java:42)
package com.abiquo.deployer.rackspace;
import java.io.File;
import org.jclouds.ContextBuilder;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
import org.jclouds.sshj.config.SshjSshClientModule;
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.io.Files;
public class RackspaceCompute {
public static void main(String[] args) throws Exception {
String publicKey = Files.toString(new File(System.getProperty("user.home") + "/.ssh/id_rsa.pub"), Charsets.UTF_8);
String privateKey = Files.toString(new File(System.getProperty("user.home") + "/.ssh/id_rsa"), Charsets.UTF_8);
ComputeServiceContext context = ContextBuilder.newBuilder("rackspace-cloudservers-us") //
.credentials("<identity>", "<credential>") //
.modules(ImmutableSet.of(new SshjSshClientModule(), new SLF4JLoggingModule())) //
.buildView(ComputeServiceContext.class);
try {
ComputeService compute = context.getComputeService();
TemplateOptions options = compute.templateOptions();
Template template = compute.templateBuilder() //
// .osFamily(OsFamily.CENTOS) //
.options(options.authorizePublicKey(publicKey) //
.overrideLoginPrivateKey(privateKey) //
.runScript("echo 'This should work'") //
) //
.smallest() //
.build();
NodeMetadata node = Iterables.getOnlyElement(compute.createNodesInGroup("jcloudstest", 1, template));
System.out.println("Created: " + node);
} finally {
context.close();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment