use of alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory in project alien4cloud by alien4cloud.
the class OrchestratorService method getLocationSupport.
/**
* Get the location support information for a given orchestrator.
*
* @param orchestratorId The id of the orchestrator for which to get location support information.
* @return location support information.
*/
public LocationSupport getLocationSupport(String orchestratorId) {
Orchestrator orchestrator = getOrFail(orchestratorId);
IOrchestratorPluginFactory orchestratorFactory = getPluginFactory(orchestrator);
return orchestratorFactory.getLocationSupport();
}
use of alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory in project alien4cloud by alien4cloud.
the class OrchestratorStateService method load.
/**
* Load and connect the given orchestrator.
*
* @param orchestrator the orchestrator to load and connect.
*/
private void load(Orchestrator orchestrator) throws PluginConfigurationException {
log.info("Loading and connecting orchestrator {} (id: {})", orchestrator.getName(), orchestrator.getId());
// check that the orchestrator is not already loaded.
if (orchestratorPluginService.get(orchestrator.getId()) != null) {
throw new AlreadyExistException("Plugin is already loaded.");
}
// switch the state to connecting
orchestrator.setState(OrchestratorState.CONNECTING);
alienDAO.save(orchestrator);
// TODO move below in a thread to perform plugin loading and connection asynchronously
IOrchestratorPluginFactory orchestratorFactory = orchestratorService.getPluginFactory(orchestrator);
IOrchestratorPlugin<Object> orchestratorInstance = orchestratorFactory.newInstance();
// Set the configuration for the provider
OrchestratorConfiguration orchestratorConfiguration = orchestratorConfigurationService.getConfigurationOrFail(orchestrator.getId());
try {
Object configuration = orchestratorConfigurationService.configurationAsValidObject(orchestrator.getId(), orchestratorConfiguration.getConfiguration());
orchestratorInstance.setConfiguration(orchestrator.getId(), configuration);
} catch (IOException e) {
throw new PluginConfigurationException("Failed convert configuration json in object.", e);
}
// index the archive in alien catalog
archiveIndexer.indexOrchestratorArchives(orchestratorFactory, orchestratorInstance);
// connect the orchestrator
orchestratorInstance.init(deploymentService.getCloudActiveDeploymentContexts(orchestrator.getId()));
// register the orchestrator instance to be polled for updates
orchestratorPluginService.register(orchestrator.getId(), orchestratorInstance);
orchestrator.setState(OrchestratorState.CONNECTED);
alienDAO.save(orchestrator);
if (orchestratorInstance instanceof ILocationAutoConfigurer) {
// trigger locations auto-configurations
locationService.autoConfigure(orchestrator, (ILocationAutoConfigurer) orchestratorInstance);
}
indexLocationsArchives(orchestrator);
}
use of alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory in project alien4cloud by alien4cloud.
the class OrchestratorServiceTest method testInitializeConfigurableOrchstratorInvalidConfig.
@SuppressWarnings("unchecked")
@Test
public void testInitializeConfigurableOrchstratorInvalidConfig() throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException, PluginConfigurationException, ExecutionException, InterruptedException, IOException {
initializeMockedOrchestratorService();
IOrchestratorPluginFactory orchestratorPluginFactory = Mockito.mock(IOrchestratorPluginFactory.class);
IOrchestratorPlugin orchestratorPlugin = Mockito.mock(IOrchestratorPlugin.class);
List<Orchestrator> enabledOrchestrators = searchOrchestrator();
Orchestrator orchestrator = enabledOrchestrators.get(0);
OrchestratorConfiguration configuration = new OrchestratorConfiguration(orchestrator.getId(), DEFAULT_CLOUD_CONFIGURATION);
initSearch(enabledOrchestrators);
Mockito.when(orchestratorService.getPluginFactory(orchestrator)).thenReturn(orchestratorPluginFactory);
Mockito.when(orchestratorPluginFactory.newInstance()).thenReturn(orchestratorPlugin);
Mockito.when(orchestratorPluginFactory.getConfigurationType()).thenReturn(String.class);
Mockito.when(orchestratorPluginFactory.getDefaultConfiguration()).thenReturn(DEFAULT_CLOUD_CONFIGURATION);
Mockito.when(orchestratorConfigurationService.getConfigurationOrFail(orchestrator.getId())).thenReturn(configuration);
Mockito.when(orchestratorConfigurationService.configurationAsValidObject(orchestrator.getId(), configuration.getConfiguration())).thenReturn(DEFAULT_CLOUD_CONFIGURATION);
Mockito.doThrow(PluginConfigurationException.class).when(orchestratorPlugin).setConfiguration(orchestrator.getId(), configuration.getConfiguration());
initializeAndWait();
Mockito.verify(orchestratorPluginService, Mockito.times(0)).register(orchestrator.getId(), orchestratorPlugin);
orchestrator = (Orchestrator) searchOrchestrator().get(0);
orchestrator.setState(OrchestratorState.DISABLED);
Mockito.verify(alienDAO, Mockito.times(2)).save(Mockito.refEq(orchestrator));
}
Aggregations