use of alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory 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());
}
}
use of alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory in project alien4cloud by alien4cloud.
the class LocationService method autoConfigure.
/**
* This method calls the orchestrator plugin to try to auto-configure the
*
* @param orchestrator The orchestrator for which to auto-configure a location.
* @param location The location to auto-configure
* @return the List of {@link LocationResourceTemplate} generated from the location auto-configuration call, null is a valid answer.
*/
private List<LocationResourceTemplate> autoConfigure(Orchestrator orchestrator, Location location) throws UnsupportedOperationException {
// get the orchestrator plugin instance
IOrchestratorPlugin orchestratorInstance = (IOrchestratorPlugin) orchestratorPluginService.getOrFail(orchestrator.getId());
ILocationConfiguratorPlugin configuratorPlugin = orchestratorInstance.getConfigurator(location.getInfrastructureType());
IOrchestratorPluginFactory orchestratorFactory = orchestratorService.getPluginFactory(orchestrator);
ILocationResourceAccessor accessor = locationResourceService.accessor(location.getId());
// let's try to auto-configure the location
List<LocationResourceTemplate> templates = configuratorPlugin.instances(accessor);
if (templates != null) {
// save the instances
for (LocationResourceTemplate template : templates) {
// initialize the instances from data.
template.setId(UUID.randomUUID().toString());
template.setLocationId(location.getId());
template.setGenerated(true);
template.setEnabled(true);
NodeType nodeType = csarRepoSearchService.getRequiredElementInDependencies(NodeType.class, template.getTemplate().getType(), location.getDependencies());
nodeType.getDerivedFrom().add(0, template.getTemplate().getType());
template.setTypes(nodeType.getDerivedFrom());
LocationTemplateCreated event = new LocationTemplateCreated(this);
event.setTemplate(template);
event.setLocation(location);
event.setToscaType(nodeType);
applicationContext.publishEvent(event);
}
alienDAO.save(templates.toArray(new LocationResourceTemplate[templates.size()]));
alienDAO.save(location);
}
return templates;
}
use of alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory in project alien4cloud by alien4cloud.
the class PluginArchiveIndexer method deleteArchives.
/**
* Delete all archives related to a location, if not exposed or used by another location
*
* @param location
* @return Map of usages per archives if found (that means the deletion wasn't performed successfully), null if everything went well.
*/
public Map<Csar, List<Usage>> deleteArchives(Orchestrator orchestrator, Location location) {
ILocationConfiguratorPlugin configuratorPlugin = getConfiguratorPlugin(location);
IOrchestratorPluginFactory orchestratorFactory = orchestratorService.getPluginFactory(orchestrator);
List<PluginArchive> pluginArchives = configuratorPlugin.pluginArchives();
// abort if no archive is exposed by this location
if (CollectionUtils.isEmpty(pluginArchives)) {
return null;
}
Map<String, List<Location>> allExposedArchivesIds = getAllExposedArchivesIdsExluding(location);
Map<Csar, List<Usage>> usages = Maps.newHashMap();
for (PluginArchive pluginArchive : pluginArchives) {
Csar csar = pluginArchive.getArchive().getArchive();
List<Location> locationsExposingArchive = allExposedArchivesIds.get(csar.getId());
LocationArchiveDeleteRequested e = new LocationArchiveDeleteRequested(this);
e.setCsar(csar);
e.setLocation(location);
e.setOrchestratorFactory(orchestratorFactory);
e.setLocationsExposingArchive(locationsExposingArchive);
// only delete if no other location exposed this archive
if (locationsExposingArchive == null) {
List<Usage> csarUsage = csarService.deleteCsarWithElements(csar);
if (CollectionUtils.isNotEmpty(csarUsage)) {
usages.put(csar, csarUsage);
}
e.setDeleted(true);
} else {
e.setDeleted(false);
}
applicationContext.publishEvent(e);
}
return usages.isEmpty() ? null : usages;
}
use of alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory 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.orchestrators.plugin.IOrchestratorPluginFactory 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