Skip to content

Instantly share code, notes, and snippets.

@etoews
Created August 7, 2012 17:48
Show Gist options
  • Save etoews/3287748 to your computer and use it in GitHub Desktop.
Save etoews/3287748 to your computer and use it in GitHub Desktop.
jclouds resize broken (Rackspace)
Calling resizeServer...
org.jclouds.http.HttpResponseException: command: POST https://dfw.servers.api.rackspacecloud.com/v2/711924/servers/45b23d7b-ec6a-49dc-a642-dadbba42af17/action HTTP/1.1 failed with response: HTTP/1.1 400 Bad Request; content: [{"badRequest": {"message": "Resize requests require 'flavorRef' attribute.", "code": 400}}]
at org.jclouds.openstack.nova.v2_0.handlers.NovaErrorHandler.handleError(NovaErrorHandler.java:48)
at org.jclouds.http.handlers.DelegatingErrorHandler.handleError(DelegatingErrorHandler.java:69)
at org.jclouds.http.internal.BaseHttpCommandExecutorService$HttpResponseCallable.shouldContinue(BaseHttpCommandExecutorService.java:197)
at org.jclouds.http.internal.BaseHttpCommandExecutorService$HttpResponseCallable.call(BaseHttpCommandExecutorService.java:167)
at org.jclouds.http.internal.BaseHttpCommandExecutorService$HttpResponseCallable.call(BaseHttpCommandExecutorService.java:1)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
at org.jclouds.concurrent.config.DescribingExecutorService.submit(DescribingExecutorService.java:89)
at org.jclouds.http.internal.BaseHttpCommandExecutorService.submit(BaseHttpCommandExecutorService.java:132)
at org.jclouds.http.TransformingHttpCommandExecutorServiceImpl.submit(TransformingHttpCommandExecutorServiceImpl.java:54)
at org.jclouds.http.TransformingHttpCommandImpl.execute(TransformingHttpCommandImpl.java:73)
at org.jclouds.rest.internal.AsyncRestClientProxy.createListenableFutureForHttpRequestMappedToMethodAndArgs(AsyncRestClientProxy.java:248)
at org.jclouds.rest.internal.AsyncRestClientProxy.invoke(AsyncRestClientProxy.java:148)
at $Proxy83.resizeServer(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jclouds.concurrent.internal.SyncProxy.invoke(SyncProxy.java:164)
at $Proxy84.resizeServer(Unknown Source)
at com.rackspace.Test.resizeServer(Test.java:51)
at com.rackspace.Test.main(Test.java:44)
at org.jclouds.concurrent.config.DescribingExecutorService.submit(DescribingExecutorService.java:89)
at org.jclouds.http.internal.BaseHttpCommandExecutorService.submit(BaseHttpCommandExecutorService.java:132)
at org.jclouds.http.TransformingHttpCommandExecutorServiceImpl.submit(TransformingHttpCommandExecutorServiceImpl.java:54)
at org.jclouds.http.TransformingHttpCommandImpl.execute(TransformingHttpCommandImpl.java:73)
at org.jclouds.rest.internal.AsyncRestClientProxy.createListenableFutureForHttpRequestMappedToMethodAndArgs(AsyncRestClientProxy.java:248)
at org.jclouds.rest.internal.AsyncRestClientProxy.invoke(AsyncRestClientProxy.java:148)
at $Proxy83.resizeServer(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jclouds.concurrent.internal.SyncProxy.invoke(SyncProxy.java:164)
at $Proxy84.resizeServer(Unknown Source)
at com.rackspace.Test.resizeServer(Test.java:51)
at com.rackspace.Test.main(Test.java:44)
package com.rackspace;
import java.lang.Thread.UncaughtExceptionHandler;
import org.jclouds.ContextBuilder;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.NodeMetadata.Status;
import org.jclouds.compute.domain.NodeMetadataBuilder;
import org.jclouds.enterprise.config.EnterpriseConfigurationModule;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
import org.jclouds.openstack.nova.v2_0.NovaApi;
import org.jclouds.openstack.nova.v2_0.NovaAsyncApi;
import org.jclouds.openstack.nova.v2_0.features.ServerApi;
import org.jclouds.rest.RestContext;
import org.jclouds.sshj.config.SshjSshClientModule;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
public class Test {
private RestContext<NovaApi, NovaAsyncApi> nova;
public static void main(String[] args) {
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
public void uncaughtException(Thread t, Throwable e) {
e.printStackTrace();
System.exit(1);
}
});
Test test = new Test();
test.init();
NodeMetadata nodeMetadata = new NodeMetadataBuilder()
.id("DFW/id-of-some-server")
.providerId("id-of-some-server")
.imageId("")
.status(Status.RUNNING)
.publicAddresses(ImmutableSet.<String> of("public.ip.of.server"))
.privateAddresses(ImmutableSet.<String> of("private.ip.of.server"))
.build();
test.resizeServer(nodeMetadata);
System.exit(0);
}
private void resizeServer(NodeMetadata nodeMetadata) {
System.out.println("Calling resizeServer...");
ServerApi serverApi = nova.getApi().getServerApiForZone("DFW");
serverApi.resizeServer(nodeMetadata.getProviderId(), "3");
}
private void init() {
Iterable<Module> modules = ImmutableSet.<Module> of(
new SshjSshClientModule(),
new SLF4JLoggingModule(),
new EnterpriseConfigurationModule());
String provider = "rackspace-cloudservers-us";
String identity = "my-username";
String apiKey = "my-api-key";
ComputeServiceContext context = ContextBuilder.newBuilder(provider)
.credentials(identity, apiKey)
.modules(modules)
.buildView(ComputeServiceContext.class);
nova = context.unwrap();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment