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