Search in sources :

Example 1 with FAILED

use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.

the class FreeIpaOperationCheckerTask method checkStatus.

@Override
public boolean checkStatus(T operationPollerObject) {
    OperationStatus operationStatus = ThreadBasedUserCrnProvider.doAsInternalActor(operationPollerObject.getRegionalAwareInternalCrnGeneratorFactory().iam().getInternalCrnForServiceAsString(), () -> operationPollerObject.getOperationV1Endpoint().getOperationStatus(operationPollerObject.getOperationId(), operationPollerObject.getAccountId()));
    LOGGER.debug("OperationStatus for operationId[{}]: {}", operationPollerObject.getOperationId(), operationStatus);
    if (OperationState.COMPLETED.equals(operationStatus.getStatus())) {
        return true;
    } else if (OperationState.RUNNING.equals(operationStatus.getStatus())) {
        return false;
    } else {
        String failureDetails = extractFailureDetails(operationStatus);
        throw new FreeIpaOperationFailedException(String.format("FreeIPA [%s] operation [%s] failed with state [%s] and error message [%s]. " + "Failure details: [%s]", operationStatus.getOperationType(), operationPollerObject.getOperationId(), operationStatus.getStatus(), operationStatus.getError(), failureDetails));
    }
}
Also used : OperationStatus(com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus)

Example 2 with FAILED

use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.

the class FreeIpaUpgradeTests method generateServiceKeytab.

private void generateServiceKeytab(com.sequenceiq.freeipa.api.client.FreeIpaClient ipaClient, String environmentCrn) {
    try {
        ServiceKeytabRequest serviceKeytabRequest = new ServiceKeytabRequest();
        serviceKeytabRequest.setEnvironmentCrn(environmentCrn);
        serviceKeytabRequest.setServiceName("test");
        serviceKeytabRequest.setServerHostName("test.local");
        serviceKeytabRequest.setDoNotRecreateKeytab(Boolean.FALSE);
        ipaClient.getKerberosMgmtV1Endpoint().generateServiceKeytab(serviceKeytabRequest, null);
    } catch (Exception e) {
        logger.error("Generate Service keytab test failed during upgrade", e);
        throw new TestFailException("Generate Service keytab test failed during upgrade with: " + e.getMessage(), e);
    }
}
Also used : ServiceKeytabRequest(com.sequenceiq.freeipa.api.v1.kerberosmgmt.model.ServiceKeytabRequest) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) WebApplicationException(javax.ws.rs.WebApplicationException) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException)

Example 3 with FAILED

use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.

the class FreeIpaUpgradeTests method syncUsers.

private void syncUsers(TestContext testContext, com.sequenceiq.freeipa.api.client.FreeIpaClient ipaClient, String environmentCrn, String accountId) {
    try {
        SyncOperationStatus lastSyncOperationStatus = ipaClient.getUserV1Endpoint().getLastSyncOperationStatus(environmentCrn);
        if (lastSyncOperationStatus.getStatus() == SynchronizationStatus.RUNNING) {
            waitToCompleted(testContext, lastSyncOperationStatus.getOperationId(), "Initial or periodic usersync");
        }
        SynchronizeAllUsersRequest request = new SynchronizeAllUsersRequest();
        request.setAccountId(accountId);
        request.setEnvironments(Set.of(environmentCrn));
        request.setWorkloadCredentialsUpdateType(WorkloadCredentialsUpdateType.FORCE_UPDATE);
        try {
            SyncOperationStatus syncOperationStatus = ipaClient.getUserV1Endpoint().synchronizeAllUsers(request);
            waitToCompleted(testContext, syncOperationStatus.getOperationId(), "Full forced usersync");
        } catch (WebApplicationException e) {
            if (e.getResponse() != null && Response.Status.CONFLICT.getStatusCode() == e.getResponse().getStatus()) {
                logger.info("Usersync is already running");
            } else {
                throw e;
            }
        }
    } catch (Exception e) {
        logger.error("Full forced usersync test failed during upgrade", e);
        throw new TestFailException("Full forced usersync test failed during upgrade with: " + e.getMessage(), e);
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) SyncOperationStatus(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) SynchronizeAllUsersRequest(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizeAllUsersRequest) WebApplicationException(javax.ws.rs.WebApplicationException) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException)

Example 4 with FAILED

use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.

the class FreeIpaUpgradeTests method addAndDeleteDnsARecord.

private void addAndDeleteDnsARecord(com.sequenceiq.freeipa.api.client.FreeIpaClient ipaClient, String environmentCrn) {
    try {
        AddDnsARecordRequest aRecordRequest = new AddDnsARecordRequest();
        aRecordRequest.setHostname("test-a-record");
        aRecordRequest.setCreateReverse(true);
        aRecordRequest.setEnvironmentCrn(environmentCrn);
        aRecordRequest.setIp("1.2.3.4");
        ipaClient.getDnsV1Endpoint().addDnsARecord(aRecordRequest);
        ipaClient.getDnsV1Endpoint().deleteDnsARecord(environmentCrn, null, aRecordRequest.getHostname());
    } catch (Exception e) {
        logger.error("DNS A record test failed during upgrade", e);
        throw new TestFailException("DNS A record test failed during upgrade with: " + e.getMessage(), e);
    }
}
Also used : AddDnsARecordRequest(com.sequenceiq.freeipa.api.v1.dns.model.AddDnsARecordRequest) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) WebApplicationException(javax.ws.rs.WebApplicationException) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException)

Example 5 with FAILED

use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizationStatus.FAILED in project cloudbreak by hortonworks.

the class FreeIpaUpgradeTests method generateHostKeyTab.

private void generateHostKeyTab(com.sequenceiq.freeipa.api.client.FreeIpaClient ipaClient, String environmentCrn) {
    try {
        HostKeytabRequest hostKeytabRequest = new HostKeytabRequest();
        hostKeytabRequest.setEnvironmentCrn(environmentCrn);
        hostKeytabRequest.setServerHostName("test.local");
        hostKeytabRequest.setDoNotRecreateKeytab(Boolean.FALSE);
        ipaClient.getKerberosMgmtV1Endpoint().generateHostKeytab(hostKeytabRequest);
    } catch (Exception e) {
        logger.error("Generate Host keytab test failed during upgrade", e);
        throw new TestFailException("Generate Host keytab test failed during upgrade with: " + e.getMessage(), e);
    }
}
Also used : HostKeytabRequest(com.sequenceiq.freeipa.api.v1.kerberosmgmt.model.HostKeytabRequest) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) WebApplicationException(javax.ws.rs.WebApplicationException) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException)

Aggregations

Stack (com.sequenceiq.freeipa.entity.Stack)12 WebApplicationException (javax.ws.rs.WebApplicationException)11 FailureDetails (com.sequenceiq.freeipa.api.v1.freeipa.user.model.FailureDetails)9 SuccessDetails (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SuccessDetails)9 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)9 ArrayList (java.util.ArrayList)8 List (java.util.List)8 Map (java.util.Map)7 OperationService (com.sequenceiq.freeipa.service.operation.OperationService)6 Bean (org.springframework.context.annotation.Bean)6 OperationStatus (com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus)5 FreeIpaOperationFailedException (com.sequenceiq.environment.exception.FreeIpaOperationFailedException)4 FlowParameters (com.sequenceiq.flow.core.FlowParameters)4 SyncOperationStatus (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus)4 StateContext (org.springframework.statemachine.StateContext)4 Flow (com.sequenceiq.flow.core.Flow)3 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)3 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)3 Test (org.junit.jupiter.api.Test)3 ImageV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageV4Response)2