use of com.emc.storageos.keystone.restapi.KeystoneApiClient in project coprhd-controller by CoprHD.
the class KeystoneUtils method deleteCinderEndpoints.
/**
* Delete endpoints for cinder service.
*
* @param managerDN of an Authentication Provider.
* @param serverUrls of an Authentication Provider
* @param managerPassword of an Authentication Provider
*/
public void deleteCinderEndpoints(String managerDN, StringSet serverUrls, String managerPassword) {
// Create a new KeystoneAPI.
KeystoneApiClient keystoneApi = getKeystoneApi(managerDN, serverUrls, managerPassword);
// Get a cinderv2 service id.
String serviceIdV2 = findServiceId(keystoneApi, KeystoneUtils.OPENSTACK_CINDER_V2_NAME);
// Get a cinderv1 service id.
String serviceIdV1 = findServiceId(keystoneApi, KeystoneUtils.OPENSTACK_CINDER_V1_NAME);
// Delete endpoint when cinderv2 service exist.
if (serviceIdV2 != null) {
// Delete endpoint for cinderv2 service.
deleteKeystoneEndpoint(keystoneApi, serviceIdV2);
}
// Delete endpoint when cinder service exist.
if (serviceIdV1 != null) {
// Delete endpoint for cinder service.
deleteKeystoneEndpoint(keystoneApi, serviceIdV1);
}
}
use of com.emc.storageos.keystone.restapi.KeystoneApiClient in project coprhd-controller by CoprHD.
the class KeystoneUtils method populateKeystoneToken.
/**
* Populate or Modify the keystone token
* in authentication provider.
*
* @param managerDN of an Authentication Provider.
* @param serverUrls of an Authentication Provider
* @param password of an Authentication Provider
*
* @return StringMap containing keystone authentication keys.
*/
public StringMap populateKeystoneToken(StringSet serverUrls, String managerDN, String password) {
URI authUri = retrieveUriFromServerUrls(serverUrls);
StringMap usernameAndTenantMap = getUsernameAndTenant(managerDN);
String username = usernameAndTenantMap.get(CinderConstants.USERNAME);
String tenantName = usernameAndTenantMap.get(CinderConstants.TENANTNAME);
KeystoneApiClient keystoneApi = getKeystoneApi(authUri, username, password, tenantName);
keystoneApi.authenticate_keystone();
StringMap keystoneAuthKeys = new StringMap();
keystoneAuthKeys.put(KeystoneConstants.AUTH_TOKEN, keystoneApi.getAuthToken());
return keystoneAuthKeys;
}
use of com.emc.storageos.keystone.restapi.KeystoneApiClient in project coprhd-controller by CoprHD.
the class KeystoneUtils method getTenantWithId.
/**
* Retrieves OpenStack Tenant with given id.
*
* @param id Tenant ID.
*
* @return OpenStack Tenant.
*/
public KeystoneTenant getTenantWithId(String id) {
AuthnProvider keystoneProvider = getKeystoneProvider();
if (keystoneProvider == null) {
throw APIException.internalServerErrors.targetIsNullOrEmpty("Keystone provider");
}
// Get Keystone API client.
KeystoneApiClient keystoneApiClient = getKeystoneApi(keystoneProvider.getManagerDN(), keystoneProvider.getServerUrls(), keystoneProvider.getManagerPassword());
for (KeystoneTenant tenant : keystoneApiClient.getKeystoneTenants().getTenants()) {
if (tenant.getId().equals(id)) {
return tenant;
}
}
return null;
}
use of com.emc.storageos.keystone.restapi.KeystoneApiClient in project coprhd-controller by CoprHD.
the class KeystoneUtils method getKeystoneApi.
/**
* Get Keystone API client.
*
* @param authUri URI pointing to Keystone server.
* @param username OpenStack username.
* @param usernamePassword OpenStack password.
* @param tenantName OpenStack tenantname.
* @return keystoneApi KeystoneApiClient.
*/
public KeystoneApiClient getKeystoneApi(URI authUri, String username, String usernamePassword, String tenantName) {
// Get Keystone API Client.
KeystoneApiClient keystoneApi = (KeystoneApiClient) _keystoneApiFactory.getRESTClient(authUri, username, usernamePassword);
keystoneApi.setTenantName(tenantName);
return keystoneApi;
}
Aggregations