Search in sources :

Example 1 with ServiceTypes

use of org.opentosca.toscana.plugins.cloudfoundry.application.ServiceTypes in project TOSCAna by StuPro-TOSCAna.

the class ServiceHandler method readProviderServices.

/**
 *     reads the offered services from the provider
 *     tries to find a suitable service for the needed purpose.
 *     always add a service with a free plan
 */
private List<String> readProviderServices(List<String> alreadyHandledServices) throws IOException {
    if (application.getProvider() != null && !application.getServices().isEmpty() && application.getConnection() != null) {
        Provider provider = application.getProvider();
        logger.debug("Read service offerings from provider");
        provider.setOfferedService(application.getConnection().getServices());
        for (Map.Entry<String, ServiceTypes> service : application.getServices().entrySet()) {
            if (!alreadyHandledServices.contains(service.getKey())) {
                alreadyHandledServices.add(service.getKey());
                matchingServices(service, provider, true);
            } else {
                matchingServices(service, provider, false);
            }
        }
    } else {
        for (Map.Entry<String, ServiceTypes> service : application.getServices().entrySet()) {
            if (!alreadyHandledServices.contains(service.getKey())) {
                alreadyHandledServices.add(service.getKey());
                logger.error("Could not find a suitable service, add the default value {}. Please adapt the line in the deploy script!", CLI_CREATE_SERVICE_DEFAULT);
                deploymentScript.append(CLI_CREATE_SERVICE_DEFAULT + service.getKey());
            }
        }
    }
    return alreadyHandledServices;
}
Also used : ServiceTypes(org.opentosca.toscana.plugins.cloudfoundry.application.ServiceTypes) Map(java.util.Map) Provider(org.opentosca.toscana.plugins.cloudfoundry.application.Provider)

Aggregations

Map (java.util.Map)1 Provider (org.opentosca.toscana.plugins.cloudfoundry.application.Provider)1 ServiceTypes (org.opentosca.toscana.plugins.cloudfoundry.application.ServiceTypes)1