Search in sources :

Example 1 with MissingCSARDependenciesException

use of alien4cloud.exception.MissingCSARDependenciesException in project alien4cloud by alien4cloud.

the class LocationService method createLocation.

private void createLocation(Orchestrator orchestrator, Location location, String infrastructureType) {
    ensureNameUnicityAndSave(location);
    // TODO checks that the infrastructure type is valid
    location.setInfrastructureType(infrastructureType);
    // TODO add User and Group managed by the Orchestrator security
    Set<CSARDependency> dependencies = locationArchiveIndexer.indexLocationArchives(orchestrator, location);
    location.setDependencies(dependencies);
    // initialize meta properties
    location.setMetaProperties(Maps.<String, String>newHashMap());
    // add existing meta properties to the cloud
    GetMultipleDataResult<MetaPropConfiguration> result = alienDAO.find(MetaPropConfiguration.class, singleKeyFilter("target", MetaPropertyTarget.LOCATION), Integer.MAX_VALUE);
    for (MetaPropConfiguration element : result.getData()) {
        if (Objects.equals(element.getTarget(), MetaPropertyTarget.LOCATION)) {
            // we only support string values for meta properties
            PropertyUtil.setScalarDefaultValueOrNull(location.getMetaProperties(), element.getId(), element.getDefault());
            log.debug("Added meta property [ {} ] to the new location [ {} ] ", element.getName(), location.getName());
        }
    }
    // save the new location
    alienDAO.save(location);
    try {
        autoConfigure(orchestrator, location);
    } catch (UnsupportedOperationException e) {
    // do nothing
    }
    // We call the LocationRessourceService to check the dependencies
    try {
        locationResourceService.getLocationResourcesFromOrchestrator(location);
    } catch (NotFoundException e) {
        // WARN: FIXME we load orch twice !!!!!!!!!!!!!!!!!!!!!!!!!
        delete(orchestrator.getId(), location.getId());
        throw new MissingCSARDependenciesException(e.getMessage());
    }
}
Also used : MetaPropConfiguration(alien4cloud.model.common.MetaPropConfiguration) NotFoundException(alien4cloud.exception.NotFoundException) MissingCSARDependenciesException(alien4cloud.exception.MissingCSARDependenciesException) CSARDependency(org.alien4cloud.tosca.model.CSARDependency)

Aggregations

MissingCSARDependenciesException (alien4cloud.exception.MissingCSARDependenciesException)1 NotFoundException (alien4cloud.exception.NotFoundException)1 MetaPropConfiguration (alien4cloud.model.common.MetaPropConfiguration)1 CSARDependency (org.alien4cloud.tosca.model.CSARDependency)1