Search in sources :

Example 16 with Orchestrator

use of alien4cloud.model.orchestrators.Orchestrator in project alien4cloud by alien4cloud.

the class DeployService method generateOrchestratorDeploymentId.

/**
 * Generate the human readable deployment id for the orchestrator.
 *
 * @param envId Id of the deployed environment.
 * @param orchestratorId Id of the orchestrator on which the deployment is performed.
 * @return The orchestrator deployment id.
 * @throws alien4cloud.paas.exception.OrchestratorDeploymentIdConflictException
 */
private String generateOrchestratorDeploymentId(String envId, String orchestratorId) throws OrchestratorDeploymentIdConflictException {
    log.debug("Generating deployment paaS Id...");
    log.debug("All spaces will be replaced by an \"_\" charactr. You might consider it while naming your applications.");
    ApplicationEnvironment env = applicationEnvironmentService.getOrFail(envId);
    Orchestrator orchestrator = orchestratorService.getOrFail(orchestratorId);
    String namePattern = orchestrator.getDeploymentNamePattern();
    ExpressionParser parser = new SpelExpressionParser();
    Expression exp = parser.parseExpression(namePattern);
    String orchestratorDeploymentId = (String) exp.getValue(new OrchestratorIdContext(env, applicationService.getOrFail(env.getApplicationId()), namePattern.contains("metaProperties[")));
    // ensure that the id is not used by another deployment.
    if (deploymentService.isActiveDeployment(orchestratorId, orchestratorDeploymentId)) {
        throw new OrchestratorDeploymentIdConflictException("Conflict detected with the generated paasId <" + orchestratorDeploymentId + ">.");
    }
    return orchestratorDeploymentId;
}
Also used : SpelExpressionParser(org.springframework.expression.spel.standard.SpelExpressionParser) Expression(org.springframework.expression.Expression) ExpressionParser(org.springframework.expression.ExpressionParser) SpelExpressionParser(org.springframework.expression.spel.standard.SpelExpressionParser) OrchestratorDeploymentIdConflictException(alien4cloud.paas.exception.OrchestratorDeploymentIdConflictException) ApplicationEnvironment(alien4cloud.model.application.ApplicationEnvironment) Orchestrator(alien4cloud.model.orchestrators.Orchestrator)

Example 17 with Orchestrator

use of alien4cloud.model.orchestrators.Orchestrator in project alien4cloud by alien4cloud.

the class LocationService method delete.

/**
 * Delete a locations.
 *
 * @param id id of the locations to delete.
 * @return true if the location was successfully , false if not.
 */
public synchronized boolean delete(String orchestratorId, String id) {
    Orchestrator orchestrator = orchestratorService.getOrFail(orchestratorId);
    if (alienDAO.count(Deployment.class, null, fromKeyValueCouples("orchestratorId", orchestratorId, "locationIds", id, "endDate", null)) > 0) {
        return false;
    }
    Location location = getOrFail(id);
    publisher.publishEvent(new BeforeLocationDeleted(this, location.getId()));
    // delete all location resources for the given location
    alienDAO.delete(LocationResourceTemplate.class, QueryBuilders.termQuery("locationId", id));
    // delete the location
    alienDAO.delete(Location.class, id);
    // delete all archives associated with this location only, if possible of course
    Map<Csar, List<Usage>> usages = locationArchiveIndexer.deleteArchives(orchestrator, location);
    if (MapUtils.isNotEmpty(usages)) {
        // TODO what to do when some archives were not deleted?
        log.warn("Some archives for location were not deleted! \n" + usages);
    }
    publisher.publishEvent(new AfterLocationDeleted(this, location.getId()));
    return true;
}
Also used : Csar(org.alien4cloud.tosca.model.Csar) BeforeLocationDeleted(alien4cloud.orchestrators.locations.events.BeforeLocationDeleted) Deployment(alien4cloud.model.deployment.Deployment) List(java.util.List) Orchestrator(alien4cloud.model.orchestrators.Orchestrator) Location(alien4cloud.model.orchestrators.locations.Location) AfterLocationDeleted(alien4cloud.orchestrators.locations.events.AfterLocationDeleted)

Example 18 with Orchestrator

use of alien4cloud.model.orchestrators.Orchestrator in project alien4cloud by alien4cloud.

the class LocationService method create.

/**
 * Add a new locations for a given orchestrator.
 */
