use of alien4cloud.orchestrators.plugin.IOrchestratorPlugin in project alien4cloud by alien4cloud.
the class PluginArchiveIndexer method getArchivesToIndex.
/**
* From all exposed plugin archives of the location, get the one that are not yet indexed
*
* @param orchestrator
* @param location
* @return an object of type {@link ArchiveToIndex} with the indexable archives and the full list of dependencies
*/
private ArchiveToIndex getArchivesToIndex(Orchestrator orchestrator, Location location) {
Set<CSARDependency> dependencies = Sets.newHashSet();
IOrchestratorPlugin orchestratorInstance = (IOrchestratorPlugin) orchestratorPluginService.getOrFail(orchestrator.getId());
ILocationConfiguratorPlugin configuratorPlugin = orchestratorInstance.getConfigurator(location.getInfrastructureType());
List<PluginArchive> allPluginArchives = configuratorPlugin.pluginArchives();
Set<PluginArchive> archivesToIndex = Sets.newHashSet();
for (PluginArchive pluginArchive : safe(allPluginArchives)) {
ArchiveRoot archive = pluginArchive.getArchive();
Csar csar = csarService.get(archive.getArchive().getName(), archive.getArchive().getVersion());
String lastParsedHash = null;
if (csar == null) {
// the archive does not exist into the repository: should be indexed
lastParsedHash = archive.getArchive().getHash();
archivesToIndex.add(pluginArchive);
} else {
// Else, just take the hash
lastParsedHash = csar.getHash();
}
if (archive.getArchive().getDependencies() != null) {
dependencies.addAll(archive.getArchive().getDependencies());
}
dependencies.add(new CSARDependency(archive.getArchive().getName(), archive.getArchive().getVersion(), lastParsedHash));
}
return new ArchiveToIndex(dependencies, archivesToIndex);
}
use of alien4cloud.orchestrators.plugin.IOrchestratorPlugin 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