use of com.sequenceiq.environment.telemetry.domain.AccountTelemetry in project cloudbreak by hortonworks.
the class EnvironmentApiConverterTest method testAzureSingleRgEnabledAndEmptyAzureRequest.
@Test
void testAzureSingleRgEnabledAndEmptyAzureRequest() {
EnvironmentRequest request = createEnvironmentRequest(AZURE);
request.setAzure(null);
FreeIpaCreationDto freeIpaCreationDto = mock(FreeIpaCreationDto.class);
EnvironmentTelemetry environmentTelemetry = mock(EnvironmentTelemetry.class);
AccountTelemetry accountTelemetry = mock(AccountTelemetry.class);
Features features = mock(Features.class);
NetworkDto networkDto = mock(NetworkDto.class);
when(credentialService.getCloudPlatformByCredential(anyString(), anyString(), any())).thenReturn(AZURE.name());
when(freeIpaConverter.convert(request.getFreeIpa(), "id", CloudConstants.AWS)).thenReturn(freeIpaCreationDto);
when(accountTelemetry.getFeatures()).thenReturn(features);
when(accountTelemetryService.getOrDefault(any())).thenReturn(accountTelemetry);
when(telemetryApiConverter.convert(eq(request.getTelemetry()), any(), anyString())).thenReturn(environmentTelemetry);
when(tunnelConverter.convert(request.getTunnel())).thenReturn(request.getTunnel());
when(networkRequestToDtoConverter.convert(request.getNetwork())).thenReturn(networkDto);
EnvironmentCreationDto actual = testInitCreationDto(request);
assertEquals(ResourceGroupUsagePattern.USE_MULTIPLE, actual.getParameters().getAzureParametersDto().getAzureResourceGroupDto().getResourceGroupUsagePattern());
}
use of com.sequenceiq.environment.telemetry.domain.AccountTelemetry in project cloudbreak by hortonworks.
the class AccountTelemetryService method createDefaultAccuontTelemetry.
public AccountTelemetry createDefaultAccuontTelemetry() {
AccountTelemetry defaultTelemetry = new AccountTelemetry();
List<AnonymizationRule> defaultEncodedRules = defaultRules.stream().map(rule -> {
AnonymizationRule encodedRule = new AnonymizationRule();
encodedRule.setValue(Base64.getEncoder().encodeToString(rule.getValue().getBytes()));
encodedRule.setReplacement(rule.getReplacement());
return encodedRule;
}).collect(Collectors.toList());
Features defaultFeatures = new Features();
defaultFeatures.addClusterLogsCollection(false);
defaultFeatures.addCloudStorageLogging(true);
defaultTelemetry.setRules(defaultEncodedRules);
defaultTelemetry.setFeatures(defaultFeatures);
return defaultTelemetry;
}
use of com.sequenceiq.environment.telemetry.domain.AccountTelemetry in project cloudbreak by hortonworks.
the class AccountTelemetryService method updateFeatures.
public Features updateFeatures(String accountId, Features newFeatures) {
try {
LOGGER.debug("Update account telemetry features for account: {}", accountId);
Optional<AccountTelemetry> telemetryOpt = accountTelemetryRepository.findByAccountId(accountId);
AccountTelemetry telemetry = telemetryOpt.orElse(createDefaultAccuontTelemetry());
Features features = telemetry.getFeatures();
Features finalFeatures = null;
if (features != null && newFeatures != null) {
finalFeatures = new Features();
finalFeatures.setClusterLogsCollection(features.getClusterLogsCollection());
finalFeatures.setWorkloadAnalytics(features.getWorkloadAnalytics());
finalFeatures.setMonitoring(features.getMonitoring());
finalFeatures.setCloudStorageLogging(features.getCloudStorageLogging());
if (newFeatures.getClusterLogsCollection() != null) {
LOGGER.debug("Account telemetry feature request contains log collection feature " + "for account {} (set: {})", accountId, newFeatures.getClusterLogsCollection().isEnabled());
finalFeatures.setClusterLogsCollection(newFeatures.getClusterLogsCollection());
}
if (newFeatures.getWorkloadAnalytics() != null) {
LOGGER.debug("Account telemetry feature request contains workload analytics feature " + "for account {} (set: {})", accountId, newFeatures.getWorkloadAnalytics().isEnabled());
finalFeatures.setWorkloadAnalytics(newFeatures.getWorkloadAnalytics());
}
if (newFeatures.getMonitoring() != null) {
LOGGER.debug("Account telemetry feature request contains monitoring feature " + "for account {} (set: {})", accountId, newFeatures.getMonitoring().isEnabled());
finalFeatures.setMonitoring(newFeatures.getMonitoring());
}
if (newFeatures.getCloudStorageLogging() != null) {
LOGGER.debug("Account telemetry feature request contains cloud storage logging feature " + "for account {} (set: {})", accountId, newFeatures.getCloudStorageLogging().isEnabled());
finalFeatures.setMonitoring(newFeatures.getCloudStorageLogging());
}
}
telemetry.setFeatures(finalFeatures);
return create(telemetry, accountId).getFeatures();
} catch (DataIntegrityViolationException e) {
throw new AccessDeniedException("Access denied", e);
}
}
use of com.sequenceiq.environment.telemetry.domain.AccountTelemetry in project cloudbreak by hortonworks.
the class AccountTelemetryController method update.
@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.POWERUSER_ONLY)
public AccountTelemetryResponse update(AccountTelemetryRequest request) {
String accountId = ThreadBasedUserCrnProvider.getAccountId();
AccountTelemetry telemetry = accountTelemetryConverter.convert(request);
return accountTelemetryConverter.convert(accountTelemetryService.create(telemetry, accountId));
}
use of com.sequenceiq.environment.telemetry.domain.AccountTelemetry in project cloudbreak by hortonworks.
the class AccountTelemetryServiceTest method testValidateRulesWithoutRules.
@Test
public void testValidateRulesWithoutRules() {
// GIVEN
AccountTelemetry telemetry = new AccountTelemetry();
// WHEN
underTest.validateAnonymizationRules(telemetry);
}
Aggregations