Search in sources :

Example 1 with SecretProviderConfigurationAndCredentials

use of alien4cloud.deployment.model.SecretProviderConfigurationAndCredentials in project alien4cloud by alien4cloud.

the class WorkflowExecutionService method launchWorkflow.

/**
 * Launch a given workflow.
 */
public synchronized void launchWorkflow(SecretProviderConfigurationAndCredentials secretProviderConfigurationAndCredentials, String applicationEnvironmentId, String workflowName, Map<String, Object> params, IPaaSCallback<?> iPaaSCallback) {
    Deployment deployment = deploymentService.getActiveDeploymentOrFail(applicationEnvironmentId);
    DeploymentTopology deploymentTopology = deploymentRuntimeStateService.getRuntimeTopologyFromEnvironment(deployment.getEnvironmentId());
    IOrchestratorPlugin orchestratorPlugin = orchestratorPluginService.getOrFail(deployment.getOrchestratorId());
    final DeploymentTopology topology = alienMonitorDao.findById(DeploymentTopology.class, deployment.getId());
    // get the secret provider configuration from the location
    Map<String, String> locationIds = TopologyLocationUtils.getLocationIds(topology);
    Map<String, Location> locations = deploymentTopologyService.getLocations(locationIds);
    SecretProviderConfigurationAndCredentials authResponse = null;
    if (secretProviderService.isSecretProvided(secretProviderConfigurationAndCredentials)) {
        authResponse = secretProviderService.generateToken(locations, secretProviderConfigurationAndCredentials.getSecretProviderConfiguration().getPluginName(), secretProviderConfigurationAndCredentials.getCredentials());
    }
    PaaSDeploymentContext deploymentContext = new PaaSDeploymentContext(deployment, deploymentTopology, authResponse);
    orchestratorPlugin.launchWorkflow(deploymentContext, workflowName, params, iPaaSCallback);
}
Also used : PaaSDeploymentContext(alien4cloud.paas.model.PaaSDeploymentContext) DeploymentTopology(alien4cloud.model.deployment.DeploymentTopology) Deployment(alien4cloud.model.deployment.Deployment) SecretProviderConfigurationAndCredentials(alien4cloud.deployment.model.SecretProviderConfigurationAndCredentials) IOrchestratorPlugin(alien4cloud.orchestrators.plugin.IOrchestratorPlugin) Location(alien4cloud.model.orchestrators.locations.Location)

Example 2 with SecretProviderConfigurationAndCredentials

use of alien4cloud.deployment.model.SecretProviderConfigurationAndCredentials in project alien4cloud by alien4cloud.

the class SecretProviderService method internalGenerateToken.

/**
 * Generate a token wrapped in an instance of SecretProviderConfigurationAndCredentials by authenticating the credentials (username, password) with ldap
 *
 * @param locationConfiguration
 * @param credentials
 * @return SecretProviderConfigurationAndCredentials wrapping a token
 */
private SecretProviderConfigurationAndCredentials internalGenerateToken(SecretProviderConfiguration locationConfiguration, Object credentials) {
    // Instead of saving the credentials username and password, we transform the username and password to a client token
    ISecretProvider secretProvider = this.getPluginBean(locationConfiguration.getPluginName());
    Object configuration = this.getPluginConfiguration(locationConfiguration.getPluginName(), locationConfiguration.getConfiguration());
    SecretAuthResponse authResponse = secretProvider.auth(configuration, this.getCredentials(locationConfiguration.getPluginName(), configuration, credentials));
    SecretProviderConfigurationAndCredentials result = new SecretProviderConfigurationAndCredentials();
    SecretProviderConfiguration secretProviderConfiguration = new SecretProviderConfiguration();
    secretProviderConfiguration.setPluginName(locationConfiguration.getPluginName());
    secretProviderConfiguration.setConfiguration(authResponse.getConfiguration());
    result.setSecretProviderConfiguration(secretProviderConfiguration);
    result.setCredentials(authResponse.getCredentials());
    return result;
}
Also used : ISecretProvider(org.alien4cloud.secret.ISecretProvider) SecretAuthResponse(alien4cloud.model.secret.SecretAuthResponse) SecretProviderConfigurationAndCredentials(alien4cloud.deployment.model.SecretProviderConfigurationAndCredentials) SecretProviderConfiguration(alien4cloud.model.secret.SecretProviderConfiguration)

Example 3 with SecretProviderConfigurationAndCredentials

use of alien4cloud.deployment.model.SecretProviderConfigurationAndCredentials in project alien4cloud by alien4cloud.

the class DeployService method saveDeploymentTopologyAndGenerateDeploymentContext.

private PaaSTopologyDeploymentContext saveDeploymentTopologyAndGenerateDeploymentContext(final SecretProviderCredentials secretProviderCredentials, final DeploymentTopology deploymentTopology, final Deployment deployment, final Map<String, Location> locations) {
    String deploymentTopologyId = deploymentTopology.getId();
    // save the topology as a deployed topology.
    // change the Id before saving
    deploymentTopology.setId(deployment.getId());
    deploymentTopology.setDeployed(true);
    alienMonitorDao.save(deploymentTopology);
    // put back the old Id for deployment
    deploymentTopology.setId(deploymentTopologyId);
    SecretProviderConfigurationAndCredentials secretProviderConfigurationAndCredentials = null;
    if (secretProviderCredentials != null) {
        secretProviderConfigurationAndCredentials = secretProviderService.generateToken(locations, secretProviderCredentials.getPluginName(), secretProviderCredentials.getCredentials());
    }
    PaaSTopologyDeploymentContext deploymentContext = deploymentContextService.buildTopologyDeploymentContext(secretProviderConfigurationAndCredentials, deployment, locations, deploymentTopology);
    // Process services relationships to inject the service side based on the service resource.
    serviceResourceRelationshipService.process(deploymentContext);
    // Download and process all remote artifacts before deployment
    artifactProcessorService.processArtifacts(deploymentContext);
    return deploymentContext;
}
Also used : PaaSTopologyDeploymentContext(alien4cloud.paas.model.PaaSTopologyDeploymentContext) SecretProviderConfigurationAndCredentials(alien4cloud.deployment.model.SecretProviderConfigurationAndCredentials)

