You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jclouds.apache.org by Karim <ka...@gmail.com> on 2015/01/09 11:53:44 UTC
JClouds and OpenStack : uses or overrides a deprecated API
Hello,
I'm trying to list images available on OpenStack using Jclouds (Version 1.8.1).
When i run the command :
javac -classpath ".:lib/*" JCloudsOpenStack.java to compile the java File, i got the following error :
JCloudsOpenStack.java:23: error: cannot find symbol
private RestContext<NovaApi, NovaAsyncApi> nova;
^
symbol: class NovaAsyncApi
location: class JCloudsOpenStack
Note: JCloudsOpenStack.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
Any idea to resolve this problem please...
This is the content of the Java file :
--------------------------------------------------
import java.util.Set;
import java.lang.Thread.UncaughtExceptionHandler;
import org.jclouds.ContextBuilder;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.domain.ComputeMetadata;
import org.jclouds.openstack.nova.v2_0.features.ImageApi;
import org.jclouds.openstack.nova.v2_0.domain.Image;
import org.jclouds.rest.RestContext;
import org.jclouds.openstack.nova.v2_0.NovaApi;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
import org.jclouds.openstack.nova.v2_0.domain.Server;
import org.jclouds.openstack.nova.v2_0.features.ServerApi;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.FluentIterable;
import com.google.inject.Module;
public class JCloudsOpenStack {
private ComputeService compute;
private RestContext<NovaApi, NovaAsyncApi> nova;
private Set<String> zones;
public static void main(String[] args) {
JCloudsOpenStack jCloudsOpenStack = new JCloudsOpenStack();
jCloudsOpenStack.init();
jCloudsOpenStack.listImages();
jCloudsOpenStack.close();
}
private void init() {
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
public void uncaughtException(Thread t, Throwable e) {
if (compute != null) close();
e.printStackTrace();
System.exit(1);
}
});
Iterable<Module> modules = ImmutableSet.<Module> of(
new SLF4JLoggingModule());
String provider = "openstack-nova";
String identity = "demo:demo"; // tenantName:userName
String password = "openstack";
ComputeServiceContext context = ContextBuilder.newBuilder(provider)
.credentials(identity, password)
.endpoint("http://10.0.2.15:5000/v2.0/")
.modules(modules)
.buildView(ComputeServiceContext.class);
compute = context.getComputeService();
nova = context.unwrap();
zones = nova.getApi().getConfiguredZones();
}
private void listImages() {
for (String zone: zones) {
ImageApi imageApi = nova.getApi().getImageApiForZone(zone);
System.out.println("Calling listImages for " + zone + ":");
FluentIterable<? extends Image> images = imageApi.listInDetail().concat();
for (Image image: images) {
System.out.println("\t" + image);
}
}
}
private void close() {
compute.getContext().close();
}
}
--
Best Regards
Karim
Re: JClouds and OpenStack : uses or overrides a deprecated API
Posted by Everett Toews <ev...@RACKSPACE.COM>.
Have a look at how the Context is built in the OpenStack Getting Started Guide
http://jclouds.apache.org/guides/openstack/
That will steer you clear of those deprecations.
Thanks,
Everett
On Jan 9, 2015, at 4:53 AM, Karim <ka...@gmail.com>> wrote:
Hello,
I'm trying to list images available on OpenStack using Jclouds (Version 1.8.1).
When i run the command :
javac -classpath ".:lib/*" JCloudsOpenStack.java to compile the java File, i got the following error :
JCloudsOpenStack.java:23: error: cannot find symbol
private RestContext<NovaApi, NovaAsyncApi> nova;
^
symbol: class NovaAsyncApi
location: class JCloudsOpenStack
Note: JCloudsOpenStack.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
Any idea to resolve this problem please...
This is the content of the Java file :
--------------------------------------------------
import java.util.Set;
import java.lang.Thread.UncaughtExceptionHandler;
import org.jclouds.ContextBuilder;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.domain.ComputeMetadata;
import org.jclouds.openstack.nova.v2_0.features.ImageApi;
import org.jclouds.openstack.nova.v2_0.domain.Image;
import org.jclouds.rest.RestContext;
import org.jclouds.openstack.nova.v2_0.NovaApi;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
import org.jclouds.openstack.nova.v2_0.domain.Server;
import org.jclouds.openstack.nova.v2_0.features.ServerApi;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.FluentIterable;
import com.google.inject.Module;
public class JCloudsOpenStack {
private ComputeService compute;
private RestContext<NovaApi, NovaAsyncApi> nova;
private Set<String> zones;
public static void main(String[] args) {
JCloudsOpenStack jCloudsOpenStack = new JCloudsOpenStack();
jCloudsOpenStack.init();
jCloudsOpenStack.listImages();
jCloudsOpenStack.close();
}
private void init() {
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
public void uncaughtException(Thread t, Throwable e) {
if (compute != null) close();
e.printStackTrace();
System.exit(1);
}
});
Iterable<Module> modules = ImmutableSet.<Module> of(
new SLF4JLoggingModule());
String provider = "openstack-nova";
String identity = "demo:demo"; // tenantName:userName
String password = "openstack";
ComputeServiceContext context = ContextBuilder.newBuilder(provider)
.credentials(identity, password)
.endpoint("http://10.0.2.15:5000/v2.0/")
.modules(modules)
.buildView(ComputeServiceContext.class);
compute = context.getComputeService();
nova = context.unwrap();
zones = nova.getApi().getConfiguredZones();
}
private void listImages() {
for (String zone: zones) {
ImageApi imageApi = nova.getApi().getImageApiForZone(zone);
System.out.println("Calling listImages for " + zone + ":");
FluentIterable<? extends Image> images = imageApi.listInDetail().concat();
for (Image image: images) {
System.out.println("\t" + image);
}
}
}
private void close() {
compute.getContext().close();
}
}
--
Best Regards
Karim
Re: JClouds and OpenStack : uses or overrides a deprecated API
Posted by Sofiane Soulfly <sa...@hotmail.com>.
Hi,
I think the "NovaAsyncApi" is deprecated
(http://jclouds.apache.org/reference/javadoc/1.7.x/org/jclouds/openstack/nova/v2_0/package-summary.html).
On 09.01.2015 11:53, Karim wrote:
> Hello,
> I'm trying to list images available on OpenStack using Jclouds (Version 1.8.1).
> When i run the command :
>
> javac -classpath ".:lib/*" JCloudsOpenStack.java to compile the java File, i got the following error :
> JCloudsOpenStack.java:23: error: cannot find symbol
> private RestContext<NovaApi, NovaAsyncApi> nova;
> ^
> symbol: class NovaAsyncApi
> location: class JCloudsOpenStack
> Note: JCloudsOpenStack.java uses or overrides a deprecated API.
> Note: Recompile with -Xlint:deprecation for details.
> 1 error
> Any idea to resolve this problem please...
>
> This is the content of the Java file :
> --------------------------------------------------
> import java.util.Set;
> import java.lang.Thread.UncaughtExceptionHandler;
>
> import org.jclouds.ContextBuilder;
> import org.jclouds.compute.ComputeService;
> import org.jclouds.compute.ComputeServiceContext;
> import org.jclouds.compute.domain.ComputeMetadata;
> import org.jclouds.openstack.nova.v2_0.features.ImageApi;
> import org.jclouds.openstack.nova.v2_0.domain.Image;
> import org.jclouds.rest.RestContext;
> import org.jclouds.openstack.nova.v2_0.NovaApi;
> import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
> import org.jclouds.openstack.nova.v2_0.domain.Server;
> import org.jclouds.openstack.nova.v2_0.features.ServerApi;
>
>
>
> import com.google.common.collect.ImmutableSet;
> import com.google.common.collect.FluentIterable;
> import com.google.inject.Module;
>
> public class JCloudsOpenStack {
> private ComputeService compute;
> private RestContext<NovaApi, NovaAsyncApi> nova;
> private Set<String> zones;
>
> public static void main(String[] args) {
> JCloudsOpenStack jCloudsOpenStack = new JCloudsOpenStack();
> jCloudsOpenStack.init();
> jCloudsOpenStack.listImages();
> jCloudsOpenStack.close();
> }
>
> private void init() {
> Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
> public void uncaughtException(Thread t, Throwable e) {
> if (compute != null) close();
> e.printStackTrace();
> System.exit(1);
> }
> });
>
> Iterable<Module> modules = ImmutableSet.<Module> of(
> new SLF4JLoggingModule());
>
> String provider = "openstack-nova";
> String identity = "demo:demo"; // tenantName:userName
> String password = "openstack";
>
> ComputeServiceContext context = ContextBuilder.newBuilder(provider)
> .credentials(identity, password)
> .endpoint("http://10.0.2.15:5000/v2.0/")
> .modules(modules)
> .buildView(ComputeServiceContext.class);
> compute = context.getComputeService();
> nova = context.unwrap();
> zones = nova.getApi().getConfiguredZones();
> }
>
> private void listImages() {
> for (String zone: zones) {
> ImageApi imageApi = nova.getApi().getImageApiForZone(zone);
>
> System.out.println("Calling listImages for " + zone + ":");
>
> FluentIterable<? extends Image> images = imageApi.listInDetail().concat();
>
> for (Image image: images) {
> System.out.println("\t" + image);
> }
> }
> }
> private void close() {
> compute.getContext().close();
> }
> }
>
>
>
>