Search in sources :

Example 1 with Orchestrator

use of alien4cloud.model.orchestrators.Orchestrator in project alien4cloud by alien4cloud.

the class OrchestratorDaoTest method getEnabledOrchestratorTest.

@Test
public void getEnabledOrchestratorTest() throws NoSuchFieldException, IllegalAccessException {
    Orchestrator orchestrator = new Orchestrator();
    orchestrator.setId("a");
    orchestrator.setState(OrchestratorState.DISABLED);
    dao.save(orchestrator);
    orchestrator.setId("b");
    orchestrator.setState(OrchestratorState.CONNECTED);
    dao.save(orchestrator);
    List<Orchestrator> enabledOrchestrators = orchestratorService.getAllEnabledOrchestrators();
    System.out.println(enabledOrchestrators.size());
// alienDAO
}
Also used : Orchestrator(alien4cloud.model.orchestrators.Orchestrator) Test(org.junit.Test) AbstractDAOTest(alien4cloud.component.dao.AbstractDAOTest)

Example 2 with Orchestrator

use of alien4cloud.model.orchestrators.Orchestrator 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 3 with Orchestrator

use of alien4cloud.model.orchestrators.Orchestrator in project alien4cloud by alien4cloud.

the class LocationResourceService method getLocationResourcesFromOrchestrator.

/*
     * (non-Javadoc)
     * 
     * @see
     * alien4cloud.orchestrators.locations.services.ILocationResourceService#getLocationResourcesFromOrchestrator(alien4cloud.model.orchestrators.locations.
     * Location)
     */
@Override
public LocationResources getLocationResourcesFromOrchestrator(Location location) {
    LocationResources locationResources = new LocationResources();
    Orchestrator orchestrator = orchestratorService.getOrFail(location.getOrchestratorId());
    IOrchestratorPlugin orchestratorInstance = orchestratorPluginService.getOrFail(orchestrator.getId());
    ILocationConfiguratorPlugin configuratorPlugin = orchestratorInstance.getConfigurator(location.getInfrastructureType());
    fillLocationResourceTypes(configuratorPlugin.getResourcesTypes(), locationResources, location.getDependencies());
    fillPoliciesLocationResourceTypes(configuratorPlugin.getPoliciesTypes(), locationResources, location.getDependencies());
    // add LocationResourceTemplate
    List<LocationResourceTemplate> locationResourceTemplates = getResourcesTemplates(location.getId());
    setLocationRessource(locationResourceTemplates, locationResources);
    // add PolicyLocationResourceTemplate
    locationResources.getPolicyTemplates().addAll(getPoliciesResourcesTemplates(location.getId()));
    return locationResources;
}
Also used : LocationResources(alien4cloud.model.orchestrators.locations.LocationResources) ILocationConfiguratorPlugin(alien4cloud.orchestrators.plugin.ILocationConfiguratorPlugin) PolicyLocationResourceTemplate(alien4cloud.model.orchestrators.locations.PolicyLocationResourceTemplate) AbstractLocationResourceTemplate(alien4cloud.model.orchestrators.locations.AbstractLocationResourceTemplate) LocationResourceTemplate(alien4cloud.model.orchestrators.locations.LocationResourceTemplate) Orchestrator(alien4cloud.model.orchestrators.Orchestrator) IOrchestratorPlugin(alien4cloud.orchestrators.plugin.IOrchestratorPlugin)

Example 4 with Orchestrator

use of alien4cloud.model.orchestrators.Orchestrator in project alien4cloud by alien4cloud.

the class LocationResourceService method getLocationResources.

/*
     * (non-Javadoc)
     *
     * @see alien4cloud.orchestrators.locations.services.ILocationResourceService#getLocationResources(alien4cloud.model.orchestrators.locations.Location)
     */
