use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class ProviderChecker method updateAndGetStatuses.
public List<ProviderSyncResult> updateAndGetStatuses(Stack stack, Set<InstanceMetaData> checkableInstances, Map<InstanceMetaData, DetailedStackStatus> instanceHealthStatusMap, boolean updateStatusFromFlow) {
return checkedMeasure(() -> {
List<ProviderSyncResult> results = new ArrayList<>();
List<CloudVmInstanceStatus> statuses = stackInstanceProviderChecker.checkStatus(stack, checkableInstances);
if (!updateStatusFromFlow && flowLogService.isOtherFlowRunning(stack.getId())) {
throw new InterruptSyncingException(":::Auto sync::: interrupt syncing in updateAndGetStatuses, flow is running on freeipa stack " + stack.getName());
} else {
statuses.forEach(s -> {
Optional<InstanceMetaData> instanceMetaData = checkableInstances.stream().filter(i -> s.getCloudInstance().getInstanceId().equals(i.getInstanceId())).findFirst();
if (instanceMetaData.isPresent()) {
InstanceStatus instanceStatus = updateStatuses(s, instanceMetaData.get(), instanceHealthStatusMap);
if (instanceStatus != null) {
results.add(new ProviderSyncResult("", instanceStatus, false, s.getCloudInstance().getInstanceId()));
}
} else {
LOGGER.info(":::Auto sync::: Cannot find instanceMetaData");
}
});
checkableInstances.forEach(instanceMetaData -> {
if (statuses.stream().noneMatch(s -> s.getCloudInstance().getInstanceId().equals(instanceMetaData.getInstanceId()))) {
if (updateStatus) {
setStatusIfNotTheSame(instanceMetaData, InstanceStatus.DELETED_ON_PROVIDER_SIDE);
instanceMetaDataService.save(instanceMetaData);
} else {
LOGGER.debug("updateStatus flag is false, don't update status");
}
}
});
return results;
}
}, LOGGER, ":::Auto sync::: provider is checked in {}ms");
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class ProviderChecker method updateStatuses.
private InstanceStatus updateStatuses(CloudVmInstanceStatus vmInstanceStatus, InstanceMetaData instanceMetaData, Map<InstanceMetaData, DetailedStackStatus> instanceHealthStatusMap) {
LOGGER.info(":::Auto sync::: {} instance metadata status update in progress, new status: {}", instanceMetaData.getShortHostname(), vmInstanceStatus);
InstanceStatus status = null;
switch(vmInstanceStatus.getStatus()) {
case STARTED:
if (DetailedStackStatus.UNREACHABLE == instanceHealthStatusMap.get(instanceMetaData)) {
setStatusIfNotTheSame(instanceMetaData, InstanceStatus.UNREACHABLE);
status = InstanceStatus.UNREACHABLE;
} else if (DetailedStackStatus.UNHEALTHY == instanceHealthStatusMap.get(instanceMetaData)) {
setStatusIfNotTheSame(instanceMetaData, InstanceStatus.UNHEALTHY);
status = InstanceStatus.UNHEALTHY;
} else {
setStatusIfNotTheSame(instanceMetaData, InstanceStatus.CREATED);
status = InstanceStatus.CREATED;
}
break;
case STOPPED:
setStatusIfNotTheSame(instanceMetaData, InstanceStatus.STOPPED);
status = InstanceStatus.STOPPED;
break;
case FAILED:
setStatusIfNotTheSame(instanceMetaData, InstanceStatus.FAILED);
status = InstanceStatus.FAILED;
break;
case TERMINATED:
setStatusIfNotTheSame(instanceMetaData, InstanceStatus.DELETED_ON_PROVIDER_SIDE);
status = InstanceStatus.DELETED_ON_PROVIDER_SIDE;
break;
case TERMINATED_BY_PROVIDER:
setStatusIfNotTheSame(instanceMetaData, InstanceStatus.DELETED_BY_PROVIDER);
status = InstanceStatus.DELETED_BY_PROVIDER;
break;
default:
LOGGER.info(":::Auto sync::: the '{}' status is not converted", vmInstanceStatus.getStatus());
}
if (updateStatus) {
instanceMetaDataService.save(instanceMetaData);
} else {
LOGGER.debug("updateStatus flag is false, don't update status");
}
return status;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class DistroXServiceTest method testWithValidEnvironmentNameValueButTheActualEnvIsNotAvailableBadRequestExceptionShouldCome.
@ParameterizedTest
@EnumSource(value = com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus.class)
@DisplayName("When request contains a valid environment name but that environment is not in the AVAILABLE state then BadRequestException should come")
void testWithValidEnvironmentNameValueButTheActualEnvIsNotAvailableBadRequestExceptionShouldCome(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus detailedStackStatus) {
if (!detailedStackStatus.getAvailabilityStatus().isAvailable()) {
String envName = "someAwesomeExistingButNotAvailableEnvironment";
DistroXV1Request r = new DistroXV1Request();
r.setEnvironmentName(envName);
DetailedEnvironmentResponse envResponse = new DetailedEnvironmentResponse();
envResponse.setCrn("crn");
envResponse.setName(envName);
DescribeFreeIpaResponse freeipa = new DescribeFreeIpaResponse();
freeipa.setAvailabilityStatus(detailedStackStatus.getAvailabilityStatus());
freeipa.setStatus(detailedStackStatus.getStatus());
when(freeipaClientService.getByEnvironmentCrn("crn")).thenReturn(freeipa);
when(environmentClientService.getByName(envName)).thenReturn(envResponse);
BadRequestException err = assertThrows(BadRequestException.class, () -> underTest.post(r));
assertEquals(String.format("If you want to provision a Data Hub then the FreeIPA instance must be running in the '%s' Environment.", envName), err.getMessage());
verify(environmentClientService, calledOnce()).getByName(any());
verify(environmentClientService, calledOnce()).getByName(eq(envName));
verify(stackOperations, never()).post(any(), any(), any(), anyBoolean());
verify(workspaceService, never()).getForCurrentUser();
verify(stackRequestConverter, never()).convert(any(DistroXV1Request.class));
}
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class UpgradeCcmService method checkPrerequisitesState.
public void checkPrerequisitesState(Long stackId) {
DetailedStackStatus detailedStatus = UPGRADE_CCM_IN_PROGRESS;
String statusReason = "Checking prerequisites";
stackUpdater.updateStackStatus(stackId, detailedStatus, statusReason);
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class UpgradeCcmService method registerClusterProxyState.
public void registerClusterProxyState(Long stackId) {
DetailedStackStatus detailedStatus = UPGRADE_CCM_IN_PROGRESS;
String statusReason = "Registering into Cluster Proxy";
stackUpdater.updateStackStatus(stackId, detailedStatus, statusReason);
}
Aggregations