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));
}
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));
}
}
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;
}
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);
}
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);
}
Aggregations