Search in sources :

Example 6 with IOrchestratorPlugin

use of alien4cloud.orchestrators.plugin.IOrchestratorPlugin in project alien4cloud by alien4cloud.

the class OrchestratorStateService method unloadAllOrchestrators.

/**
 * Unload all orchestrators from JVM memory, it's typically to refresh/reload code
 */
public void unloadAllOrchestrators() {
    List<Orchestrator> enabledOrchestratorList = orchestratorService.getAllEnabledOrchestrators();
    if (enabledOrchestratorList != null && !enabledOrchestratorList.isEmpty()) {
        log.info("Unloading orchestrators");
        for (final Orchestrator orchestrator : enabledOrchestratorList) {
            // un-register the orchestrator.
            IOrchestratorPlugin orchestratorInstance = orchestratorPluginService.unregister(orchestrator.getId());
            if (orchestratorInstance != null) {
                IOrchestratorPluginFactory orchestratorFactory = orchestratorService.getPluginFactory(orchestrator);
                orchestratorFactory.destroy(orchestratorInstance);
            }
        }
        log.info("{} Orchestrators Unloaded", enabledOrchestratorList.size());
    }
}
Also used : IOrchestratorPluginFactory(alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory) Orchestrator(alien4cloud.model.orchestrators.Orchestrator) IOrchestratorPlugin(alien4cloud.orchestrators.plugin.IOrchestratorPlugin)

Example 7 with IOrchestratorPlugin

use of alien4cloud.orchestrators.plugin.IOrchestratorPlugin in project alien4cloud by alien4cloud.

the class LocationMatchingConfigurationService method getMatchingConfiguration.

/**
 * Get the matching configuration for a given location.
 *
 * @param location The location for which to get the configuration.
 * @return A map nodetype, matching configuration to be used for matching.
 */
public Map<String, MatchingConfiguration> getMatchingConfiguration(Location location) {
    Orchestrator orchestrator = orchestratorService.getOrFail(location.getOrchestratorId());
    IOrchestratorPlugin orchestratorInstance = (IOrchestratorPlugin) orchestratorPluginService.get(orchestrator.getId());
    if (orchestratorInstance == null) {
        return null;
    }
    ILocationConfiguratorPlugin configuratorPlugin = orchestratorInstance.getConfigurator(location.getInfrastructureType());
    return configuratorPlugin.getMatchingConfigurations();
}
Also used : ILocationConfiguratorPlugin(alien4cloud.orchestrators.plugin.ILocationConfiguratorPlugin) Orchestrator(alien4cloud.model.orchestrators.Orchestrator) IOrchestratorPlugin(alien4cloud.orchestrators.plugin.IOrchestratorPlugin)

Example 8 with IOrchestratorPlugin

use of alien4cloud.orchestrators.plugin.IOrchestratorPlugin in project alien4cloud by alien4cloud.

the class DeploymentRuntimeStateService method getInstancesInformation.

/**
 * Get the detailed status for each instance of each node template.
 *
 * @param deployment The deployment for witch to get the instance informations.
 * @param callback callback on witch to send the map of node template's id to map of instance's id to instance information.
 * @throws alien4cloud.paas.exception.OrchestratorDisabledException In case the cloud selected for the topology is disabled.
 */
public void getInstancesInformation(final Deployment deployment, IPaaSCallback<Map<String, Map<String, InstanceInformation>>> callback) throws OrchestratorDisabledException {
    Map<String, Map<String, InstanceInformation>> instancesInformation = Maps.newHashMap();
    if (deployment == null) {
        callback.onSuccess(instancesInformation);
        return;
    }
    DeploymentTopology runtimeTopology = alienMonitorDao.findById(DeploymentTopology.class, deployment.getId());
    PaaSTopologyDeploymentContext deploymentContext = deploymentContextService.buildTopologyDeploymentContext(null, deployment, deploymentTopologyService.getLocations(runtimeTopology), runtimeTopology);
    IOrchestratorPlugin orchestratorPlugin = orchestratorPluginService.getOrFail(deployment.getOrchestratorId());
    orchestratorPlugin.getInstancesInformation(deploymentContext, callback);
}
Also used : DeploymentTopology(alien4cloud.model.deployment.DeploymentTopology) Map(java.util.Map) IOrchestratorPlugin(alien4cloud.orchestrators.plugin.IOrchestratorPlugin)

Example 9 with IOrchestratorPlugin

use of alien4cloud.orchestrators.plugin.IOrchestratorPlugin in project alien4cloud by alien4cloud.

the class DeployService method deploy.

/**
 * Deploy a topology and return the deployment ID.
 *
 * @param deploymentTopology Location aware and matched topology.
 * @param deploymentSource Application to be deployed or the Csar that contains test toplogy to be deployed
 * @return The id of the generated deployment.
 */
