use of org.alien4cloud.tosca.model.types.NodeType in project alien4cloud by alien4cloud.
the class MockPaaSProvider method switchMaintenanceMode.
@Override
public void switchMaintenanceMode(PaaSDeploymentContext deploymentContext, boolean maintenanceModeOn) {
String deploymentPaaSId = deploymentContext.getDeploymentPaaSId();
MockRuntimeDeploymentInfo runtimeDeploymentInfo = runtimeDeploymentInfos.get(deploymentContext.getDeploymentPaaSId());
Topology topology = runtimeDeploymentInfo.getDeploymentContext().getDeploymentTopology();
Map<String, Map<String, InstanceInformation>> nodes = runtimeDeploymentInfo.getInstanceInformations();
if (nodes == null || nodes.isEmpty()) {
return;
}
for (Entry<String, Map<String, InstanceInformation>> nodeEntry : nodes.entrySet()) {
String nodeTemplateId = nodeEntry.getKey();
Map<String, InstanceInformation> nodeInstances = nodeEntry.getValue();
if (nodeInstances != null && !nodeInstances.isEmpty()) {
NodeTemplate nodeTemplate = topology.getNodeTemplates().get(nodeTemplateId);
NodeType nodeType = toscaTypeSearchService.getRequiredElementInDependencies(NodeType.class, nodeTemplate.getType(), topology.getDependencies());
if (ToscaTypeUtils.isOfType(nodeType, NormativeComputeConstants.COMPUTE_TYPE)) {
for (Entry<String, InstanceInformation> nodeInstanceEntry : nodeInstances.entrySet()) {
String instanceId = nodeInstanceEntry.getKey();
InstanceInformation instanceInformation = nodeInstanceEntry.getValue();
if (instanceInformation != null) {
switchInstanceMaintenanceMode(deploymentPaaSId, nodeTemplateId, instanceId, instanceInformation, maintenanceModeOn);
}
}
}
}
}
}
use of org.alien4cloud.tosca.model.types.NodeType 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 org.alien4cloud.tosca.model.types.NodeType in project alien4cloud by alien4cloud.
the class LocationResourceService method addResourceTemplate.
private LocationResourceTemplate addResourceTemplate(Location location, String resourceName, String resourceTypeName) {
NodeType resourceType = csarRepoSearchService.getRequiredElementInDependencies(NodeType.class, resourceTypeName, location.getDependencies());
NodeTemplate nodeTemplate = templateBuilder.buildNodeTemplate(location.getDependencies(), resourceType);
LocationResourceTemplate locationResourceTemplate = new LocationResourceTemplate();
locationResourceTemplate.setGenerated(false);
fillAndSaveLocationResourceTemplate(location, resourceName, locationResourceTemplate, resourceType, nodeTemplate);
return locationResourceTemplate;
}
use of org.alien4cloud.tosca.model.types.NodeType in project alien4cloud by alien4cloud.
the class PluginArchiveIndexer method publishLocationTypeIndexedEvent.
private void publishLocationTypeIndexedEvent(Collection<NodeType> collection, IOrchestratorPluginFactory orchestratorFactory, Location location) {
if (CollectionUtils.isNotEmpty(collection)) {
for (NodeType nodeType : collection) {
LocationTypeIndexed event = new LocationTypeIndexed(this);
event.setNodeType(nodeType);
event.setLocation(location);
event.setOrchestratorFactory(orchestratorFactory);
applicationContext.publishEvent(event);
}
}
}
use of org.alien4cloud.tosca.model.types.NodeType in project alien4cloud by alien4cloud.
the class LocationResourceGeneratorService method generateComputeFromImageAndFlavor.
/**
* Generate resources of type compute given a set of images and flavors
*
* @param imageContext
* @param flavorContext
* @param linuxComputeContext
* @param windowsComputeContext
* @param resourceAccessor
* @return
*/
public List<LocationResourceTemplate> generateComputeFromImageAndFlavor(ImageFlavorContext imageContext, ImageFlavorContext flavorContext, ComputeContext linuxComputeContext, ComputeContext windowsComputeContext, ILocationResourceAccessor resourceAccessor) {
List<LocationResourceTemplate> images = imageContext.getTemplates();
List<LocationResourceTemplate> flavors = flavorContext.getTemplates();
Set<CSARDependency> dependencies = resourceAccessor.getDependencies();
List<LocationResourceTemplate> generated = Lists.newArrayList();
for (LocationResourceTemplate image : images) {
for (LocationResourceTemplate flavor : flavors) {
String defaultComputeName = generateDefaultName(image, flavor);
int count = 0;
ComputeContext computeContext = isWindowsImage(image) && windowsComputeContext != null ? windowsComputeContext : linuxComputeContext;
for (NodeType indexedNodeType : computeContext.getNodeTypes()) {
String name = StringUtils.isNotBlank(computeContext.getGeneratedNamePrefix()) ? computeContext.getGeneratedNamePrefix() : defaultComputeName;
if (count > 0) {
name = name + "_" + count;
}
NodeTemplate node = templateBuilder.buildNodeTemplate(dependencies, indexedNodeType);
// set the imageId
node.getProperties().put(computeContext.getImageIdPropertyName(), image.getTemplate().getProperties().get(imageContext.getIdPropertyName()));
// set the flavorId
node.getProperties().put(computeContext.getFlavorIdPropertyName(), flavor.getTemplate().getProperties().get(flavorContext.getIdPropertyName()));
// copy os and host capabilities properties
copyCapabilityBasedOnTheType(image.getTemplate(), node, "os");
copyCapabilityBasedOnTheType(flavor.getTemplate(), node, "host");
LocationResourceTemplate resource = new LocationResourceTemplate();
resource.setService(false);
resource.setTemplate(node);
resource.setName(name);
count++;
generated.add(resource);
}
}
}
return generated;
}
Aggregations