Java jclouds API fails to connect to an OpenStack provider.
Exception is thrown with the following message: java.util.NoSuchElementException: apiType compute not found in catalog [].
Other APIs (python-novaclient, ruby-fog) work just fine, so the problem looks language (API)-specific.
import static com.google.common.io.Closeables.closeQuietly;
import java.io.Closeable;
import java.util.Set;
import org.jclouds.ContextBuilder;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.domain.ComputeMetadata;
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.domain.Server;
import org.jclouds.openstack.nova.v2_0.features.ServerApi;
import org.jclouds.rest.RestContext;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
public class jcloudsOpenStack implements Closeable {
private ComputeService compute;
private RestContext nova;
public static void main(String[] args) {
jcloudsOpenStack jcloudOpenStack = new jcloudsOpenStack();
try {
jcloudOpenStack.init();
jcloudOpenStack.listServers();
jcloudOpenStack.close();
}
catch (Exception e) {
e.printStackTrace();
}
finally {
jcloudOpenStack.close();
}
}
private void init() {
Iterable modules = ImmutableSet. of(new SLF4JLoggingModule());
String provider = "openstack-nova";
String identity = "..."; // login name
String password = "..."; // password
ComputeServiceContext context = ContextBuilder.newBuilder(provider)
.endpoint("https://UltiCloud.com:5000/v2.0/")
.credentials(identity, password)
.modules(modules)
.buildView(ComputeServiceContext.class);
compute = context.getComputeService();
nova = context.unwrap();
}
private void listServers() {
Set<? extends ComputeMetadata> nodes = compute.listNodes();
System.out.println(nodes.size());
}
public void close() {
closeQuietly(compute.getContext());
}
}
Any help or a hint is greatly appreciated