Search in sources :

Example 1 with IOrchestratorPluginFactory

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());
    ;
}
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)

Example 2 with IOrchestratorPluginFactory

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;
}
Also used : IOrchestratorPluginFactory(alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory) ILocationConfiguratorPlugin(alien4cloud.orchestrators.plugin.ILocationConfiguratorPlugin) OrchestratorDisabledException(alien4cloud.paas.exception.OrchestratorDisabledException) IOrchestratorPlugin(alien4cloud.orchestrators.plugin.IOrchestratorPlugin)

Example 3 with IOrchestratorPluginFactory

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);
}
Also used : IOrchestratorPluginFactory(alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory)

Example 4 with IOrchestratorPluginFactory

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

Example 5 with IOrchestratorPluginFactory

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;
}
Also used : IOrchestratorPluginFactory(alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory) Usage(alien4cloud.model.common.Usage) Deployment(alien4cloud.model.deployment.Deployment) AlreadyExistException(alien4cloud.exception.AlreadyExistException) IOException(java.io.IOException) PluginConfigurationException(alien4cloud.paas.exception.PluginConfigurationException) IOrchestratorPlugin(alien4cloud.orchestrators.plugin.IOrchestratorPlugin)

Aggregations

IOrchestratorPluginFactory (alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory)13 Orchestrator (alien4cloud.model.orchestrators.Orchestrator)7 IOrchestratorPlugin (alien4cloud.orchestrators.plugin.IOrchestratorPlugin)6 OrchestratorConfiguration (alien4cloud.model.orchestrators.OrchestratorConfiguration)4 ILocationConfiguratorPlugin (alien4cloud.orchestrators.plugin.ILocationConfiguratorPlugin)3 AlreadyExistException (alien4cloud.exception.AlreadyExistException)2 Usage (alien4cloud.model.common.Usage)2 PluginConfigurationException (alien4cloud.paas.exception.PluginConfigurationException)2 IOException (java.io.IOException)2 Test (org.junit.Test)2 LocationArchiveDeleteRequested (alien4cloud.events.LocationArchiveDeleteRequested)1 LocationTemplateCreated (alien4cloud.events.LocationTemplateCreated)1 Deployment (alien4cloud.model.deployment.Deployment)1 Location (alien4cloud.model.orchestrators.locations.Location)1 LocationResourceTemplate (alien4cloud.model.orchestrators.locations.LocationResourceTemplate)1 ILocationAutoConfigurer (alien4cloud.orchestrators.plugin.ILocationAutoConfigurer)1 ILocationResourceAccessor (alien4cloud.orchestrators.plugin.ILocationResourceAccessor)1 PluginArchive (alien4cloud.orchestrators.plugin.model.PluginArchive)1 OrchestratorDisabledException (alien4cloud.paas.exception.OrchestratorDisabledException)1 ArrayList (java.util.ArrayList)1