Skip to content

Commit

Permalink
Support YAML Policies
Browse files Browse the repository at this point in the history
- Add ability to specify targets for a policy type in management-ui
- Add ability to create policies at the topology level in the topology modeler
- Add ability to toggle policies applied to node templates in topology modeler
- Ensure inheritance of policy properties in topology modeler
- Ensure inheritance of policy targets in topology modeler
- Enforce policy type's targets when showing the possible policies of a node template in topology modeler
  • Loading branch information
ghareeb-falazi committed Jan 22, 2020
2 parents 456a598 + 164b046 commit d6aeb12
Show file tree
Hide file tree
Showing 103 changed files with 1,912 additions and 539 deletions.
25 changes: 18 additions & 7 deletions Dockerfile
@@ -1,27 +1,37 @@
FROM maven:3-jdk-8 as builder

RUN rm /dev/random && ln -s /dev/urandom /dev/random \
&& apt-get update -qq && apt-get install -qqy \
unzip \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& echo '{ "allow_root": true }' > /root/.bowerrc

COPY . /tmp/winery
WORKDIR /tmp/winery
RUN mvn package -DskipTests -Dmaven.javadoc.skip=true -B -V -q
RUN mvn package -DskipTests


FROM tomcat:8.5.31
LABEL maintainer = "Oliver Kopp <kopp.dev@gmail.com>, Michael Wurster <miwurster@gmail.com>, Lukas Harzenetter <lharzenetter@gmx.de>"

ARG DOCKERIZE_VERSION=v0.3.0

ENV WINERY_HOSTNAME localhost
ENV WINERY_PORT 8080
ENV WINERY_REPOSITORY_PROVIDER xml
ENV WINERY_REPOSITORY_PATH "/repository"
ENV WINERY_REPOSITORY_URL ""
ENV WINERY_HEAP_MAX 2048m
ENV WINERY_JMX_ENABLED ""
ENV CONTAINER_HOSTNAME localhost
ENV CONTAINER_PORT 1337
ENV WORKFLOWMODELER_HOSTNAME localhost
ENV WORKFLOWMODELER_PORT 8080
ENV TOPOLOGYMODELER_HOSTNAME localhost
ENV TOPOLOGYMODELER_PORT 8080
ENV CONTAINER_HOSTNAME localhost
ENV CONTAINER_PORT 1337
ENV WINERY_REPOSITORY_PATH "/var/opentosca/repository"
ENV WINERY_HOSTNAME localhost
ENV WINERY_PORT 8080
ENV EDMM_TRANSFORMATION_HOSTNAME localhost
ENV EDMM_TRANSFORMATION_PORT 5000
ENV WINERY_FEATURE_ACCOUNTABILITY false
ENV WINERY_FEATURE_TEST_COMPLETION false
ENV WINERY_FEATURE_TEST_COMPLIANCE false
Expand All @@ -32,6 +42,7 @@ ENV WINERY_FEATURE_PATTERN_REFINEMENT false
ENV WINERY_FEATURE_PROBLEM_DETECTION false
ENV WINERY_FEATURE_SPLITTING false
ENV WINERY_FEATURE_TEST_REFINEMENT false
ENV WINERY_FEATURE_EDMM_MODELING false

