use of org.alien4cloud.tosca.model.CSARDependency in project alien4cloud by alien4cloud.
the class ToscaArchiveParser method initDependencyBeanFromToscaMeta.
private CsarDependenciesBean initDependencyBeanFromToscaMeta(ToscaMeta toscaMeta) {
CsarDependenciesBean csarDependenciesBean = new CsarDependenciesBean();
csarDependenciesBean.setSelf(new CSARDependency(toscaMeta.getName(), toscaMeta.getVersion()));
return csarDependenciesBean;
}
use of org.alien4cloud.tosca.model.CSARDependency in project alien4cloud by alien4cloud.
the class NodeTemplateUtilsTest method getCapabilityByTypeTest.
@Test
public void getCapabilityByTypeTest() {
NodeTemplate nodeTemplate = new NodeTemplate();
Capability nodeCapability = new Capability("org.alien4cloud.capabilities.SampleCapability", null);
nodeTemplate.setCapabilities(Maps.newHashMap("test", nodeCapability));
// if the capability type exactly equals then no tosca context and request is required
Capability capability = getCapabilityByType(nodeTemplate, "org.alien4cloud.capabilities.SampleCapability");
assertSame(nodeCapability, capability);
// if the capability derives from parent type then a TOSCA context and query is required to fetch the type.
CapabilityType capabilityType = new CapabilityType();
capabilityType.setElementId("org.alien4cloud.capabilities.SampleCapability");
capabilityType.setDerivedFrom(Lists.newArrayList("org.alien4cloud.capabilities.TestCapability"));
Mockito.reset(csarRepositorySearchService);
Mockito.when(csarRepositorySearchService.getElementInDependencies(Mockito.eq(CapabilityType.class), Mockito.eq("org.alien4cloud.capabilities.SampleCapability"), Mockito.any(Set.class))).thenReturn(capabilityType);
capability = toscaContextualAspect.execInToscaContext(() -> getCapabilityByType(nodeTemplate, "org.alien4cloud.capabilities.TestCapability"), false, Sets.newHashSet(new CSARDependency("org.alien4cloud.testArchive", "1.0.0-SNAPSHOT")));
assertSame(nodeCapability, capability);
}
use of org.alien4cloud.tosca.model.CSARDependency in project alien4cloud by alien4cloud.
the class NodeTemplateUtilsTest method getMissingCapabilityByTypeTest.
@Test
public void getMissingCapabilityByTypeTest() {
NodeTemplate nodeTemplate = new NodeTemplate();
Capability nodeCapability = new Capability("org.alien4cloud.capabilities.SampleCapability", null);
nodeTemplate.setCapabilities(Maps.newHashMap("test", nodeCapability));
// if the capability derives from parent type then a TOSCA context and query is required to fetch the type.
CapabilityType capabilityType = new CapabilityType();
capabilityType.setElementId("org.alien4cloud.capabilities.SampleCapability");
capabilityType.setDerivedFrom(Lists.newArrayList("org.alien4cloud.capabilities.TestCapability"));
Mockito.reset(csarRepositorySearchService);
Mockito.when(csarRepositorySearchService.getElementInDependencies(Mockito.eq(CapabilityType.class), Mockito.eq("org.alien4cloud.capabilities.SampleCapability"), Mockito.any(Set.class))).thenReturn(capabilityType);
Capability capability = toscaContextualAspect.execInToscaContext(() -> getCapabilityByType(nodeTemplate, "org.alien4cloud.capabilities.Unknown"), false, Sets.newHashSet(new CSARDependency("org.alien4cloud.testArchive", "1.0.0-SNAPSHOT")));
assertNull(capability);
}
use of org.alien4cloud.tosca.model.CSARDependency in project alien4cloud by alien4cloud.
the class DeploymentTopologyDTOBuilder method enrichSubstitutionTypesWithServicesDependencies.
/**
* Enrich {@link LocationResourceTypes} adding types coming from on demand service resources.
*/
private void enrichSubstitutionTypesWithServicesDependencies(Collection<LocationResourceTemplate> resourceTemplates, LocationResourceTypes locationResourceTypes) {
Set<String> serviceTypes = Sets.newHashSet();
Set<CSARDependency> dependencies = Sets.newHashSet();
for (LocationResourceTemplate resourceTemplate : resourceTemplates) {
if (resourceTemplate.isService()) {
String serviceId = resourceTemplate.getId();
ServiceResource serviceResource = serviceResourceService.getOrFail(serviceId);
NodeType serviceType = ToscaContext.get(NodeType.class, serviceResource.getNodeInstance().getNodeTemplate().getType());
if (serviceType == null || !serviceType.getArchiveVersion().equals(serviceResource.getNodeInstance().getTypeVersion())) {
serviceType = toscaTypeSearchService.findOrFail(NodeType.class, serviceResource.getNodeInstance().getNodeTemplate().getType(), serviceResource.getNodeInstance().getTypeVersion());
}
dependencies.addAll(csarDependencyLoader.getDependencies(serviceType.getArchiveName(), serviceType.getArchiveVersion()));
dependencies.add(new CSARDependency(serviceType.getArchiveName(), serviceType.getArchiveVersion()));
serviceTypes.add(serviceResource.getNodeInstance().getNodeTemplate().getType());
}
}
locationResourceService.fillLocationResourceTypes(serviceTypes, locationResourceTypes, dependencies);
}
use of org.alien4cloud.tosca.model.CSARDependency 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);
}
Aggregations