Ask Your Question

Fabio's profile - activity

2016-04-14 14:28:38 -0500 received badge  Popular Question (source)
2016-04-13 08:37:07 -0500 answered a question How can I create a new Role with openstack4j?

Solved! OpenStack V2 needs just the name of the role to crete it, but the version of Openstack4j I used automatically embedded in the request also the "enabled" parameter. That's why I got an exception, The bug was fixed in the latest version of the library (2.20)

2016-03-31 04:48:21 -0500 asked a question How can I create a new Role with openstack4j?

Hi all, I'm developing a project by exploiting openstack4j APIs (v. 2.0.9). I need to create a new role so I tried (after authentication) to use a Builder like Users creation:

public void role_create(String name) { 
org.openstack4j.model.identity.Role role = os.identity().roles().create(Builders.role().name(name).build());

When I noticed the error The method create(String) in the type RoleService is not applicable for the arguments (Role), I supposed I just had to pass the 'name' parameter to the create method:

public void role_create(String name) {
org.openstack4j.model.identity.Role role = os.identity().roles().create(name);

Anyway when I run the program on the server I get this error:

 Exception in thread "main" ServerResponseException{message=Internal Server Error, status=500, status-code=INTERNAL_SERVER_ERROR} 
at org.openstack4j.core.transport.HttpExceptionHandler.mapException( at org.openstack4j.core.transport.HttpExceptionHandler.mapException( at org.openstack4j.core.transport.HttpEntityHandler.handle( at org.openstack4j.connectors.okhttp.HttpResponseImpl.getEntity( at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute( at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute( at org.openstack4j.openstack.identity.internal.RoleServiceImpl.create( at openstack.Identity.role_create( at openstack.openstackTest.main(

I used V2 authentication:

public OSClient connect() {
        return OSFactory.builder()
                .credentials("myuser", "mypwd")

As I mentioned before I used Builders to create users:

public void user_create(String username, String password, String email, String tenant, Boolean enable) {
        try {
            User user = os.identity().users()
        } catch (ClientResponseException ex) {
            System.out.println("[CLIENT RESPONSE EXCEPTION] Cannot create user: duplicate name " + username);

Can anyone help me to solve this problem and create a new Role in openstack4j?

Best regards, Fabio