HI,
I am new to JClouds. I was trying one quick sample code to test neutron
API. I tried fro list network. But I got *java.lang.IllegalArgumentException:
No enum constant
org.jclouds.openstack.neutron.v2_0.domain.State.active *exception.
I can see in the terminal all the list of network and it happened at the
the time of formatting. Any Help ? I am attaching the java and pom file.
Thnx
import java.io.Closeable;
import java.io.IOException;
import java.util.List;
import org.jclouds.ContextBuilder;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
import org.jclouds.openstack.neutron.v2_0.NeutronApi;
import org.jclouds.openstack.neutron.v2_0.domain.Network;
import org.jclouds.openstack.neutron.v2_0.features.NetworkApi;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
public class FirstNeutron implements Closeable {
private static final String ZONE = "RegionOne";
private final NeutronApi neutronApi;
public static void main(String[] args) throws IOException {
FirstNeutron neutron1 = new FirstNeutron();
try {
neutron1.listNetworks();
}
catch (Exception e) {
e.printStackTrace();
}
finally {
neutron1.close();
}
}
public FirstNeutron() {
Iterable<Module> modules = ImmutableSet.<Module> of(new SLF4JLoggingModule());
String provider = "openstack-neutron";
String identity = "admin:admin";
String password = "admin_pass";
neutronApi = ContextBuilder.newBuilder(provider)
.credentials(identity, password)
.endpoint("http://192.168.100.174:5000/v2.0")
.modules(modules)
.buildApi(NeutronApi.class);
}
public void listNetworks() {
NetworkApi networkApi = neutronApi.getNetworkApiForZone(ZONE);
List<? extends Network> networks = networkApi.listInDetail().concat().toList();
//System.out.format(" Networks: %n");
System.out.format("Networks ------ %s", networks);
for (Network network : networks) {
System.out.format(" %s %n", network);
}
}
public void close() throws IOException {
// TODO Auto-generated method stub
}
}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<jclouds.version>1.7.3</jclouds.version>
</properties>
<groupId>org.apache.jclouds.examples</groupId>
<artifactId>openstack-examples</artifactId>
<version>1.0</version>
<dependencies>
<!-- jclouds dependencies -->
<dependency>
<groupId>org.apache.jclouds.driver</groupId>
<artifactId>jclouds-slf4j</artifactId>
<version>${jclouds.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds.driver</groupId>
<artifactId>jclouds-sshj</artifactId>
<version>${jclouds.version}</version>
</dependency>
<!-- jclouds OpenStack dependencies -->
<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>openstack-keystone</artifactId>
<version>${jclouds.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>openstack-nova</artifactId>
<version>${jclouds.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds.labs</groupId>
<artifactId>openstack-swift</artifactId>
<version>${jclouds.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>openstack-cinder</artifactId>
<version>${jclouds.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>openstack-trove</artifactId>
<version>${jclouds.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds.labs</groupId>
<artifactId>openstack-glance</artifactId>
<version>${jclouds.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds.labs</groupId>
<artifactId>openstack-marconi</artifactId>
<version>${jclouds.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds.labs</groupId>
<artifactId>openstack-neutron</artifactId>
<version>${jclouds.version}</version>
</dependency>
<!-- 3rd party dependencies -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.25</version>
</dependency>
</dependencies>
</project>