public String deploy(final User deployer, final SecretProviderCredentials secretProviderCredentials, final DeploymentTopology deploymentTopology, IDeploymentSource deploymentSource) {
    Map<String, String> locationIds = TopologyLocationUtils.getLocationIds(deploymentTopology);
    Map<String, Location> locations = deploymentTopologyService.getLocations(locationIds);
    final Location firstLocation = locations.values().iterator().next();
    String deploymentPaaSId = generateOrchestratorDeploymentId(deploymentTopology.getEnvironmentId(), firstLocation.getOrchestratorId());
    return deploymentLockService.doWithDeploymentWriteLock(deploymentPaaSId, () -> {
        // Get the orchestrator that will perform the deployment
        IOrchestratorPlugin orchestratorPlugin = orchestratorPluginService.getOrFail(firstLocation.getOrchestratorId());
        // Create a deployment object to be kept in ES.
        final Deployment deployment = new Deployment();
        deployment.setId(UUID.randomUUID().toString());
        deployment.setOrchestratorId(firstLocation.getOrchestratorId());
        deployment.setLocationIds(locationIds.values().toArray(new String[locationIds.size()]));
        deployment.setOrchestratorDeploymentId(deploymentPaaSId);
        deployment.setSourceId(deploymentSource.getId());
        deployment.setDeployerUsername(deployer.getUsername());
        String sourceName;
        if (deploymentSource.getName() == null) {
            sourceName = UUID.randomUUID().toString();
        } else {
            sourceName = deploymentSource.getName();
        }
        deployment.setSourceName(sourceName);
        deployment.setSourceType(DeploymentSourceType.fromSourceType(deploymentSource.getClass()));
        // mandatory for the moment since we could have deployment with no environment (csar test)
        deployment.setEnvironmentId(deploymentTopology.getEnvironmentId());
        deployment.setVersionId(deploymentTopology.getVersionId());
        deployment.setStartDate(new Date());
        setUsedServicesResourcesIds(deploymentTopology, deployment);
        alienDao.save(deployment);
        // publish an event for the eventual managed service
        eventPublisher.publishEvent(new DeploymentCreatedEvent(this, deployment.getId()));
        PaaSTopologyDeploymentContext deploymentContext = saveDeploymentTopologyAndGenerateDeploymentContext(secretProviderCredentials, deploymentTopology, deployment, locations);
        // Build the context for deployment and deploy
        orchestratorPlugin.deploy(deploymentContext, new IPaaSCallback<Object>() {

            @Override
            public void onSuccess(Object data) {
                log.debug("Deployed topology [{}] on location [{}], generated deployment with id [{}]", deploymentTopology.getInitialTopologyId(), firstLocation.getId(), deployment.getId());
            }

            @Override
            public void onFailure(Throwable t) {
                log.error("Deployment failed with cause", t);
                log(deployment, t);
            }
        });
        log.debug("Triggered deployment of topology [{}] on location [{}], generated deployment with id [{}]", deploymentTopology.getInitialTopologyId(), firstLocation.getId(), deployment.getId());
        return deployment.getId();
    });
}
Also used : DeploymentCreatedEvent(alien4cloud.events.DeploymentCreatedEvent) PaaSTopologyDeploymentContext(alien4cloud.paas.model.PaaSTopologyDeploymentContext) Deployment(alien4cloud.model.deployment.Deployment) Date(java.util.Date) IOrchestratorPlugin(alien4cloud.orchestrators.plugin.IOrchestratorPlugin) Location(alien4cloud.model.orchestrators.locations.Location)

Example 10 with IOrchestratorPlugin

use of alien4cloud.orchestrators.plugin.IOrchestratorPlugin in project alien4cloud by alien4cloud.

the class DeploymentRuntimeService method triggerOperationExecution.

public void triggerOperationExecution(PaaSTopologyDeploymentContext context, OperationExecRequest request, IPaaSCallback<Map<String, String>> callback) throws OperationExecutionException {
    IOrchestratorPlugin orchestratorPlugin = orchestratorPluginService.getOrFail(context.getDeployment().getOrchestratorId());
    orchestratorPlugin.executeOperation(context, request, callback);
}
Also used : IOrchestratorPlugin(alien4cloud.orchestrators.plugin.IOrchestratorPlugin)

Aggregations

IOrchestratorPlugin (alien4cloud.orchestrators.plugin.IOrchestratorPlugin)22 DeploymentTopology (alien4cloud.model.deployment.DeploymentTopology)6 IOrchestratorPluginFactory (alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory)6 Deployment (alien4cloud.model.deployment.Deployment)5 Orchestrator (alien4cloud.model.orchestrators.Orchestrator)5 ILocationConfiguratorPlugin (alien4cloud.orchestrators.plugin.ILocationConfiguratorPlugin)5 PaaSDeploymentContext (alien4cloud.paas.model.PaaSDeploymentContext)5 Location (alien4cloud.model.orchestrators.locations.Location)4 OrchestratorConfiguration (alien4cloud.model.orchestrators.OrchestratorConfiguration)3 IPaaSCallback (alien4cloud.paas.IPaaSCallback)3 PaaSTopologyDeploymentContext (alien4cloud.paas.model.PaaSTopologyDeploymentContext)3 Map (java.util.Map)3 SecretProviderConfigurationAndCredentials (alien4cloud.deployment.model.SecretProviderConfigurationAndCredentials)2 LocationResourceTemplate (alien4cloud.model.orchestrators.locations.LocationResourceTemplate)2 Test (org.junit.Test)2 DeploymentCreatedEvent (alien4cloud.events.DeploymentCreatedEvent)1 LocationTemplateCreated (alien4cloud.events.LocationTemplateCreated)1 AlreadyExistException (alien4cloud.exception.AlreadyExistException)1 NotFoundException (alien4cloud.exception.NotFoundException)1 Usage (alien4cloud.model.common.Usage)1