use of alien4cloud.paas.model.PaaSTopology 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 alien4cloud.paas.model.PaaSTopology in project yorc-a4c-plugin by ystia.
the class DeployTask method buildZip.
/**
* Create the zip for yorc, with a modified yaml and all needed archives.
* Assumes a file original.yml exists in the current directory
* @param ctx all needed information about the deployment
* @throws IOException
*/
private void buildZip(PaaSTopologyDeploymentContext ctx) throws IOException {
// Check location
int location = LOC_OPENSTACK;
Location loc = ctx.getLocations().get("_A4C_ALL");
Set<CSARDependency> locdeps = loc.getDependencies();
for (CSARDependency dep : locdeps) {
if (dep.getName().contains("kubernetes")) {
location = LOC_KUBERNETES;
break;
}
if (dep.getName().contains("slurm")) {
location = LOC_SLURM;
break;
}
if (dep.getName().contains("aws")) {
location = LOC_AWS;
break;
}
}
// Final zip file will be named topology.zip
final File zip = new File("topology.zip");
final OutputStream out = new FileOutputStream(zip);
final ZipOutputStream zout = new ZipOutputStream(out);
final Closeable res = zout;
final int finalLocation = location;
this.ctx.getDeploymentTopology().getDependencies().forEach(d -> {
if (!"tosca-normative-types".equals(d.getName())) {
Csar csar = csarRepoSearchService.getArchive(d.getName(), d.getVersion());
if (CSARSource.ORCHESTRATOR != CSARSource.valueOf(csar.getImportSource())) {
try {
csar2zip(zout, csar, finalLocation);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
});
// Copy overwritten artifacts for each node
PaaSTopology ptopo = ctx.getPaaSTopology();
for (PaaSNodeTemplate node : ptopo.getAllNodes().values()) {
copyArtifacts(node, zout);
}
String topoFileName = "topology.yml";
// Copy modified topology
createZipEntries(topoFileName, zout);
// Get the yaml of the application as built by from a4c
DeploymentTopology dtopo = ctx.getDeploymentTopology();
Csar myCsar = new Csar(ctx.getDeploymentPaaSId(), dtopo.getArchiveVersion());
myCsar.setToscaDefinitionsVersion(ToscaParser.LATEST_DSL);
String yaml = orchestrator.getToscaTopologyExporter().getYaml(myCsar, dtopo, true);
zout.write(yaml.getBytes(Charset.forName("UTF-8")));
zout.closeEntry();
res.close();
}
use of alien4cloud.paas.model.PaaSTopology in project alien4cloud by alien4cloud.
the class TopologyTreeBuilderService method buildPaaSTopology.
/**
* Build the topology for deployment on the PaaS.
*
* @param topology The topology.
* @return The parsed topology for the PaaS with.
*/
@ToscaContextual
public PaaSTopology buildPaaSTopology(Topology topology) {
PaaSTopology paaSTopology = buildPaaSTopology(buildPaaSNodeTemplates(topology));
// Reuse this utility to query all types and inject them in the PaaSTopology
TopologyDTO topologyDTO = topologyDTOBuilder.initTopologyDTO(topology, new TopologyDTO());
paaSTopology.setDataTypes(topologyDTO.getDataTypes());
paaSTopology.setCapabilityTypes(topologyDTO.getCapabilityTypes());
paaSTopology.setRelationshipTypes(topologyDTO.getRelationshipTypes());
paaSTopology.setNodeTypes(topologyDTO.getNodeTypes());
return paaSTopology;
}
use of alien4cloud.paas.model.PaaSTopology in project alien4cloud by alien4cloud.
the class DeploymentContextService method buildTopologyDeploymentContext.
/**
* Build a topology deployment context from a given topology and deployment.
*
* @param deployment The deployment object.
* @param topology The topology that will be processed.
* @return A PaaSTopologyDeploymentContext matching the input topology.
*/
public PaaSTopologyDeploymentContext buildTopologyDeploymentContext(SecretProviderConfigurationAndCredentials secretProviderConfigurationAndCredentials, Deployment deployment, Map<String, Location> locations, DeploymentTopology topology) {
PaaSTopology paaSTopology = topologyTreeBuilderService.buildPaaSTopology(topology);
PaaSTopologyDeploymentContext topologyDeploymentContext = new PaaSTopologyDeploymentContext();
topologyDeploymentContext.setLocations(locations);
topologyDeploymentContext.setDeployment(deployment);
topologyDeploymentContext.setPaaSTopology(paaSTopology);
topologyDeploymentContext.setDeploymentTopology(topology);
topologyDeploymentContext.setDeployment(deployment);
topologyDeploymentContext.setSecretProviderConfigurationAndCredentials(secretProviderConfigurationAndCredentials);
return topologyDeploymentContext;
}
use of alien4cloud.paas.model.PaaSTopology in project alien4cloud by alien4cloud.
the class TopologyTreeBuilderService method buildPaaSTopology.
/**
* Build the topology for deployment on the PaaS.
*
* @param nodeTemplates The node templates that are part of the topology.
* @return The parsed topology for the PaaS with.
*/
public PaaSTopology buildPaaSTopology(Map<String, PaaSNodeTemplate> nodeTemplates) {
// Build hosted_on tree
List<PaaSNodeTemplate> computes = new ArrayList<PaaSNodeTemplate>();
List<PaaSNodeTemplate> networks = new ArrayList<PaaSNodeTemplate>();
List<PaaSNodeTemplate> volumes = new ArrayList<PaaSNodeTemplate>();
List<PaaSNodeTemplate> nonNatives = new ArrayList<PaaSNodeTemplate>();
Map<String, List<PaaSNodeTemplate>> groups = Maps.newHashMap();
for (Entry<String, PaaSNodeTemplate> entry : nodeTemplates.entrySet()) {
PaaSNodeTemplate paaSNodeTemplate = entry.getValue();
boolean isCompute = ToscaTypeUtils.isOfType(paaSNodeTemplate.getIndexedToscaElement(), NormativeComputeConstants.COMPUTE_TYPE);
boolean isNetwork = ToscaTypeUtils.isOfType(paaSNodeTemplate.getIndexedToscaElement(), NormativeNetworkConstants.NETWORK_TYPE);
boolean isVolume = ToscaTypeUtils.isOfType(paaSNodeTemplate.getIndexedToscaElement(), NormativeBlockStorageConstants.BLOCKSTORAGE_TYPE);
if (isVolume) {
// manage block storage
processBlockStorage(paaSNodeTemplate, nodeTemplates);
volumes.add(paaSNodeTemplate);
} else if (isCompute) {
// manage compute
processNetwork(paaSNodeTemplate, nodeTemplates);
processRelationship(paaSNodeTemplate, nodeTemplates);
computes.add(paaSNodeTemplate);
} else if (isNetwork) {
// manage network
networks.add(paaSNodeTemplate);
} else {
// manage non native
nonNatives.add(paaSNodeTemplate);
processRelationship(paaSNodeTemplate, nodeTemplates);
}
if (entry.getValue().getGroups() != null) {
for (String group : entry.getValue().getGroups()) {
List<PaaSNodeTemplate> currentGroupMembers = groups.get(group);
if (currentGroupMembers == null) {
currentGroupMembers = Lists.newArrayList();
groups.put(group, currentGroupMembers);
}
currentGroupMembers.add(entry.getValue());
}
}
}
// check and register possible operation outputs
processOperationsOutputs(nodeTemplates);
// inject all properties as operation inputs for related interfaces
PaaSUtils.injectPropertiesAsOperationInputs(nodeTemplates);
return new PaaSTopology(computes, networks, volumes, nonNatives, nodeTemplates, groups);
}
Aggregations