You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Requirement mapping differs from other mappings in the following two
ways:
It is possible for a substituted node to have multiple requirements
with the same name, each of which may need to be mapped
separately.
It is possible for the same requirement in a substituted node to be
mapped multiple times.
To accommodate this use case, requirement mappings are defined using
YAML lists rather than maps.
Mapping Multiple Requirements with the Same Name
The following example shows a Client node type that defines a service requirement with a count_range of [2, 2], which means
that client nodes need exactly two relationships to nodes of type Server.
tosca_definitions_version: tosca_2_0capability_types:
Service:
description: >- Ability to provide service.relationship_types:
ServedBy:
description: >- Connection to a service.node_types:
Client:
requirements:
- service:
capability: Servicerelationship: ServedBynode: Servercount_range: [ 2, 2]Server:
capabilities:
service:
type: Service
This following figure shows a service that consists of one such client
node connected to two server nodes.
graph LR;
subgraph T [Simple Service]
client --> |service| server1
client --> |service| server2
end
Loading
This service can be implemented using the following TOSCA service
template:
In this template, the client nodes is annotated with the substitute directive, which means that a substituting template must
be found to instantiate this node. The following figure shows one
possible substitution.
graph BT
S --> |substitutes| client
subgraph T [Top-Level Topology]
client --> |service| server1
client --> |service| server2
end
subgraph S [Substituting Topology]
direction BT
software1 --> |host| compute
software2 --> |host| compute
software1 -.-> |service| server1
software2 -.-> |service| server2
end
Loading
The substituting template decomposes the client node into two
different software nodes, each with exactly one service
requirement. The requirement mapping syntax distributes the two service requirements from the substituted client node between the
two software nodes. The following code snippet shows the substituting
template:
The following template shows an alternative substitution. In this
example, both service requirements of the substituted client node
are mapped to corresponding requirements of a single software node:
This example shows two identical mappings for the two service
requirements. As a convience feature, it is possible to group
identical mapping statements using the syntax in the following
example. This syntax states that two service requirements of the
substituted node are mapped to two corresponding service
requirements of the software node in the substituting template.
The following shows a substituting template that decomposes the node
of type Client into two software components, each of which needs to
be hosted on the compute node defined in the top-level template that
defines the client node. This can be accomplished by mapping the host requirement of the client node twice, once to the host
requirement of the software1 node and once to the host requirement
of the software2 node.
Using this syntax, the target of the requirement mapping is a list
of target requirements rather than a single requirement.
Requirement Mapping Rules
This section documents the rules for requirement mapping. The types
defined in the following code snippet are used to illustrate the
rules:
tosca_definitions_version: tosca_2_0capability_types:
Service:
description: >- Ability to provide service.relationship_types:
ServedBy:
description: >- Connection to a service.node_types:
Client:
requirements:
- service:
capability: Servicerelationship: ServedBynode: Servercount_range: [ 1, 4 ]Server:
capabilities:
service:
type: Service
In this example, the Client node type defines a service
requirement with a count_range of [1, 4]. This means that a client
can have up to four service connections to a Server node, but only
one of those is mandatory.
Requirement Assignments
Any service template that uses the Client node type must specify the
correct number of requirement assignments, i.e, the number of
mandatory requirements must be greater than or equal to the lower
bound of the count_range and he total number of requirement
assignments (optional as well as mandatory) must be less than or equal
to the upper bound of the count range.
The following shows a valid service template that uses Client and Server nodes.
In this example, only the first service assignment is mandatory. The
next two are optional. However, after the orchestrator fulfills the
dangling requirement, the resulting service topology for this second
example will likely be identical to the service topology in the first
example, since the orchestrator is able to fulfill both of the
optional requirements using server nodes in this topology.
Note that after requirements have been fulfilled, it no longer matters
whether the requirement were mandatory or optional. All that matters
is that if the service topology is valid, the number of established
relationships is guaranteed to fall within the count_range specified
in the corresponding requirement definition.
Mapping Requirements
This section introduces the rules for requirement mappings:
As in earlier versions of the spec, requirements from a substituted node can only be mapped onto dangling requirements
in the substituting template.
The total number of requirements mapped onto mandatory
requirements in the substituting template must not exceed the lower
bound of the count_range in the corresponding requirement
definition in the substituted node's type.
The total number of requirement mappings must not exceed the upper
bound of the count_range in the corresponding requirement
definition in the substituted node's type. Note that this is a
convenience rule only, since according to rule 2, any excess
mappings would have to map onto optional requirements, and as a
result can safely be ignored.
Note that there are no constraints on the minimum number of
requirement mappings. More specifically, the total number of
requirement mappings is allowed to be smaller than the lower bound of
the count_range in the corresponding requirement definition.
The following code snippet shows a valid substituting template for the client node in the template shown above:
While the substituted client node in the template above has three
requirement assigments with target nodes, only one of those
requirements is mapped to a requirement in the substituting template.
The next code snippet shows a slightly different substituting template
for the client node in the template shown above. This template decomposes the client node into three different software nodes,
each with a single service requirement to its own server. The
substitution mapping defines three requirement mappings for the service requirement of the client node, one to each of the service requirements of the software nodes in the substituting
template.
Unfortunately, this substituting template is invalid. Since the service requirement of each software node is mandatory, this
template needs three different service requirements in any node of
type Client for which it is a substitution. This cannot be
guaranteed, since the service requirement definition in the Client
node type specifies a count_range with a lower bound of one, which
means that only such requirement is guaranteed to exist.
The following shows a corrected version of this substituting template:
In this template, the service requirement of the ClientSoftware
node type is defined with a count_range of [0, 1], which means the
requirement is no longer mandatory. Only the software1 node template
annotates its service requirement as mandatory (using the optional: False statement). The other two software nodes leave their service
requirement optional. As a result, this is now a valid substituting
template for nodes of type Client that define a service
requirement with count_range equal to [1, 4].
Requirement mapping must take one more rule into account: if the
number of requirement mappings is greater than the lower bound of the count_range, the orchestrator must first perform those mappings that
map requirements onto mandatory requirements in the substituting
template, and then it will perform the remaining mappings (which
presumably will map onto optional requirements in the substituting
template). This is done independent of the order in which the
requirement mappings are specified.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Substitution Mapping
Requirement Mapping Syntax
Requirement mapping differs from other mappings in the following two
ways:
with the same name, each of which may need to be mapped
separately.
mapped multiple times.
To accommodate this use case, requirement mappings are defined using
YAML lists rather than maps.
Mapping Multiple Requirements with the Same Name
The following example shows a
Client
node type that defines aservice
requirement with acount_range
of[2, 2]
, which meansthat client nodes need exactly two relationships to nodes of type
Server
.This following figure shows a service that consists of one such client
node connected to two server nodes.
This service can be implemented using the following TOSCA service
template:
In this template, the
client
nodes is annotated with thesubstitute
directive, which means that a substituting template mustbe found to instantiate this node. The following figure shows one
possible substitution.
The substituting template decomposes the
client
node into twodifferent
software
nodes, each with exactly oneservice
requirement. The requirement mapping syntax distributes the two
service
requirements from the substitutedclient
node between thetwo software nodes. The following code snippet shows the substituting
template:
The following template shows an alternative substitution. In this
example, both
service
requirements of the substitutedclient
nodeare mapped to corresponding requirements of a single
software
node:This example shows two identical mappings for the two
service
requirements. As a convience feature, it is possible to group
identical mapping statements using the syntax in the following
example. This syntax states that two
service
requirements of thesubstituted node are mapped to two corresponding
service
requirements of the
software
node in the substituting template.Mapping Requirements Multiple Times
Imagine a scenario wher nodes of type
Client
need to be hosted onnodes of type
Compute
as shown by the following type definitions:The following template shows such nodes and their relationships:
The following shows a substituting template that decomposes the node
of type
Client
into two software components, each of which needs tobe hosted on the
compute
node defined in the top-level template thatdefines the
client
node. This can be accomplished by mapping thehost
requirement of theclient
node twice, once to thehost
requirement of the
software1
node and once to thehost
requirementof the
software2
node.Using this syntax, the target of the requirement mapping is a list
of target requirements rather than a single requirement.
Requirement Mapping Rules
This section documents the rules for requirement mapping. The types
defined in the following code snippet are used to illustrate the
rules:
In this example, the
Client
node type defines aservice
requirement with a
count_range
of[1, 4]
. This means that a clientcan have up to four
service
connections to aServer
node, but onlyone of those is mandatory.
Requirement Assignments
Any service template that uses the
Client
node type must specify thecorrect number of requirement assignments, i.e, the number of
mandatory requirements must be greater than or equal to the lower
bound of the
count_range
and he total number of requirementassignments (optional as well as mandatory) must be less than or equal
to the upper bound of the count range.
The following shows a valid service template that uses
Client
andServer
nodes.In this example, the requirement assignments specify the target nodes
directly, but it is also valid to leave requirements dangling as
follows:
In this example, only the first
service
assignment is mandatory. Thenext two are optional. However, after the orchestrator fulfills the
dangling requirement, the resulting service topology for this second
example will likely be identical to the service topology in the first
example, since the orchestrator is able to fulfill both of the
optional requirements using
server
nodes in this topology.Note that after requirements have been fulfilled, it no longer matters
whether the requirement were mandatory or optional. All that matters
is that if the service topology is valid, the number of established
relationships is guaranteed to fall within the
count_range
specifiedin the corresponding requirement definition.
Mapping Requirements
This section introduces the rules for requirement mappings:
substituted node can only be mapped onto dangling requirements
in the substituting template.
requirements in the substituting template must not exceed the lower
bound of the
count_range
in the corresponding requirementdefinition in the substituted node's type.
bound of the
count_range
in the corresponding requirementdefinition in the substituted node's type. Note that this is a
convenience rule only, since according to rule 2, any excess
mappings would have to map onto optional requirements, and as a
result can safely be ignored.
Note that there are no constraints on the minimum number of
requirement mappings. More specifically, the total number of
requirement mappings is allowed to be smaller than the lower bound of
the
count_range
in the corresponding requirement definition.The following code snippet shows a valid substituting template for the
client
node in the template shown above:While the substituted
client
node in the template above has threerequirement assigments with target nodes, only one of those
requirements is mapped to a requirement in the substituting template.
The next code snippet shows a slightly different substituting template
for the
client
node in the template shown above. This templatedecomposes the
client
node into three different software nodes,each with a single
service
requirement to its own server. Thesubstitution mapping defines three requirement mappings for the
service
requirement of theclient
node, one to each of theservice
requirements of thesoftware
nodes in the substitutingtemplate.
Unfortunately, this substituting template is invalid. Since the
service
requirement of eachsoftware
node is mandatory, thistemplate needs three different
service
requirements in any node oftype
Client
for which it is a substitution. This cannot beguaranteed, since the
service
requirement definition in theClient
node type specifies a
count_range
with a lower bound of one, whichmeans that only such requirement is guaranteed to exist.
The following shows a corrected version of this substituting template:
In this template, the
service
requirement of theClientSoftware
node type is defined with a
count_range
of[0, 1]
, which means therequirement is no longer mandatory. Only the
software1
node templateannotates its
service
requirement as mandatory (using theoptional: False
statement). The other two software nodes leave theirservice
requirement optional. As a result, this is now a valid substituting
template for nodes of type
Client
that define aservice
requirement with
count_range
equal to[1, 4]
.Requirement mapping must take one more rule into account: if the
number of requirement mappings is greater than the lower bound of the
count_range
, the orchestrator must first perform those mappings thatmap requirements onto mandatory requirements in the substituting
template, and then it will perform the remaining mappings (which
presumably will map onto optional requirements in the substituting
template). This is done independent of the order in which the
requirement mappings are specified.
Handling
UNBOUNDED
Count RangesTo be provided
Beta Was this translation helpful? Give feedback.
All reactions