use of com.sequenceiq.sdx.api.model.RangerCloudIdentitySyncStatus in project cloudbreak by hortonworks.
the class CloudIdSyncStatusListenerTask method checkStatus.
@Override
public boolean checkStatus(CloudIdSyncPollerObject pollerObject) {
RangerCloudIdentitySyncStatus syncStatus = sdxEndpoint.getRangerCloudIdentitySyncStatus(pollerObject.getEnvironmentCrn(), pollerObject.getCommandId());
LOGGER.info("syncStatus = {}", syncStatus);
switch(syncStatus.getState()) {
case SUCCESS:
LOGGER.info("Successfully synced cloud identity, envCrn = {}", pollerObject.getEnvironmentCrn());
return true;
case NOT_APPLICABLE:
LOGGER.info("Cloud identity sync not applicable, envCrn = {}", pollerObject.getEnvironmentCrn());
return true;
case FAILED:
LOGGER.error("Failed to sync cloud identity, envCrn = {}", pollerObject.getEnvironmentCrn());
throw new CloudbreakServiceException("Failed to sync cloud identity");
case ACTIVE:
LOGGER.info("Sync is still in progress");
return false;
default:
LOGGER.error("Encountered unknown cloud identity sync state");
throw new CloudbreakServiceException("Failed to sync cloud identity");
}
}
use of com.sequenceiq.sdx.api.model.RangerCloudIdentitySyncStatus in project cloudbreak by hortonworks.
the class RangerCloudIdentityService method toRangerCloudIdentitySyncStatus.
private RangerCloudIdentitySyncStatus toRangerCloudIdentitySyncStatus(ApiCommand apiCommand) {
RangerCloudIdentitySyncStatus status = new RangerCloudIdentitySyncStatus();
status.setCommandId(apiCommand.getId().longValue());
status.setStatusReason(apiCommand.getResultMessage());
status.setState(toRangerCloudIdentitySyncState(apiCommand));
return status;
}
use of com.sequenceiq.sdx.api.model.RangerCloudIdentitySyncStatus in project cloudbreak by hortonworks.
the class RangerCloudIdentityServiceTest method testSetAzureCloudIdentityMappingNoDatalake.
@Test
public void testSetAzureCloudIdentityMappingNoDatalake() throws ApiException {
when(sdxService.listSdxByEnvCrn(anyString())).thenReturn(Collections.emptyList());
Map<String, String> userMapping = Map.of("user", "val1");
RangerCloudIdentitySyncStatus status = underTest.setAzureCloudIdentityMapping("env-crn", userMapping);
assertEquals(RangerCloudIdentitySyncState.NOT_APPLICABLE, status.getState());
verify(clouderaManagerRangerUtil, never()).setAzureCloudIdentityMapping(eq("stack-crn"), eq(userMapping));
}
use of com.sequenceiq.sdx.api.model.RangerCloudIdentitySyncStatus in project cloudbreak by hortonworks.
the class RangerCloudIdentityServiceTest method testSetAzureCloudIdentityMappingDatalakNotRunning.
@Test
public void testSetAzureCloudIdentityMappingDatalakNotRunning() throws ApiException {
when(sdxService.listSdxByEnvCrn(anyString())).thenReturn(List.of(mock(SdxCluster.class)));
SdxStatusEntity sdxStatus = mockSdxStatus(DatalakeStatusEnum.PROVISIONING_FAILED);
when(sdxStatusService.getActualStatusForSdx(any())).thenReturn(sdxStatus);
Map<String, String> userMapping = Map.of("user", "val1");
RangerCloudIdentitySyncStatus status = underTest.setAzureCloudIdentityMapping("env-crn", userMapping);
assertEquals(RangerCloudIdentitySyncState.NOT_APPLICABLE, status.getState());
verify(clouderaManagerRangerUtil, never()).setAzureCloudIdentityMapping(eq("stack-crn"), eq(userMapping));
}
use of com.sequenceiq.sdx.api.model.RangerCloudIdentitySyncStatus in project cloudbreak by hortonworks.
the class RangerCloudIdentityServiceTest method testSetAzureCloudIdentityMapping.
private void testSetAzureCloudIdentityMapping(Optional<ApiCommand> apiCommand, RangerCloudIdentitySyncState expectedStatus) throws ApiException {
SdxCluster cluster = mock(SdxCluster.class);
when(cluster.getStackCrn()).thenReturn("stack-crn");
when(sdxService.listSdxByEnvCrn(anyString())).thenReturn(List.of(cluster));
when(clouderaManagerRangerUtil.isCloudIdMappingSupported(any())).thenReturn(true);
when(clouderaManagerRangerUtil.setAzureCloudIdentityMapping(any(), any())).thenReturn(apiCommand);
Map<String, String> userMapping = Map.of("user", "val1");
RangerCloudIdentitySyncStatus status = underTest.setAzureCloudIdentityMapping("env-crn", userMapping);
assertEquals(expectedStatus, status.getState());
verify(clouderaManagerRangerUtil, times(1)).setAzureCloudIdentityMapping(eq("stack-crn"), eq(userMapping));
}
Aggregations