use of org.alien4cloud.tosca.model.workflow.Workflow in project yorc-a4c-plugin by ystia.
the class ShowTopology method topologyInLog.
/**
* Log topology infos for debugging
* @param ctx
*/
public static void topologyInLog(PaaSTopologyDeploymentContext ctx) {
String paasId = ctx.getDeploymentPaaSId();
PaaSTopology ptopo = ctx.getPaaSTopology();
DeploymentTopology dtopo = ctx.getDeploymentTopology();
// Deployment Workflows
Map<String, Workflow> workflows = dtopo.getWorkflows();
for (String wfname : workflows.keySet()) {
log.debug("***** Workflow " + wfname);
Workflow wf = workflows.get(wfname);
log.debug("name: " + wf.getName());
log.debug("host: " + wf.getHosts().toString());
log.debug("steps: " + wf.getSteps().keySet().toString());
}
// Deployment Groups
Map<String, NodeGroup> groups = dtopo.getGroups();
if (groups != null) {
for (String grname : groups.keySet()) {
NodeGroup group = groups.get(grname);
log.debug("***** Group " + grname);
log.debug("name: " + group.getName());
log.debug("members: " + group.getMembers().toString());
}
}
// PaaS Compute Nodes
for (PaaSNodeTemplate node : ptopo.getAllNodes().values()) {
printNode(node);
}
}
use of org.alien4cloud.tosca.model.workflow.Workflow in project yorc-a4c-plugin by ystia.
the class OpenStackBSComputeWFModifier method doProcess.
private void doProcess(Topology topology, FlowExecutionContext context) {
Csar csar = new Csar(topology.getArchiveName(), topology.getArchiveVersion());
Workflow installWF = topology.getWorkflows().get("install");
Workflow uninstallWF = topology.getWorkflows().get("uninstall");
Set<NodeTemplate> bsSet = TopologyNavigationUtil.getNodesOfType(topology, YORC_OPENSTACK_BS_TYPE, true);
// Let's process all BS
bsSet.forEach(bs -> safe(bs.getRelationships()).forEach((rn, rt) -> {
if ("tosca.capabilities.Attachment".equals(rt.getRequirementType())) {
// Attachment found
context.getLog().info("Found a BlockStorage <{}> with an attachment on <{}>. Let's swap their workflow steps to match Yorc " + "expectations.", bs.getName(), rt.getTarget());
String computeNodeName = rt.getTarget();
// Now lets locate corresponding wf steps in install wf
for (Map.Entry<String, WorkflowStep> workflowStepEntry : installWF.getSteps().entrySet()) {
if (workflowStepEntry.getValue().getTarget().equals(bs.getName())) {
for (String precedingStepName : workflowStepEntry.getValue().getPrecedingSteps()) {
WorkflowStep precedingStep = installWF.getSteps().get(precedingStepName);
if (precedingStep.getTarget().equals(computeNodeName)) {
// We do not use swap operation here as it may mess up other workflow edges
// First remove the edge between steps
RemoveEdgeOperation removeEdgeOperation = new RemoveEdgeOperation();
removeEdgeOperation.setWorkflowName(installWF.getName());
removeEdgeOperation.setFromStepId(precedingStepName);
removeEdgeOperation.setToStepId(workflowStepEntry.getKey());
log.debug("Swapping {} with target {}", precedingStepName, workflowStepEntry.getKey());
removeEdgeProcessor.process(csar, topology, removeEdgeOperation);
// Then reconnect them in the right sequence
ConnectStepFromOperation connectStepFromOperation = new ConnectStepFromOperation();
connectStepFromOperation.setWorkflowName(installWF.getName());
connectStepFromOperation.setFromStepIds(new String[] { workflowStepEntry.getKey() });
connectStepFromOperation.setToStepId(precedingStepName);
connectStepFromProcessor.process(csar, topology, connectStepFromOperation);
break;
}
}
break;
}
}
// Now lets locate corresponding wf steps in uninstall wf
for (Map.Entry<String, WorkflowStep> workflowStepEntry : uninstallWF.getSteps().entrySet()) {
if (workflowStepEntry.getValue().getTarget().equals(bs.getName())) {
for (String onSuccessStepName : workflowStepEntry.getValue().getOnSuccess()) {
WorkflowStep onSuccessStep = uninstallWF.getSteps().get(onSuccessStepName);
if (onSuccessStep.getTarget().equals(computeNodeName)) {
// We do not use swap operation here as it may mess up other workflow edges
// First remove the edge between steps
RemoveEdgeOperation removeEdgeOperation = new RemoveEdgeOperation();
removeEdgeOperation.setWorkflowName(uninstallWF.getName());
removeEdgeOperation.setFromStepId(workflowStepEntry.getKey());
removeEdgeOperation.setToStepId(onSuccessStepName);
log.debug("Swapping {} with target {}", onSuccessStepName, workflowStepEntry.getKey());
removeEdgeProcessor.process(csar, topology, removeEdgeOperation);
// Then reconnect them in the right sequence
ConnectStepFromOperation connectStepFromOperation = new ConnectStepFromOperation();
connectStepFromOperation.setWorkflowName(uninstallWF.getName());
connectStepFromOperation.setFromStepIds(new String[] { onSuccessStepName });
connectStepFromOperation.setToStepId(workflowStepEntry.getKey());
connectStepFromProcessor.process(csar, topology, connectStepFromOperation);
break;
}
}
break;
}
}
// Start & Stop make no sense for those kind of nodes in Yorc as those operations are not implemented.
// Do not change those WFs
}
}));
}
use of org.alien4cloud.tosca.model.workflow.Workflow in project alien4cloud by alien4cloud.
the class AbstractValidationTest method prepare.
@Before
public void prepare() {
wf = new Workflow();
wf.setName(INSTALL);
}
use of org.alien4cloud.tosca.model.workflow.Workflow in project alien4cloud by alien4cloud.
the class GraphPathsTest method testCycles.
@Test
public void testCycles() {
Workflow wf = new Workflow();
wf.setName(INSTALL);
WorkflowStep a = wf.addStep(new SimpleStep("a"));
WorkflowStep b = wf.addStep(new SimpleStep("b"));
WorkflowStep c = wf.addStep(new SimpleStep("c"));
WorkflowUtils.linkSteps(a, b);
WorkflowUtils.linkSteps(b, c);
WorkflowUtils.linkSteps(c, a);
List<Path> paths = WorkflowGraphUtils.getWorkflowGraphCycles(wf);
System.out.println(paths);
Assert.assertEquals(1, paths.size());
log.info(paths.toString());
}
use of org.alien4cloud.tosca.model.workflow.Workflow in project alien4cloud by alien4cloud.
the class GraphPathsTest method test23.
/**
* <pre>
* c
* /
* -- a
* \
* b
* </pre>
*/
@Test
public void test23() {
Workflow wf = new Workflow();
wf.setName(INSTALL);
WorkflowStep a = wf.addStep(new SimpleStep("a"));
WorkflowStep b = wf.addStep(new SimpleStep("b"));
WorkflowStep c = wf.addStep(new SimpleStep("c"));
WorkflowUtils.linkSteps(a, b);
WorkflowUtils.linkSteps(a, c);
List<Path> paths = WorkflowGraphUtils.getWorkflowGraphCycles(wf);
log.info(paths.toString());
}
Aggregations