use of com.sequenceiq.flow.api.model.operation.OperationResource in project cloudbreak by hortonworks.
the class OperationService method getOperationProgressByResourceCrn.
public OperationView getOperationProgressByResourceCrn(String resourceCrn, boolean detailed) {
OperationView stackOperationView = new OperationView();
try {
OperationResource operationResource = OperationResource.fromCrn(Crn.safeFromString(resourceCrn));
Optional<OperationFlowsView> operationFlowsViewOpt = flowService.getLastFlowOperationByResourceCrn(resourceCrn);
if (operationFlowsViewOpt.isPresent()) {
OperationFlowsView operationFlowsView = operationFlowsViewOpt.get();
OperationType operationType = operationFlowsView.getOperationType();
if (OperationType.PROVISION.equals(operationType)) {
stackOperationView = handleProvisionOperation(resourceCrn, operationResource, operationFlowsView, detailed);
} else {
stackOperationView = operationDetailsPopulator.createOperationView(operationFlowsView, operationResource);
}
}
} catch (Exception e) {
LOGGER.debug(String.format("Could not fetch remote database details for stack with crn %s", resourceCrn), e);
}
return stackOperationView;
}
use of com.sequenceiq.flow.api.model.operation.OperationResource in project cloudbreak by hortonworks.
the class OperationService method handleProvisionOperation.
private OperationView handleProvisionOperation(String resourceCrn, OperationResource operationResource, OperationFlowsView operationFlowsView, boolean detailed) {
OperationView stackOperationView;
stackOperationView = operationDetailsPopulator.createOperationView(operationFlowsView, operationResource, List.of(CloudConfigValidationFlowConfig.class, KerberosConfigValidationFlowConfig.class, ExternalDatabaseCreationFlowConfig.class, StackCreationFlowConfig.class, ClusterCreationFlowConfig.class));
if (detailed && !OperationResource.DATALAKE.equals(operationResource)) {
Stack stack = stackOperations.getStackByCrn(resourceCrn);
DatabaseAvailabilityType databaseAvailabilityType = stack.getExternalDatabaseCreationType();
Map<OperationResource, OperationCondition> conditionMap = new HashMap<>();
Map<OperationResource, OperationView> subOperations = new HashMap<>();
if (!DatabaseAvailabilityType.NONE.equals(databaseAvailabilityType)) {
conditionMap.put(OperationResource.REMOTEDB, OperationCondition.REQUIRED);
subOperations.put(OperationResource.REMOTEDB, databaseService.getRemoteDatabaseOperationProgress(stack, detailed).orElse(null));
} else {
conditionMap.put(OperationResource.REMOTEDB, OperationCondition.NONE);
}
stackOperationView.setSubOperationConditions(conditionMap);
stackOperationView.setSubOperations(subOperations);
}
return stackOperationView;
}
use of com.sequenceiq.flow.api.model.operation.OperationResource in project cloudbreak by hortonworks.
the class FlowOperationService method getOperationProgressByEnvironmentCrn.
public OperationView getOperationProgressByEnvironmentCrn(String environmentCrn, boolean detailed) {
OperationView operationView = new OperationView();
Optional<OperationFlowsView> operationFlowsViewOpt = flowService.getLastFlowOperationByResourceCrn(environmentCrn);
if (operationFlowsViewOpt.isPresent()) {
OperationFlowsView operationFlowsView = operationFlowsViewOpt.get();
OperationResource operationResource = OperationResource.FREEIPA;
com.sequenceiq.flow.api.model.operation.OperationType operationType = operationFlowsView.getOperationType();
if (com.sequenceiq.flow.api.model.operation.OperationType.PROVISION.equals(operationType)) {
operationView = operationDetailsPopulator.createOperationView(operationFlowsView, operationResource, List.of(StackProvisionFlowConfig.class, FreeIpaProvisionFlowConfig.class));
} else {
operationView = operationDetailsPopulator.createOperationView(operationFlowsView, operationResource);
}
}
return operationView;
}
use of com.sequenceiq.flow.api.model.operation.OperationResource in project cloudbreak by hortonworks.
the class OperationService method handleProvisionOperation.
private void handleProvisionOperation(String resourceCrn, OperationView sdxOperationView, boolean detailed) {
String userCrn = ThreadBasedUserCrnProvider.getUserCrn();
SdxCluster sdxCluster = sdxService.getByCrn(userCrn, resourceCrn);
boolean createDb = sdxCluster.isCreateDatabase();
Map<OperationResource, OperationView> subOperations = new HashMap<>();
Map<OperationResource, OperationCondition> conditionMap = new HashMap<>();
conditionMap.put(OperationResource.DATALAKE, OperationCondition.REQUIRED);
if (createDb) {
conditionMap.put(OperationResource.REMOTEDB, OperationCondition.REQUIRED);
try {
OperationView rdbOperationView = databaseService.getOperationProgressStatus(sdxCluster.getDatabaseCrn(), detailed);
if (OperationType.PROVISION.equals(rdbOperationView.getOperationType())) {
subOperations.put(OperationResource.REMOTEDB, rdbOperationView);
}
} catch (Exception e) {
LOGGER.warn("Error during fetching provision progress from remote database API. Skip filling remote database response.", e);
}
} else {
conditionMap.put(OperationResource.REMOTEDB, OperationCondition.NONE);
}
sdxOperationView.setSubOperationConditions(conditionMap);
try {
OperationView stackOperationProgressView = operationV4Endpoint.getOperationProgressByResourceCrn(resourceCrn, detailed);
if (OperationType.PROVISION.equals(stackOperationProgressView.getOperationType())) {
subOperations.put(OperationResource.DATALAKE, stackOperationProgressView);
}
} catch (Exception e) {
LOGGER.warn("Error during fetching provision progress from stack API. Skip filling stack progress response.", e);
}
sdxOperationView.setSubOperations(subOperations);
}
Aggregations