Search in sources :

Example 1 with Host

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;
}
Also used : Host(com.sequenceiq.freeipa.client.model.Host)

Example 2 with 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);
}
Also used : Host(com.sequenceiq.freeipa.client.model.Host)

Example 3 with 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);
    }
}
Also used : RetryableFreeIpaClientException(com.sequenceiq.freeipa.client.RetryableFreeIpaClientException) KeytabCreationException(com.sequenceiq.freeipa.kerberosmgmt.exception.KeytabCreationException) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException) RetryableFreeIpaClientException(com.sequenceiq.freeipa.client.RetryableFreeIpaClientException) Host(com.sequenceiq.freeipa.client.model.Host)

Example 4 with Host

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);
    }
}
Also used : KeytabCache(com.sequenceiq.freeipa.entity.KeytabCache) FreeIpaClient(com.sequenceiq.freeipa.client.FreeIpaClient) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Host(com.sequenceiq.freeipa.client.model.Host) Stack(com.sequenceiq.freeipa.entity.Stack)

Example 5 with Host

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"));
}
Also used : Set(java.util.Set) Host(com.sequenceiq.freeipa.client.model.Host) Map(java.util.Map) Test(org.junit.Test)

Aggregations

Host (com.sequenceiq.freeipa.client.model.Host)25 RoleRequest (com.sequenceiq.freeipa.api.v1.kerberosmgmt.model.RoleRequest)13 Test (org.junit.jupiter.api.Test)13 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)12 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)10 JsonRpcClientException (com.googlecode.jsonrpc4j.JsonRpcClientException)6 Stack (com.sequenceiq.freeipa.entity.Stack)6 RetryableFreeIpaClientException (com.sequenceiq.freeipa.client.RetryableFreeIpaClientException)5 Role (com.sequenceiq.freeipa.client.model.Role)5 KeytabCache (com.sequenceiq.freeipa.entity.KeytabCache)5 Set (java.util.Set)5 Test (org.junit.Test)5 Secret (com.sequenceiq.cloudbreak.service.secret.domain.Secret)4 SecretResponse (com.sequenceiq.cloudbreak.service.secret.model.SecretResponse)4 HostKeytabRequest (com.sequenceiq.freeipa.api.v1.kerberosmgmt.model.HostKeytabRequest)4 HostKeytabResponse (com.sequenceiq.freeipa.api.v1.kerberosmgmt.model.HostKeytabResponse)4 Privilege (com.sequenceiq.freeipa.client.model.Privilege)4 HashSet (java.util.HashSet)4 Map (java.util.Map)4 Optional (java.util.Optional)4