public Access getAccessByTenant(String tenantName) { Access access = hashTenantAccess.get(tenantName); if (access == null) { access = keystone.tokens().authenticate(new UsernamePassword(username, password)) .withTenantName(tenantName) .execute(); hashTenantAccess.put(tenantName, access); } return access; }
public Access getAccessByTenant(String tenantName) { Access access = hashTenantAccess.get(tenantName); if (access == null) { access = keystone.tokens().authenticate(new UsernamePassword(username, password)) .withTenantName(tenantName) .execute(); hashTenantAccess.put(tenantName, access); } return access; }
/** * @param args */ public static void main(String[] args) { Keystone keystone = new Keystone(KEYSTONE_AUTH_URL); // access with unscoped token Access access = keystone .tokens() .authenticate() .withUsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD) .execute(); System.out.println(access); }
/** * Returns the access object used to authenticate the user and to authorize access to resources owned by this * tenant. * * @param tenantName * The name or id of the tenant * @return The object to represent the access to resources of this tenant * @throws OpenStackConnectException * If the connection to the provider cannot be established. This exception indicates that the provider * is not reachable, or that some failure occurred attempting to open the connection to the provider. * @throws OpenStackResponseException * If the provider responds with some form of error regarding the request, such as unauthorized. This is * an indication that there is a problem with the request itself, not the connection. @see * com.woorea.openstack * .base.client.OpenStackClientConnector#request(com.woorea.openstack.base.client.OpenStackRequest) */ public Access getAccessByTenant(String tenantName) throws OpenStackConnectException, OpenStackResponseException { Access access = hashTenantAccess.get(tenantName); if (access == null) { access = keystone.tokens().authenticate(new UsernamePassword(username, password)).withTenantName(tenantName) .execute(); hashTenantAccess.put(tenantName, access); } return access; }
Authenticate auth = keystone.tokens().authenticate( new UsernamePassword( iaasProperties.get(OpenstackConstants.USER), iaasProperties.get(OpenstackConstants.PASSWORD)));
Access access = keystone.tokens().authenticate(new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD)).execute(); access = keystone.tokens().authenticate(new TokenAuthentication(access.getToken().getId())) .withTenantId(tenants.getList().get(0).getId()) .execute();
Access access = keystone.tokens().authenticate( new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD)) .execute(); access = keystone.tokens().authenticate(new TokenAuthentication(access.getToken().getId())).withTenantId(tenants.getList().get(0).getId()).execute();
/** * @param args */ public static void main(String[] args) { Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL); Access access = keystone.tokens().authenticate(new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD)) .withTenantName("demo") .execute(); //use the token in the following requests keystone.token(access.getToken().getId()); //NovaClient novaClient = new NovaClient(KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "compute", null, "public"), access.getToken().getId()); Nova novaClient = new Nova(ExamplesConfiguration.NOVA_ENDPOINT.concat("/").concat(access.getToken().getTenant().getId())); novaClient.token(access.getToken().getId()); //novaClient.enableLogging(Logger.getLogger("nova"), 100 * 1024); Servers servers = novaClient.servers().list(true).execute(); for(Server server : servers) { System.out.println(server); } }
/** * @param args */ public static void main(String[] args) { Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL); // access with unscoped token Access access = keystone.tokens().authenticate( new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD)) .execute(); // use the token in the following requests keystone.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken().getId())); Tenants tenants = keystone.tenants().list().execute(); // try to exchange token using the first tenant if (tenants.getList().size() > 0) { // access with tenant access = keystone.tokens().authenticate(new TokenAuthentication(access.getToken().getId())).withTenantId(tenants.getList().get(0).getId()).execute(); Quantum quantum = new Quantum(KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "network", null, "public")); quantum.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken().getId())); Networks networks = quantum.networks().list().execute(); for (Network network : networks) { System.out.println(network); } } else { System.out.println("No tenants found!"); } } }
@Override public void execute(Console console, CommandLine args) { if(args.getArgs().length == 1) { Keystone keystone = new Keystone((String) console.getProperty("keystone.endpoint")); Access access = keystone.tokens().authenticate( new UsernamePassword( console.getProperty("keystone.username"), console.getProperty("keystone.password") ) ) .withTenantName(console.getProperty("keystone.tenant_name")) .execute(); System.out.println(console.getProperty("nova.endpoint")); Nova client = new Nova(console.getProperty("nova.endpoint")+args.getArgs()[0]); client.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken().getId())); NovaEnvironment environment = new NovaEnvironment(console.getEnvironment(), client); environment.register(new NovaServerList()); console.setEnvironment(environment); } }
public static void main(String[] args) throws InterruptedException { Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL); Access access = keystone.tokens().authenticate(new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD)) .withTenantName(ExamplesConfiguration.TENANT_NAME) .execute(); //use the token in the following requests keystone.token(access.getToken().getId()); Nova novaClient = new Nova(ExamplesConfiguration.NOVA_ENDPOINT.concat("/").concat(access.getToken().getTenant().getId())); novaClient.token(access.getToken().getId()); Servers servers = novaClient.servers().list(true).execute(); if(servers.getList().size() > 0) { // Server has to be in activated state. ServersResource.StopServer stopServer = novaClient.servers().stop(servers.getList().get(0).getId()); stopServer.endpoint(ExamplesConfiguration.NOVA_ENDPOINT); stopServer.execute(); // Wait until server shutdown. Or 400 error occurs. Thread.sleep(5000); ServersResource.StartServer startServer = novaClient.servers().start(servers.getList().get(0).getId()); startServer.endpoint(ExamplesConfiguration.NOVA_ENDPOINT); startServer.execute(); } } }
/** * @param args */ public static void main(String[] args) { Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL); //access with unscoped token Access access = keystone.tokens().authenticate( new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD)) .execute(); access = keystone.tokens().authenticate(new TokenAuthentication(access.getToken().getId())).withTenantName("admin").execute(); 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 Keystone("http://keystone.x.org/v2.0"); keystone.token(access.getToken().getId()); tenant = keystone.tenants().create(tenant).execute(); System.out.println(tenant); keystone.tenants().delete(tenant.getId()); } }
Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL); Access access = keystone.tokens().authenticate( new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD)) .execute(); access = keystone.tokens().authenticate(new TokenAuthentication(access.getToken().getId())).withTenantId(tenants.getList().get(0).getId()).execute();
.authenticate() .withUsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD) .execute(); access = keystone.tokens().authenticate() .withToken(access.getToken().getId()) .withTenantId(tenants.getList().get(0).getId()).execute();
TokensResource.Authenticate authenticate = tokens.authenticate(authentication); authenticate = authenticate.withTenantName(tenantName); access = authenticate.execute();
Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL); Access access = keystone.tokens() .authenticate(new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD)) .withTenantName("admin") .execute();
Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL); Access access = keystone.tokens().authenticate( new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD)) .execute(); access = keystone.tokens().authenticate(new TokenAuthentication(access.getToken().getId())).withTenantId(tenants.getList().get(0).getId()).execute();
/** * @param args */ public static void main(String[] args) { Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL); //access with unscoped token Access access = keystone.tokens() .authenticate(new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD)) .withTenantName("admin") .execute(); User user = new User(); user.setEmail("luis@woorea.es"); user.setUsername("luis.gervaso"); user.setPassword("password.0"); user.setName("Luis"); user.setEnabled(Boolean.TRUE); keystone = new Keystone("http://keystone.x.org/v2.0"); keystone.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken().getId())); //keystone.enableLogging(Logger.getLogger("keystone"), 10000); user = keystone.users().create(user).execute(); System.out.println(user); keystone.users().delete(user.getId()).execute(); } }
.authenticate( new UsernamePassword( ExamplesConfiguration.KEYSTONE_USERNAME, access = keystone .tokens() .authenticate( new TokenAuthentication(access.getToken().getId())) .withTenantId("tenantId").execute();
@Override public void execute(Console console, CommandLine args) { Keystone client = new Keystone(console.getProperty("keystone.endpoint")); Access access = client.tokens() .authenticate(new UsernamePassword( console.getProperty("keystone.username"), console.getProperty("keystone.password") )) .withTenantName(console.getProperty("keystone.tenant_name")) .execute(); client.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken().getId())); KeystoneEnvironment environment = new KeystoneEnvironment(console.getEnvironment(), client); environment.register(new KeystoneTenantList()); environment.register(new KeystoneTenantCreate()); environment.register(new KeystoneTenantDelete()); environment.register(new KeystoneUserList()); environment.register(new KeystoneUserCreate()); environment.register(new KeystoneUserDelete()); environment.register(new KeystoneRoleList()); environment.register(new KeystoneRoleDelete()); environment.register(new KeystoneServiceList()); console.setEnvironment(environment); }