@Override
public LocationResources getLocationResources(Location location) {
    Orchestrator orchestrator = orchestratorService.get(location.getOrchestratorId());
    Optional<LocationResources> locationResourcesFromOrchestrator = Optional.empty();
    if (orchestrator != null && orchestratorPluginService.get(orchestrator.getId()) != null) {
        locationResourcesFromOrchestrator = Optional.ofNullable(getLocationResourcesFromOrchestrator(location));
    }
    // Also get resource templates from outside of the orchestrator definition - eg custom resources
    List<LocationResourceTemplate> locationResourceTemplates = getResourcesTemplates(location.getId());
    LocationResources locationResources = new LocationResources(getLocationResourceTypes(locationResourceTemplates));
    // process policies types also
    List<PolicyLocationResourceTemplate> policyLocationResourceTemplates = getPoliciesResourcesTemplates(location.getId());
    locationResources.addFrom(getPoliciesLocationResourceTypes(policyLocationResourceTemplates));
    /*
         * If the orchestrator is present, take node types computed from the resources template
         * as "Custom resources types". If not, consider this is an orchestrator-free location.
         */
    locationResourcesFromOrchestrator.ifPresent(orchestratorResources -> {
        locationResources.getCapabilityTypes().putAll(orchestratorResources.getCapabilityTypes());
        locationResources.getConfigurationTypes().putAll(orchestratorResources.getConfigurationTypes());
        locationResources.getNodeTypes().putAll(orchestratorResources.getNodeTypes());
        locationResources.getProvidedTypes().addAll(orchestratorResources.getNodeTypes().keySet());
        locationResources.getAllNodeTypes().putAll(orchestratorResources.getAllNodeTypes());
        locationResources.getOnDemandTypes().putAll(orchestratorResources.getOnDemandTypes());
        locationResources.getPolicyTypes().putAll(orchestratorResources.getPolicyTypes());
    });
    setLocationRessource(locationResourceTemplates, locationResources);
    locationResources.getPolicyTemplates().addAll(policyLocationResourceTemplates);
    return locationResources;
}
Also used : LocationResources(alien4cloud.model.orchestrators.locations.LocationResources) PolicyLocationResourceTemplate(alien4cloud.model.orchestrators.locations.PolicyLocationResourceTemplate) AbstractLocationResourceTemplate(alien4cloud.model.orchestrators.locations.AbstractLocationResourceTemplate) LocationResourceTemplate(alien4cloud.model.orchestrators.locations.LocationResourceTemplate) Orchestrator(alien4cloud.model.orchestrators.Orchestrator) PolicyLocationResourceTemplate(alien4cloud.model.orchestrators.locations.PolicyLocationResourceTemplate)

Example 5 with Orchestrator

use of alien4cloud.model.orchestrators.Orchestrator in project alien4cloud by alien4cloud.

the class LocationService method autoConfigure.

/**
 * Trigger plugin auto-configuration for the given location.
 *
 * @param locationId Id of the location.
 */
public List<LocationResourceTemplate> autoConfigure(String locationId) throws UnsupportedOperationException {
    Location location = getOrFail(locationId);
    Orchestrator orchestrator = orchestratorService.getOrFail(location.getOrchestratorId());
    List<LocationResourceTemplate> generatedLocationResources = autoConfigure(orchestrator, location);
    if (CollectionUtils.isEmpty(generatedLocationResources)) {
        generatedLocationResources = Lists.newArrayList();
    }
    return generatedLocationResources;
}
Also used : LocationResourceTemplate(alien4cloud.model.orchestrators.locations.LocationResourceTemplate) Orchestrator(alien4cloud.model.orchestrators.Orchestrator) Location(alien4cloud.model.orchestrators.locations.Location)

Aggregations

Orchestrator (alien4cloud.model.orchestrators.Orchestrator)28 IOrchestratorPluginFactory (alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory)7 Location (alien4cloud.model.orchestrators.locations.Location)6 IOrchestratorPlugin (alien4cloud.orchestrators.plugin.IOrchestratorPlugin)5 ApiOperation (io.swagger.annotations.ApiOperation)4 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 OrchestratorConfiguration (alien4cloud.model.orchestrators.OrchestratorConfiguration)3 LocationResourceTemplate (alien4cloud.model.orchestrators.locations.LocationResourceTemplate)3 Test (org.junit.Test)3 Audit (alien4cloud.audit.annotation.Audit)2 GetMultipleDataResult (alien4cloud.dao.model.GetMultipleDataResult)2 ILocationMatch (alien4cloud.model.deployment.matching.ILocationMatch)2 LocationMatch (alien4cloud.model.deployment.matching.LocationMatch)2 AbstractLocationResourceTemplate (alien4cloud.model.orchestrators.locations.AbstractLocationResourceTemplate)2 LocationResources (alien4cloud.model.orchestrators.locations.LocationResources)2 PolicyLocationResourceTemplate (alien4cloud.model.orchestrators.locations.PolicyLocationResourceTemplate)2 ILocationConfiguratorPlugin (alien4cloud.orchestrators.plugin.ILocationConfiguratorPlugin)2 LocationMatchingException (alien4cloud.paas.exception.LocationMatchingException)2 LocationPolicyTask (alien4cloud.topology.task.LocationPolicyTask)2