use of alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory in project alien4cloud by alien4cloud.
the class OrchestratorServiceTest method testInitializeConfigurableOrchestratorValidConfig.
@SuppressWarnings("unchecked")
@Test
public void testInitializeConfigurableOrchestratorValidConfig() 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.configurationAsValidObject(orchestrator.getId(), configuration.getConfiguration())).thenReturn(DEFAULT_CLOUD_CONFIGURATION);
Mockito.when(orchestratorConfigurationService.getConfigurationOrFail(orchestrator.getId())).thenReturn(configuration);
initializeAndWait();
Mockito.verify(orchestratorPlugin, Mockito.times(1)).setConfiguration(orchestrator.getId(), configuration.getConfiguration());
Mockito.verify(orchestratorPluginService, Mockito.times(1)).register(orchestrator.getId(), orchestratorPlugin);
IOrchestratorPluginFactory fatory = orchestratorService.getPluginFactory(orchestrator);
Mockito.verify(archiveIndexer, Mockito.times(1)).indexOrchestratorArchives(fatory, fatory.newInstance());
;
}
use of alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory in project alien4cloud by alien4cloud.
the class PluginArchiveIndexer method getConfiguratorPlugin.
private ILocationConfiguratorPlugin getConfiguratorPlugin(Location location) {
ILocationConfiguratorPlugin configuratorPlugin;
try {
IOrchestratorPlugin<Object> orchestratorInstance = orchestratorPluginService.getOrFail(location.getOrchestratorId());
configuratorPlugin = orchestratorInstance.getConfigurator(location.getInfrastructureType());
} catch (OrchestratorDisabledException e) {
IOrchestratorPluginFactory orchestratorFactory = orchestratorService.getPluginFactory(orchestratorService.getOrFail(location.getOrchestratorId()));
IOrchestratorPlugin<Object> orchestratorInstance = orchestratorFactory.newInstance();
configuratorPlugin = orchestratorInstance.getConfigurator(location.getInfrastructureType());
orchestratorFactory.destroy(orchestratorInstance);
}
return configuratorPlugin;
}
use of alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory in project alien4cloud by alien4cloud.
the class PluginArchiveIndexer method publishLocationTypeIndexedEvent.
private void publishLocationTypeIndexedEvent(Collection<NodeType> collection, Orchestrator orchestrator, Location location) {
IOrchestratorPluginFactory orchestratorFactory = orchestratorService.getPluginFactory(orchestrator);
publishLocationTypeIndexedEvent(collection, orchestratorFactory, location);
}
use of alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory in project alien4cloud by alien4cloud.
the class OrchestratorService method getArtifactSupport.
/**
* Get the artifact support information for a given orchestrator.
*
* @param orchestratorId The id of the orchestrator for which to get location support information.
* @return artifact support information.
*/
public ArtifactSupport getArtifactSupport(String orchestratorId) {
Orchestrator orchestrator = getOrFail(orchestratorId);
IOrchestratorPluginFactory orchestratorFactory = getPluginFactory(orchestrator);
return orchestratorFactory.getArtifactSupport();
}
use of alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory in project alien4cloud by alien4cloud.
the class OrchestratorStateService method disable.
/**
* Disable an orchestrator.
*
* @param orchestrator The orchestrator to disable.
* @param force If true the orchestrator is disabled even if some deployments are currently running.
*/
public synchronized List<Usage> disable(Orchestrator orchestrator, boolean force) {
if (!force) {
// If there is at least one active deployment.
GetMultipleDataResult<Deployment> result = alienDAO.buildQuery(Deployment.class).setFilters(MapUtil.newHashMap(new String[] { "orchestratorId", "endDate" }, new String[][] { new String[] { orchestrator.getId() }, new String[] { null } })).prepareSearch().setFieldSort("_timestamp", true).search(0, 1);
// TODO place a lock to avoid deployments during the disabling of the orchestrator.
if (result.getData().length > 0) {
List<Usage> usages = generateDeploymentUsages(result.getData());
return usages;
}
}
try {
// unregister the orchestrator.
IOrchestratorPlugin orchestratorInstance = orchestratorPluginService.unregister(orchestrator.getId());
if (orchestratorInstance != null) {
IOrchestratorPluginFactory orchestratorFactory = orchestratorService.getPluginFactory(orchestrator);
orchestratorFactory.destroy(orchestratorInstance);
}
} catch (Exception e) {
log.info("Unable to destroy orchestrator, it may not be created yet", e);
} finally {
// Mark the orchestrator as disabled
orchestrator.setState(OrchestratorState.DISABLED);
alienDAO.save(orchestrator);
}
return null;
}
Aggregations