@Test public void deleteCredentials() throws ApiException, CloudbreakException, ClouderaManagerClientInitException { when(clouderaManagerApiFactory.getClouderaManagerResourceApi(client)).thenReturn(clouderaManagerResourceApi); when(clouderaManagerResourceApi.deleteCredentialsCommand("all")).thenReturn(new ApiCommand().id(BigDecimal.ZERO)); underTest.deleteCredentials(clientConfig, stack); verify(modificationService).stopCluster(false); clouderaManagerPollingServiceProvider.startPollingCmKerberosJob(stack, client, BigDecimal.ZERO); }
public void deleteCredentials(HttpClientConfig clientConfig, Stack stack) { Cluster cluster = stack.getCluster(); String user = cluster.getCloudbreakAmbariUser(); String password = cluster.getCloudbreakAmbariPassword(); try { ApiClient client = clouderaManagerApiClientProvider.getClient(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); ClouderaManagerClusterDecomissionService decomissionService = applicationContext.getBean(ClouderaManagerClusterDecomissionService.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); } }
ClouderaManagerKerberosService { public void deleteCredentials(HttpClientConfig clientConfig, Stack stack) { Cluster cluster = stack.getCluster(); String user = cluster.getCloudbreakAmbariUser(); String password = cluster.getCloudbreakAmbariPassword(); try { ApiClient client = clouderaManagerApiClientProvider.getClient(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); ClouderaManagerClusterDecomissionService decomissionService = applicationContext.getBean(ClouderaManagerClusterDecomissionService.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); } } }
ClouderaManagerKerberosService { public void deleteCredentials(HttpClientConfig clientConfig, Stack stack) { Cluster cluster = stack.getCluster(); String user = cluster.getCloudbreakAmbariUser(); String password = cluster.getCloudbreakAmbariPassword(); try { ApiClient client = clouderaManagerApiClientProvider.getClient(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); ClouderaManagerClusterDecomissionService decomissionService = applicationContext.getBean(ClouderaManagerClusterDecomissionService.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); } }  }
ClouderaManagerKerberosService { public void deleteCredentials(HttpClientConfig clientConfig, Stack stack) { Cluster cluster = stack.getCluster(); String user = cluster.getCloudbreakAmbariUser(); String password = cluster.getCloudbreakAmbariPassword(); try { ApiClient client = clouderaManagerApiClientProvider.getClient(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); ClouderaManagerClusterDecomissionService decomissionService = applicationContext.getBean(ClouderaManagerClusterDecomissionService.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); } }  void configureKerberosViaApi(ApiClient client, HttpClientConfig clientConfig, Stack stack, KerberosConfig kerberosConfig); void deleteCredentials(HttpClientConfig clientConfig, Stack stack); }
ClouderaManagerKerberosService { public void deleteCredentials(HttpClientConfig clientConfig, Stack stack) { Cluster cluster = stack.getCluster(); String user = cluster.getCloudbreakAmbariUser(); String password = cluster.getCloudbreakAmbariPassword(); try { ApiClient client = clouderaManagerApiClientProvider.getClient(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); ClouderaManagerClusterDecomissionService decomissionService = applicationContext.getBean(ClouderaManagerClusterDecomissionService.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); } }  void configureKerberosViaApi(ApiClient client, HttpClientConfig clientConfig, Stack stack, KerberosConfig kerberosConfig); void deleteCredentials(HttpClientConfig clientConfig, Stack stack);  }