use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class FreeipaStructuredFlowEventFactory method createStructuredFlowEvent.
@Override
public CDPStructuredFlowEvent createStructuredFlowEvent(Long resourceId, FlowDetails flowDetails, Boolean detailed, Exception exception) {
Stack stack = stackService.getStackById(resourceId);
String resourceType = CloudbreakEventService.FREEIPA_RESOURCE_TYPE;
CDPOperationDetails operationDetails = new CDPOperationDetails(clock.getCurrentTimeMillis(), FLOW, resourceType, stack.getId(), stack.getName(), nodeConfig.getId(), serviceVersion, stack.getAccountId(), stack.getResourceCrn(), ThreadBasedUserCrnProvider.getUserCrn(), stack.getEnvironmentCrn(), null);
StackStatus stackStatus = stack.getStackStatus();
CDPStructuredFlowEvent event = new CDPStructuredFlowEvent(operationDetails, flowDetails, null, stackStatus.getDetailedStackStatus().name(), stackStatus.getStatusReason());
if (exception != null) {
event.setException(ExceptionUtils.getStackTrace(exception));
}
return event;
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class UserSyncServiceTest method testAsyncSynchronizeUsersUsesInternalCrn.
@Test
void testAsyncSynchronizeUsersUsesInternalCrn() {
Stack stack = mock(Stack.class);
when(stack.getEnvironmentCrn()).thenReturn(ENV_CRN);
when(stackService.getMultipleByEnvironmentCrnOrChildEnvironmantCrnAndAccountId(anySet(), anyString())).thenReturn(List.of(stack));
Operation operation = mock(Operation.class);
when(operation.getStatus()).thenReturn(OperationState.RUNNING);
when(operation.getOperationId()).thenReturn("operationId");
when(operationService.startOperation(anyString(), any(OperationType.class), anyCollection(), anyCollection())).thenReturn(operation);
UserSyncStatus userSyncStatus = mock(UserSyncStatus.class);
when(userSyncStatusService.getOrCreateForStack(any(Stack.class))).thenReturn(userSyncStatus);
when(userSyncStatusService.save(userSyncStatus)).thenReturn(userSyncStatus);
UserSyncService spyService = spy(underTest);
doAnswer(invocation -> {
assertEquals(INTERNAL_ACTOR_CRN, ThreadBasedUserCrnProvider.getUserCrn());
return null;
}).when(spyService).asyncSynchronizeUsers(anyString(), anyString(), anyList(), any(), any());
spyService.synchronizeUsers("accountId", "actorCrn", Set.of(), Set.of(), Set.of(), WorkloadCredentialsUpdateType.UPDATE_IF_CHANGED);
verify(spyService).asyncSynchronizeUsers(anyString(), anyString(), anyList(), any(), any());
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class CcmUserDataService method saveCcmV2Config.
private void saveCcmV2Config(Long stackId, CcmV2Parameters ccmV2Parameters) {
String ccmV2AgentCrn = ccmV2Parameters.getAgentCrn();
if (StringUtils.isNotBlank(ccmV2AgentCrn)) {
LOGGER.debug("Adding CcmV2AgentCrn '{}' to stack", ccmV2AgentCrn);
Stack stack = stackService.getStackById(stackId);
stack.setCcmV2AgentCrn(ccmV2AgentCrn);
stackService.save(stack);
LOGGER.debug("Added CcmV2AgentCrn '{}' to stack", ccmV2AgentCrn);
}
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class FreeIpaOrchestationConfigServiceTest method testGetSaltConfig.
@Test
public void testGetSaltConfig() throws Exception {
Stack stack = mock(Stack.class);
FreeIpaConfigView freeIpaConfigView = mock(FreeIpaConfigView.class);
Map freeIpaConfigViewMap = mock(Map.class);
when(freeIpaConfigService.createFreeIpaConfigs(any(), any())).thenReturn(freeIpaConfigView);
when(stack.getCloudPlatform()).thenReturn(CLOUD_PLATFORM);
when(freeIpaConfigView.toMap()).thenReturn(freeIpaConfigViewMap);
when(telemetryConfigService.createTelemetryPillarConfig(any())).thenReturn(Map.of());
when(proxyConfigService.createProxyPillarConfig(any())).thenReturn(Map.of());
when(tagConfigService.createTagsPillarConfig(any())).thenReturn(Map.of());
SaltConfig saltConfig = underTest.getSaltConfig(stack, Set.of());
Map<String, SaltPillarProperties> servicePillarConfig = saltConfig.getServicePillarConfig();
assertNotNull(servicePillarConfig);
SaltPillarProperties freeIpaProperties = servicePillarConfig.get("freeipa");
assertNotNull(freeIpaProperties);
assertEquals("/freeipa/init.sls", freeIpaProperties.getPath());
assertEquals(freeIpaConfigViewMap, freeIpaProperties.getProperties().get("freeipa"));
SaltPillarProperties discoveryProperties = servicePillarConfig.get("discovery");
assertNotNull(discoveryProperties);
assertEquals("/discovery/init.sls", discoveryProperties.getPath());
assertEquals(CLOUD_PLATFORM, discoveryProperties.getProperties().get("platform"));
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class CreateFreeIpaRequestToStackConverter method extendGatewaySecurityGroupWithDefaultGatewayCidrs.
private void extendGatewaySecurityGroupWithDefaultGatewayCidrs(Stack stack) {
Set<InstanceGroup> gateways = stack.getInstanceGroups().stream().filter(ig -> InstanceGroupType.MASTER == ig.getInstanceGroupType()).collect(Collectors.toSet());
Set<String> defaultGatewayCidrs = defaultGatewayCidr.stream().filter(StringUtils::isNotBlank).collect(Collectors.toSet());
if (!defaultGatewayCidrs.isEmpty() && !stack.getTunnel().useCcm()) {
for (InstanceGroup gateway : gateways) {
if (gateway.getSecurityGroup() != null && CollectionUtils.isEmpty(gateway.getSecurityGroup().getSecurityGroupIds())) {
Set<SecurityRule> rules = gateway.getSecurityGroup().getSecurityRules();
defaultGatewayCidrs.forEach(cloudbreakCidr -> rules.add(createSecurityRule(gateway.getSecurityGroup(), cloudbreakCidr, stack.getGatewayport().toString())));
LOGGER.info("The control plane cidrs {} are added to the {} gateway group for the {} port.", defaultGatewayCidrs, gateway.getGroupName(), stack.getGatewayport());
}
}
}
}
Aggregations