Search in sources :

Example 1 with ClouderaManagerResourceApi

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");
    }
}
Also used : ApiConfigList(com.cloudera.api.swagger.model.ApiConfigList) ConfigUtils.makeApiConfigList(com.sequenceiq.cloudbreak.cm.util.ConfigUtils.makeApiConfigList) ApiRole(com.cloudera.api.swagger.model.ApiRole) HashMap(java.util.HashMap) AltusCredential(com.sequenceiq.cloudbreak.auth.altus.model.AltusCredential) ClouderaManagerResourceApi(com.cloudera.api.swagger.ClouderaManagerResourceApi) WorkloadAnalytics(com.sequenceiq.common.api.telemetry.model.WorkloadAnalytics)

Example 2 with ClouderaManagerResourceApi

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);
    }
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) ClouderaManagerResourceApi(com.cloudera.api.swagger.ClouderaManagerResourceApi) ApiException(com.cloudera.api.swagger.client.ApiException)

Example 3 with ClouderaManagerResourceApi

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);
    }
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ApiConfigList(com.cloudera.api.swagger.model.ApiConfigList) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) ClouderaManagerResourceApi(com.cloudera.api.swagger.ClouderaManagerResourceApi) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) ApiException(com.cloudera.api.swagger.client.ApiException)

Example 4 with ClouderaManagerResourceApi

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();
    }
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ApiConfigureForKerberosArguments(com.cloudera.api.swagger.model.ApiConfigureForKerberosArguments) ClouderaManagerResourceApi(com.cloudera.api.swagger.ClouderaManagerResourceApi) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ClustersResourceApi(com.cloudera.api.swagger.ClustersResourceApi) BigDecimal(java.math.BigDecimal)

Example 5 with ClouderaManagerResourceApi

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);
    }
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ClouderaManagerResourceApi(com.cloudera.api.swagger.ClouderaManagerResourceApi) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException) ApiClient(com.cloudera.api.swagger.client.ApiClient) ApiException(com.cloudera.api.swagger.client.ApiException)

Aggregations

ClouderaManagerResourceApi (com.cloudera.api.swagger.ClouderaManagerResourceApi)28 ApiException (com.cloudera.api.swagger.client.ApiException)15 ApiCommand (com.cloudera.api.swagger.model.ApiCommand)13 ApiClient (com.cloudera.api.swagger.client.ApiClient)11 ApiConfigList (com.cloudera.api.swagger.model.ApiConfigList)11 Test (org.junit.jupiter.api.Test)8 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)7 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)7 ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)7 ClustersResourceApi (com.cloudera.api.swagger.ClustersResourceApi)5 ApiConfig (com.cloudera.api.swagger.model.ApiConfig)5 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)5 BigDecimal (java.math.BigDecimal)5 ApiRole (com.cloudera.api.swagger.model.ApiRole)4 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)4 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)4 ApiHostNameList (com.cloudera.api.swagger.model.ApiHostNameList)3 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)3 ClouderaManagerClientInitException (com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException)3 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)3