/** @param args */ public static void main(String[] args) { KeystoneClient keystone = new KeystoneClient(KEYSTONE_AUTH_URL); // access with unscoped token Access access = keystone.execute( Authenticate.withPasswordCredentials(KEYSTONE_USERNAME, KEYSTONE_PASSWORD)); access = keystone.execute(Authenticate.withToken(access.getToken().getId()).withTenantName("admin")); Tenant tenant = new Tenant(); tenant.setName("benn.cs"); tenant.setDescription("benn.cs"); tenant.setEnabled(true); // Get the adminURL client and use the token got above keystone = new KeystoneClient( KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "identity", null, "admin"), access.getToken().getId()); tenant = keystone.execute(new CreateTenant(tenant)); System.out.println(tenant); keystone.execute(new DeleteTenant(tenant.getId())); }
/** @param args */ public static void main(String[] args) { KeystoneClient keystone = new KeystoneClient(ExamplesConfiguration.KEYSTONE_AUTH_URL); // access with unscoped token Access access = keystone.execute( Authenticate.withPasswordCredentials( ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD) .withTenantName("admin")); User user = new User(); user.setEmail("*****@*****.**"); user.setUsername("luis.gervaso"); user.setPassword("password.0"); user.setName("Luis"); user.setEnabled(Boolean.TRUE); keystone = new KeystoneClient(ExamplesConfiguration.KEYSTONE_AUTH_URL, access.getToken().getId()); keystone.enableLogging(Logger.getLogger("keystone"), 10000); user = keystone.execute(new CreateUser(user)); System.out.println(user); keystone.execute(new DeleteUser(user.getId())); }