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