RUN rm /dev/random && ln -s /dev/urandom /dev/random \
&& curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash \
Expand Down
4 changes: 3 additions & 1 deletion docker/winery.yml.tpl
Expand Up @@ -10,14 +10,16 @@ ui:
problemDetection: {{ .Env.WINERY_FEATURE_PROBLEM_DETECTION }}
splitting: {{ .Env.WINERY_FEATURE_SPLITTING }}
testRefinement: {{ .Env.WINERY_FEATURE_TEST_REFINEMENT }}
edmmModeling: {{ .Env.WINERY_FEATURE_EDMM_MODELING }}
endpoints:
container: http://{{ .Env.CONTAINER_HOSTNAME }}:{{ .Env.CONTAINER_PORT }}
workflowmodeler: http://{{ .Env.WORKFLOWMODELER_HOSTNAME }}:{{ .Env.WORKFLOWMODELER_PORT }}/winery-workflowmodeler
topologymodeler: http://{{ .Env.TOPOLOGYMODELER_HOSTNAME }}:{{ .Env.TOPOLOGYMODELER_PORT }}/winery-topologymodeler
repositoryApiUrl: http://{{ .Env.WINERY_HOSTNAME }}:{{ .Env.WINERY_PORT }}/winery
repositoryUiUrl: http://{{ .Env.WINERY_HOSTNAME }}:{{ .Env.WINERY_PORT }}/#
edmmTransformationTool: http://{{ .Env.EDMM_TRANSFORMATION_HOSTNAME }}:{{ .Env.EDMM_TRANSFORMATION_PORT }}/plugins/check-model-support
repository:
provider: {{ .Env.WINERY_REPOSITORY_PROVIDER }}
provider: file
repositoryRoot: {{ .Env.WINERY_REPOSITORY_PATH }}
git:
clientSecret: secret
Expand Down
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Contributors to the Eclipse Foundation
* Copyright (c) 2019-2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand Down Expand Up @@ -97,7 +97,7 @@ public EntityGraph transform(TServiceTemplate serviceTemplate) {
}

