use of org.opentosca.container.core.model.csar.Csar in project container by OpenTOSCA.
the class OpenToscaControlServiceImpl method generatePlans.
@Override
public boolean generatePlans(CsarId csarId, ServiceTemplateId serviceTemplate) {
Csar csar = storage.findById(csarId);
final TServiceTemplate entryServiceTemplate = csar.entryServiceTemplate();
if (entryServiceTemplate == null) {
LOGGER.error("No EntryServiceTemplate defined for CSAR [{}]. Aborting plan generation", csarId);
return false;
}
deploymentTracker.storeDeploymentState(csarId, PLAN_DEPLOYMENT_ACTIVE);
List<TPlan> plans = entryServiceTemplate.getPlans();
if (plans == null) {
LOGGER.info("No Plans to process");
return true;
}
String namespace = serviceTemplate.getQName().getNamespaceURI();
List<TPlan> unDeployed = new ArrayList<>();
for (final TPlan plan : plans) {
if (!planEngine.deployPlan(plan, namespace, csarId)) {
unDeployed.add(plan);
}
}
if (!unDeployed.isEmpty()) {
LOGGER.error("Plan deployment failed");
deploymentTracker.storeDeploymentState(csarId, TOSCA_PROCESSED);
return false;
}
LOGGER.info("Successfully deployeed management plans of [{}] in CSAR [{}]", serviceTemplate, csarId);
deploymentTracker.storeDeploymentState(csarId, PLANS_DEPLOYED);
// endpointService.printPlanEndpoints();
return true;
}
use of org.opentosca.container.core.model.csar.Csar in project container by OpenTOSCA.
the class PlanService method getPlanInstances.
public List<PlanInstance> getPlanInstances(final Csar csar, final PlanType... planTypes) {
final ServiceTemplateInstanceRepository repo = new ServiceTemplateInstanceRepository();
final Collection<ServiceTemplateInstance> serviceInstances = repo.findByCsarId(csar.id());
return serviceInstances.stream().flatMap(sti -> sti.getPlanInstances().stream()).filter(p -> {
final PlanType currentType = PlanType.fromString(p.getType().toString());
return Arrays.stream(planTypes).anyMatch(pt -> pt.equals(currentType));
}).collect(Collectors.toList());
}
use of org.opentosca.container.core.model.csar.Csar in project container by OpenTOSCA.
the class RelationshipTemplateService method getRelationshipTemplatesOfServiceTemplate.
/**
* Gets a collection of relationship templates associated to a given service template.
*
* @param csarId The id of the CSAR
* @param serviceTemplateQName The QName of the service template within the given CSAR
* @return A collection of relationship templates stored within the given service template.
*/
public List<RelationshipTemplateDTO> getRelationshipTemplatesOfServiceTemplate(final String csarId, final String serviceTemplateQName) {
final Csar csar = storage.findById(new CsarId(csarId));
List<TRelationshipTemplate> relationshipTemplates = csar.serviceTemplates().stream().filter(st -> st.getName().equals(serviceTemplateQName)).findFirst().get().getTopologyTemplate().getRelationshipTemplates();
return relationshipTemplates.stream().map(RelationshipTemplateDTO::fromToscaObject).collect(Collectors.toList());
}
use of org.opentosca.container.core.model.csar.Csar in project container by OpenTOSCA.
the class CamundaPlanEnginePlugin method planLocationOnDisk.
@Nullable
private Path planLocationOnDisk(CsarId csarId, QName planId, PlanModelReference planRef) {
if (storage == null) {
return null;
}
Csar csar = storage.findById(csarId);
IRepository repository = RepositoryFactory.getRepository(csar.getSaveLocation());
PlanId plan = new PlanId(new PlansId(new ServiceTemplateId(csar.entryServiceTemplate().getTargetNamespace(), csar.entryServiceTemplate().getId(), false)), new XmlId(planId.toString(), false));
Collection<RepositoryFileReference> fileRefs = repository.getContainedFiles(plan);
Path planPath = null;
for (RepositoryFileReference ref : fileRefs) {
if (ref.getFileName().endsWith(".war")) {
planPath = repository.ref2AbsolutePath(ref);
break;
}
if (ref.getFileName().endsWith(".zip")) {
planPath = repository.ref2AbsolutePath(ref);
break;
}
}
return planPath;
}
use of org.opentosca.container.core.model.csar.Csar in project container by OpenTOSCA.
the class BpelPlanEnginePlugin method planLocationOnDisk.
@Nullable
private Path planLocationOnDisk(CsarId csarId, QName planId, PlanModelReference planRef) {
if (storage == null) {
return null;
}
Csar csar = storage.findById(csarId);
IRepository repository = RepositoryFactory.getRepository(csar.getSaveLocation());
PlanId plan = new PlanId(new PlansId(new ServiceTemplateId(csar.entryServiceTemplate().getTargetNamespace(), csar.entryServiceTemplate().getId(), false)), new XmlId(planId.toString(), false));
Collection<RepositoryFileReference> fileRefs = repository.getContainedFiles(plan);
Path planPath = null;
for (RepositoryFileReference ref : fileRefs) {
if (ref.getFileName().endsWith(".zip")) {
planPath = repository.ref2AbsolutePath(ref);
}
}
return planPath;
}
Aggregations