use of com.sequenceiq.environment.exception.FreeIpaOperationFailedException in project cloudbreak by hortonworks.
the class FreeIpaCreationRetrievalTask method checkStatus.
@Override
public boolean checkStatus(FreeIpaPollerObject freeIpaPollerObject) {
String environmentCrn = freeIpaPollerObject.getEnvironmentCrn();
try {
LOGGER.info("Checking the state of FreeIpa creation progress for environment: '{}'", environmentCrn);
Optional<DescribeFreeIpaResponse> freeIpaOptional = freeIpaService.describe(environmentCrn);
if (freeIpaOptional.isEmpty()) {
throw new FreeIpaOperationFailedException("FreeIpa cluster not found for environment: " + environmentCrn);
}
DescribeFreeIpaResponse freeIpa = freeIpaOptional.get();
if (freeIpa.getStatus().isDeletionInProgress() || freeIpa.getStatus().isSuccessfullyDeleted()) {
LOGGER.error("FreeIpa '{}' '{}' is getting terminated (status:'{}'), polling is cancelled.", freeIpa.getName(), freeIpa.getCrn(), freeIpa.getStatus());
throw new FreeIpaOperationFailedException("FreeIpa instance deleted under the creation process.");
}
if (freeIpa.getStatus().isFailed()) {
LOGGER.error("FreeIpa '{}' '{}' is in failed state (status:'{}'), polling is cancelled.", freeIpa.getName(), freeIpa.getCrn(), freeIpa.getStatus());
throw new FreeIpaOperationFailedException(String.format("Reason: '%s'", freeIpa.getStatusReason()));
}
if (freeIpa.getAvailabilityStatus() != null && freeIpa.getAvailabilityStatus().isAvailable()) {
return true;
}
} catch (Exception e) {
throw new FreeIpaOperationFailedException("FreeIpa creation operation failed. " + e.getMessage(), e);
}
return false;
}
use of com.sequenceiq.environment.exception.FreeIpaOperationFailedException in project cloudbreak by hortonworks.
the class FreeIpaDeletionHandler method detachChildEnvironmentFromFreeIpa.
private void detachChildEnvironmentFromFreeIpa(Environment environment) {
try {
DetachChildEnvironmentRequest detachChildEnvironmentRequest = new DetachChildEnvironmentRequest();
detachChildEnvironmentRequest.setParentEnvironmentCrn(environment.getParentEnvironment().getResourceCrn());
detachChildEnvironmentRequest.setChildEnvironmentCrn(environment.getResourceCrn());
freeIpaService.detachChildEnvironment(detachChildEnvironmentRequest);
if (lastChildEnvironmentInNetworkIsGettingDeleted(environment)) {
try {
dnsV1Endpoint.deleteDnsZoneBySubnet(environment.getParentEnvironment().getResourceCrn(), environment.getNetwork().getNetworkCidr());
} catch (Exception e) {
LOGGER.warn("Failed to delete dns zone of child environment.", e);
}
}
} catch (FreeIpaOperationFailedException e) {
if (e.getCause() instanceof NotFoundException) {
LOGGER.warn("Child FreeIpa is already detached.", e);
} else {
throw e;
}
}
}
use of com.sequenceiq.environment.exception.FreeIpaOperationFailedException in project cloudbreak by hortonworks.
the class FreeIpaDeletionRetrievalTask method handleTimeout.
@Override
public void handleTimeout(FreeIpaPollerObject freeIpaPollerObject) {
try {
String envCrn = freeIpaPollerObject.getEnvironmentCrn();
Optional<DescribeFreeIpaResponse> freeIpa = freeIpaService.describe(envCrn);
if (freeIpa.isEmpty()) {
throw new FreeIpaOperationFailedException("FreeIpa was not found for environment: " + envCrn);
}
throw new FreeIpaOperationFailedException(String.format("Polling operation timed out, FreeIpa deletion failed. FreeIpa status: '%s' " + "statusReason: '%s'", freeIpa.get().getStatus(), freeIpa.get().getStatusReason()));
} catch (Exception e) {
throw new FreeIpaOperationFailedException("Polling operation timed out, FreeIpa deletion failed. Also failed to get FreeIpa status: " + e.getMessage(), e);
}
}
use of com.sequenceiq.environment.exception.FreeIpaOperationFailedException in project cloudbreak by hortonworks.
the class FreeIpaService method startFreeIpa.
void startFreeIpa(String environmentCrn) {
try {
LOGGER.info("Starting freeipa");
freeIpaV1Endpoint.start(environmentCrn);
} catch (WebApplicationException e) {
String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e);
LOGGER.error(String.format("Failed to start FreeIpa cluster for environment '%s' due to: '%s'", environmentCrn, errorMessage), e);
throw new FreeIpaOperationFailedException(errorMessage, e);
}
}
use of com.sequenceiq.environment.exception.FreeIpaOperationFailedException in project cloudbreak by hortonworks.
the class FreeIpaService method stopFreeIpa.
void stopFreeIpa(String environmentCrn) {
try {
LOGGER.info("Stopping freeipa");
freeIpaV1Endpoint.stop(environmentCrn);
} catch (WebApplicationException e) {
String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e);
LOGGER.error(String.format("Failed to stop FreeIpa cluster for environment '%s' due to: '%s'", environmentCrn, errorMessage), e);
throw new FreeIpaOperationFailedException(errorMessage, e);
}
}
Aggregations