use of alien4cloud.paas.model.PaaSDeploymentContext in project alien4cloud by alien4cloud.
the class DeploymentRuntimeService method switchInstanceMaintenanceMode.
/**
* Switch an instance in a deployment to maintenance mode. If so the orchestrator should not perform self healing operations for this instance.
*
* @param applicationEnvironmentId The id of the application environment.
* @param nodeTemplateId The id of the node template on which to enable maintenance mode.
* @param instanceId The id of the instance.
* @param maintenanceModeOn true if we should enable the maintenance mode, false if we should disable it.
* @throws MaintenanceModeException In case the operation fails.
*/
public void switchInstanceMaintenanceMode(String applicationEnvironmentId, String nodeTemplateId, String instanceId, boolean maintenanceModeOn) throws MaintenanceModeException {
Deployment deployment = deploymentService.getActiveDeploymentOrFail(applicationEnvironmentId);
IOrchestratorPlugin orchestratorPlugin = orchestratorPluginService.getOrFail(deployment.getOrchestratorId());
DeploymentTopology deploymentTopology = deploymentRuntimeStateService.getRuntimeTopologyFromEnvironment(deployment.getEnvironmentId());
PaaSDeploymentContext deploymentContext = new PaaSDeploymentContext(deployment, deploymentTopology, null);
orchestratorPlugin.switchInstanceMaintenanceMode(deploymentContext, nodeTemplateId, instanceId, maintenanceModeOn);
}
use of alien4cloud.paas.model.PaaSDeploymentContext 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.paas.model.PaaSDeploymentContext in project alien4cloud by alien4cloud.
the class DeploymentRuntimeService method switchMaintenanceMode.
/**
* Switch all instances in a deployment to maintenance mode. If so the orchestrator should not perform self healing operations for this instance.
*
* @param applicationEnvironmentId The id of the application environment.
* @param maintenanceModeOn true if we should enable the maintenance mode, false if we should disable it.
* @throws MaintenanceModeException In case the operation fails.
*/
public void switchMaintenanceMode(String applicationEnvironmentId, boolean maintenanceModeOn) throws MaintenanceModeException {
Deployment deployment = deploymentService.getActiveDeploymentOrFail(applicationEnvironmentId);
DeploymentTopology deploymentTopology = deploymentRuntimeStateService.getRuntimeTopologyFromEnvironment(deployment.getEnvironmentId());
IOrchestratorPlugin orchestratorPlugin = orchestratorPluginService.getOrFail(deployment.getOrchestratorId());
PaaSDeploymentContext deploymentContext = new PaaSDeploymentContext(deployment, deploymentTopology, null);
orchestratorPlugin.switchMaintenanceMode(deploymentContext, maintenanceModeOn);
}
use of alien4cloud.paas.model.PaaSDeploymentContext in project alien4cloud by alien4cloud.
the class DeploymentRuntimeService method doScaleNode.
private void doScaleNode(final String nodeTemplateId, final int instances, final IPaaSCallback<Object> callback, final Deployment deployment, final DeploymentTopology topology, NodeTemplate nodeTemplate, SecretProviderConfigurationAndCredentials secretProviderConfigurationAndCredentials) {
final Capability capability = NodeTemplateUtils.getCapabilityByTypeOrFail(nodeTemplate, NormativeCapabilityTypes.SCALABLE);
final int previousInitialInstances = TopologyUtils.getScalingProperty(NormativeComputeConstants.SCALABLE_DEFAULT_INSTANCES, capability);
final int newInitialInstances = previousInitialInstances + instances;
log.info("Scaling [ {} ] node from [ {} ] to [ {} ]. Updating runtime topology...", nodeTemplateId, previousInitialInstances, newInitialInstances);
TopologyUtils.setScalingProperty(NormativeComputeConstants.SCALABLE_DEFAULT_INSTANCES, newInitialInstances, capability);
alienMonitorDao.save(topology);
IOrchestratorPlugin orchestratorPlugin = orchestratorPluginService.getOrFail(deployment.getOrchestratorId());
PaaSDeploymentContext deploymentContext = new PaaSDeploymentContext(deployment, topology, secretProviderConfigurationAndCredentials);
orchestratorPlugin.scale(deploymentContext, nodeTemplateId, instances, new IPaaSCallback() {
@Override
public void onFailure(Throwable throwable) {
log.info("Failed to scale [ {} ] node from [ {} ] to [ {} ]. rolling back to {}...", nodeTemplateId, previousInitialInstances, newInitialInstances, previousInitialInstances);
TopologyUtils.setScalingProperty(NormativeComputeConstants.SCALABLE_DEFAULT_INSTANCES, previousInitialInstances, capability);
alienMonitorDao.save(topology);
callback.onFailure(throwable);
}
@Override
public void onSuccess(Object data) {
callback.onSuccess(data);
}
});
}
use of alien4cloud.paas.model.PaaSDeploymentContext 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;
});
}
Aggregations