Search in sources :

Example 1 with PaaSTopology

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);
    }
}
Also used : PaaSTopology(alien4cloud.paas.model.PaaSTopology) PaaSNodeTemplate(alien4cloud.paas.model.PaaSNodeTemplate) DeploymentTopology(alien4cloud.model.deployment.DeploymentTopology) Workflow(org.alien4cloud.tosca.model.workflow.Workflow) NodeGroup(org.alien4cloud.tosca.model.templates.NodeGroup)

Example 2 with PaaSTopology

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();
}
Also used : Csar(org.alien4cloud.tosca.model.Csar) PaaSTopology(alien4cloud.paas.model.PaaSTopology) DeploymentTopology(alien4cloud.model.deployment.DeploymentTopology) ZipOutputStream(java.util.zip.ZipOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) Closeable(java.io.Closeable) ZipException(java.util.zip.ZipException) YorcRestException(org.ystia.yorc.alien4cloud.plugin.rest.YorcRestException) ParsingException(alien4cloud.tosca.parser.ParsingException) IOException(java.io.IOException) CSARDependency(org.alien4cloud.tosca.model.CSARDependency) PaaSNodeTemplate(alien4cloud.paas.model.PaaSNodeTemplate) ZipOutputStream(java.util.zip.ZipOutputStream) FileOutputStream(java.io.FileOutputStream) File(java.io.File) Location(alien4cloud.model.orchestrators.locations.Location)

Example 3 with PaaSTopology

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;
}
Also used : PaaSTopology(alien4cloud.paas.model.PaaSTopology) TopologyDTO(alien4cloud.topology.TopologyDTO) ToscaContextual(alien4cloud.tosca.context.ToscaContextual)

Example 4 with 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;
}
Also used : PaaSTopology(alien4cloud.paas.model.PaaSTopology) PaaSTopologyDeploymentContext(alien4cloud.paas.model.PaaSTopologyDeploymentContext)

Example 5 with PaaSTopology

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);
}
Also used : PaaSTopology(alien4cloud.paas.model.PaaSTopology) PaaSNodeTemplate(alien4cloud.paas.model.PaaSNodeTemplate) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

PaaSTopology (alien4cloud.paas.model.PaaSTopology)6 PaaSNodeTemplate (alien4cloud.paas.model.PaaSNodeTemplate)4 DeploymentTopology (alien4cloud.model.deployment.DeploymentTopology)2 Location (alien4cloud.model.orchestrators.locations.Location)1 PaaSTopologyDeploymentContext (alien4cloud.paas.model.PaaSTopologyDeploymentContext)1 TopologyDTO (alien4cloud.topology.TopologyDTO)1 ToscaContextual (alien4cloud.tosca.context.ToscaContextual)1 ParsingException (alien4cloud.tosca.parser.ParsingException)1 Closeable (java.io.Closeable)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ZipException (java.util.zip.ZipException)1 ZipOutputStream (java.util.zip.ZipOutputStream)1 CSARDependency (org.alien4cloud.tosca.model.CSARDependency)1 Csar (org.alien4cloud.tosca.model.Csar)1 AbstractPropertyValue (org.alien4cloud.tosca.model.definitions.AbstractPropertyValue)1