Search in sources :

Example 21 with IOrchestratorPlugin

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);
}
Also used : Csar(org.alien4cloud.tosca.model.Csar) ArchiveRoot(alien4cloud.tosca.model.ArchiveRoot) ILocationConfiguratorPlugin(alien4cloud.orchestrators.plugin.ILocationConfiguratorPlugin) PluginArchive(alien4cloud.orchestrators.plugin.model.PluginArchive) CSARDependency(org.alien4cloud.tosca.model.CSARDependency) IOrchestratorPlugin(alien4cloud.orchestrators.plugin.IOrchestratorPlugin)

Example 22 with IOrchestratorPlugin

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));
}
Also used : IOrchestratorPluginFactory(alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory) Orchestrator(alien4cloud.model.orchestrators.Orchestrator) OrchestratorConfiguration(alien4cloud.model.orchestrators.OrchestratorConfiguration) IOrchestratorPlugin(alien4cloud.orchestrators.plugin.IOrchestratorPlugin) Test(org.junit.Test)

Aggregations

IOrchestratorPlugin (alien4cloud.orchestrators.plugin.IOrchestratorPlugin)22 DeploymentTopology (alien4cloud.model.deployment.DeploymentTopology)6 IOrchestratorPluginFactory (alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory)6 Deployment (alien4cloud.model.deployment.Deployment)5 Orchestrator (alien4cloud.model.orchestrators.Orchestrator)5 ILocationConfiguratorPlugin (alien4cloud.orchestrators.plugin.ILocationConfiguratorPlugin)5 PaaSDeploymentContext (alien4cloud.paas.model.PaaSDeploymentContext)5 Location (alien4cloud.model.orchestrators.locations.Location)4 OrchestratorConfiguration (alien4cloud.model.orchestrators.OrchestratorConfiguration)3 IPaaSCallback (alien4cloud.paas.IPaaSCallback)3 PaaSTopologyDeploymentContext (alien4cloud.paas.model.PaaSTopologyDeploymentContext)3 Map (java.util.Map)3 SecretProviderConfigurationAndCredentials (alien4cloud.deployment.model.SecretProviderConfigurationAndCredentials)2 LocationResourceTemplate (alien4cloud.model.orchestrators.locations.LocationResourceTemplate)2 Test (org.junit.Test)2 DeploymentCreatedEvent (alien4cloud.events.DeploymentCreatedEvent)1 LocationTemplateCreated (alien4cloud.events.LocationTemplateCreated)1 AlreadyExistException (alien4cloud.exception.AlreadyExistException)1 NotFoundException (alien4cloud.exception.NotFoundException)1 Usage (alien4cloud.model.common.Usage)1