public String create(String orchestratorId, String locationName, String infrastructureType) {
    Orchestrator orchestrator = orchestratorService.getOrFail(orchestratorId);
    if (!OrchestratorState.CONNECTED.equals(orchestrator.getState())) {
    // we cannot configure locations for orchestrator that are not connected.
    // TODO throw exception
    }
    ensureMultipleLocations(orchestratorId);
    Location location = new Location();
    location.setId(UUID.randomUUID().toString());
    location.setName(locationName);
    location.setOrchestratorId(orchestratorId);
    createLocation(orchestrator, location, infrastructureType);
    publisher.publishEvent(new AfterLocationCreated(this, location));
    return location.getId();
}
Also used : AfterLocationCreated(alien4cloud.orchestrators.locations.events.AfterLocationCreated) Orchestrator(alien4cloud.model.orchestrators.Orchestrator) Location(alien4cloud.model.orchestrators.locations.Location)

Example 19 with Orchestrator

use of alien4cloud.model.orchestrators.Orchestrator in project alien4cloud by alien4cloud.

the class OrchestratorDeploymentService method getDeploymentPropertyDefinitions.

public Map<String, PropertyDefinition> getDeploymentPropertyDefinitions(String orchestratorId) {
    Orchestrator orchestrator = orchestratorService.getOrFail(orchestratorId);
    IOrchestratorPluginFactory orchestratorFactory = orchestratorService.getPluginFactory(orchestrator);
    return orchestratorFactory.getDeploymentPropertyDefinitions();
}
Also used : IOrchestratorPluginFactory(alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory) Orchestrator(alien4cloud.model.orchestrators.Orchestrator)

Example 20 with Orchestrator

use of alien4cloud.model.orchestrators.Orchestrator in project alien4cloud by alien4cloud.

the class OrchestratorService method create.

/**
 * Creates an orchestrator.
 *
 * @param name The unique name that defines the orchestrator from user point of view.
 * @param pluginId The id of the plugin used to communicate with the orchestrator.
 * @param pluginBean The bean in the plugin that is indeed managing communication.
 * @return The generated identifier for the orchestrator.
 */
public synchronized String create(String name, String pluginId, String pluginBean) {
    Orchestrator orchestrator = new Orchestrator();
    // generate an unique id
    orchestrator.setId(UUID.randomUUID().toString());
    orchestrator.setName(name);
    orchestrator.setPluginId(pluginId);
    orchestrator.setPluginBean(pluginBean);
    // by default clouds are disabled as it should be configured before being enabled.
    orchestrator.setState(OrchestratorState.DISABLED);
    // get default configuration for the orchestrator.
    IOrchestratorPluginFactory orchestratorFactory = getPluginFactory(orchestrator);
    OrchestratorConfiguration configuration = new OrchestratorConfiguration(orchestrator.getId(), orchestratorFactory.getDefaultConfiguration());
    ensureNameUnicityAndSave(orchestrator);
    alienDAO.save(configuration);
    return orchestrator.getId();
}
Also used : IOrchestratorPluginFactory(alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory) Orchestrator(alien4cloud.model.orchestrators.Orchestrator) OrchestratorConfiguration(alien4cloud.model.orchestrators.OrchestratorConfiguration)

Aggregations

Orchestrator (alien4cloud.model.orchestrators.Orchestrator)28 IOrchestratorPluginFactory (alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory)7 Location (alien4cloud.model.orchestrators.locations.Location)6 IOrchestratorPlugin (alien4cloud.orchestrators.plugin.IOrchestratorPlugin)5 ApiOperation (io.swagger.annotations.ApiOperation)4 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 OrchestratorConfiguration (alien4cloud.model.orchestrators.OrchestratorConfiguration)3 LocationResourceTemplate (alien4cloud.model.orchestrators.locations.LocationResourceTemplate)3 Test (org.junit.Test)3 Audit (alien4cloud.audit.annotation.Audit)2 GetMultipleDataResult (alien4cloud.dao.model.GetMultipleDataResult)2 ILocationMatch (alien4cloud.model.deployment.matching.ILocationMatch)2 LocationMatch (alien4cloud.model.deployment.matching.LocationMatch)2 AbstractLocationResourceTemplate (alien4cloud.model.orchestrators.locations.AbstractLocationResourceTemplate)2 LocationResources (alien4cloud.model.orchestrators.locations.LocationResources)2 PolicyLocationResourceTemplate (alien4cloud.model.orchestrators.locations.PolicyLocationResourceTemplate)2 ILocationConfiguratorPlugin (alien4cloud.orchestrators.plugin.ILocationConfiguratorPlugin)2 LocationMatchingException (alien4cloud.paas.exception.LocationMatchingException)2 LocationPolicyTask (alien4cloud.topology.task.LocationPolicyTask)2