@Test public void testSetupTelemetry() throws ApiException { Stack stack = new Stack(); stack.setType(StackType.WORKLOAD); WorkloadAnalytics wa = new WorkloadAnalytics(); Telemetry telemetry = new Telemetry(); telemetry.setWorkloadAnalytics(wa); ApiConfigList apiConfigList = new ApiConfigList(); ApiResponse response = new ApiResponse<>(0, null, apiConfigList); AltusCredential credential = new AltusCredential("accessKey", "secretKey".toCharArray()); when(apiClient.execute(any(), any())).thenReturn(response); when(clouderaManagerDatabusService.getAltusCredential(stack)).thenReturn(credential); when(clouderaManagerApiFactory.getClouderaManagerResourceApi(apiClient)).thenReturn(cmResourceApi); when(cmResourceApi.updateConfig(anyString(), any())).thenReturn(apiConfigList); underTest.setupTelemetryRole(stack, apiClient, null, new ApiRoleList(), telemetry); verify(externalAccountService, times(1)).createExternalAccount(anyString(), anyString(), anyString(), anyMap(), any(ApiClient.class)); verify(clouderaManagerDatabusService, times(1)).getAltusCredential(stack); }
public void setupTelemetryRole(final Stack stack, final ApiClient client, final ApiHostRef cmHostRef, final ApiRoleList mgmtRoles, final Telemetry telemetry) throws ApiException { if (isWorkflowAnalyticsEnabled(stack, telemetry)) { WorkloadAnalytics workloadAnalytics = telemetry.getWorkloadAnalytics(); ClouderaManagerResourceApi cmResourceApi = clouderaManagerApiFactory.getClouderaManagerResourceApi(client); ApiConfigList apiConfigList = buildTelemetryCMConfigList(workloadAnalytics); cmResourceApi.updateConfig("Adding telemetry settings.", apiConfigList); AltusCredential credentials = clouderaManagerDatabusService.getAltusCredential(stack); 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"); } }
ClouderaManagerMgmtTelemetryService { public void setupTelemetryRole(final Stack stack, final ApiClient client, final ApiHostRef cmHostRef, final ApiRoleList mgmtRoles, final Telemetry telemetry) throws ApiException { if (isWorkflowAnalyticsEnabled(stack, telemetry)) { WorkloadAnalytics workloadAnalytics = telemetry.getWorkloadAnalytics(); ClouderaManagerResourceApi cmResourceApi = clouderaManagerApiFactory.getClouderaManagerResourceApi(client); ApiConfigList apiConfigList = buildTelemetryCMConfigList(workloadAnalytics); cmResourceApi.updateConfig("Adding telemetry settings.", apiConfigList); AltusCredential credentials = clouderaManagerDatabusService.getAltusCredential(stack); 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"); } } }
ClouderaManagerMgmtTelemetryService { public void setupTelemetryRole(final Stack stack, final ApiClient client, final ApiHostRef cmHostRef, final ApiRoleList mgmtRoles, final Telemetry telemetry) throws ApiException { if (isWorkflowAnalyticsEnabled(stack, telemetry)) { WorkloadAnalytics workloadAnalytics = telemetry.getWorkloadAnalytics(); ClouderaManagerResourceApi cmResourceApi = clouderaManagerApiFactory.getClouderaManagerResourceApi(client); ApiConfigList apiConfigList = buildTelemetryCMConfigList(workloadAnalytics); cmResourceApi.updateConfig("Adding telemetry settings.", apiConfigList); AltusCredential credentials = clouderaManagerDatabusService.getAltusCredential(stack); 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"); } }  }
ClouderaManagerMgmtTelemetryService { public void setupTelemetryRole(final Stack stack, final ApiClient client, final ApiHostRef cmHostRef, final ApiRoleList mgmtRoles, final Telemetry telemetry) throws ApiException { if (isWorkflowAnalyticsEnabled(stack, telemetry)) { WorkloadAnalytics workloadAnalytics = telemetry.getWorkloadAnalytics(); ClouderaManagerResourceApi cmResourceApi = clouderaManagerApiFactory.getClouderaManagerResourceApi(client); ApiConfigList apiConfigList = buildTelemetryCMConfigList(workloadAnalytics); cmResourceApi.updateConfig("Adding telemetry settings.", apiConfigList); AltusCredential credentials = clouderaManagerDatabusService.getAltusCredential(stack); 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"); } }  void setupTelemetryRole(final Stack stack, final ApiClient client, final ApiHostRef cmHostRef,
            final ApiRoleList mgmtRoles, final Telemetry telemetry); void updateTelemetryConfigs(final Stack stack, final ApiClient client,
            final Telemetry telemetry, final String sdxContextName,
            final String sdxStackCrn, final ProxyConfig proxyConfig); }
ClouderaManagerMgmtTelemetryService { public void setupTelemetryRole(final Stack stack, final ApiClient client, final ApiHostRef cmHostRef, final ApiRoleList mgmtRoles, final Telemetry telemetry) throws ApiException { if (isWorkflowAnalyticsEnabled(stack, telemetry)) { WorkloadAnalytics workloadAnalytics = telemetry.getWorkloadAnalytics(); ClouderaManagerResourceApi cmResourceApi = clouderaManagerApiFactory.getClouderaManagerResourceApi(client); ApiConfigList apiConfigList = buildTelemetryCMConfigList(workloadAnalytics); cmResourceApi.updateConfig("Adding telemetry settings.", apiConfigList); AltusCredential credentials = clouderaManagerDatabusService.getAltusCredential(stack); 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"); } }  void setupTelemetryRole(final Stack stack, final ApiClient client, final ApiHostRef cmHostRef,
            final ApiRoleList mgmtRoles, final Telemetry telemetry); void updateTelemetryConfigs(final Stack stack, final ApiClient client,
            final Telemetry telemetry, final String sdxContextName,
            final String sdxStackCrn, final ProxyConfig proxyConfig);  }