use of alien4cloud.model.orchestrators.locations.Location in project yorc-a4c-plugin by ystia.
the class DeployTask method buildZip.
/**
* Create the zip for yorc, with a modified yaml and all needed archives.
* Assumes a file original.yml exists in the current directory
* @param ctx all needed information about the deployment
* @throws IOException
*/
private void buildZip(PaaSTopologyDeploymentContext ctx) throws IOException {
// Check location
int location = LOC_OPENSTACK;
Location loc = ctx.getLocations().get("_A4C_ALL");
Set<CSARDependency> locdeps = loc.getDependencies();
for (CSARDependency dep : locdeps) {
if (dep.getName().contains("kubernetes")) {
location = LOC_KUBERNETES;
break;
}
if (dep.getName().contains("slurm")) {
location = LOC_SLURM;
break;
}
if (dep.getName().contains("aws")) {
location = LOC_AWS;
break;
}
}
// Final zip file will be named topology.zip
final File zip = new File("topology.zip");
final OutputStream out = new FileOutputStream(zip);
final ZipOutputStream zout = new ZipOutputStream(out);
final Closeable res = zout;
final int finalLocation = location;
this.ctx.getDeploymentTopology().getDependencies().forEach(d -> {
if (!"tosca-normative-types".equals(d.getName())) {
Csar csar = csarRepoSearchService.getArchive(d.getName(), d.getVersion());
if (CSARSource.ORCHESTRATOR != CSARSource.valueOf(csar.getImportSource())) {
try {
csar2zip(zout, csar, finalLocation);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
});
// Copy overwritten artifacts for each node
PaaSTopology ptopo = ctx.getPaaSTopology();
for (PaaSNodeTemplate node : ptopo.getAllNodes().values()) {
copyArtifacts(node, zout);
}
String topoFileName = "topology.yml";
// Copy modified topology
createZipEntries(topoFileName, zout);
// Get the yaml of the application as built by from a4c
DeploymentTopology dtopo = ctx.getDeploymentTopology();
Csar myCsar = new Csar(ctx.getDeploymentPaaSId(), dtopo.getArchiveVersion());
myCsar.setToscaDefinitionsVersion(ToscaParser.LATEST_DSL);
String yaml = orchestrator.getToscaTopologyExporter().getYaml(myCsar, dtopo, true);
zout.write(yaml.getBytes(Charset.forName("UTF-8")));
zout.closeEntry();
res.close();
}
use of alien4cloud.model.orchestrators.locations.Location in project alien4cloud by alien4cloud.
the class AlienContextVariablesTest method setUp.
@Before
public void setUp() throws Exception {
alienContextVariables = new AlienContextVariables();
Application app = new Application();
app.setTags(Arrays.asList(new Tag("tagName", "tagValue"), new Tag("yolo", "oloy")));
app.setMetaProperties(ImmutableMap.of("meta1", "meta1 value", "meta2", "meta2 value"));
alienContextVariables.setApplication(app);
Location location = new Location();
location.setMetaProperties(ImmutableMap.of("loc_meta1", "meta1 value", "loc_meta2", "meta2 value"));
alienContextVariables.setLocation(location);
}
use of alien4cloud.model.orchestrators.locations.Location in project alien4cloud by alien4cloud.
the class LocationResourceService method setTemplateCapabilityProperty.
private void setTemplateCapabilityProperty(LocationResourceTemplate resourceTemplate, String capabilityName, String propertyName, Object propertyValue) throws ConstraintViolationException, ConstraintValueDoNotMatchPropertyTypeException {
Location location = locationService.getOrFail(resourceTemplate.getLocationId());
NodeType resourceType = csarRepoSearchService.getRequiredElementInDependencies(NodeType.class, resourceTemplate.getTemplate().getType(), location.getDependencies());
Capability capability = getOrFailCapability(resourceTemplate.getTemplate(), capabilityName);
CapabilityDefinition capabilityDefinition = getOrFailCapabilityDefinition(resourceType, capabilityName);
CapabilityType capabilityType = csarRepoSearchService.getRequiredElementInDependencies(CapabilityType.class, capabilityDefinition.getType(), location.getDependencies());
PropertyDefinition propertyDefinition = getOrFailCapabilityPropertyDefinition(capabilityType, propertyName);
propertyService.setCapabilityPropertyValue(location.getDependencies(), capability, propertyDefinition, propertyName, propertyValue);
}
use of alien4cloud.model.orchestrators.locations.Location in project alien4cloud by alien4cloud.
the class LocationResourceService method deleteResourceTemplate.
/*
* (non-Javadoc)
*
* @see alien4cloud.orchestrators.locations.services.ILocationResourceService#deleteResourceTemplate(Class, String)
*/
@Override
public void deleteResourceTemplate(String resourceId) {
AbstractLocationResourceTemplate resourceTemplate = getOrFail(resourceId);
Location location = locationService.getOrFail(resourceTemplate.getLocationId());
alienDAO.delete(resourceTemplate.getClass(), resourceId);
refreshDependencies(location);
alienDAO.save(location);
}
use of alien4cloud.model.orchestrators.locations.Location in project alien4cloud by alien4cloud.
the class LocationResourceService method updateLocationDependencies.
private Location updateLocationDependencies(String locationId, String archiveName, String archiveVersion) {
Location location = locationService.getOrFail(locationId);
// If an archive is specified, update the location dependencies accordingly. Dependencies are in a Set so there is no duplication issue.
if (!(StringUtils.isEmpty(archiveName) && StringUtils.isEmpty(archiveVersion))) {
Optional.ofNullable(csarRepoSearchService.getArchive(archiveName, archiveVersion)).map(Csar::getDependencies).ifPresent(csarDependencies -> location.getDependencies().addAll(csarDependencies));
// Add the archive as dependency too
final CSARDependency archive = new CSARDependency(archiveName, archiveVersion);
location.getDependencies().add(archive);
}
return location;
}
Aggregations