Example 4 with SecretProviderConfigurationAndCredentials

use of alien4cloud.deployment.model.SecretProviderConfigurationAndCredentials in project alien4cloud by alien4cloud.

the class DeploymentRuntimeService method buildPaaSTopologyDeploymentContext.

/**
 * Build the deployment context from an operation execution request
 *
 * @param request the operation execution request
 * @return the deployment context
 */
public PaaSTopologyDeploymentContext buildPaaSTopologyDeploymentContext(OperationExecRequest request) {
    Deployment deployment = deploymentService.getActiveDeploymentOrFail(request.getApplicationEnvironmentId());
    DeploymentTopology deploymentTopology = deploymentRuntimeStateService.getRuntimeTopologyFromEnvironment(deployment.getEnvironmentId());
    Map<String, String> locationIds = TopologyLocationUtils.getLocationIds(deploymentTopology);
    Map<String, Location> locations = deploymentTopologyService.getLocations(locationIds);
    SecretProviderConfigurationAndCredentials secretProviderConfigurationAndCredentials = secretProviderService.generateToken(locations, request.getSecretProviderPluginName(), request.getSecretProviderCredentials());
    return deploymentContextService.buildTopologyDeploymentContext(secretProviderConfigurationAndCredentials, deployment, deploymentTopologyService.getLocations(deploymentTopology), deploymentTopology);
}
Also used : DeploymentTopology(alien4cloud.model.deployment.DeploymentTopology) Deployment(alien4cloud.model.deployment.Deployment) SecretProviderConfigurationAndCredentials(alien4cloud.deployment.model.SecretProviderConfigurationAndCredentials) Location(alien4cloud.model.orchestrators.locations.Location)

Example 5 with SecretProviderConfigurationAndCredentials

use of alien4cloud.deployment.model.SecretProviderConfigurationAndCredentials in project alien4cloud by alien4cloud.

the class DeploymentRuntimeService method doScale.

private void doScale(final String nodeTemplateId, final int instances, final IPaaSCallback<Object> callback, final Deployment deployment, final DeploymentTopology topology, SecretProviderConfigurationAndCredentials secretProviderConfigurationAndCredentials) {
    NodeTemplate nodeTemplate = TopologyUtils.getNodeTemplate(topology, nodeTemplateId);
    // get the secret provider configuration from the location
    Map<String, String> locationIds = TopologyLocationUtils.getLocationIds(topology);
    Map<String, Location> locations = deploymentTopologyService.getLocations(locationIds);
    SecretProviderConfigurationAndCredentials authResponse = null;
    if (secretProviderService.isSecretProvided(secretProviderConfigurationAndCredentials)) {
        authResponse = secretProviderService.generateToken(locations, secretProviderConfigurationAndCredentials.getSecretProviderConfiguration().getPluginName(), secretProviderConfigurationAndCredentials.getCredentials());
    }
    // Get alien4cloud specific interface to support cluster controller nodes.
    Capability clusterControllerCapability = NodeTemplateUtils.getCapabilityByType(nodeTemplate, AlienCapabilityTypes.CLUSTER_CONTROLLER);
    if (clusterControllerCapability == null) {
        doScaleNode(nodeTemplateId, instances, callback, deployment, topology, nodeTemplate, authResponse);
    } else {
        triggerClusterManagerScaleOperation(nodeTemplateId, instances, callback, deployment, topology, clusterControllerCapability, secretProviderConfigurationAndCredentials);
    }
}
Also used : NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) Capability(org.alien4cloud.tosca.model.templates.Capability) SecretProviderConfigurationAndCredentials(alien4cloud.deployment.model.SecretProviderConfigurationAndCredentials) Location(alien4cloud.model.orchestrators.locations.Location)

Aggregations

SecretProviderConfigurationAndCredentials (alien4cloud.deployment.model.SecretProviderConfigurationAndCredentials)8 Location (alien4cloud.model.orchestrators.locations.Location)4 DeploymentTopology (alien4cloud.model.deployment.DeploymentTopology)3 SecretProviderConfiguration (alien4cloud.model.secret.SecretProviderConfiguration)3 Deployment (alien4cloud.model.deployment.Deployment)2 IOrchestratorPlugin (alien4cloud.orchestrators.plugin.IOrchestratorPlugin)2 PaaSDeploymentContext (alien4cloud.paas.model.PaaSDeploymentContext)2 When (cucumber.api.java.en.When)2 SecretAuthResponse (alien4cloud.model.secret.SecretAuthResponse)1 PaaSTopologyDeploymentContext (alien4cloud.paas.model.PaaSTopologyDeploymentContext)1 ISecretProvider (org.alien4cloud.secret.ISecretProvider)1 Capability (org.alien4cloud.tosca.model.templates.Capability)1 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)1 ResponseEntity (org.springframework.http.ResponseEntity)1