try {
LOGGER.info("Starting Ambari cluster installation [Ambari server address: {}]", stack.getAmbariIp());
stackUpdater.updateStackStatus(stack.getId(), Status.UPDATE_IN_PROGRESS);
cluster.setCreationStarted(new Date().getTime());
cluster = clusterRepository.save(cluster);
Blueprint blueprint = cluster.getBlueprint();
AmbariClient ambariClient = createAmbariClient(stack.getAmbariIp());
addBlueprint(stack, ambariClient, blueprint);
Map<String, List<String>> hostGroupMappings = recommend(stack, ambariClient, blueprint.getBlueprintName());
saveHostMetadata(cluster, hostGroupMappings);
ambariClient.createCluster(cluster.getName(), blueprint.getBlueprintName(), hostGroupMappings);
waitForClusterInstall(stack, ambariClient);
clusterCreateSuccess(cluster, new Date().getTime(), stack.getAmbariIp());
} catch (AmbariHostsUnavailableException | AmbariOperationFailedException | InvalidHostGroupHostAssociation e) {
LOGGER.error(e.getMessage(), e);
clusterCreateFailed(cluster, e.getMessage());