Skip to content
This repository has been archived by the owner on Mar 25, 2018. It is now read-only.

new Keystone user #1440

Open
Dorra01 opened this issue Mar 20, 2013 · 2 comments
Open

new Keystone user #1440

Dorra01 opened this issue Mar 20, 2013 · 2 comments

Comments

@Dorra01
Copy link

Dorra01 commented Mar 20, 2013

Hi, I'm working in a java project that let me to connect to my openstack using API. I used jclouds to create Server and to do other actions. But now my problem is that i can't create new user with jclouds (using my ptalform java). Is there any suggesstion plz?

@jdaggett
Copy link

Hi Dorra01,

What version of the Keystone API does your OpenStack environment support?
Can you please send a snippet of your code and what you are trying to do?

/jd

On Wed, Mar 20, 2013 at 8:58 AM, Dorra01 [email protected] wrote:

Hi, I'm working in a java project that let me to connect to my openstack
using API. I used jclouds to create Server and to do other actions. But now
my problem is that i can't create new user with jclouds (using my ptalform
java). Is there any suggesstion plz?


Reply to this email directly or view it on GitHubhttps://github.com/jclouds/jclouds/issues/1440
.

@Dorra01
Copy link
Author

Dorra01 commented Mar 20, 2013

This is my code. it lets me just to have the list of my user in openstack. And i want to add a code to create new user keystone.

package org.jclouds.examples.rackspace.cloudfiles;

import java.io.Closeable;
import org.jclouds.ContextBuilder;
import org.jclouds.rest.RestContext;

import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
import org.jclouds.openstack.keystone.v2_0.domain.Access;
import org.jclouds.openstack.keystone.v2_0.domain.PasswordCredentials;
import org.jclouds.openstack.keystone.v2_0.domain.User;
import org.jclouds.openstack.keystone.v2_0.features.UserApi;
import org.jclouds.openstack.keystone.v2_0.AuthenticationApi;
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
import org.jclouds.openstack.keystone.v2_0.KeystoneAsyncApi;

import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;

public class list implements Closeable {
private RestContext<KeystoneApi, KeystoneAsyncApi> keystone;
//private RestContext<AuthenticationApi,AuthenticationAsyncApi> keystone;
public static void main(String[] args) {
list l=new list();

  try {
    l.init();
     l.close();
  }
  catch (Exception e) {
     e.printStackTrace();
  }
  finally {
     l.close();
  }

}

private void init() {

  String provider = "openstack-keystone";
  String identity = "openstackDemo:1"; // tenantName:userName
  String password = "azer"; // demo account uses ADMIN_PASSWORD too

  Iterable<Module> modules = ImmutableSet.<Module> of(
          new SLF4JLoggingModule());
  ContextBuilder contextBuilder =ContextBuilder.newBuilder(provider);

             keystone = contextBuilder
               .credentials(identity, password)
               .endpoint("http://192.168.1.3:5000/v2.0/")
               .modules(modules)
               .build();
             KeystoneApi keystoneApi =  keystone.getApi();

AuthenticationApi authenticationApi = keystone.utils().injector().getInstance(AuthenticationApi.class);
Access access = authenticationApi.authenticateWithTenantNameAndCredentials("openstackDemo", PasswordCredentials.createWithUsernameAndPassword("1", "azer"));
System.out.println(access);
Access.builder().user(User.builder().name("nova52").id("12548").build());

             UserApi uapi=keystone.getApi().getUserApi().get();
            System.out.println("user");
       //  User u1= uapi.get("b7a38e397be349a389e20c80be29e2c1");
        //System.out.println("  " + u1);

       //Set<Role> roles = u1.getRoles();
      //System.out.println(roles.toString());

}

public void close() {
//closeQuietly(keystone);
}
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants