use of com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException in project cloudbreak by hortonworks.
the class ClouderaManagerModificationService method buildv46ApiClient.
private ApiClient buildv46ApiClient() throws CloudbreakException {
Cluster cluster = stack.getCluster();
String user = cluster.getCloudbreakAmbariUser();
String password = cluster.getCloudbreakAmbariPassword();
try {
return clouderaManagerApiClientProvider.getV46Client(stack.getGatewayPort(), user, password, clientConfig);
} catch (ClouderaManagerClientInitException e) {
LOGGER.error("Failed to init V46 client.", e);
throw new CloudbreakException(e);
}
}
use of com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException in project cloudbreak by hortonworks.
the class ClouderaManagerSecurityService method replaceUserNamePassword.
@Override
public void replaceUserNamePassword(String newUserName, String newPassword) throws CloudbreakException {
Cluster cluster = stack.getCluster();
String user = cluster.getCloudbreakAmbariUser();
String password = cluster.getCloudbreakAmbariPassword();
try {
ApiClient client = getClient(stack.getGatewayPort(), user, password, clientConfig);
UsersResourceApi usersResourceApi = clouderaManagerApiFactory.getUserResourceApi(client);
ApiUser2List oldUserList = usersResourceApi.readUsers2("SUMMARY");
Optional<ApiUser2> oldAdminUser = oldUserList.getItems().stream().filter(apiUser2 -> apiUser2.getName().equals(stack.getCluster().getUserName())).findFirst();
if (oldAdminUser.isPresent()) {
createNewUser(usersResourceApi, oldAdminUser.get().getAuthRoles(), newUserName, newPassword, oldUserList);
usersResourceApi.deleteUser2(oldAdminUser.get().getName());
} else {
throw new CloudbreakException("Can't find original admin user");
}
} catch (ApiException | ClouderaManagerClientInitException e) {
LOGGER.info("Can't replace original admin user due to: ", e);
throw new CloudbreakException("Can't replace original admin user due to: " + e.getMessage());
}
}
use of com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException in project cloudbreak by hortonworks.
the class ClouderaManagerSecurityService method removeDefaultAdminUser.
private void removeDefaultAdminUser(boolean ldapConfigured, Optional<String> userName) {
if (ldapConfigured && isUserIsNullOrNotAdmin(userName)) {
try {
String user = stack.getCluster().getCloudbreakAmbariUser();
String password = stack.getCluster().getCloudbreakAmbariPassword();
ApiClient client = getClient(stack.getGatewayPort(), user, password, clientConfig);
UsersResourceApi usersResourceApi = clouderaManagerApiFactory.getUserResourceApi(client);
usersResourceApi.deleteUser2(ADMIN_USER);
} catch (ApiException | ClouderaManagerClientInitException e) {
LOGGER.info("Can't remove default admin user due to: ", e);
}
}
}
use of com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException in project cloudbreak by hortonworks.
the class ClouderaManagerSecurityService method updateUserNamePassword.
@Override
public void updateUserNamePassword(String newPassword) throws CloudbreakException {
Cluster cluster = stack.getCluster();
String cmUser = cluster.getCloudbreakAmbariUser();
String password = cluster.getCloudbreakAmbariPassword();
try {
ApiClient client = getClient(stack.getGatewayPort(), cmUser, password, clientConfig);
UsersResourceApi usersResourceApi = clouderaManagerApiFactory.getUserResourceApi(client);
ApiUser2List oldUserList = usersResourceApi.readUsers2("SUMMARY");
Optional<ApiUser2> oldAdminUser = oldUserList.getItems().stream().filter(apiUser2 -> apiUser2.getName().equals(stack.getCluster().getUserName())).findFirst();
if (oldAdminUser.isPresent()) {
ApiUser2 user = oldAdminUser.get();
user.setPassword(newPassword);
usersResourceApi.updateUser2(user.getName(), user);
} else {
throw new CloudbreakException("Can't find admin user");
}
} catch (ApiException | ClouderaManagerClientInitException e) {
LOGGER.info("Can't replace admin password due to: ", e);
throw new CloudbreakException("Can't replace admin password due to: " + e.getMessage());
}
}
use of com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException in project cloudbreak by hortonworks.
the class ClouderaManagerSecurityService method rotateHostCertificates.
@Override
public void rotateHostCertificates(String sshUser, KeyPair sshKeyPair, String subAltName) throws CloudbreakException {
Cluster cluster = stack.getCluster();
String user = cluster.getCloudbreakAmbariUser();
String password = cluster.getCloudbreakAmbariPassword();
try {
ApiClient client = getClient(stack.getGatewayPort(), user, password, clientConfig);
HostsResourceApi hostsResourceApi = clouderaManagerApiFactory.getHostsResourceApi(client);
BatchResourceApi batchResourceApi = clouderaManagerApiFactory.getBatchResourceApi(client);
ApiHostList hostList = hostsResourceApi.readHosts(null, null, "SUMMARY");
ApiBatchRequest batchRequest = createHostCertsBatchRequest(hostList, sshUser, sshKeyPair, subAltName);
ApiBatchResponse apiBatchResponse = batchResourceApi.execute(batchRequest);
processHostCertsBatchResponse(client, apiBatchResponse);
} catch (ApiException | ClouderaManagerClientInitException e) {
LOGGER.warn("Can't rotate the host certificates", e);
throw new CloudbreakException("Can't rotate the host certificates due to: " + e.getMessage());
}
}
Aggregations