use of com.cloudera.api.swagger.ClouderaManagerResourceApi in project cloudbreak by hortonworks.
the class ClouderaManagerMgmtTelemetryService method setupTelemetryRole.
public void setupTelemetryRole(final Stack stack, final ApiClient client, final ApiHostRef cmHostRef, final ApiRoleList mgmtRoles, final Telemetry telemetry, String sdxStackCrn) throws ApiException {
if (isWorkflowAnalyticsEnabled(stack, telemetry)) {
WorkloadAnalytics workloadAnalytics = telemetry.getWorkloadAnalytics();
String accountId = Crn.safeFromString(stack.getResourceCrn()).getAccountId();
boolean useDbusCnameEndpoint = entitlementService.useDataBusCNameEndpointEnabled(accountId);
String databusEndpoint = dataBusEndpointProvider.getDataBusEndpoint(workloadAnalytics.getDatabusEndpoint(), useDbusCnameEndpoint);
ClouderaManagerResourceApi cmResourceApi = clouderaManagerApiFactory.getClouderaManagerResourceApi(client);
ApiConfigList apiConfigList = buildTelemetryCMConfigList(workloadAnalytics, databusEndpoint);
cmResourceApi.updateConfig("Adding telemetry settings.", apiConfigList);
AltusCredential credentials = clouderaManagerDatabusService.getAltusCredential(stack, sdxStackCrn);
Map<String, String> accountConfigs = new HashMap<>();
accountConfigs.put(ALTUS_CREDENTIAL_ACCESS_KEY_NAME, credentials.getAccessKey());
accountConfigs.put(ALTUS_CREDENTIAL_PRIVATE_KEY_NAME, new String(credentials.getPrivateKey()));
externalAccountService.createExternalAccount(ALTUS_CREDENTIAL_NAME, ALTUS_CREDENTIAL_NAME, ALTUS_CREDENTIAL_TYPE, accountConfigs, client);
final ApiRole telemetryPublisher = new ApiRole();
telemetryPublisher.setName(TELEMETRYPUBLISHER);
telemetryPublisher.setType(TELEMETRYPUBLISHER);
telemetryPublisher.setHostRef(cmHostRef);
mgmtRoles.addItemsItem(telemetryPublisher);
} else {
LOGGER.info("Telemetry WA is disabled");
}
}
use of com.cloudera.api.swagger.ClouderaManagerResourceApi in project cloudbreak by hortonworks.
the class ClouderaManagerDecomissioner method deleteUnusedCredentialsFromCluster.
public void deleteUnusedCredentialsFromCluster(Stack stack, ApiClient client) {
LOGGER.debug("Deleting unused credentials");
ClouderaManagerResourceApi clouderaManagerResourceApi = clouderaManagerApiFactory.getClouderaManagerResourceApi(client);
try {
ApiCommand command = clouderaManagerResourceApi.deleteCredentialsCommand("unused");
clouderaManagerPollingServiceProvider.startPollingCmKerberosJob(stack, client, command.getId());
} catch (ApiException e) {
LOGGER.error("Failed to delete unused credentials", e);
throw new CloudbreakServiceException(e.getMessage(), e);
}
}
use of com.cloudera.api.swagger.ClouderaManagerResourceApi in project cloudbreak by hortonworks.
the class ClouderaManagerDiagnosticsService method collectDiagnostics.
@Override
public void collectDiagnostics(CmDiagnosticsParameters parameters) throws CloudbreakException {
ClouderaManagerResourceApi resourceApi = clouderaManagerApiFactory.getClouderaManagerResourceApi(client);
try {
ApiConfigList configList = resourceApi.getConfig(null);
Boolean globalPhoneHomeConfig = getPhoneHomeConfig(configList);
preUpdatePhoneHomeConfig(parameters.getDestination(), resourceApi, globalPhoneHomeConfig);
ApiCommand collectDiagnostics = resourceApi.collectDiagnosticDataCommand(convertToCollectDiagnosticDataArguments(parameters));
ExtendedPollingResult pollingResult = clouderaManagerPollingServiceProvider.startPollingCollectDiagnostics(stack, client, collectDiagnostics.getId());
if (pollingResult.isExited()) {
throw new CancellationException("Cluster was terminated while waiting for command API to be available for diagnostics collections");
} else if (pollingResult.isTimeout()) {
throw new CloudbreakException("Timeout during waiting for command API to be available (diagnostics collections).");
}
postUpdatePhoneHomeConfig(parameters.getDestination(), resourceApi, globalPhoneHomeConfig);
} catch (ApiException e) {
LOGGER.error("Error during CM based diagnostics collection", e);
throw new ClouderaManagerOperationFailedException("Collect diagnostics failed", e);
}
}
use of com.cloudera.api.swagger.ClouderaManagerResourceApi in project cloudbreak by hortonworks.
the class ClouderaManagerKerberosService method configureKerberosViaApi.
public void configureKerberosViaApi(ApiClient client, HttpClientConfig clientConfig, Stack stack, KerberosConfig kerberosConfig) throws ApiException, CloudbreakException {
Cluster cluster = stack.getCluster();
if (kerberosDetailService.isAdJoinable(kerberosConfig) || kerberosDetailService.isIpaJoinable(kerberosConfig)) {
ClouderaManagerModificationService modificationService = applicationContext.getBean(ClouderaManagerModificationService.class, stack, clientConfig);
ClouderaManagerResourceApi clouderaManagerResourceApi = clouderaManagerApiFactory.getClouderaManagerResourceApi(client);
modificationService.stopCluster(false);
ClustersResourceApi clustersResourceApi = clouderaManagerApiFactory.getClustersResourceApi(client);
ApiCommand configureForKerberos = clustersResourceApi.configureForKerberos(cluster.getName(), new ApiConfigureForKerberosArguments());
clouderaManagerPollingServiceProvider.startPollingCmKerberosJob(stack, client, configureForKerberos.getId());
ApiCommand generateCredentials = clouderaManagerResourceApi.generateCredentialsCommand();
clouderaManagerPollingServiceProvider.startPollingCmKerberosJob(stack, client, generateCredentials.getId());
List<ApiCommand> commands = clustersResourceApi.listActiveCommands(stack.getName(), SUMMARY).getItems();
BigDecimal deployClusterConfigId = clouderaManagerCommonCommandService.getDeployClientConfigCommandId(stack, clustersResourceApi, commands);
clouderaManagerPollingServiceProvider.startPollingCmKerberosJob(stack, client, deployClusterConfigId);
modificationService.startCluster();
}
}
use of com.cloudera.api.swagger.ClouderaManagerResourceApi in project cloudbreak by hortonworks.
the class ClouderaManagerKerberosService method deleteCredentials.
public void deleteCredentials(HttpClientConfig clientConfig, Stack stack) {
Cluster cluster = stack.getCluster();
String user = cluster.getCloudbreakAmbariUser();
String password = cluster.getCloudbreakAmbariPassword();
try {
ApiClient client = clouderaManagerApiClientProvider.getV31Client(stack.getGatewayPort(), user, password, clientConfig);
clouderaManagerConfigService.disableKnoxAutorestartIfCmVersionAtLeast(CLOUDERAMANAGER_VERSION_7_1_0, client, stack.getName());
ClouderaManagerModificationService modificationService = applicationContext.getBean(ClouderaManagerModificationService.class, stack, clientConfig);
modificationService.stopCluster(false);
ClouderaManagerClusterDecommissionService decomissionService = applicationContext.getBean(ClouderaManagerClusterDecommissionService.class, stack, clientConfig);
decomissionService.removeManagementServices();
ClouderaManagerResourceApi apiInstance = clouderaManagerApiFactory.getClouderaManagerResourceApi(client);
ApiCommand command = apiInstance.deleteCredentialsCommand("all");
clouderaManagerPollingServiceProvider.startPollingCmKerberosJob(stack, client, command.getId());
} catch (ApiException | CloudbreakException | ClouderaManagerClientInitException e) {
LOGGER.info("Failed to remove Kerberos credentials", e);
throw new ClouderaManagerOperationFailedException("Failed to remove Kerberos credentials", e);
}
}
Aggregations