/** * This method is used to locate a service from the OpenStack service catalog if it is available. * * @param serviceType * The type of service requested (such as "image"). * @param access * The security access object to be used * @return A reference to the <code>Service</code> object, or null if not available. */ public Service locateService(String serviceType, Access access) { for (Service service : access.getServiceCatalog()) { if (service.getType().equals(serviceType)) { return service; } } getLogger().error(EELFResourceManager.format(OSMsg.PAL_OS_LOCATE_SERVICE_FAILED, serviceType)); return null; }
String endpointURL = KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "orchestration", null, "public");
for (Service service : access.getServiceCatalog()) { if (service.getType().equals("image")) { glanceService = service;
getKeystone().setTokenProvider(tokenProvider); List<Access.Service> services = access.getServiceCatalog(); OpenStackContext osContext = context; osContext.registerServices(services);
/** * @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!"); } } }
Quantum quantumClient = new Quantum(KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "network", null, "public")); quantumClient.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken().getId()));
Swift swift = new Swift(KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "object-store", null, "public")); swift.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken().getId()));
.withTenantId("tenantId").execute(); Quantum quantum = new Quantum(KeystoneUtils.findEndpointURL( access.getServiceCatalog(), "network", null, "public")); quantum.setTokenProvider(new OpenStackSimpleTokenProvider(access .getToken().getId()));