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);
}
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;
}
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;
}
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);
}
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);
}
}
Aggregations