private void createRelation(TRelationshipTemplate relationship, EntityGraph entityGraph) {
EntityId sourceComponentEntityId = EntityGraph.COMPONENTS.extend(relationship.getSourceElement().getRef().getId());
EntityId sourceComponentEntityId = EntityGraph.COMPONENTS.extend(relationship.getSourceElement().getRef().getName());
// the entity will always be in the graph since we first transform the NodeTemplates
entityGraph.getEntity(sourceComponentEntityId).ifPresent(entity -> {
EntityId relationTypeEntityId = createType(
Expand All @@ -117,15 +117,15 @@ private void createRelation(TRelationshipTemplate relationship, EntityGraph enti
entityGraph.addEntity(new MappingEntity(relationEntityId, entityGraph));
createProperties(relationship, relationEntityId, entityGraph);
} else {
String targetComponent = relationship.getTargetElement().getRef().getId();
String targetComponent = relationship.getTargetElement().getRef().getName();
entityGraph.addEntity(new ScalarEntity(targetComponent, relationEntityId, entityGraph));
}
});
}

private void createNode(TNodeTemplate nodeTemplate, EntityGraph entityGraph) {
// create the component inside the topology.
EntityId componentNodeId = EntityGraph.COMPONENTS.extend(nodeTemplate.getId());
EntityId componentNodeId = EntityGraph.COMPONENTS.extend(nodeTemplate.getName());
entityGraph.addEntity(new MappingEntity(componentNodeId, entityGraph));

// add the type to the model
Expand All @@ -138,6 +138,7 @@ private void createNode(TNodeTemplate nodeTemplate, EntityGraph entityGraph) {

createProperties(nodeTemplate, componentNodeId, entityGraph);
createArtifact(nodeTemplate, componentNodeId, entityGraph);
createOperations(nodeTypes.get(nodeTemplate.getType()), componentNodeId, entityGraph);
}

private void createArtifact(TNodeTemplate nodeTemplate, EntityId componentNodeId, EntityGraph entityGraph) {
Expand Down Expand Up @@ -193,7 +194,6 @@ private EntityId createType(TEntityType toscaType, EntityId parentEntityId, Enti
EdmmTypeProperties.getDefaultConfiguration(edmmType, entityGraph);

this.createPropertiesDefinition(toscaType, typeEntityId, entityGraph);
this.createOperations(toscaType, typeEntityId, entityGraph);

if (Objects.nonNull(toscaType.getDerivedFrom())) {
QName inheritsFrom = toscaType.getDerivedFrom().getType();
Expand Down Expand Up @@ -235,7 +235,6 @@ private EntityId createType(TEntityType toscaType, EntityId parentEntityId, Enti
}

this.createPropertiesDefinition(toscaType, typeEntityId, entityGraph);
this.createOperations(toscaType, typeEntityId, entityGraph);
}
}

Expand Down
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Contributors to the Eclipse Foundation
* Copyright (c) 2019-2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand Down Expand Up @@ -31,6 +31,13 @@ public enum EdmmType implements Serializable {
TOMCAT("tomcat"),
WEB_APPLICATION("web_application"),
WEB_SERVER("web_server"),
PLATFORM("platform"),
PAAS("paas"),
DBAAS("dbaas"),
AWS_BEANSTALK("aws_beanstalk"),
AWS_AURORA("aws_aurora"),
SAAS("saas"),
AUTH0("auth0"),

// relation types
CONNECTS_TO("connects_to"),
Expand Down
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Contributors to the Eclipse Foundation
* Copyright (c) 2019-2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand All @@ -25,6 +25,7 @@ public class EdmmTypeProperties {
public static String BASE = "base";

public static void getDefaultConfiguration(EdmmType edmmType, EntityGraph entityGraph) {
EntityId e;
switch (edmmType) {
case COMPUTE:
EntityId computeId = EntityGraph.COMPONENT_TYPES.extend(EdmmType.COMPUTE.getValue());
Expand All @@ -51,7 +52,7 @@ public static void getDefaultConfiguration(EdmmType edmmType, EntityGraph entity
case MYSQL_DBMS:
EntityId mySqlDbmsId = EntityGraph.COMPONENT_TYPES.extend(EdmmType.MYSQL_DBMS.getValue());
entityGraph.addEntity(new MappingEntity(mySqlDbmsId, entityGraph));
entityGraph.addEntity(new ScalarEntity(EdmmType.MYSQL_DBMS.getValue(), mySqlDbmsId.extend(DefaultKeys.EXTENDS), entityGraph));
entityGraph.addEntity(new ScalarEntity(EdmmType.DBMS.getValue(), mySqlDbmsId.extend(DefaultKeys.EXTENDS), entityGraph));
getDefaultConfiguration(EdmmType.DBMS, entityGraph);
break;
case SOFTWARE_COMPONENT:
Expand Down Expand Up @@ -93,6 +94,47 @@ public static void getDefaultConfiguration(EdmmType edmmType, EntityGraph entity
entityGraph.addEntity(new ScalarEntity(EdmmType.DEPENDS_ON.getValue(), hostedOnId.extend(DefaultKeys.EXTENDS), entityGraph));
getDefaultConfiguration(EdmmType.DEPENDS_ON, entityGraph);
break;
case PLATFORM:
e = EntityGraph.COMPONENT_TYPES.extend(EdmmType.PLATFORM.getValue());
entityGraph.addEntity(new MappingEntity(e, entityGraph));
entityGraph.addEntity(new ScalarEntity(BASE, e.extend(DefaultKeys.EXTENDS), entityGraph));
break;
case PAAS:
e = EntityGraph.COMPONENT_TYPES.extend(EdmmType.PAAS.getValue());
entityGraph.addEntity(new MappingEntity(e, entityGraph));
entityGraph.addEntity(new ScalarEntity(EdmmType.PLATFORM.getValue(), e.extend(DefaultKeys.EXTENDS), entityGraph));
getDefaultConfiguration(EdmmType.PLATFORM, entityGraph);
break;
case DBAAS:
e = EntityGraph.COMPONENT_TYPES.extend(EdmmType.DBAAS.getValue());
entityGraph.addEntity(new MappingEntity(e, entityGraph));
entityGraph.addEntity(new ScalarEntity(EdmmType.PLATFORM.getValue(), e.extend(DefaultKeys.EXTENDS), entityGraph));
getDefaultConfiguration(EdmmType.PLATFORM, entityGraph);
break;
case SAAS:
e = EntityGraph.COMPONENT_TYPES.extend(EdmmType.SAAS.getValue());
entityGraph.addEntity(new MappingEntity(e, entityGraph));
entityGraph.addEntity(new ScalarEntity(EdmmType.PLATFORM.getValue(), e.extend(DefaultKeys.EXTENDS), entityGraph));
getDefaultConfiguration(EdmmType.PLATFORM, entityGraph);
break;
case AWS_BEANSTALK:
e = EntityGraph.COMPONENT_TYPES.extend(EdmmType.AWS_BEANSTALK.getValue());
entityGraph.addEntity(new MappingEntity(e, entityGraph));
entityGraph.addEntity(new ScalarEntity(EdmmType.PAAS.getValue(), e.extend(DefaultKeys.EXTENDS), entityGraph));
getDefaultConfiguration(EdmmType.PAAS, entityGraph);
break;
case AWS_AURORA:
e = EntityGraph.COMPONENT_TYPES.extend(EdmmType.AWS_AURORA.getValue());
entityGraph.addEntity(new MappingEntity(e, entityGraph));
entityGraph.addEntity(new ScalarEntity(EdmmType.DBAAS.getValue(), e.extend(DefaultKeys.EXTENDS), entityGraph));
getDefaultConfiguration(EdmmType.DBAAS, entityGraph);
break;
case AUTH0:
e = EntityGraph.COMPONENT_TYPES.extend(EdmmType.AUTH0.getValue());
entityGraph.addEntity(new MappingEntity(e, entityGraph));
entityGraph.addEntity(new ScalarEntity(EdmmType.SAAS.getValue(), e.extend(DefaultKeys.EXTENDS), entityGraph));
getDefaultConfiguration(EdmmType.SAAS, entityGraph);
break;
}
}
}
3 changes: 2 additions & 1 deletion org.eclipse.winery.common/src/main/resources/winery.yml
Expand Up @@ -11,13 +11,14 @@ ui:
splitting: true
testRefinement: true
placement: true
edmmModeling: true
edmmModeling: false
endpoints:
container: http://localhost:1337
workflowmodeler: http://localhost:9527
topologymodeler: http://localhost:4201
repositoryApiUrl: http://localhost:8080/winery
repositoryUiUrl: http://localhost:4200/#
edmmTransformationTool: http://localhost:5000/plugins/check-model-support
repository:
provider: file
repositoryRoot: ""
Expand Down
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Contributors to the Eclipse Foundation
* Copyright (c) 2019-2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand Down Expand Up @@ -190,6 +190,7 @@ void setup() {
TNodeTemplate nt1 = new TNodeTemplate();
nt1.setType(nodeType1QName);
nt1.setId("test_node_1");
nt1.setName("test_node_1");
TDeploymentArtifacts deploymentArtifacts = new TDeploymentArtifacts();
TDeploymentArtifact artifact = new TDeploymentArtifact();
artifact.setArtifactRef(deploymentArtifactIAQName);
Expand All @@ -201,11 +202,13 @@ void setup() {
TNodeTemplate nt2 = new TNodeTemplate();
nt2.setType(nodeType2QName);
nt2.setId("test_node_2");
nt2.setName("test_node_2");
nodeTemplates.put(nt2.getId(), nt2);

TNodeTemplate nt3 = new TNodeTemplate();
nt3.setType(nodeType3QName);
nt3.setId("test_node_3");
nt3.setName("test_node_3");
TEntityTemplate.Properties properties = new TEntityTemplate.Properties();
HashMap<String, String> nt3Properties = new HashMap<>();
nt3Properties.put("os_family", "ubuntu");
Expand All @@ -218,34 +221,39 @@ void setup() {
TNodeTemplate nt4 = new TNodeTemplate();
nt4.setType(nodeType4QName);
nt4.setId("test_node_4");
nt4.setName("test_node_4");
nodeTemplates.put(nt4.getId(), nt4);
// endregion

// region *** create RelationshipTemplate ***
TRelationshipTemplate rt13 = new TRelationshipTemplate();
rt13.setType(hostedOnQName);
rt13.setId("1_hosted_on_3");
rt13.setName("1_hosted_on_3");
rt13.setSourceNodeTemplate(nt1);
rt13.setTargetNodeTemplate(nt3);
relationshipTemplates.put(rt13.getId(), rt13);

TRelationshipTemplate rt23 = new TRelationshipTemplate();
rt23.setType(hostedOnQName);
rt23.setId("2_hosted_on_3");
rt23.setName("2_hosted_on_3");
rt23.setSourceNodeTemplate(nt2);
rt23.setTargetNodeTemplate(nt3);
relationshipTemplates.put(rt23.getId(), rt23);

TRelationshipTemplate rt41 = new TRelationshipTemplate();
rt41.setType(hostedOnQName);
rt41.setId("4_hosted_on_1");
rt41.setName("4_hosted_on_1");
rt41.setSourceNodeTemplate(nt4);
rt41.setTargetNodeTemplate(nt1);
relationshipTemplates.put(rt41.getId(), rt41);

TRelationshipTemplate rt12 = new TRelationshipTemplate();
rt12.setType(connectsToQName);
rt12.setId("1_connects_to_2");
rt12.setName("1_connects_to_2");
rt12.setSourceNodeTemplate(nt1);
rt12.setTargetNodeTemplate(nt2);
relationshipTemplates.put(rt12.getId(), rt12);
Expand Down Expand Up @@ -395,13 +403,13 @@ void transformTopologyWithOperations() {
assertNotNull(transform);
assertEquals(12, transform.vertexSet().size());

Optional<Entity> operations = transform.getEntity(Arrays.asList("0", "component_types", "https_ex.orgtoscatoedmm__test_node_type_4", "operations"));
Optional<Entity> operations = transform.getEntity(Arrays.asList("0", "components", "test_node_4", "operations"));
assertTrue(operations.isPresent());
Optional<Entity> start = transform.getEntity(Arrays.asList("0", "component_types", "https_ex.orgtoscatoedmm__test_node_type_4", "operations", "start"));
Optional<Entity> start = transform.getEntity(Arrays.asList("0", "components", "test_node_4", "operations", "start"));
assertTrue(start.isPresent());
assertTrue(start.get() instanceof ScalarEntity);
assertEquals("/artifacttemplates/ns/startTestNode4/files/script.sh", ((ScalarEntity) start.get()).getValue());
Optional<Entity> stop = transform.getEntity(Arrays.asList("0", "component_types", "https_ex.orgtoscatoedmm__test_node_type_4", "operations", "stop"));
Optional<Entity> stop = transform.getEntity(Arrays.asList("0", "components", "test_node_4", "operations", "stop"));
assertTrue(stop.isPresent());
assertTrue(stop.get() instanceof ScalarEntity);
assertEquals("/artifacttemplates/ns/startTestNode4/files/script.sh", ((ScalarEntity) stop.get()).getValue());
Expand Down Expand Up @@ -449,6 +457,9 @@ void transformTopology() {
" relations:\n" +
" - hosted_on: test_node_3\n" +
" test_node_4:\n" +
" operations:\n" +
" stop: /artifacttemplates/ns/startTestNode4/files/script.sh\n" +
" start: /artifacttemplates/ns/startTestNode4/files/script.sh\n" +
" type: https_ex.orgtoscatoedmm__test_node_type_4\n" +
" relations:\n" +
" - hosted_on: test_node_1\n" +
Expand Down Expand Up @@ -476,9 +487,6 @@ void transformTopology() {
" web_application:\n" +
" extends: base\n" +
" https_ex.orgtoscatoedmm__test_node_type_4:\n" +
" operations:\n" +
" stop: /artifacttemplates/ns/startTestNode4/files/script.sh\n" +
" start: /artifacttemplates/ns/startTestNode4/files/script.sh\n" +
" extends: web_application\n" +
" software_component:\n" +
" extends: base\n", stringWriter.toString());
Expand Down

0 comments on commit d6aeb12

Please sign in to comment.