Repository navigation
Endpoint URL Resolution in openstack4j: Catalog-Based Service Selection for cinder service get request #219
Description
"I would like to seek clarification regarding how openstack4j fetches the endpoint URL for services. From what we understand, openstack4j obtains the token first, which contains the catalog. It then retrieves the service URL from the catalog that appears first in the list.
For example, if we are trying to fetch the Cinder service URL and the catalog contains the following list:
- KeystoneService{id=0d9359d4fe124747ae99df5b6d9f7dd8, name=neutron, type=network, enabled=true}
- KeystoneService{id=0e8113ecf2de4670bd0330e473de997c, name=heat, type=orchestration, enabled=true}
- KeystoneService{id=40785cfb641141108ca775712bf9ffcf, name=heat-cfn, type=cloudformation, enabled=true}
- KeystoneService{id=4bad9010dc4849bbb8bc971d31f453fb, name=barbican, type=key-manager, enabled=true}
- KeystoneService{id=4f23ec1269134f8fb69eb2af26ff8827, name=nova, type=compute, enabled=true}
- KeystoneService{id=504b89dbc39341ac9f4871f9e0ea767e, name=cinder, type=volume, enabled=true}
- KeystoneService{id=70721201d6eb40f8b3c71ef8fa02564e, name=keystone, type=identity, enabled=true}
- KeystoneService{id=bfb765d84a8c4b81821d294dd8f0b6e0, name=placement, type=placement, enabled=true}
- KeystoneService{id=c0929ec27d2f4fec862d752877dbb589, name=cinderv3, type=volumev3, enabled=true}
- KeystoneService{id=d933911378e345a5a2c2addc2ad964a6, name=glance, type=image, enabled=true}
- KeystoneService{id=fa61556edd674edb9369f0b5da48becb, name=cinderv2, type=volumev2, enabled=true}
Openstack4j will fetch the following service URL:
KeystoneService{id=504b89dbc39341ac9f4871f9e0ea767e, name=cinder, type=volume, enabled=true}
Other services will be ignored. The one that appears first in the list will be used to get the endpoint URL.
Here is the code where I am retrieving Cinder volumes using openstack4j:
Config cfg = Config.newConfig().withConnectionTimeout(100000).withReadTimeout(100000);
cfg.withSSLVerificationDisabled();
String url = "";
String user = "";
String password ="";
String userDomain ="default";
String projectDomain ="default";
String tenant ="admin";
System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
OSFactory.enableHttpLoggingFilter(false);
V3 cb = OSFactory.builderV3().withConfig(cfg).endpoint(url).credentials(user, password,
Identifier.byName(userDomain));
// For V2 authentication:
// V2 cb = OSFactory.builderV2().withConfig(cfg).endpoint(url).credentials(user, password);
// if (tenant != null && !tenant.trim().isEmpty()) {
// cb.tenantName(tenant);
// }
if (projectDomain != null && !projectDomain.trim().isEmpty()) {
if (tenant != null && !tenant.trim().isEmpty()) {
// Project scoped auth
cb.scopeToProject(Identifier.byName(tenant), Identifier.byName(projectDomain));
} else {
// Domain scoped auth
cb.scopeToDomain(Identifier.byName(projectDomain));
}
}
OSClient<?> os = cb.authenticate();
Map<String, String> headers = new HashMap<String, String>();
headers.put("Connection", "Keep-Alive");
headers.put("Accept-Encoding", "gzip, deflate");
os.headers(headers);
List<? extends Volume> volumes = os.blockStorage().volumes().list();
for (Volume volume : volumes) {
System.out.println(volume.getName());
}Could you please confirm if we have more then one cinder service configured which endpoint will be used i.e order?"
Activity