Skip to content

Commit

Permalink
tosca variability 1.0-rc-2
Browse files Browse the repository at this point in the history
  • Loading branch information
milesstoetzner authored Mar 7, 2024
1 parent 96b0ace commit d1391ac
Show file tree
Hide file tree
Showing 26 changed files with 242 additions and 138 deletions.
42 changes: 29 additions & 13 deletions docs/docs/variability4tosca/specification/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ The following options are used to configure the default conditions of elements.
| relation_default_condition_mode | false | List(source | target, -) | source-target | Configure the default condition for relations. |
| relation_default_consistency_condition | false | Boolean | false | Enable default semantic condition for relations. |
| relation_default_semantic_condition | false | Boolean | false | Enable default consistency condition for relations. |
| relation_default_implied | false | Boolean | false | Enable default implication for relations. |
| policy_default_condition | false | Boolean | false | Enable default condition for policies (consistency and semantic). |
| policy_default_consistency_condition | false | Boolean | false | Enable default consistency condition for policies. |
| policy_default_semantic_condition | false | Boolean | false | Enable default semantic condition for policies. |
Expand Down Expand Up @@ -259,6 +260,21 @@ There are several predefined pruning modes which provide different useful combin
- `semantic-strict`: consistency pruning is enabled and semantic defaults
- `semantic-loose`: pruning is enabled everywhere (consistency and semantic)

### v2

`tosca_variability_1_0_rc_2` has the following default values.

```yaml linenums="1"
mode: semantic-loose
node_default_condition_mode: incomingnaive-artifact-host
optimization_topology: min
optimization_topology_unique: true
optimization_technologies: max
optimization_technologies_mode: weight
technology_constraint: true
hosting_stack_constraint: true
relation_default_implied: true
```

## Default Conditions

Expand Down Expand Up @@ -513,19 +529,19 @@ database:
A requirement assignment is a conditional element, thus, variability conditions and other options can be assigned.
These conditions must hold otherwise the respective relationship is not present.

| Keyname | Mandatory | Type | Description |
|-------------------------------|-----------|-----------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| conditions | false | VariabilityCondition | List(VariabilityCondition) | An optional variability condition. If a list is given, then the conditions are combined using the _and_ operation. |
| default_alternative | false | Boolean | Declare the requirement assignment as default. This overwrites assigned conditions. There must be only one default assignment. | |
| default_condition | false | Boolean | Enable the default condition for this element. This overrides the variability options of the variable topology template. |
| default_consistency_condition | false | Boolean | Enable the default consistency condition for this element. Default condition must be enabled for this element. This overrides the variability options of the variable topology template. |
| default_semantic_condition | false | Boolean | Enable the default semantic condition for this element. Default condition must be enabled for this element. This overrides the variability options of the variable topology template. |
| default_condition_mode | false | source-target | source | target | Configure the default condition for this element. |
| pruning | false | Boolean | Enable the pruning for this element. This overrides the variability options of the variable topology template. |
| consistency_pruning | false | Boolean | Enable the consistency pruning for this element. Pruning must be enabled for this element. This overrides the variability options of the variable topology template. |
| semantic_pruning | false | Boolean | Enable the semantic pruning for this element. Pruning must be enabled for this element. This overrides the variability options of the variable topology template. |
| implies | false | List(Tuple(Target: VariabilityCondition, Condition?: VariabilityCondition)) | An optional list of implications following the pattern `element implies target` or `(element and condition) implies target`. |
| implied | false | Boolean | SOURCE | TARGET | CONTAINER | Enables that the manual conditions are used to imply the element when the source/ target (depending on the configuration) is present. | |
| Keyname | Mandatory | Type | Description |
|-------------------------------|-----------|-----------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| conditions | false | VariabilityCondition | List(VariabilityCondition) | An optional variability condition. If a list is given, then the conditions are combined using the _and_ operation. |
| default_alternative | false | Boolean | Declare the requirement assignment as default. This overwrites assigned conditions. There must be only one default assignment. | |
| default_condition | false | Boolean | Enable the default condition for this element. This overrides the variability options of the variable topology template. |
| default_consistency_condition | false | Boolean | Enable the default consistency condition for this element. Default condition must be enabled for this element. This overrides the variability options of the variable topology template. |
| default_semantic_condition | false | Boolean | Enable the default semantic condition for this element. Default condition must be enabled for this element. This overrides the variability options of the variable topology template. |
| default_condition_mode | false | source-target | source | target | Configure the default condition for this element. |
| pruning | false | Boolean | Enable the pruning for this element. This overrides the variability options of the variable topology template. |
| consistency_pruning | false | Boolean | Enable the consistency pruning for this element. Pruning must be enabled for this element. This overrides the variability options of the variable topology template. |
| semantic_pruning | false | Boolean | Enable the semantic pruning for this element. Pruning must be enabled for this element. This overrides the variability options of the variable topology template. |
| implies | false | List(Tuple(Target: VariabilityCondition, Condition?: VariabilityCondition)) | An optional list of implications following the pattern `element implies target` or `(element and condition) implies target`. |
| implied | false | Boolean | SOURCE | TARGET | CONTAINER | Enables that the manual conditions are used to imply the element when the source/ target (depending on the configuration) is present. This overrides the variability options of the variable topology template. | |

For example, the following requirement assignment `host` has a variability condition assigned.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ The following error is expected to be thrown, when resolving variability.
```text linenums="1"
>-
Node default condition mode "incoming-host" requires at least one persistent
Node default condition mode "incoming(naive)-host" requires at least one persistent
node template
```
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tosca_definitions_version: tosca_variability_1_0
tosca_definitions_version: tosca_variability_1_0_rc_2

