Search in sources :

Example 61 with FreeIpa

use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.

the class DnsRecordServiceTest method testCnameRecordExistsDifferentValue.

@Test
public void testCnameRecordExistsDifferentValue() throws FreeIpaClientException {
    AddDnsCnameRecordRequest request = new AddDnsCnameRecordRequest();
    request.setEnvironmentCrn(ENV_CRN);
    request.setCname("Asdf");
    request.setTargetFqdn(TARGET_FQDN);
    Stack stack = createStack();
    when(stackService.getByEnvironmentCrnAndAccountId(ENV_CRN, ACCOUNT_ID)).thenReturn(stack);
    FreeIpa freeIpa = createFreeIpa();
    when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
    when(freeIpaClientFactory.getFreeIpaClientForStack(stack)).thenReturn(freeIpaClient);
    DnsRecord dnsRecord = new DnsRecord();
    dnsRecord.setCnamerecord(List.of("asdf"));
    dnsRecord.setIdnsname(request.getCname());
    when(freeIpaClient.showDnsRecord(DOMAIN, request.getCname())).thenReturn(dnsRecord);
    Assertions.assertThrows(DnsRecordConflictException.class, () -> underTest.addDnsCnameRecord(ACCOUNT_ID, request));
}
Also used : FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) AddDnsCnameRecordRequest(com.sequenceiq.freeipa.api.v1.dns.model.AddDnsCnameRecordRequest) DnsRecord(com.sequenceiq.freeipa.client.model.DnsRecord) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 62 with FreeIpa

use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.

the class DnsRemoveHandler method accept.

@Override
public void accept(Event<RemoveDnsRequest> event) {
    RemoveDnsRequest request = event.getData();
    try {
        FreeIpa freeIpa = freeIpaService.findByStackId(request.getResourceId());
        Pair<Set<String>, Map<String, String>> removeDnsResult = cleanupService.removeDnsEntries(request.getResourceId(), request.getHosts(), request.getIps(), freeIpa.getDomain());
        RemoveDnsResponse response = new RemoveDnsResponse(request, removeDnsResult.getFirst(), removeDnsResult.getSecond());
        eventBus.notify(response.getDnsCleanupFailed().isEmpty() ? EventSelectorUtil.selector(RemoveDnsResponse.class) : EventSelectorUtil.failureSelector(RemoveDnsResponse.class), new Event<>(event.getHeaders(), response));
    } catch (Exception e) {
        LOGGER.error("Removing DNS entries failed for hosts: [{}]", request.getHosts(), e);
        Map<String, String> failureResult = request.getHosts().stream().collect(Collectors.toMap(h -> h, h -> e.getMessage()));
        RemoveDnsResponse response = new RemoveDnsResponse(request, Collections.emptySet(), failureResult);
        eventBus.notify(EventSelectorUtil.failureSelector(RemoveDnsResponse.class), new Event<>(event.getHeaders(), response));
    }
}
Also used : RemoveDnsResponse(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsResponse) Set(java.util.Set) FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) RemoveDnsRequest(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsRequest) Event(reactor.bus.Event) Map(java.util.Map)

Example 63 with FreeIpa

use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.

the class FreeIpaServerRequestToFreeIpaConverter method convert.

@Override
public FreeIpa convert(FreeIpaServerRequest source) {
    FreeIpa freeIpa = new FreeIpa();
    freeIpa.setAdminPassword(source.getAdminPassword());
    freeIpa.setDomain(source.getDomain());
    freeIpa.setHostname(source.getHostname());
    freeIpa.setAdminGroupName(source.getAdminGroupName());
    return freeIpa;
}
Also used : FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa)

Example 64 with FreeIpa

use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.

the class KeytabCleanupServiceTest method init.

@BeforeAll
public static void init() {
    freeIpa = new FreeIpa();
    freeIpa.setDomain(DOMAIN);
    stack = new Stack();
    host = new Host();
    host.setFqdn(HOST);
    host.setKrbprincipalname(HOST_PRINCIPAL);
    service = new Service();
    service.setKrbprincipalname(List.of(SERVICE_PRINCIPAL));
    service.setKrbcanonicalname(SERVICE_PRINCIPAL);
    keytab = new Keytab();
    keytab.setKeytab(KEYTAB);
}
Also used : FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) Keytab(com.sequenceiq.freeipa.client.model.Keytab) KeytabCacheService(com.sequenceiq.freeipa.kerberosmgmt.v1.KeytabCacheService) Service(com.sequenceiq.freeipa.client.model.Service) KeytabCleanupService(com.sequenceiq.freeipa.kerberosmgmt.v1.KeytabCleanupService) KeytabCommonService(com.sequenceiq.freeipa.kerberosmgmt.v1.KeytabCommonService) HostDeletionService(com.sequenceiq.freeipa.service.freeipa.host.HostDeletionService) Host(com.sequenceiq.freeipa.client.model.Host) Stack(com.sequenceiq.freeipa.entity.Stack) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 65 with FreeIpa

use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.

the class FreeIpaService method create.

public FreeIpa create(Stack stack, FreeIpaServerRequest request) {
    FreeIpa freeIpa = freeIpaConverter.convert(request);
    freeIpa.setStack(stack);
    return save(freeIpa);
}
Also used : FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa)

Aggregations

FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)75 Stack (com.sequenceiq.freeipa.entity.Stack)62 Test (org.junit.jupiter.api.Test)50 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)12 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)11 AddDnsARecordRequest (com.sequenceiq.freeipa.api.v1.dns.model.AddDnsARecordRequest)10 AddDnsCnameRecordRequest (com.sequenceiq.freeipa.api.v1.dns.model.AddDnsCnameRecordRequest)10 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)10 ImageEntity (com.sequenceiq.freeipa.entity.ImageEntity)10 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)8 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)7 JsonRpcClientException (com.googlecode.jsonrpc4j.JsonRpcClientException)6 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)6 DnsRecord (com.sequenceiq.freeipa.client.model.DnsRecord)6 Set (java.util.Set)6 ClusterServiceConfig (com.sequenceiq.cloudbreak.clusterproxy.ClusterServiceConfig)5 ConfigRegistrationRequest (com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationRequest)5 ConfigRegistrationResponse (com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationResponse)5 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)5 Optional (java.util.Optional)5