use of org.cloudfoundry.operations.services.ServiceOffering in project TOSCAna by StuPro-TOSCAna.
the class ServiceHandler method addProviderServiceOfferings.
/**
* adds all offered services from the provider to an extra file
*/
private void addProviderServiceOfferings() throws IOException {
Provider provider = application.getProvider();
List<ServiceOffering> services = provider.getOfferedService();
BufferedLineWriter lineWriter = fileAccess.access(SERVICE_FILE_PATH);
logger.info("List all services from the provider to the file '{}'", SERVICE_FILE_PATH);
lineWriter.appendln("Following services you could choose:");
lineWriter.appendln(String.format("%-20s %-40s %-50s\n", "Name", " Plans", "Description"));
for (ServiceOffering service : services) {
String plans = "";
for (ServicePlan plan : service.getServicePlans()) {
String currentPlan;
if (plan.getFree()) {
currentPlan = plan.getName();
} else {
currentPlan = plan.getName() + "*";
}
plans = String.format("%s %s ", plans, currentPlan);
}
logger.debug("Add '{}' to the service list in file '{}'", service.getLabel(), SERVICE_FILE_PATH);
lineWriter.appendln(String.format("%-20s %-40s %-50s ", service.getLabel(), plans, service.getDescription()));
}
lineWriter.appendln("\n* These service plans have an associated cost. Creating a service instance will incur this cost.\n");
lineWriter.close();
}
use of org.cloudfoundry.operations.services.ServiceOffering in project TOSCAna by StuPro-TOSCAna.
the class ServiceHandler method addMatchedServices.
/**
* checks if a service of a provider matches the needed service
*/
private boolean addMatchedServices(List<ServiceOffering> services, BashScript deployScript, String description, Map.Entry<String, ServiceTypes> service, boolean insertCreateCommand) throws IOException {
boolean isSet = false;
for (ServiceOffering offeredService : services) {
if (offeredService.getDescription().toLowerCase().contains(description.toLowerCase())) {
for (ServicePlan plan : offeredService.getServicePlans()) {
if (plan.getFree()) {
String serviceName = offeredService.getLabel();
String planName = plan.getName();
String serviceInstanceName = service.getKey();
if (insertCreateCommand) {
logger.info("A suitable service could be found, named {}. Add a free plan named {}, you could adpat the plan in the deploy script", serviceName, planName);
deployScript.append(String.format("%s%s %s %s", CLI_CREATE_SERVICE, serviceName, planName, serviceInstanceName));
}
application.addMatchedService(new Service(serviceName, serviceInstanceName, planName, service.getValue()));
isSet = true;
break;
}
}
if (isSet) {
break;
}
}
}
return isSet;
}
use of org.cloudfoundry.operations.services.ServiceOffering in project TOSCAna by StuPro-TOSCAna.
the class Connection method getServices.
/**
* @return a list with all service offerings of the provider
*/
public List<ServiceOffering> getServices() {
ListServiceOfferingsRequest serviceOfferingsRequest = ListServiceOfferingsRequest.builder().build();
List<ServiceOffering> listServiceOfferings = cloudFoundryOperations.services().listServiceOfferings(serviceOfferingsRequest).collectList().block();
return listServiceOfferings;
}
Aggregations