Search in sources :

Example 6 with SecretProviderConfigurationAndCredentials

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

the class UndeployService method undeploy.

private void undeploy(SecretProviderConfigurationAndCredentials secretProviderConfigurationAndCredentials, final Deployment deployment) {
    deploymentLockService.doWithDeploymentWriteLock(deployment.getOrchestratorDeploymentId(), () -> {
        log.info("Un-deploying deployment [{}] on orchestrator [{}]", deployment.getId(), deployment.getOrchestratorId());
        IOrchestratorPlugin orchestratorPlugin = orchestratorPluginService.getOrFail(deployment.getOrchestratorId());
        DeploymentTopology deployedTopology = deploymentRuntimeStateService.getRuntimeTopology(deployment.getId());
        Map<String, String> locationIds = TopologyLocationUtils.getLocationIds(deployedTopology);
        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, deployedTopology, authResponse);
        orchestratorPlugin.undeploy(deploymentContext, new IPaaSCallback<ResponseEntity>() {

            @Override
            public void onSuccess(ResponseEntity data) {
                deploymentService.markUndeployed(deployment);
                log.info("Un-deployed deployment [{}] on orchestrator [{}]", deployment.getId(), deployment.getOrchestratorId());
            }

            @Override
            public void onFailure(Throwable throwable) {
                log.warn("Fail while Undeploying deployment [{}] on orchestrator [{}]", deployment.getId(), deployment.getOrchestratorId());
            }
        });
        return null;
    });
}
Also used : PaaSDeploymentContext(alien4cloud.paas.model.PaaSDeploymentContext) ResponseEntity(org.springframework.http.ResponseEntity) DeploymentTopology(alien4cloud.model.deployment.DeploymentTopology) SecretProviderConfigurationAndCredentials(alien4cloud.deployment.model.SecretProviderConfigurationAndCredentials) IOrchestratorPlugin(alien4cloud.orchestrators.plugin.IOrchestratorPlugin) Location(alien4cloud.model.orchestrators.locations.Location)

Example 7 with SecretProviderConfigurationAndCredentials

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

the class RuntimeStepDefinitions method iScaleUpTheNodeByAddingInstanceSWithTheFollowingCredentialsDefinedByTheSecretProviderPlugin.

@When("^I scale up the node \"([^\"]*)\" by adding (\\d+) instance\\(s\\) with the following credentials defined by the secret provider plugin \"([^\"]*)\"$")
public void iScaleUpTheNodeByAddingInstanceSWithTheFollowingCredentialsDefinedByTheSecretProviderPlugin(String nodeName, int instancesToAdd, String pluginName, DataTable table) throws Throwable {
    log.info("Scale up the node " + nodeName + " by " + instancesToAdd);
    SecretProviderConfigurationAndCredentials secretProviderConfigurationAndCredentials = new SecretProviderConfigurationAndCredentials();
    secretProviderConfigurationAndCredentials.setCredentials(DataTableUtils.dataTableToMap(table));
    SecretProviderConfiguration secretProviderConfiguration = new SecretProviderConfiguration();
    secretProviderConfiguration.setPluginName(pluginName);
    secretProviderConfigurationAndCredentials.setSecretProviderConfiguration(secretProviderConfiguration);
    Context.getInstance().registerRestResponse(scale(nodeName, instancesToAdd, secretProviderConfigurationAndCredentials));
    log.info("Finished scaling up the node " + nodeName + " by " + instancesToAdd);
}
Also used : SecretProviderConfigurationAndCredentials(alien4cloud.deployment.model.SecretProviderConfigurationAndCredentials) SecretProviderConfiguration(alien4cloud.model.secret.SecretProviderConfiguration) When(cucumber.api.java.en.When)

Example 8 with SecretProviderConfigurationAndCredentials

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

the class WorkflowStepDefinition method iLaunchTheWorkflowInTheEnvironmentViewAfterTheDeploymentWithTheFollowingSecretCredentials.

@When("^I launch the workflow \"([^\"]*)\" in the environment view after the deployment using the secret provider \"([^\"]*)\" with the following secret credentials:$")
public void iLaunchTheWorkflowInTheEnvironmentViewAfterTheDeploymentWithTheFollowingSecretCredentials(String workflowName, String pluginName, DataTable table) throws Throwable {
    String path = "/rest/v1/applications/" + ApplicationStepDefinitions.CURRENT_APPLICATION.getId() + "/environments/" + Context.getInstance().getDefaultApplicationEnvironmentId(ApplicationStepDefinitions.CURRENT_APPLICATION.getName()) + "/workflows/" + workflowName;
    SecretProviderConfigurationAndCredentials secretProviderConfigurationAndCredentials = new SecretProviderConfigurationAndCredentials();
    SecretProviderConfiguration secretProviderConfiguration = new SecretProviderConfiguration();
    secretProviderConfiguration.setPluginName(pluginName);
    secretProviderConfigurationAndCredentials.setSecretProviderConfiguration(secretProviderConfiguration);
    secretProviderConfigurationAndCredentials.setCredentials(DataTableUtils.dataTableToMap(table));
    String result = Context.getRestClientInstance().postJSon(path, JsonUtil.toString(secretProviderConfigurationAndCredentials));
    Context.getInstance().registerRestResponse(result);
}
Also used : SecretProviderConfigurationAndCredentials(alien4cloud.deployment.model.SecretProviderConfigurationAndCredentials) SecretProviderConfiguration(alien4cloud.model.secret.SecretProviderConfiguration) When(cucumber.api.java.en.When)

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