use of com.sequenceiq.freeipa.client.model.Host in project cloudbreak by hortonworks.
the class HostDelResponse method handleInternal.
@Override
protected Host handleInternal(List<CloudVmMetaDataStatus> metadatas, String body) {
Host host = new Host();
host.setFqdn("dummy");
return host;
}
use of com.sequenceiq.freeipa.client.model.Host in project cloudbreak by hortonworks.
the class HostFindResponse method handleInternal.
@Override
protected Set<Host> handleInternal(List<CloudVmMetaDataStatus> metadatas, String body) {
Host host = new Host();
host.setFqdn("dummy");
return Set.of(host);
}
use of com.sequenceiq.freeipa.client.model.Host in project cloudbreak by hortonworks.
the class KeytabCommonService method addHost.
public Host addHost(String hostname, RoleRequest roleRequest, FreeIpaClient ipaClient) throws FreeIpaClientException, KeytabCreationException {
try {
Host host = fetchOrCreateHost(hostname, ipaClient);
allowHostKeytabRetrieval(hostname, ipaClient);
roleComponent.addRoleAndPrivileges(Optional.empty(), Optional.of(host), roleRequest, ipaClient);
return host;
} catch (RetryableFreeIpaClientException e) {
LOGGER.error(HOST_CREATION_FAILED + " " + e.getLocalizedMessage(), e);
throw new RetryableFreeIpaClientException(HOST_CREATION_FAILED, e, new KeytabCreationException(HOST_CREATION_FAILED));
} catch (FreeIpaClientException e) {
LOGGER.error(HOST_CREATION_FAILED + " " + e.getLocalizedMessage(), e);
throw new KeytabCreationException(HOST_CREATION_FAILED);
}
}
use of com.sequenceiq.freeipa.client.model.Host in project cloudbreak by hortonworks.
the class HostKeytabService method generateHostKeytab.
public HostKeytabResponse generateHostKeytab(HostKeytabRequest request, String accountId) throws FreeIpaClientException {
LOGGER.debug("Request to generate host keytab: {}", request);
Stack freeIpaStack = keytabCommonService.getFreeIpaStackWithMdcContext(request.getEnvironmentCrn(), accountId);
FreeIpaClient ipaClient = freeIpaClientFactory.getFreeIpaClientForStack(freeIpaStack);
if (!roleComponent.privilegesExist(request.getRoleRequest(), ipaClient)) {
throw new BadRequestException(PRIVILEGE_DOES_NOT_EXIST);
} else {
Host host = keytabCommonService.addHost(request.getServerHostName(), request.getRoleRequest(), ipaClient);
KeytabCache hostKeytab = fetchKeytab(request, ipaClient, host);
return createHostKeytabResponse(hostKeytab);
}
}
use of com.sequenceiq.freeipa.client.model.Host in project cloudbreak by hortonworks.
the class HostDeletionServiceTest method successfulDeletionIfOneHostReturned.
@Test
public void successfulDeletionIfOneHostReturned() throws FreeIpaClientException {
Set<String> hosts = Set.of("host1", "host2");
Host host = new Host();
host.setFqdn("host1");
when(freeIpaClient.findAllHost()).thenReturn(Set.of(host));
Pair<Set<String>, Map<String, String>> result = underTest.removeHosts(freeIpaClient, hosts);
assertTrue(result.getSecond().isEmpty());
assertEquals(1, result.getFirst().size());
assertEquals(host.getFqdn(), result.getFirst().iterator().next());
verify(freeIpaClient).deleteHost(eq("host1"));
}
Aggregations