Skip to content

Commit

Permalink
[ALIEN-499] - fixed Custom compute derived from Based Compute cannot …
Browse files Browse the repository at this point in the history
…scale
  • Loading branch information
Igor Ngouagna committed Nov 5, 2014
1 parent 4ce3fe3 commit 251a50d
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public CloudResourceTopologyMatchResult matchTopology(Topology topology, Cloud c
Map<String, CloudImageFlavor> flavorMap = Maps.newHashMap();
for (Map.Entry<String, NodeTemplate> templateEntry : matchableNodes.entrySet()) {
List<ComputeTemplate> computeTemplates = Lists.newArrayList();
List<CloudImage> images = getAvailableImagesForCompute(cloud, templateEntry.getValue());
List<CloudImage> images = getAvailableImagesForCompute(cloud, templateEntry.getValue(), types.get(templateEntry.getKey()));
for (CloudImage image : images) {
List<CloudImageFlavor> flavors = getAvailableFlavorForCompute(cloud, templateEntry.getValue(), image);
boolean templateAdded = false;
Expand Down Expand Up @@ -99,7 +99,7 @@ private Map<String, NodeTemplate> getMatchableTemplates(Topology topology, Map<S
return matchableNodeTemplates;
}
for (Map.Entry<String, NodeTemplate> nodeTemplateEntry : allNodeTemplates.entrySet()) {
if (toscaService.isCompute(nodeTemplateEntry.getValue().getType(), types.get(nodeTemplateEntry.getKey()))) {
if (toscaService.isOfType(NormativeComputeConstants.COMPUTE_TYPE, types.get(nodeTemplateEntry.getKey()))) {
// TODO check also network and other cloud related resources ...
matchableNodeTemplates.put(nodeTemplateEntry.getKey(), nodeTemplateEntry.getValue());
}
Expand All @@ -114,8 +114,8 @@ private Map<String, NodeTemplate> getMatchableTemplates(Topology topology, Map<S
* @param nodeTemplate the compute to search for images
* @return the available images on the cloud
*/
private List<CloudImage> getAvailableImagesForCompute(Cloud cloud, NodeTemplate nodeTemplate) {
if (!NormativeComputeConstants.COMPUTE_TYPE.equals(nodeTemplate.getType())) {
private List<CloudImage> getAvailableImagesForCompute(Cloud cloud, NodeTemplate nodeTemplate, IndexedNodeType nodeType) {
if (!toscaService.isOfType(NormativeComputeConstants.COMPUTE_TYPE, nodeType)) {
throw new InvalidArgumentException("Node is not a compute but of type [" + nodeTemplate.getType() + "]");
}
Map<String, String> computeTemplateProperties = nodeTemplate.getProperties();
Expand Down Expand Up @@ -166,9 +166,6 @@ public int compare(CloudImage left, CloudImage right) {
* @return the available flavors for the compute and the image on the given cloud
*/
private List<CloudImageFlavor> getAvailableFlavorForCompute(Cloud cloud, NodeTemplate nodeTemplate, CloudImage cloudImage) {
if (!NormativeComputeConstants.COMPUTE_TYPE.equals(nodeTemplate.getType())) {
throw new InvalidArgumentException("Node is not a compute but of type [" + nodeTemplate.getType() + "]");
}
Map<String, CloudImageFlavor> allFlavors = Maps.newHashMap();
for (CloudImageFlavor flavor : cloud.getFlavors()) {
allFlavors.put(flavor.getId(), flavor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@

import org.springframework.stereotype.Component;

import alien4cloud.component.model.IndexedNodeType;
import alien4cloud.tosca.container.model.NormativeComputeConstants;
import alien4cloud.component.model.IndexedInheritableToscaElement;

@Component
public class ToscaService {

public boolean isCompute(String nodeTypeName, IndexedNodeType nodeType) {
if (NormativeComputeConstants.COMPUTE_TYPE.equals(nodeTypeName)) {
return true;
} else {
return nodeType.getDerivedFrom() != null && nodeType.getDerivedFrom().contains(NormativeComputeConstants.COMPUTE_TYPE);
}
public boolean isOfType(String type, IndexedInheritableToscaElement toscaElement) {
return type.equals(toscaElement.getElementId()) || (toscaElement.getDerivedFrom() != null && toscaElement.getDerivedFrom().contains(type));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import alien4cloud.rest.model.RestResponseBuilder;
import alien4cloud.security.ApplicationRole;
import alien4cloud.topology.TopologyServiceCore;
import alien4cloud.tosca.ToscaService;
import alien4cloud.tosca.container.model.template.DeploymentArtifact;
import alien4cloud.tosca.container.model.topology.NodeTemplate;
import alien4cloud.tosca.container.model.topology.RelationshipTemplate;
Expand Down Expand Up @@ -84,6 +85,9 @@ public class TopologyController {
@Resource
private IFileRepository artifactRepository;

@Resource
private ToscaService toscaService;

/**
* Retrieve an existing {@link Topology}
*
Expand Down Expand Up @@ -415,10 +419,17 @@ public RestResponse<TopologyDTO> deleteNodeTemplate(@PathVariable String topolog

removeInputs(nodeTemplateName, topology);
removeOutputs(nodeTemplateName, topology);
removeScalingPolicy(nodeTemplateName, topology);
alienDAO.save(topology);
return RestResponseBuilder.<TopologyDTO> builder().data(topologyService.buildTopologyDTO(topology)).build();
}

private void removeScalingPolicy(String nodeTemplateName, Topology topology) {
if (topology.getScalingPolicies() != null) {
topology.getScalingPolicies().remove(nodeTemplateName);
}
}

/**
* Remove a nodeTemplate inputs in a topology
*/
Expand Down
1 change: 1 addition & 0 deletions alien4cloud-security/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
195 changes: 93 additions & 102 deletions alien4cloud-ui/yo/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,10 @@ module.exports = function(grunt) {
// Empties folders to start fresh
clean: {
dist: {
files: [
{
dot: true,
src: ['.tmp', '<%= yeoman.dist %>/*', '!<%= yeoman.dist %>/.git*']
}
]
files: [{
dot: true,
src: ['.tmp', '<%= yeoman.dist %>/*', '!<%= yeoman.dist %>/.git*']
}]
},
server: '.tmp'
},
Expand All @@ -154,14 +152,12 @@ module.exports = function(grunt) {
browsers: ['last 1 version']
},
dist: {
files: [
{
expand: true,
cwd: '.tmp/styles/',
src: '{,*/}*.css',
dest: '.tmp/styles/'
}
]
files: [{
expand: true,
cwd: '.tmp/styles/',
src: '{,*/}*.css',
dest: '.tmp/styles/'
}]
}
},

Expand Down Expand Up @@ -236,26 +232,22 @@ module.exports = function(grunt) {
// The following *-min tasks produce minified files in the dist folder
imagemin: {
dist: {
files: [
{
expand: true,
cwd: '<%= yeoman.app %>/images',
src: '{,*/}*.{png,jpg,jpeg,gif}',
dest: '<%= yeoman.dist %>/images'
}
]
files: [{
expand: true,
cwd: '<%= yeoman.app %>/images',
src: '{,*/}*.{png,jpg,jpeg,gif}',
dest: '<%= yeoman.dist %>/images'
}]
}
},
svgmin: {
dist: {
files: [
{
expand: true,
cwd: '<%= yeoman.app %>/images',
src: '{,*/}*.svg',
dest: '<%= yeoman.dist %>/images'
}
]
files: [{
expand: true,
cwd: '<%= yeoman.app %>/images',
src: '{,*/}*.svg',
dest: '<%= yeoman.dist %>/images'
}]
}
},
htmlmin: {
Expand All @@ -266,30 +258,26 @@ module.exports = function(grunt) {
removeCommentsFromCDATA: true,
removeOptionalTags: true
},
files: [
{
expand: true,
cwd: '<%= yeoman.dist %>',
// src: ['*.html', 'views/{,*/}*.html'],
src: ['*.html', 'views/**/*.html'],
dest: '<%= yeoman.dist %>'
}
]
files: [{
expand: true,
cwd: '<%= yeoman.dist %>',
// src: ['*.html', 'views/{,*/}*.html'],
src: ['*.html', 'views/**/*.html'],
dest: '<%= yeoman.dist %>'
}]
}
},

// Allow the use of non-minsafe AngularJS files. Automatically makes it
// minsafe compatible so Uglify does not destroy the ng references
ngmin: {
dist: {
files: [
{
expand: true,
cwd: '.tmp/concat/scripts',
src: '*.js',
dest: '.tmp/concat/scripts'
}
]
files: [{
expand: true,
cwd: '.tmp/concat/scripts',
src: '*.js',
dest: '.tmp/concat/scripts'
}]
}
},

Expand All @@ -303,27 +291,24 @@ module.exports = function(grunt) {
// Copies remaining files to places other tasks can use
copy: {
dist: {
files: [
{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>',
src: ['*.{ico,png,txt}', '.htaccess', '*.html',
// 'views/{,*/}*.html',
'views/**/*.html', 'bower_components/**/*', 'images/**/*', 'data/**/*', 'api-doc/**/*',
// 'images/{,*/}*.{webp}',
// 'images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
'fonts/*'
]
},
{
expand: true,
cwd: '.tmp/images',
dest: '<%= yeoman.dist %>/images',
src: ['generated/*']
}
]
files: [{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>',
src: ['*.{ico,png,txt}', '.htaccess', '*.html',
// 'views/{,*/}*.html',
'views/**/*.html', 'bower_components/**/*', 'images/**/*', 'data/**/*', 'api-doc/**/*',
// 'images/{,*/}*.{webp}',
// 'images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
'fonts/*'
]
}, {
expand: true,
cwd: '.tmp/images',
dest: '<%= yeoman.dist %>/images',
src: ['generated/*']
}]
},
styles: {
expand: true,
Expand All @@ -340,7 +325,7 @@ module.exports = function(grunt) {
dist: ['compass:dist',
// 'imagemin',
'svgmin'
]
],
},

// By default, your `index.html`'s <!-- Usemin block --> will take care of
Expand Down Expand Up @@ -433,39 +418,45 @@ module.exports = function(grunt) {
baseUrl: 'http://localhost:8088',
specs: [
'test/e2e/setup-scenario/before-all.js',
// 'test/e2e/scenarios/admin_cloud.js',
// 'test/e2e/scenarios/admin_cloud_image.js',
// 'test/e2e/scenarios/admin_groups_management.js',
// 'test/e2e/scenarios/admin_metaprops_configuration.js',
// 'test/e2e/scenarios/admin_users_management.js',
// 'test/e2e/scenarios/application.js',
// 'test/e2e/scenarios/application_metaprops.js',
// 'test/e2e/scenarios/application_security.js',
// 'test/e2e/scenarios/application_tags.js',
// 'test/e2e/scenarios/application_topology_editor_editrelationshipname.js',
// 'test/e2e/scenarios/application_topology_editor_editrequiredprops.js',
// 'test/e2e/scenarios/application_topology_editor_input_output.js',
// 'test/e2e/scenarios/application_topology_editor_multiplenodeversions.js',
// 'test/e2e/scenarios/application_topology_editor_nodetemplate.js',
// 'test/e2e/scenarios/application_topology_editor_plan.js',
// 'test/e2e/scenarios/application_topology_editor_relationships.js',
// 'test/e2e/scenarios/application_topology_editor_replacenode.js',
// 'test/e2e/scenarios/application_topology_runtime.js',
// 'test/e2e/scenarios/authentication.js',
// 'test/e2e/scenarios/component_details.js',
// 'test/e2e/scenarios/component_details_tags.js',
// 'test/e2e/scenarios/csar.js',
// 'test/e2e/scenarios/deployment.js',
// 'test/e2e/scenarios/deployment_matcher.js',
// 'test/e2e/scenarios/homepage.js',
// 'test/e2e/scenarios/language_test.js',
// 'test/e2e/scenarios/plugins.js',
// 'test/e2e/scenarios/quick_search.js',
// 'test/e2e/scenarios/security_cloud.js',
// 'test/e2e/scenarios/security_groups.js',
// 'test/e2e/scenarios/security_users.js',
// 'test/e2e/scenarios/topology_template.js',
// 'test/e2e/scenarios/*'
// 'test/e2e/scenarios/homepage.js',
// 'test/e2e/scenarios/language_test.js',
// 'test/e2e/scenarios/authentication.js',
// 'test/e2e/scenarios/admin_users_management.js',
// 'test/e2e/scenarios/admin_groups_management.js',
// 'test/e2e/scenarios/plugins.js',
// 'test/e2e/scenarios/admin_metaprops_configuration.js',
// 'test/e2e/scenarios/admin_cloud_image.js',
// 'test/e2e/scenarios/admin_cloud.js',

// 'test/e2e/scenarios/csar_upload.js',
// 'test/e2e/scenarios/component_details.js',
// 'test/e2e/scenarios/component_details_tags.js',

// 'test/e2e/scenarios/topology_template.js',

// 'test/e2e/scenarios/application.js',
// 'test/e2e/scenarios/application_metaprops.js',
// 'test/e2e/scenarios/application_tags.js',
// 'test/e2e/scenarios/application_topology_editor_nodetemplate.js',
// 'test/e2e/scenarios/application_topology_editor_relationships.js',
// 'test/e2e/scenarios/application_topology_editor_replacenode.js',
// 'test/e2e/scenarios/application_topology_editor_editrelationshipname.js',
// 'test/e2e/scenarios/application_topology_editor_editrequiredprops.js',
// 'test/e2e/scenarios/application_topology_editor_multiplenodeversions.js',
// 'test/e2e/scenarios/application_topology_editor_input_output.js',
// 'test/e2e/scenarios/application_topology_runtime.js',
// 'test/e2e/scenarios/application_security.js',

// 'test/e2e/scenarios/deployment.js',
'test/e2e/scenarios/deployment_matcher.js',

// 'test/e2e/scenarios/quick_search.js',

// 'test/e2e/scenarios/security_users.js',
// 'test/e2e/scenarios/security_groups.js',
//'test/e2e/scenarios/security_cloud.js',
// 'test/e2e/scenarios/*'

]
}
}
Expand Down
1 change: 1 addition & 0 deletions alien4cloud-ui/yo/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
<script src="scripts/utils/CONNECTORS.Grid.js"></script>
<script src="scripts/utils/CONNECTORS.Point.js"></script>
<script src="scripts/utils/D3JS_UTILS.js"></script>
<script src="scripts/utils/CONSTANTS.js"></script>

<script src="scripts/authentication/services/authservices.js"></script>
<script src="scripts/authentication/controllers/navbar.js"></script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** TODO Update Topology runtime to make it independant from the application. */
/* global UTILS */
/* global CONSTANTS */

'use strict';

Expand Down Expand Up @@ -437,6 +438,15 @@ angular.module('alienUiApp').controller(
// reset parameter inputs ?
injectPropertyDefinitionToInterfaces($scope.selectedNodeCustomInterface);
};


// check if compute type
$scope.isComputeType = function (nodeTemplate){
if(UTILS.isUndefinedOrNull($scope.topology) || UTILS.isUndefinedOrNull(nodeTemplate)){
return false;
}
var nodeType = $scope.topology.nodeTypes[nodeTemplate.type];
return UTILS.isFromNodeType(nodeType, CONSTANTS.toscaComputeType);
};

}
]);
Loading

0 comments on commit 251a50d

Please sign in to comment.