use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class ClouderaManagerSecurityService method createClientWithNewPassword.
private ApiClient createClientWithNewPassword() throws ClouderaManagerClientInitException {
LOGGER.debug("Cloudera Manager already running, old admin user's password has been changed.");
Cluster cluster = stack.getCluster();
String user = cluster.getCloudbreakAmbariUser();
String password = cluster.getCloudbreakAmbariPassword();
return clouderaManagerApiClientProvider.getV40Client(stack.getGatewayPort(), user, password, clientConfig);
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class ClouderaManagerSecurityService method changeOriginalCredentialsAndCreateCloudbreakUser.
@Override
public void changeOriginalCredentialsAndCreateCloudbreakUser(boolean ldapConfigured) throws CloudbreakException {
LOGGER.debug("change original admin user and create cloudbreak user");
try {
ApiClient client = createApiClient();
UsersResourceApi usersResourceApi = clouderaManagerApiFactory.getUserResourceApi(client);
ApiUser2List userList = usersResourceApi.readUsers2("SUMMARY");
ApiUser2 oldAdminUser = getOldAdminUser(userList).orElseThrow(() -> new CloudbreakException("Can't find original admin user"));
Cluster cluster = stack.getCluster();
createNewUser(usersResourceApi, oldAdminUser.getAuthRoles(), cluster.getCloudbreakAmbariUser(), cluster.getCloudbreakAmbariPassword(), userList);
createNewUser(usersResourceApi, oldAdminUser.getAuthRoles(), cluster.getDpAmbariUser(), cluster.getDpAmbariPassword(), userList);
if (ADMIN_USER.equals(cluster.getUserName())) {
oldAdminUser.setPassword(cluster.getPassword());
usersResourceApi.updateUser2(oldAdminUser.getName(), oldAdminUser);
} else if (cluster.getUserName() != null) {
createUserSuppliedCMUser(userList, oldAdminUser, cluster);
}
removeDefaultAdminUser(ldapConfigured, Optional.ofNullable(cluster.getUserName()));
} catch (ApiException | ClusterClientInitException | 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.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class ClouderaManagerSetupService method addNoProxyHosts.
private void addNoProxyHosts(ProxyConfig proxyConfig, ApiConfigList proxyConfigList) {
if (StringUtils.isNotBlank(proxyConfig.getNoProxyHosts())) {
Cluster cluster = stack.getCluster();
ClouderaManagerRepo clouderaManagerRepoDetails = clusterComponentProvider.getClouderaManagerRepoDetails(cluster.getId());
if (isVersionNewerOrEqualThanLimited(clouderaManagerRepoDetails::getVersion, CLOUDERAMANAGER_VERSION_7_6_0)) {
proxyConfigList.addItemsItem(new ApiConfig().name("parcel_no_proxy_list").value(proxyConfig.getNoProxyHosts()));
}
}
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class ClouderaManagerSetupService method installCluster.
@Override
public void installCluster(String template) {
Cluster cluster = stack.getCluster();
try {
Optional<ApiCluster> cmCluster = getCmClusterByName(cluster.getName());
boolean prewarmed = isPrewarmed(cluster.getId());
Optional<ClusterCommand> importCommand = clusterCommandRepository.findTopByClusterIdAndClusterCommandType(cluster.getId(), ClusterCommandType.IMPORT_CLUSTER);
if (cmCluster.isEmpty() || importCommand.isEmpty()) {
ApiClusterTemplate apiClusterTemplate = JsonUtil.readValue(template, ApiClusterTemplate.class);
cluster.setExtendedBlueprintText(getExtendedBlueprintText(apiClusterTemplate));
ClouderaManagerResourceApi clouderaManagerResourceApi = clouderaManagerApiFactory.getClouderaManagerResourceApi(apiClient);
LOGGER.info("Generated Cloudera cluster template: {}", AnonymizerUtil.anonymize(template));
// addRepositories - if true the parcels repositories in the cluster template
// will be added.
ApiCommand apiCommand = clouderaManagerResourceApi.importClusterTemplate(calculateAddRepositories(apiClusterTemplate, prewarmed), apiClusterTemplate);
ClusterCommand clusterCommand = new ClusterCommand();
clusterCommand.setClusterId(cluster.getId());
clusterCommand.setCommandId(apiCommand.getId());
clusterCommand.setClusterCommandType(ClusterCommandType.IMPORT_CLUSTER);
importCommand = Optional.of(clusterCommandRepository.save(clusterCommand));
LOGGER.debug("Cloudera cluster template has been submitted, cluster install is in progress");
}
importCommand.ifPresent(cmd -> clouderaManagerPollingServiceProvider.startPollingCmTemplateInstallation(stack, apiClient, cmd.getCommandId()));
} catch (ApiException e) {
String msg = "Installation of CDP with Cloudera Manager has failed: " + extractMessage(e);
throw new ClouderaManagerOperationFailedException(msg, e);
} catch (CloudStorageConfigurationFailedException e) {
LOGGER.info("Error while configuring cloud storage. Message: {}", e.getMessage(), e);
throw new ClouderaManagerOperationFailedException(mapStorageError(e, stack.getResourceCrn(), stack.cloudPlatform(), cluster), e);
} catch (Exception e) {
throw mapException(e);
}
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class ClouderaManagerSetupService method waitForHosts.
@Override
public ExtendedPollingResult waitForHosts(Set<InstanceMetaData> hostsInCluster) throws ClusterClientInitException {
Cluster cluster = stack.getCluster();
String user = cluster.getCloudbreakAmbariUser();
String password = cluster.getCloudbreakAmbariPassword();
ApiClient client;
try {
client = clouderaManagerApiClientProvider.getV31Client(stack.getGatewayPort(), user, password, clientConfig);
} catch (ClouderaManagerClientInitException e) {
throw new ClusterClientInitException(e);
}
List<String> privateIps = hostsInCluster.stream().map(InstanceMetaData::getPrivateIp).collect(Collectors.toList());
return clouderaManagerPollingServiceProvider.startPollingCmHostStatus(stack, client, privateIps);
}
Aggregations