imports:
- lib/types.yaml
Expand Down Expand Up @@ -110,17 +110,6 @@ topology_template:
is_large: {not: {logic_expression: is_medium}}

options:
mode: semantic-loose

node_default_condition_mode: incomingnaive-host
hosting_stack_constraint: true

optimization_topology: true
optimization_topology_unique: true

technology_pruning: true
technology_constraint: true

optimization_technologies: min
optimization_technologies_mode: count

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tosca_definitions_version: tosca_variability_1_0
tosca_definitions_version: tosca_variability_1_0_rc_2

imports:
- lib/types.yaml
Expand Down Expand Up @@ -110,16 +110,7 @@ topology_template:
is_large: {not: {logic_expression: is_medium}}

options:
mode: semantic-loose

node_default_condition_mode: incomingnaive-host
hosting_stack_constraint: true

optimization_topology: true
optimization_topology_unique: true

technology_pruning: true
technology_constraint: true
optimization_technologies: false

node_templates:
shop:
Expand Down
Empty file modified examples/unfurl-technology-automated-weighted/scripts/clean.sh
100755 → 100644
Empty file.
Empty file modified examples/unfurl-technology-automated-weighted/scripts/code.sh
100755 → 100644
Empty file.
Empty file.
Empty file.
Empty file modified examples/unfurl-technology-automated-weighted/scripts/deploy.sh
100755 → 100644
Empty file.
Empty file.
Empty file modified examples/unfurl-technology-automated-weighted/scripts/setup.sh
100755 → 100644
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tosca_definitions_version: tosca_variability_1_0
tosca_definitions_version: tosca_variability_1_0_rc_2

imports:
- lib/types.yaml
Expand Down Expand Up @@ -109,21 +109,6 @@ topology_template:
is_medium: {variability_input: medium}
is_large: {not: {logic_expression: is_medium}}

options:
mode: semantic-loose

node_default_condition_mode: incomingnaive-host
hosting_stack_constraint: true

optimization_topology: true
optimization_topology_unique: true

technology_pruning: true
technology_constraint: true

optimization_technologies: max
optimization_technologies_mode: weight

node_templates:
shop:
type: shop.component
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tosca_definitions_version: tosca_variability_1_0
tosca_definitions_version: tosca_variability_1_0_rc_2

imports:
- lib/types.yaml
Expand Down Expand Up @@ -139,21 +139,6 @@ topology_template:
is_medium: {variability_input: medium}
is_large: {not: {logic_expression: is_medium}}

options:
mode: semantic-loose

node_default_condition_mode: incomingnaive-host
hosting_stack_constraint: true

optimization_topology: true
optimization_topology_unique: true

technology_pruning: true
technology_constraint: false

optimization_technologies: max
optimization_technologies_mode: weight

node_templates:
shop:
type: shop.component
Expand Down Expand Up @@ -204,7 +189,6 @@ topology_template:

- depends:
node: mysql_dbms_expose
implied: true
conditions: {logic_expression: is_kubernetes}

mysql_dbms:
Expand Down
10 changes: 3 additions & 7 deletions src/enricher/constraints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,14 @@ export class ConstraintEnricher {
*/
private enrichImplications(element: Element) {
if (check.isUndefined(element.container)) return

// TODO: move this up into class?
const implied = element.raw.implied
if (check.isUndefined(implied)) return
if (check.isFalse(implied)) return
if (!element.implied) return

let left
if (implied === 'TARGET') {
if (element.implied === 'TARGET') {
assert.isRelation(element)
left = element.target.id
}
if (implied === 'SOURCE' || implied === 'CONTAINER' || check.isTrue(implied)) {
if (element.implied === 'SOURCE' || element.implied === 'CONTAINER' || check.isTrue(element.implied)) {
left = element.container.id
}
assert.isDefined(left, 'Left not defined')
Expand Down
1 change: 1 addition & 0 deletions src/enricher/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export default class Transformer {
delete this.topology.variability.options.relation_default_condition_mode
delete this.topology.variability.options.relation_default_consistency_condition
delete this.topology.variability.options.relation_default_semantic_condition
delete this.topology.variability.options.relation_default_implied

delete this.topology.variability.options.policy_default_condition
delete this.topology.variability.options.policy_default_consistency_condition
Expand Down
4 changes: 4 additions & 0 deletions src/graph/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ export default abstract class Element {
return this._graph
}

get implied() {
return this.raw.implied ?? false
}

isInput(): this is Input {
return false
}
Expand Down
1 change: 1 addition & 0 deletions src/graph/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export default class Graph {
![
TOSCA_DEFINITIONS_VERSION.TOSCA_SIMPLE_YAML_1_3,
TOSCA_DEFINITIONS_VERSION.TOSCA_VARIABILITY_1_0,
TOSCA_DEFINITIONS_VERSION.TOSCA_VARIABILITY_1_0_RC_2,
].includes(this.serviceTemplate.tosca_definitions_version)
)
throw new Error('Unsupported TOSCA definitions version')
Expand Down
2 changes: 0 additions & 2 deletions src/graph/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ export default class Loader {
* Load rules from specified file
*/
if (check.isString(conditions)) {
console.log('going to load')
conditions = files.loadYAML<TypeSpecificLogicExpressions>(path.join(this.dir, conditions))
console.log(conditions)
}

/**
Expand Down
Loading

0 comments on commit d1391ac

Please sign in to comment.