The project has been forked and it is hosted at openstack4j/openstack4j.
containx / openstack4j Goto Github PK
View Code? Open in Web Editor NEWA Fluent OpenStack SDK / Client Library for Java
Home Page: http://openstack4j.com
License: Other
A Fluent OpenStack SDK / Client Library for Java
Home Page: http://openstack4j.com
License: Other
The project has been forked and it is hosted at openstack4j/openstack4j.
Hi and thanks for a nice java api for openstack.
I see that you have a getUserData() function in the service api, but no way of setting it when creating a new server. Is that correct and if so, would it be hard to implement?
Hi,
I'm a student working on a school project, and i'm using openstack4j, but i'm guetting an exception while using the addpool method. Is that a bug or i'm doing something wrong?
Thanks.
Hi, Can provide Compute API v2.1 (EXPERIMENTAL) binding ?
Dear Gondor,
I want to rebuild an instance from OpenStack4J, I've searched but did not found any results.
Please help me.
Thanks you so much
what's wrong?i added openstack4j-1.0.1-withdeps.jar.
Dear all,
I am trying to call some function of openstack4J from web application (JSF)
I write my function in my bean as following:
public List getFlavorList() {
List<SelectItem> items = new ArrayList<SelectItem>();
OSClient osClient = OSFactory.builder().endpoint("http://xxx.xxx.xxx.xxx:5000/v2.0")
.credentials("admin", "nova").tenantName("admin").authenticate();
List<? extends Flavor> flavors = osClient.compute().flavors().list();
SelectItem item = null;
for (Flavor flv: flavors){
item = new SelectItem();
item.setLabel(flv.getName());
item.setValue(flv.getId());
items.add(item);
}
return items;
}
If i create a main function to test this function directly so that it ok, i can get flavor list. But If i try to call from my JSF page, It appear an error.
<h:selectOneMenu value="#{dropletBean.droplet.flavorID}">
<f:selectItem itemLabel="Please select one size" />
<f:selectItems value="#{flavorBean.getFlavorList()}" />
/h:selectOneMenu
The error is below, please check it for me, thanks you so much
java.lang.NullPointerException: URI template of the newly created target must not be null. at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:229) at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:179) at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:69) at org.openstack4j.core.transport.internal.HttpExecutor.invoke(HttpExecutor.java:73) at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:52) at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:43) at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:136) at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:131) at org.openstack4j.openstack.compute.internal.FlavorServiceImpl.list(FlavorServiceImpl.java:24) at com.vdco.icloud.openstack.web.service.impl.FlavorServiceImpl.getFlavorIDList(FlavorServiceImpl.java:39) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Hello,
I create a new Server like this:
ServerCreate sc = Builders.server()
.name("Ubuntu 2")
.flavor("flavorId")
.image("imageId")
.addPersonality("/etc/motd", "Welcome to the new VM! Restricted access only")
.build();
I want to ask if i can set the Availability Zone of Server. I know that with server.getAvailabilityZone() i get the AvailabilityZone but how can i set by myself with this API?
Thank you
I am trying to find a full fetched examples for openstack 4j.It will be useful if a proper example is given as i am new to Openstack4j
in Glance, creating image occurs error
below is my test code
I wrapped some code
OSSession.getInstance().getImage().create(Builders.image()
.name(imgName)
.isPublic(isPublic)
.containerFormat(containerFormat)
.diskFormat(diskFormat)
.build()
, payload);
below is error log.
My JVM heap size is 1.5G and img size is 960M
Exception in thread "main" ConnectionException{message=Java heap space, status=0}
at org.openstack4j.core.transport.internal.HttpExecutor.invoke(HttpExecutor.java:94)
at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:52)
at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:43)
at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:136)
at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:131)
at org.openstack4j.openstack.image.internal.ImageServiceImpl.create(ImageServiceImpl.java:88)
Caused by: javax.ws.rs.ProcessingException: Java heap space
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:224)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:634)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:631)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:421)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:631)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:391)
at org.openstack4j.core.transport.internal.HttpExecutor.invoke(HttpExecutor.java:87)
... 9 more
Caused by: java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2271)
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140)
at sun.net.www.http.PosterOutputStream.write(PosterOutputStream.java:78)
at org.glassfish.jersey.message.internal.CommittingOutputStream.write(CommittingOutputStream.java:227)
at org.glassfish.jersey.message.internal.ReaderWriter.writeTo(ReaderWriter.java:111)
at org.glassfish.jersey.message.internal.AbstractMessageReaderWriterProvider.writeTo(AbstractMessageReaderWriterProvider.java:77)
at org.glassfish.jersey.message.internal.InputStreamProvider.writeTo(InputStreamProvider.java:103)
at org.glassfish.jersey.message.internal.InputStreamProvider.writeTo(InputStreamProvider.java:58)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:194)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)
at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1005)
at org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:430)
at org.glassfish.jersey.client.HttpUrlConnector._apply(HttpUrlConnector.java:287)
at org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:200)
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:215)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:634)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:631)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:421)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:631)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:391)
at org.openstack4j.core.transport.internal.HttpExecutor.invoke(HttpExecutor.java:87)
at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:52)
at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:43)
at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:136)
at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:131)
at org.openstack4j.openstack.image.internal.ImageServiceImpl.create(ImageServiceImpl.java:88)
When I'm using the openstack4j dependency (with deps) I got this error:
Exception in thread "main" java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;
at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119)
at org.glassfish.jersey.client.JerseyWebTarget.(JerseyWebTarget.java:72)
at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:180)
at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:69)
at org.openstack4j.core.transport.internal.HttpExecutor.invoke(HttpExecutor.java:63)
at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:42)
at org.openstack4j.openstack.OSFactory.authenticate(OSFactory.java:67)
When I remove the jersey-servlet dependency (I'm using it in my project), I don't have this problem anymore.
I tried to use exclusions in pom file like this:
But still same issue...
when I use the normal OpenStack4j dependency I have more errors of notfound classes.
Any help would be nice.
hi,I want to use openstack4j in my environment,but I plan to use keystone v3 and openstack4j does not support. I see that you say “I don't have full support for the V3 endpoint yet”,and I wonder when I can use V3 in openstack4j.Thanks a lot.
Added a new feature to get user by name.
Dear Gondor,
I am trying to list all of my server from Openstack4J
private void listServer() {
// Find all Servers
OSClient os = OSFactory.builder().endpoint("http://xxx.xxx.xxx.xxx:5000/v2.0")
.credentials("admin", "passwd").tenantName("admin").authenticate();
List<? extends Server> servers = os.compute().servers().list();
for (Server sv : servers) {
System.out.println("Instance name: " + sv.getName());
System.out.println("Server ID: " + sv.getId());
}
}
Below is error appearing (I make a main method to test)
Exception in thread "main" javax.ws.rs.ProcessingException: Error reading entity from input stream.
at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:849)
at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:768)
at org.glassfish.jersey.client.InboundJaxrsResponse.readEntity(InboundJaxrsResponse.java:96)
at org.glassfish.jersey.client.ScopedJaxrsResponse.access$001(ScopedJaxrsResponse.java:56)
at org.glassfish.jersey.client.ScopedJaxrsResponse$1.call(ScopedJaxrsResponse.java:77)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:396)
at org.glassfish.jersey.client.ScopedJaxrsResponse.readEntity(ScopedJaxrsResponse.java:74)
at org.openstack4j.core.transport.HttpResponse.getEntity(HttpResponse.java:112)
at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:136)
at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:131)
at org.openstack4j.openstack.compute.internal.ServerServiceImpl.list(ServerServiceImpl.java:45)
at org.openstack4j.openstack.compute.internal.ServerServiceImpl.list(ServerServiceImpl.java:37)
at com.vdco.icloud.openstack.web.servlet.jsf2.Ops4J.listServer(Ops4J.java:91)
at com.vdco.icloud.openstack.web.servlet.jsf2.Ops4J.main(Ops4J.java:296)
Caused by: org.codehaus.jackson.map.JsonMappingException: Can not instantiate value of type [simple type, class org.openstack4j.openstack.compute.domain.NovaImage] from JSON String; no single-String constructor/factory method (through reference chain: org.openstack4j.openstack.compute.domain.Servers["servers"]->org.openstack4j.openstack.compute.domain.NovaServer["image"])
at org.codehaus.jackson.map.deser.std.StdValueInstantiator._createFromStringFallbacks(StdValueInstantiator.java:379)
at org.codehaus.jackson.map.deser.std.StdValueInstantiator.createFromString(StdValueInstantiator.java:268)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromString(BeanDeserializer.java:765)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:585)
at org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:299)
at org.codehaus.jackson.map.deser.SettableBeanProperty$FieldProperty.deserializeAndSet(SettableBeanProperty.java:579)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:697)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
at org.codehaus.jackson.map.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:217)
at org.codehaus.jackson.map.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:194)
at org.codehaus.jackson.map.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:30)
at org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:299)
at org.codehaus.jackson.map.deser.SettableBeanProperty$FieldProperty.deserializeAndSet(SettableBeanProperty.java:579)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:697)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
at org.codehaus.jackson.map.ObjectMapper._readValue(ObjectMapper.java:2704)
at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1315)
at org.codehaus.jackson.jaxrs.JacksonJsonProvider.readFrom(JacksonJsonProvider.java:419)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:188)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:134)
at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:988)
at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:833)
... 16 more
I checked in my dashboard and also checked by cURL command is ok.
I dont know why it's error from OpenStack4J. Please help me to check it out.
Thanks you so much
Hi,
The code for getting list of SecurityGroup rules in the file NeutronSecurityGroup is not implemented.
Here is the snippet according to latest code:-
public List<? extends SecurityGroupRule> getRules() { // TODO Auto-generated method stub return null; }
So would you please Implement this and push at the earliest.
Thank you in advance.
As part of the Jackson 1.x -> 2.x upgrade we will be upgrading Jersey from the legacy 2.0 -> 2.10.1
Dear Gondor,
Maybe the last topic i make it's hard to understand, I make new one for more easy understand, please take a look to help me!
I want to get fixed IP from Openstack4J, I make a main method as below to test
public static void main(String[] args) {
OSClient osClient= OSFactory.builder().endpoint(enpoint).credentials("keystoneUsername", "keystonePasswd").tenantName("Tenant").authenticate();
List<String> pools = osClient.compute().floatingIps().getPoolNames();
for (String str: pools){
FloatingIP ip = osClient.compute().floatingIps().allocateIP(str);
System.out.println("Pool name is: " + ip.getPool());
System.out.println("Fixed_IP: "+ ip.getFixedIpAddress());
System.out.println("Floating_IP: "+ ip.getFloatingIpAddress());
}
}
The result is:
Pool name is: public
Fixed_IP: null
Floating_IP: 172.24.4.128
Pool name is: testNetwork
Fixed_IP: null
Floating_IP: 172.24.4.12
I dont know why Fixed_IP is null. But if i call create instance with fixed_ip it's work and i check in my dashboard "IP Address" field, it's have an ip address. I dont know why:( Please help me to check it
Thanks you so much
I have flowed the OpenStack4j Getting Started,and run the Queries successful:
// Find all Users
List<? extends User> users = os.identity().users().list();
// List all Tenants
List<? extends Tenant> tenants = os.identity().tenants().list();
// Find all Compute Flavors
List<? extends Flavor> flavors = os.compute().flavors().list();
// Find all running Servers
List<? extends Server> servers = os.compute().servers().list();
// Suspend a Server
os.compute().servers().action("serverId", Action.SUSPEND);
// List all Networks
List<? extends Network> networks = os.networking().network().list();
// List all Subnets
List<? extends Subnet> subnets = os.networking().subnet().list();
// List all Routers
List<? extends Router> routers = os.networking().router().list();
// List all Images (Glance)
List<? extends Image> images = os.images().list();
// Download the Image Data
InputStream is = os.images().getAsStream("imageId");
But when I run Telemetry(Ceilometer) API
List<? extends Meter> meters = os.telemetry().meters().list();
I got an exception:
Exception in thread "main" org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyReader not found for media type=text/xml; charset=UTF-8, type=class [Lorg.openstack4j.openstack.telemetry.domain.CeilometerStatistics;, genericType=class [Lorg.openstack4j.openstack.telemetry.domain.CeilometerStatistics;.
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:173)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:134)
at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:988)
at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:833)
at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:768)
at org.glassfish.jersey.client.InboundJaxrsResponse.readEntity(InboundJaxrsResponse.java:96)
at org.glassfish.jersey.client.ScopedJaxrsResponse.access$001(ScopedJaxrsResponse.java:56)
at org.glassfish.jersey.client.ScopedJaxrsResponse$1.call(ScopedJaxrsResponse.java:77)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:396)
at org.glassfish.jersey.client.ScopedJaxrsResponse.readEntity(ScopedJaxrsResponse.java:74)
at org.openstack4j.core.transport.HttpResponse.getEntity(HttpResponse.java:112)
at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:136)
at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:131)
at org.openstack4j.openstack.telemetry.internal.MeterServiceImpl.statistics(MeterServiceImpl.java:54)
at org.openstack4j.openstack.telemetry.internal.MeterServiceImpl.statistics(MeterServiceImpl.java:47)
Who can help me?
I keep getting
ClientResponseException{message=Bad Request, status=400, status-code=BAD_REQUEST}
when I try to authenticate.
I simply copy pasted code from your homepage
OSClient os = OSFactory.builder().endpoint("https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0")
.useNonStrictSSLClient(true)
.credentials("***","***")
.tenantName("***")
.authenticate();
I am sure my details are correct because when I do an HTTP request myself, It succeeds.
I don't find out in the java doc [1]. I want to know whether the openstack4j support param in list request and how? Or will it be supported?
[1] http://www.openstack4j.com/javadoc/org/openstack4j/api/compute/ServerService.html#list()
Here is the user case.
If a user is in multi project/tenant. How can I control the code to get the resource from expected project/tenant, rather then generate different OSClient for different tenantName.
The simplest java code is to create OSClient,
OSClient os = OSFactory.builder()
.endpoint("https://b.c-1.a.com:12345/v3/auth/tokens")
.credentials("my_username","my_pass")
.tenantId("1234567890")
.authenticate();
the resultant exception was,
Exception in thread "main" ClientResponseException{message=Method Not Allowed, status=405, status-code=METHOD_NOT_ALLOWED}
at org.openstack4j.core.transport.HttpResponse.mapException(HttpResponse.java:175)
at org.openstack4j.core.transport.HttpResponse.mapException(HttpResponse.java:160)
at org.openstack4j.core.transport.HttpResponse.getEntity(HttpResponse.java:104)
at org.openstack4j.core.transport.HttpResponse.getEntity(HttpResponse.java:59)
at org.openstack4j.openstack.OSFactory.authenticate(OSFactory.java:110)
Use the same the endpoint and run a request from a test tool, Postman, it worked with no problem.
In Postman, the http post has a body (json) like,
{
"auth": {
"identity": {
"methods": ["password"],
"password": {
"user": {
"name": "my_username",
"password": "my_password"
}
}
},
"scope": {
"project": {
"id": "1234567890"
}
}
}
}
what's the issue in the java code?
Thanks in advance.
Upcoming version 2 is planning to upgrade Jackson from version 1 to 2. This issue is created to track change
Feature request.
I see on the main page that you have the following listed as dependencies.
Which of these are actually required for the runtime as apposed to the test applications, etc.? I want to build the runtime jar with the minimal 3rd party libraries. You are listed as ApacheV2 license, but the dependencies are not and can be tricky to manage.
A simple build or downloadable jar what only needs the minimum runtime would be ideal.
Dear Gondor,
From the time i follow your recommend that I can get osClient by the way call the method clientFromAccess() as:
OSClient osClient = OSFactory.clientFromAccess(access);
The first time everything seem ok but after a time later, i dont know exactly how many hours later if i try to create instance again or do something with openstack system, it's appear an error that "Unauthorized: in my web browser.
I try to print out the token Expires, it's 3 hours? right?
System.out.println("Token Expire: "+ access.getToken().getExpires().getHours());
The result is 3.
So how can i do if i want to create instance or do something everytime with openstack (choose image, list user...etc) without Unauthorized error on my web site? The problem may be the token of access variable?
Thanks in advance!
Version: 1.0.1
was trying out the example in the "Getting Started" section of your documentation and ran into a problem with getting the network list:
List<? extends Network> networks = os.networking().network().list();
Exception in thread "main" ConnectionException{message=java.net.ConnectException: Connection refused: connect, status=0}
at org.openstack4j.core.transport.internal.HttpExecutor.invoke(HttpExecutor.java:94)
at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:52)
at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:43)
at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:136)
at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:131)
at org.openstack4j.openstack.networking.internal.NetworkServiceImpl.list(NetworkServiceImpl.java:24)
at carey.jon.openstack4j.MainClass.main(MainClass.java:62)
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.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: javax.ws.rs.ProcessingException: java.net.ConnectException: Connection refused: connect
at org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:202)
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:215)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:634)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:631)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:421)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:631)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:366)
at org.openstack4j.core.transport.internal.HttpExecutor.invoke(HttpExecutor.java:92)
... 11 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
at sun.net.www.http.HttpClient.(HttpClient.java:211)
at sun.net.www.http.HttpClient.New(HttpClient.java:308)
at sun.net.www.http.HttpClient.New(HttpClient.java:326)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:996)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:932)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:850)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1300)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
at org.glassfish.jersey.client.HttpUrlConnector._apply(HttpUrlConnector.java:293)
at org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:200)
... 21 more
The API endpoint for my neutron service is on a different host than my keystone service, but the out going request request looked something like:
GET http://:9696/v2.0/networks
Which produced the connection refused connection above.
The method OSClientSession.getEndpointURL was replacing the neutron host name in the given EndPoint with the keystone host name. I commented out some code in
OSClientSession.getEndpointURL like so:
...
private String getEndpointURL(Endpoint endpoint) {
// if (endpoint.getAdminURL() != null)
// {
// if (getPublicIP() != null && !getPublicIP().equals(endpoint.getAdminURL().getHost()))
// {
// return endpoint.getAdminURL().toString().replaceAll(endpoint.getAdminURL().getHost(), getPublicIP());
// }
// return endpoint.getAdminURL().toString();
// }
return endpoint.getPublicURL().toString();
}
...
My neutron Endpoint did have an admin URL that was different than getPublicIP().
After this hack, all the examples in "Getting Started" worked fine for me. I'm kind of new to the OpenStack side so I'm not clear on the use of the admin URL for the neutron service.
Sorry for such a verbose posting :-/
Hi,
We noticed that all the Action commands work except for SUSPEND.
In the code:
src/main/java/org/openstack4j/openstack/compute/internal/ServerServiceImpl.java
In the function ActionResponse action(String serverId, Action action)
There is no case SUSPEND: in the switch
When we add a case for SUSPEND action, everything works fine.
Best,
JB
It seems the build() returns ServerCreate rather than Server and I don't know how to get to the server??
We are developing a solution using the openstack4j library that will run as a component of an existing platform. This platform has a mechanism for managing secure communications with servers by creating custom SSL socket factories and host name verifiers and passing those to the individual plug-ins.
Right now it looks like the only way we can use this custom SSL socket factory/host name verifier is to set them as the default using HttpsURLConnection.setDefaultSSLSocketFactory and HttpsURLConnection.setDefaultHostnameVerifier. However, this has the downside of potentially impacting other plugins running on the platform.
It would be nice if we could optionally pass a custom SSL socket factory and host name verifier to the client builder that would be used by the constructed OSClient.
We are attempting to read the limits for each tenant, but we are running across an issue. It seems that the call works correctly for the first tenant, but after that we get the following error:
Malformed request URL: URL's project_id '7a03ba3cad8446fd8d8ba285756bed44' doesn't match Context's project_id '3a52cb057dbc4e898eb650e32e3d9e09'
Here is the sample code we are using:
OSClient os = OSFactory.builder()
.endpoint("http://<IP>:5000/v2.0")
.credentials("admin", "<password>")
.tenantName("admin")
.authenticate();
List<? extends Tenant> tenants = os.identity().tenants().list();
for (Tenant tenant : tenants) {
OSClient osTenant = OSFactory.builder()
.endpoint("http://<IP>:5000/v2.0")
.credentials("admin", "<password>")
.tenantName(tenant.getName())
.authenticate();
Limits quotaLimits = osTenant.compute().quotaSets().limits(); // Throws exception on second tenant
}
I've enabled the logging filter, and this is the output from the above code (for just the last call):
INFO: 1 * LoggingFilter - Request received on thread main
1 > GET http://:8774/v2/7a03ba3cad8446fd8d8ba285756bed44/limits
1 > Accept: application/json
1 > X-Auth-Token:
Sep 23, 2014 11:35:35 AM org.openstack4j.core.transport.internal.HttpLoggingFilter log
INFO: 2 * LoggingFilter - Response received on thread main
2 < 400
2 < X-Compute-Request-Id: req-037a5de2-7685-4a13-ac83-c6aabc5ae000
2 < Connection: keep-alive
2 < Content-Length: 188
2 < Date: Tue, 23 Sep 2014 15:35:30 GMT
2 < Content-Type: application/json; charset=UTF-8
{"badRequest": {"message": "Malformed request URL: URL's project_id '7a03ba3cad8446fd8d8ba285756bed44' doesn't match Context's project_id '3a52cb057dbc4e898eb650e32e3d9e09'", "code": 400}}
The strange thing is that this works fine in the 1.0.1 released package, but for a local (unmodified) build of 1.0.2, we are getting this error.
Any ideas?
Hi,
I want to push my code changes, after you review them of course.
These changes were made and has improved the code in the aspect of JSON parsing.
The code changes were made taking latest code from master as a base.
Please, let me know, How do I get started ?
Do I need to create a remote branch and then create a pull request ?
I am new to contributing code on Git. That is why asking you. I have read contirbuting guidelines (https://github.com/gondor/openstack4j/blob/master/CONTRIBUTING.md#chat-with-me ) and that's why decided to write here.
Thanking you in advance,
Akshay.
Hello, we are trying to connect to an untrusted certificate Openstack server, but it seems the API doesn't allow untrusted certs.
Anybody knows a solution? Thanks
Dear Gordon,
after creating a Vm I am not able to know the Ip address automatically assigned by nova_network. I use flat_dhcp configuration. This is my piece of code:
ServerCreate sc = Builders.server().name(name).flavor(flavor_id).image(image_id).build();
Server server = os.compute().servers().boot(sc);
while(!(os.compute().servers().get(server.getId()).getStatus().equals(Status.ACTIVE))){
}
System.out.println("Addresses Vm: " + server.getAddresses());
System.out.println("Ipv4: " + os.compute().servers().get(server.getId()).getAccessIPv4());
I get this result:
Addresses Vm: null
Ipv4:
How can I have the private ip of the VM?
Thank you very much for your help!
how to list zones.I am not able to list it using getAvailabilityZone...but it doesn't seems to work
Dear Gondor,
I write a function to get fixed ip address and floating IP address for creating instance with OpenStack4J.
The have 2 network name, one named is "public" and one name is "private" so that I have to depend on network name to get fixed ip (and floating ip) from networkname.
1- the first method is for getting fixed ip address.
public String getFixedIPFromNetworkName(String networkName){
OSClient osClient = OSFactory.clientFromAccess(access);
FloatingIP ip = osClient.compute().floatingIps().allocateIP(networkName);
System.err.println("FIXED_IP: " + ip.getFixedIpAddress());
return ip.getFixedIpAddress();
}
2- the second method is for getting floating ip address from networkname
public String getFloatingIPFromNetworkName(String networkName){
OSClient osClient = OSFactory.clientFromAccess(access);
FloatingIP ip = osClient.compute().floatingIps().allocateIP(networkName);
System.err.println("FLOATING_IP: " + ip.getFloatingIpAddress());
return ip.getFloatingIpAddress();
}
With the getFixedIPFromNetworkName() method, I created a main method to test, the result is "FIXED_IP= null", but when i call create instance method, i checked in my dashboard it's created instance successfully with an IP address ("172.24.4.112) for my instance.
With the getFloatingIPFromNetworkName(), I also created main method to test, It's have result an ip address (for example: FLOATING_IP: 172.24.4.113) but i checked in my dashboard instance also created but dont have any IP address and the status field is "Error"
Below is my createAndLunchServer() method, with IP address that I get from 2 function above
public void createAndLunchServer(String serverName, String flavorID, String imageID, String networkID, String ip){
OSClient osClient = OSFactory.clientFromAccess(access);
ServerCreate sc = Builders.server().name(serverName)
.flavor(flavorID)
.image(imageID)
.build();
sc.addNetwork(networkID, ip); // ip get from 2 function above
osClient.compute().servers().boot(sc);
}
Please help me to check it out. Thanks so much
Currently we use Jersey as our main connector. In the past the community has asked about using HttpClient and others. I plan on breaking out Jersey into a module and implementing a Connector API in OpenStack4j.
This will allow for additional connector options to be created allowing users to specify the preferred connector to use in their environment
Hi,
Currently, if I want to get list of all flavors Openstack4j provides :- "List flavors = os.compute().flavors().list();" But similar is not available for listing all hypervisors used in Openstack.
I am majorly interested in getting the hypervisor data. I could not find any function for fetching the hypervisor data as mentioned here :- http://developer.openstack.org/api-ref-compute-v2-ext.html#ext-os-hypervisors
The ReST API for the same will be /v2/{tenant_id}/os-hypervisors.
It will be very helpful, if you could provide any pointers about the issue mentioned above.
Thanks in advance.
Hi,
I keep getting
java.io.IOException: Invalid Http response
when I'm trying to get the server list:
os = OSFactory.builder()
.endpoint("https://**********/v2.0")
.credentials(username,password)
.tenantName(tenant)
.useNonStrictSSLClient(true)
.authenticate();
System.out.println(os.compute().servers().list());
Maybe the problem is on the get request:
juin 25, 2014 10:44:07 AM org.openstack4j.core.transport.internal.HttpLoggingFilter log
Infos: 1 * LoggingFilter - Request received on thread AWT-EventQueue-0
1 > GET http://*******/v2/********/servers/detail
It try a GET on a http endpoint instead of https (our compute endpoint as an https address)
Result of getServiceCatalog():
name=nova, type=compute, endpoints=[KeystoneEndpoint{id=*************************, region=RegionOne, publicURL=https://*******/v2/********, internalURL=http://*******/v2/*******, adminURL=http://*******/v2/********}]},
Can you please help me ?
OSClient os = OSFactory.builder()
.endpoint("http://127.0.0.1:5000/v2.0")
.credentials("admin","sample")
.tenantName("admin")
.authenticate();
gave following exception
Exception in thread "main" java.lang.NoClassDefFoundError: javax/ws/rs/ClientErrorException
at org.openstack4j.openstack.OSFactory.authenticate(OSFactory.java:67)
at test.OpenstackImage.main(OpenstackImage.java:29)
Caused by: java.lang.ClassNotFoundException: javax.ws.rs.ClientErrorException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
If authentication was bad, the library will throw an exception unrelated to the issue. The ultimate return will claim "Return Code 401: This site requires authentication."
I followed the part of LEARN on openstack4j.com by using "1.0.1-withdeps Single Jar (With Dependencies)"
ActionResponse r = os.compute().floatingIps().addFloatingIP(server, "192.168.0.250", "50.50.2.3");
where I replaced the fixed ip and floating ip accordingly.
But as a result of this, r.isSuccess() turns out to be false.
I checked the horizon web page and found that the floating ip did not be added to the specified server.
Is there anything wrong?
Dear Gondor,
I've found a problem with list server to compare between 1.0.1 version with 1.0.2
I've written a function to test list server as following:
private void listServer() {
List<? extends Server> servers = os.compute().servers().list();
System.out.println("Server Size List: "+ servers.size());
for (int i = 0; i < servers.size(); i++) {
System.out.println("Server: " + i + ": " + servers.get(i).getId());
}
}
If I use openstack4j1.0.1 so that the result as below
Server Size List: 2
Server 0: dd18d30e-11ce-47b0-805b-d30033eb6e61
Server 1: 806be12a-ca74-4b5b-bbb0-745cd9fe3cdc
But if I use openstack4j 1.0.2 so the result is as following
Server Size List: 4
Server 0: ab94498a-423f-409b-be26-d0a530944d07
Server 1: dd18d30e-11ce-47b0-805b-d30033eb6e61
Server 2: 806be12a-ca74-4b5b-bbb0-745cd9fe3cdc
Server 3: 9a2c47c0-9e93-420f-b56e-32587cd803a6
Actually I my openstack dashboard have total 4 server but 2 server created by admin user, and 2 server that created by another user (with admin role).
So how can I list server with only the server that created by one user?
So openstack4j-1.0.1 is correct?
Thanks you very much
EDIT ---- found the problem in my code
I cannot seem to create a server against DevStack IceHouse.
Connecting, auth, and getting list of servers / flavors works.
I tried both with stable release (1.0.1) and 1.0.2.snap.
What am I doing wrong?
thx.
Code:
// Create a Server Model Object
ServerCreateBuilder sb = os.compute().servers().serverBuilder();
ServerCreate sc = sb.name(request.getVEEType())
.flavor(this.flavors.get(0).getId())
.image("9d796431-c655-45b9-8d94-e7982742264b")
.addPersonality("/etc/motd", "Welcome to the new VM! Restricted access only")
.build();
// Boot the Server
Server server = os.compute().servers().boot(sc);
Exception Thrown:
java.lang.NullPointerException: URI template of the newly created target must not be null.
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:208)
at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:179)
at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:69)
at org.openstack4j.core.transport.internal.HttpExecutor.invoke(HttpExecutor.java:74)
at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:53)
at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:44)
at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:136)
at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:131)
at org.openstack4j.openstack.compute.internal.ServerServiceImpl.boot(ServerServiceImpl.java:65)
Hello. I have been using "openstack4j-1.0.2-withdeps.jar" in a standalone Java application, which worked perfectly. However, after deploying this JAR file to a JBoss AS 7.1.0.Final "Thunder" I keep getting the following exceptions in the log in this line of code:
OSFactory.builder().endpoint(endpoint).credentials(identity, password).tenantName(tenant).authenticate();
14:16:17,950 ERROR [org.jboss.msc.service.fail](MSC service thread 1-7) MSC00001: Failed to start service jboss.deployment.subunit."ear.ear"."xxxx-ejb.jar".component.ResourceAllocatorWS.START: org.jboss.msc.service.StartException in service jboss.deployment.subunit."ear.ear"."xxxx-ejb.jar".component.ResourceAllocatorWS.START: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_45]
at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_45]
Caused by: java.lang.IllegalStateException: JBAS011048: Failed to construct component instance
at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:163)
at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:85)
at org.jboss.as.ejb3.component.singleton.SingletonComponent.getComponentInstance(SingletonComponent.java:113)
at org.jboss.as.ejb3.component.singleton.SingletonComponent.start(SingletonComponent.java:127)
at org.jboss.as.ee.component.ComponentStartService.start(ComponentStartService.java:44)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
... 3 more
Caused by: javax.ejb.EJBException: ConnectionException{message=javax.ws.rs.core.Response$Status$Family.familyOf(I)Ljavax/ws/rs/core/Response$Status$Family;, status=0}
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:166)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:230)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.requiresNew(CMTTxInterceptor.java:333)
at org.jboss.as.ejb3.tx.SingletonLifecycleCMTTxInterceptor.processInvocation(SingletonLifecycleCMTTxInterceptor.java:56)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:161)
... 9 more
Caused by: ConnectionException{message=javax.ws.rs.core.Response$Status$Family.familyOf(I)Ljavax/ws/rs/core/Response$Status$Family;, status=0}
at org.openstack4j.core.transport.internal.HttpExecutor.invoke(HttpExecutor.java:94)
at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:52)
at org.openstack4j.openstack.OSFactory.authenticate(OSFactory.java:99)
at xx.xxx.xxxxx.xxxx.allocation.OpenStackPlugin.(OpenStackPlugin.java:35)
at xx.xxx.xxxxx.xxxx.allocation.ResourceAllocatorWS.postCreate(ResourceAllocatorWS.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_45]
at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_45]
at org.jboss.as.ee.component.ManagedReferenceLifecycleMethodInterceptorFactory$ManagedReferenceLifecycleMethodInterceptor.processInvocation(ManagedReferenceLifecycleMethodInterceptorFactory.java:130)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.as.ee.component.ManagedReferenceInterceptorFactory$ManagedReferenceInterceptor.processInvocation(ManagedReferenceInterceptorFactory.java:95)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228)
... 18 more
Caused by: javax.ws.rs.ProcessingException: javax.ws.rs.core.Response$Status$Family.familyOf(I)Ljavax/ws/rs/core/Response$Status$Family;
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:224)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:634)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:631)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:421)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:631)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:391)
at org.openstack4j.core.transport.internal.HttpExecutor.invoke(HttpExecutor.java:87)
... 37 more
Caused by: java.lang.NoSuchMethodError: javax.ws.rs.core.Response$Status$Family.familyOf(I)Ljavax/ws/rs/core/Response$Status$Family;
at org.glassfish.jersey.message.internal.Statuses$StatusImpl.(Statuses.java:63)
at org.glassfish.jersey.message.internal.Statuses$StatusImpl.(Statuses.java:54)
at org.glassfish.jersey.message.internal.Statuses.from(Statuses.java:93)
at org.glassfish.jersey.client.HttpUrlConnector._apply(HttpUrlConnector.java:295)
at org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:200)
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:215)
... 46 more
I have found out that both "openstack4j-1.0.2-withdeps.jar" and "javaee-api-6.0.jar" have "javax.ws.rs.core" package, containing different versions of same classes. E.g. the
javax.ws.rs.core.Response.Status.Family from "openstack4j-1.0.2-withdeps.jar" does have "familyOf" method while the same class from "javaee-api-6.0.jar" doesn't, which leads to the "java.lang.NoSuchMethodError" exception. This problem also occurs when using "openstack4j-1.0.1.jar" (when specifying as a Maven dependency).
Is there an easy way around this or I'd have to somehow tweak the classpath via MANIFEST file of my EJB module?
Sometimes, after you've booted and started a server you may need to inmediately do some stuff; maybe execute some configuration scripts via SSH or whatever you need to do.
When you need to program and automate this kind of tasks directly from Java using openstack4j, you will need to know when the instance you've just booted has become ACTIVE. As openstack4j doesn't support this functionality yet, you may need to code it yourself by just calling some of the functions it's API provides you.
By now, you can use my solution to this by calling the function waitUntilServerActive() you'll find in the following code:
// Somewhere in your code you must have authenticated...
OSClient os = OSFactory.builder()
.endpoint("http://127.0.0.1:5000/v2.0")
.credentials("admin","sample")
.tenantName("admin")
.authenticate();
// ...and created and booted a Server...
ServerCreate sc = Builders.server()
.name("Ubuntu 2")
.flavor("flavorId")
.image("imageId")
.build();
Server server = os.compute().servers().boot(sc);
// ...and it's now when you call the waitUntilServerActive method:
Server myServer = waitUntilServerActive(os, server);
// Now it's booted and ACTIVE, so let's do things myServer...
myServer.whatever(...);
/*
* This method waits until the Server server has become ACTIVE, and returns it.
*/
private Server waitUntilServerActive(OSClient os, Server server) throws
ClientResponseException, ServerResponseException {
Sring serverId = server.getId();
boolean serverIsReady = false;
Server server2 = null;
while ( !serverIsReady ) {
server2 = os.compute().servers().get(serverId);
if ( server2.getStatus().toString().equals("ACTIVE") ) {
// The server is now ACTIVE
serverIsReady = true;
}
// Wait a little bit, to avoid sending too many petitions away continuoulsy
TimeUnit.SECONDS.sleep(15);
}
return server2;
}
So that's all! Regards @gondor!
Plans are to move OS4J from using the internal APIs lookup to utilize dependency injection. Currently thinking about using Guice but as an alternative can use an alternate single dependency library which will minimize our dependency scope.
Allowing community to provide feedback if they would prefer Guice or an alternate I've used in the past which is not dependent on any other 3rd party libraries.
Please comment. As of right now I'm leaning towards Guice as it's the common standard.
I create a instance using Openstack4j.Now i am trying get the public and private address assigned to the instance.I am using server.getaddress() it returns NovaAddresses{addresses={private=[NovaAddress{address=10.0.0.2, type=fixed, version=4, macaddr=fa:16:3e:c7:1f:87,
}, NovaAddress{address=10.0.0.1, type=floating, version=4, macaddr=fa:16:3e:c7:1f:87,
}]},
}
i want to list private & public addresses separately without other information..Specifically public address
Dear Gondor,
I want to shutdown a server with openstack4j, I do it as following:
osClient.compute().servers().action(server_id, Action.STOP);
After call above code, i check in my dashboard It's seem ok in my dashboard the status of my server is "Shutoff", but i check in my web the status is "UNRECOGNIZED" and I try to print it out
System.out.println(osClient.compute().servers().get("server_id").getStatus().name()));
And the result is also "UNRECOGNIZED"
Thanks you so much
Hello!
As it's the first time I'm using openstack4j I've first created a simple Java project (I'm using Eclipse IDE), and used the '-withdependencies' JAR to get started. So, until here, everything worked fine.
The problem comes when I add openstack4j to an existing project and run it in Tomcat. As I'm using older jackson and jersey versions in this project, could you please specify which are exactly the JAR jackson/jersey files that openstack4j uses? (For example: jersey-core-2.0, jersey-client2.0, etc... ).
I would really appreciate it, so I can add the openstack4j JAR and also delete/update/add only the dependencies I need inside my project... I haven't realized it my own yet, so I'm having some little issues with that!
Thank you very much!
can I use openstack4j(jar) to develop application for android
I can see I can list endpoints and each endpoint map to a region but OsClient gives me a handle on a ComputeService that doesn't seem to be region specific. How can I list servers say that belong to a specific region?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.