-
Type: New Feature
-
Status: Closed
-
Priority: Major
-
Resolution: Unresolved
-
Affects Version/s: CSD2
-
Fix Version/s: CSD2
-
Component/s: Profile-YAML
-
Labels:None
-
Proposal:Hide
Proposed text:
------------------
H.2.1 Defining a nested template that implements a node type
From an application perspective, it is often not necessary or desired to dive into platform details, but the platform/runtime for an application is abstracted. In such cases, the template for an application can use generic representations of platform components. The details for such platform components can then be defined in separate template files that get used as nested templates.
• Using a node type that is defined by another template
The following sample defines a web application (my_web_app) connected to a database (my_db), where both of these application layer components are hosted on a platform my_platform that has the capabilities to host web applications and databases. These hosting requirements are expressed by the corresponding requirements sections of the node templates: the my_web_app node template specifies in its container entry that it needs the web_container capability of my_platform, and my_db node template specifies in its container entry the need for the db_container capability of my_platform.
The my_platform template is of my.types.MyPlatform node type defined elsewhere (see below). This node type has properties the values of which are set in the my_platform template. After successful deployment of the web application it can be administered at the URL that is passed in the web_admin_url output parameter. The value of this parameter is retrieved via the get_property intrinsic function that accesses admin_url property of my_platform.
tosca_definitions_version: tosca_simple_yaml_1_0description: Template of an application and its database hosted on a platform
inputs:
- omitted here for sake of brevity
node_templates:
my_web_app:
type: my.types.MyWebApp
requirements:- container:
node: my_platform
capability: web_container - database: my_db
my_db:
type: my.types.MyDatabase
requirements:- container:
node: my_platform
capability: db_container
my_platform:
type: my.types.MyPlatform
properties:
web_port: 8080
db_port: 9090
cache_size: 1024outputs:
{ get_property: [ my_platform, admin_url ] }
web_admin_url:
description: The URL used to administer the Web application
value:The my.types.MyPlatform node type of the my_platform template is defined in the following example. It has the web_port, db_port, cache_size and admin_url properties; the values of the first three properties are set by the my_platform template in the sample above, and the value of the admin_url property has been returned as output of the template above. The my.types.MyPlatform node type specifies two capabilities it provides: the web_container capability of type xxx.WebApplicationContainer and the db_container capability of type xxx.DBMS. These two capabilities have been referred to by the my_web_app and my_db templates above as their respective container requirements.
tosca_definitions_version: tosca_simple_yaml_1_0node_types:
my.types.MyPlatform
properties:
web_port:
type: integer
db_port:
type: integer
cache_size:
type: integer
admin_url:
type: string
capabilities:
web_container: xxx.WebApplicationContainer
db_container: xxx.DBMS
The other two node types used on the file above are defined as follows:
tosca_definitions_version: tosca_simple_yaml_1_0node_types:
my.types.MyWebApp:
derived_from: my.types.Apps
requirements:
container: xxx.WebApplicationContainer
database: my.types.Databasemy.types.MyDatabase:
derived_from: my.types.DataStores
requirements:
container: xxx.DBMS
H.2.2 Defining a template implementing a node type
The following sample defines a template that implements a particular node type. The implements section specifies the node type the template implements, which is in this case the my.types.MyPlatform node type. The template specifies in its capabilities section that is provides a web_container capability as well as a db_container capability as prescribed by the implemented node type. These capabilities are realized by instances of node templates: web_container capability is provided by an instance of the web_app_container template, and the db_container capability is provided by an instance of the dbms template. The collection of properties of the my.types.MyPlatform node type are realized by the template below as inputs and outputs: the web_port, db_port and cache_size properties are expected as input values when the template is instantiated and the admin_url parameter is returned as output of the template. The actual values specified as properties of the my_platform node template above will be passed as inputs to the template in the example below; the output of the template below will be made available to the intrinsic function used in the outputs section of the example above.
tosca_definitions_version: tosca_simple_yaml_1_0description: Template of an application and its database hosted on a platform
implements: my.types.MyPlatform
capabilities:
web_container: web_app_container
db_container: dbmsinputs:
web_port:
type: integer
description: TCP port for web container
db_port:
type: integer
description: TCP port for DBMS
cache_size:
type: integer
description: size of web cachenode_templates:
{ get_input: web_port }
web_app_container:
type: xxx.WebApplicationContainer
properties:
port:cache_size:
{ get_input: cache_size }internal_web_container:
type: xxx.WebApplicationContainermanagement_module:
type: xxx.WebApp
requirements:
container: internal_web_containerdbms:
{ get_input: db_port }
type: xxx.DBMS
properties:
port:outputs:
{ get_property: [ management_module, admin_url ] }
admin_url:
description: asldjalsjdlsad
value:Note that the file above defines two node templates of type xxx:WebApplicationContainer namely the web_app_container node template as well as the internal_web_container node template. The latter is used by the management_module that has been defined in the file above as specified by its corresponding container requirement that refers to the internal_web_container. Thus, only the web_app_container node template is available for external usage, which is why exactly this node template is referred to by the web_container capability of the template in its capabilities section.
The xxx.WebApplicationContainer node type used by the template above is defined in the following file:
tosca_definitions_version: tosca_simple_yaml_1_0node_types:
xxx.WebApplicationContainer:
derived_from: xxx.Container
capabilities:
web_app_container: xxx.WebApplicationContainerCapabilityShowProposed text: ------------------ H.2.1 Defining a nested template that implements a node type From an application perspective, it is often not necessary or desired to dive into platform details, but the platform/runtime for an application is abstracted. In such cases, the template for an application can use generic representations of platform components. The details for such platform components can then be defined in separate template files that get used as nested templates. • Using a node type that is defined by another template The following sample defines a web application (my_web_app) connected to a database (my_db), where both of these application layer components are hosted on a platform my_platform that has the capabilities to host web applications and databases. These hosting requirements are expressed by the corresponding requirements sections of the node templates: the my_web_app node template specifies in its container entry that it needs the web_container capability of my_platform, and my_db node template specifies in its container entry the need for the db_container capability of my_platform. The my_platform template is of my.types.MyPlatform node type defined elsewhere (see below). This node type has properties the values of which are set in the my_platform template. After successful deployment of the web application it can be administered at the URL that is passed in the web_admin_url output parameter. The value of this parameter is retrieved via the get_property intrinsic function that accesses admin_url property of my_platform. tosca_definitions_version: tosca_simple_yaml_1_0 description: Template of an application and its database hosted on a platform inputs: omitted here for sake of brevity node_templates: my_web_app: type: my.types.MyWebApp requirements: container: node: my_platform capability: web_container database: my_db my_db: type: my.types.MyDatabase requirements: container: node: my_platform capability: db_container my_platform: type: my.types.MyPlatform properties: web_port: 8080 db_port: 9090 cache_size: 1024 outputs: web_admin_url: description: The URL used to administer the Web application value: { get_property: [ my_platform, admin_url ] } The my.types.MyPlatform node type of the my_platform template is defined in the following example. It has the web_port, db_port, cache_size and admin_url properties; the values of the first three properties are set by the my_platform template in the sample above, and the value of the admin_url property has been returned as output of the template above. The my.types.MyPlatform node type specifies two capabilities it provides: the web_container capability of type xxx.WebApplicationContainer and the db_container capability of type xxx.DBMS. These two capabilities have been referred to by the my_web_app and my_db templates above as their respective container requirements. tosca_definitions_version: tosca_simple_yaml_1_0 node_types: my.types.MyPlatform properties: web_port: type: integer db_port: type: integer cache_size: type: integer admin_url: type: string capabilities: web_container: xxx.WebApplicationContainer db_container: xxx.DBMS The other two node types used on the file above are defined as follows: tosca_definitions_version: tosca_simple_yaml_1_0 node_types: my.types.MyWebApp: derived_from: my.types.Apps requirements: container: xxx.WebApplicationContainer database: my.types.Database my.types.MyDatabase: derived_from: my.types.DataStores requirements: container: xxx.DBMS H.2.2 Defining a template implementing a node type The following sample defines a template that implements a particular node type. The implements section specifies the node type the template implements, which is in this case the my.types.MyPlatform node type. The template specifies in its capabilities section that is provides a web_container capability as well as a db_container capability as prescribed by the implemented node type. These capabilities are realized by instances of node templates: web_container capability is provided by an instance of the web_app_container template, and the db_container capability is provided by an instance of the dbms template. The collection of properties of the my.types.MyPlatform node type are realized by the template below as inputs and outputs: the web_port, db_port and cache_size properties are expected as input values when the template is instantiated and the admin_url parameter is returned as output of the template. The actual values specified as properties of the my_platform node template above will be passed as inputs to the template in the example below; the output of the template below will be made available to the intrinsic function used in the outputs section of the example above. tosca_definitions_version: tosca_simple_yaml_1_0 description: Template of an application and its database hosted on a platform implements: my.types.MyPlatform capabilities: web_container: web_app_container db_container: dbms inputs: web_port: type: integer description: TCP port for web container db_port: type: integer description: TCP port for DBMS cache_size: type: integer description: size of web cache node_templates: web_app_container: type: xxx.WebApplicationContainer properties: port: { get_input: web_port } cache_size: { get_input: cache_size } internal_web_container: type: xxx.WebApplicationContainer management_module: type: xxx.WebApp requirements: container: internal_web_container dbms: type: xxx.DBMS properties: port: { get_input: db_port } outputs: admin_url: description: asldjalsjdlsad value: { get_property: [ management_module, admin_url ] } Note that the file above defines two node templates of type xxx:WebApplicationContainer namely the web_app_container node template as well as the internal_web_container node template. The latter is used by the management_module that has been defined in the file above as specified by its corresponding container requirement that refers to the internal_web_container. Thus, only the web_app_container node template is available for external usage, which is why exactly this node template is referred to by the web_container capability of the template in its capabilities section. The xxx.WebApplicationContainer node type used by the template above is defined in the following file: tosca_definitions_version: tosca_simple_yaml_1_0 node_types: xxx.WebApplicationContainer: derived_from: xxx.Container capabilities: web_app_container: xxx.WebApplicationContainerCapability
Some initial text exists from Thomas/Frank, but was deferred to WD02. See "proposal" section below for proposed draft text (which will need to be update to grammar/changes made in WD01).
The MS Word version is in the Interop. SC's document folder:
https://www.oasis-open.org/apps/org/workgroup/tosca-interop/download.php/52332/TOSCA-133%20-%20Proposal%20for%20Defining%20a%20nested%20template%20that%20implements%20a%20node%20type.docx