From eef7cc5e367fab1c21bdafa7ec8c8d3986db3fb2 Mon Sep 17 00:00:00 2001 From: huruifeng Date: Wed, 29 Apr 2015 10:59:45 +0800 Subject: [PATCH] Apply topology_template to tosca_template Using TopologyTemplate in tosca_template to replace Input, Output, NodeTemplates and RelationshipTemplates. But keeping the functions to allow users to get above resources from ToscaTemplate. Modified testing templates with 'topology_template' section. partially implements: bp tosca-topology-template Change-Id: If3007c81d51f271a53c9940924f46e79a7648021 --- translator/hot/translate_node_templates.py | 3 +- .../tests/data/tosca_single_server.yaml | 51 +-- .../tosca_single_instance_wordpress.yaml | 187 +++++----- ..._custom_datatypes_in_current_template.yaml | 31 +- ...ustom_datatypes_nested_datatype_error.yaml | 33 +- .../test_custom_datatypes_positive.yaml | 31 +- .../test_custom_datatypes_value_error.yaml | 19 +- .../test_get_attribute_host_keyword.yaml | 51 +-- .../test_get_attribute_host_not_found.yaml | 23 +- ...get_attribute_illegal_host_in_outputs.yaml | 17 +- ..._get_attribute_unknown_attribute_name.yaml | 35 +- ..._attribute_unknown_node_template_name.yaml | 35 +- .../test_unknown_capability_property.yaml | 57 +-- .../test_unknown_input_in_interface.yaml | 23 +- .../test_unknown_input_in_property.yaml | 11 +- .../network/tosca_one_server_one_network.yaml | 66 ++-- .../tosca_one_server_three_networks.yaml | 102 ++--- .../tosca_server_on_existing_network.yaml | 56 +-- .../tosca_two_servers_one_network.yaml | 124 +++--- .../tosca_blockstorage_with_attachment.yaml | 101 ++--- ...lockstorage_with_attachment_notation1.yaml | 121 +++--- ...lockstorage_with_attachment_notation2.yaml | 135 +++---- ...multiple_blockstorage_with_attachment.yaml | 139 +++---- .../storage/tosca_single_object_store.yaml | 21 +- .../data/test_invalid_template_version.yaml | 11 +- .../data/test_no_inputs_in_template.yaml | 13 +- .../data/test_no_outputs_in_template.yaml | 13 +- .../tests/data/test_requirements.yaml | 89 ++--- ...est_tosca_normative_type_by_shortname.yaml | 51 +-- .../data/test_tosca_top_level_error1.yaml | 51 +-- .../data/test_tosca_top_level_error2.yaml | 51 +-- translator/toscalib/tests/data/tosca_elk.yaml | 352 +++++++++--------- .../tosca_nodejs_mongodb_two_instances.yaml | 122 +++--- .../data/tosca_single_instance_wordpress.yaml | 207 +++++----- translator/toscalib/topology_template.py | 5 +- translator/toscalib/tosca_template.py | 131 ++----- 36 files changed, 1267 insertions(+), 1301 deletions(-) diff --git a/translator/hot/translate_node_templates.py b/translator/hot/translate_node_templates.py index 3ac685e9..433dfddc 100644 --- a/translator/hot/translate_node_templates.py +++ b/translator/hot/translate_node_templates.py @@ -208,7 +208,8 @@ class TranslateNodeTemplates(object): relationship_tpl = req elif rkey == 'template': relationship_tpl = \ - self.tosca._tpl_relationship_templates()[rval] + (self.tosca.topology_template. + _tpl_relationship_templates()[rval]) else: continue if relationship_tpl: diff --git a/translator/tests/data/tosca_single_server.yaml b/translator/tests/data/tosca_single_server.yaml index eab308ca..be719018 100644 --- a/translator/tests/data/tosca_single_server.yaml +++ b/translator/tests/data/tosca_single_server.yaml @@ -3,30 +3,31 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 description: > TOSCA simple profile for Compute. -inputs: - cpus: - type: integer - description: Number of CPUs for the server. - constraints: - - valid_values: [ 1, 2, 4, 8 ] +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] -node_templates: - server: - type: tosca.nodes.Compute - properties: - # compute properties (flavor) - disk_size: 10 - num_cpus: { get_input: cpus } - mem_size: 4096 - capabilities: - os: - properties: - architecture: x86_64 - type: Linux - distribution: Fedora - version: 18 + node_templates: + server: + type: tosca.nodes.Compute + properties: + # compute properties (flavor) + disk_size: 10 + num_cpus: { get_input: cpus } + mem_size: 4096 + capabilities: + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18 -outputs: - server_address: - description: IP address of server instance. - value: { get_attribute: [server, private_address] } + outputs: + server_address: + description: IP address of server instance. + value: { get_attribute: [server, private_address] } diff --git a/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Definitions/tosca_single_instance_wordpress.yaml b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Definitions/tosca_single_instance_wordpress.yaml index fc822edc..9250bad2 100644 --- a/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Definitions/tosca_single_instance_wordpress.yaml +++ b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Definitions/tosca_single_instance_wordpress.yaml @@ -6,103 +6,104 @@ description: > imports: - wordpress.yaml -inputs: - cpus: - type: integer - description: Number of CPUs for the server. - constraints: - - valid_values: [ 1, 2, 4, 8 ] - db_name: - type: string - description: The name of the database. - db_user: - type: string - description: The user name of the DB user. - db_pwd: - type: string - description: The WordPress database admin account password. - db_root_pwd: - type: string - description: Root password for MySQL. - db_port: - type: integer - description: Port for the MySQL database. +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + db_name: + type: string + description: The name of the database. + db_user: + type: string + description: The user name of the DB user. + db_pwd: + type: string + description: The WordPress database admin account password. + db_root_pwd: + type: string + description: Root password for MySQL. + db_port: + type: integer + description: Port for the MySQL database. -node_templates: - wordpress: - type: tosca.nodes.WebApplication.WordPress - requirements: - - host: webserver - - database_endpoint: mysql_database - interfaces: - tosca.interfaces.node.lifecycle.Standard: - create: Scripts/WordPress/install.sh - configure: - implementation: Scripts/WordPress/configure.sh - inputs: - wp_db_name: { get_property: [ mysql_database, db_name ] } - wp_db_user: { get_property: [ mysql_database, db_user ] } - wp_db_password: { get_property: [ mysql_database, db_password ] } + node_templates: + wordpress: + type: tosca.nodes.WebApplication.WordPress + requirements: + - host: webserver + - database_endpoint: mysql_database + interfaces: + tosca.interfaces.node.lifecycle.Standard: + create: Scripts/WordPress/install.sh + configure: + implementation: Scripts/WordPress/configure.sh + inputs: + wp_db_name: { get_property: [ mysql_database, db_name ] } + wp_db_user: { get_property: [ mysql_database, db_user ] } + wp_db_password: { get_property: [ mysql_database, db_password ] } - mysql_database: - type: tosca.nodes.Database - properties: - db_name: { get_input: db_name } - db_user: { get_input: db_user } - db_password: { get_input: db_pwd } - requirements: - - host: mysql_dbms - interfaces: - tosca.interfaces.node.lifecycle.Standard: - configure: - implementation: Scripts/MYSQLDatabase/configure.sh + mysql_database: + type: tosca.nodes.Database + properties: + db_name: { get_input: db_name } + db_user: { get_input: db_user } + db_password: { get_input: db_pwd } + requirements: + - host: mysql_dbms + interfaces: + tosca.interfaces.node.lifecycle.Standard: + configure: + implementation: Scripts/MYSQLDatabase/configure.sh + inputs: + db_name: { get_property: [ SELF, db_name ] } + db_user: { get_property: [ SELF, db_user ] } + db_password: { get_property: [ SELF, db_password ] } + db_root_password: { get_property: [ mysql_dbms, dbms_root_password ] } + + mysql_dbms: + type: tosca.nodes.DBMS + properties: + dbms_root_password: { get_input: db_root_pwd } + dbms_port: { get_input: db_port } + requirements: + - host: server + interfaces: + tosca.interfaces.node.lifecycle.Standard: + create: Scripts/MYSQLDBMS/install.sh + start: Scripts/MYSQLDBMS/start.sh + configure: + implementation: Scripts/MYSQLDBMS/configure.sh inputs: - db_name: { get_property: [ SELF, db_name ] } - db_user: { get_property: [ SELF, db_user ] } - db_password: { get_property: [ SELF, db_password ] } db_root_password: { get_property: [ mysql_dbms, dbms_root_password ] } - mysql_dbms: - type: tosca.nodes.DBMS - properties: - dbms_root_password: { get_input: db_root_pwd } - dbms_port: { get_input: db_port } - requirements: - - host: server - interfaces: - tosca.interfaces.node.lifecycle.Standard: - create: Scripts/MYSQLDBMS/install.sh - start: Scripts/MYSQLDBMS/start.sh - configure: - implementation: Scripts/MYSQLDBMS/configure.sh - inputs: - db_root_password: { get_property: [ mysql_dbms, dbms_root_password ] } + webserver: + type: tosca.nodes.WebServer + requirements: + - host: server + interfaces: + tosca.interfaces.node.lifecycle.Standard: + create: Scripts/WebServer/install.sh + start: Scripts/WebServer/start.sh - webserver: - type: tosca.nodes.WebServer - requirements: - - host: server - interfaces: - tosca.interfaces.node.lifecycle.Standard: - create: Scripts/WebServer/install.sh - start: Scripts/WebServer/start.sh + server: + type: tosca.nodes.Compute + properties: + # compute properties (flavor) + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 MB + capabilities: + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18 - server: - type: tosca.nodes.Compute - properties: - # compute properties (flavor) - disk_size: 10 GB - num_cpus: { get_input: cpus } - mem_size: 4096 MB - capabilities: - os: - properties: - architecture: x86_64 - type: Linux - distribution: Fedora - version: 18 - -outputs: - website_url: - description: IP address for Wordpress wiki. - value: { get_attribute: [server, private_address] } + outputs: + website_url: + description: IP address for Wordpress wiki. + value: { get_attribute: [server, private_address] } diff --git a/translator/toscalib/tests/data/datatypes/test_custom_datatypes_in_current_template.yaml b/translator/toscalib/tests/data/datatypes/test_custom_datatypes_in_current_template.yaml index fa5e290d..77bd4e38 100644 --- a/translator/toscalib/tests/data/datatypes/test_custom_datatypes_in_current_template.yaml +++ b/translator/toscalib/tests/data/datatypes/test_custom_datatypes_in_current_template.yaml @@ -47,18 +47,19 @@ datatype_definitions: contact_phone: type: string -node_templates: - positive: - type: tosca.nodes.my.SomeNode - properties: - people: - name: Mike - gender: male - addresses: {Home: 1 foo street, Office: 9 bar avenue} - contacts: - - {contact_name: Tom, - contact_email: tom@email.com, - contact_phone: '123456789'} - - {contact_name: Jerry, - contact_email: jerry@email.com, - contact_phone: '321654987'} \ No newline at end of file +topology_template: + node_templates: + positive: + type: tosca.nodes.my.SomeNode + properties: + people: + name: Mike + gender: male + addresses: {Home: 1 foo street, Office: 9 bar avenue} + contacts: + - {contact_name: Tom, + contact_email: tom@email.com, + contact_phone: '123456789'} + - {contact_name: Jerry, + contact_email: jerry@email.com, + contact_phone: '321654987'} \ No newline at end of file diff --git a/translator/toscalib/tests/data/datatypes/test_custom_datatypes_nested_datatype_error.yaml b/translator/toscalib/tests/data/datatypes/test_custom_datatypes_nested_datatype_error.yaml index 0612e8c5..8c52f7d2 100644 --- a/translator/toscalib/tests/data/datatypes/test_custom_datatypes_nested_datatype_error.yaml +++ b/translator/toscalib/tests/data/datatypes/test_custom_datatypes_nested_datatype_error.yaml @@ -6,19 +6,20 @@ description: > imports: - custom_datatype_def.yaml -node_templates: - # 123456789 is not a string - error in nested datatype: - type: tosca.nodes.my.SomeNode - properties: - people: - name: Mike - gender: male - addresses: {Home: 1 foo street, Office: 9 bar avenue} - contacts: - - {contact_name: Tom, - contact_email: tom@email.com, - contact_phone: 123456789} - - {contact_name: Jerry, - contact_email: jerry@email.com, - contact_phone: '321654987'} +topology_template: + node_templates: + # 123456789 is not a string + error in nested datatype: + type: tosca.nodes.my.SomeNode + properties: + people: + name: Mike + gender: male + addresses: {Home: 1 foo street, Office: 9 bar avenue} + contacts: + - {contact_name: Tom, + contact_email: tom@email.com, + contact_phone: 123456789} + - {contact_name: Jerry, + contact_email: jerry@email.com, + contact_phone: '321654987'} diff --git a/translator/toscalib/tests/data/datatypes/test_custom_datatypes_positive.yaml b/translator/toscalib/tests/data/datatypes/test_custom_datatypes_positive.yaml index 1def6b6e..657201ac 100644 --- a/translator/toscalib/tests/data/datatypes/test_custom_datatypes_positive.yaml +++ b/translator/toscalib/tests/data/datatypes/test_custom_datatypes_positive.yaml @@ -6,18 +6,19 @@ description: > imports: - custom_datatype_def.yaml -node_templates: - positive: - type: tosca.nodes.my.SomeNode - properties: - people: - name: Mike - gender: male - addresses: {Home: 1 foo street, Office: 9 bar avenue} - contacts: - - {contact_name: Tom, - contact_email: tom@email.com, - contact_phone: '123456789'} - - {contact_name: Jerry, - contact_email: jerry@email.com, - contact_phone: '321654987'} +topology_template: + node_templates: + positive: + type: tosca.nodes.my.SomeNode + properties: + people: + name: Mike + gender: male + addresses: {Home: 1 foo street, Office: 9 bar avenue} + contacts: + - {contact_name: Tom, + contact_email: tom@email.com, + contact_phone: '123456789'} + - {contact_name: Jerry, + contact_email: jerry@email.com, + contact_phone: '321654987'} diff --git a/translator/toscalib/tests/data/datatypes/test_custom_datatypes_value_error.yaml b/translator/toscalib/tests/data/datatypes/test_custom_datatypes_value_error.yaml index c622ecbd..94ba2bb4 100644 --- a/translator/toscalib/tests/data/datatypes/test_custom_datatypes_value_error.yaml +++ b/translator/toscalib/tests/data/datatypes/test_custom_datatypes_value_error.yaml @@ -6,12 +6,13 @@ description: > imports: - custom_datatype_def.yaml -node_templates: - # addresses is not a map - error in field value: - type: tosca.nodes.my.SomeNode - properties: - people: - name: Mike - gender: male - addresses: [1 foo street, 9 bar avenue] +topology_template: + node_templates: + # addresses is not a map + error in field value: + type: tosca.nodes.my.SomeNode + properties: + people: + name: Mike + gender: male + addresses: [1 foo street, 9 bar avenue] diff --git a/translator/toscalib/tests/data/functions/test_get_attribute_host_keyword.yaml b/translator/toscalib/tests/data/functions/test_get_attribute_host_keyword.yaml index a02e71c7..bbb00156 100644 --- a/translator/toscalib/tests/data/functions/test_get_attribute_host_keyword.yaml +++ b/translator/toscalib/tests/data/functions/test_get_attribute_host_keyword.yaml @@ -3,30 +3,31 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 description: > TOSCA template for testing get_attribute with HOST keyword. -node_templates: - server: - type: tosca.nodes.Compute - properties: - num_cpus: 2 +topology_template: + node_templates: + server: + type: tosca.nodes.Compute + properties: + num_cpus: 2 - dbms: - type: tosca.nodes.DBMS - requirements: - - host: server - interfaces: - tosca.interfaces.node.lifecycle.Standard: - configure: - implementation: configure.sh - inputs: - ip_address: { get_attribute: [ HOST, private_address ] } + dbms: + type: tosca.nodes.DBMS + requirements: + - host: server + interfaces: + tosca.interfaces.node.lifecycle.Standard: + configure: + implementation: configure.sh + inputs: + ip_address: { get_attribute: [ HOST, private_address ] } - database: - type: tosca.nodes.Database - requirements: - - host: dbms - interfaces: - tosca.interfaces.node.lifecycle.Standard: - configure: - implementation: configure.sh - inputs: - ip_address: { get_attribute: [ HOST, private_address ] } + database: + type: tosca.nodes.Database + requirements: + - host: dbms + interfaces: + tosca.interfaces.node.lifecycle.Standard: + configure: + implementation: configure.sh + inputs: + ip_address: { get_attribute: [ HOST, private_address ] } diff --git a/translator/toscalib/tests/data/functions/test_get_attribute_host_not_found.yaml b/translator/toscalib/tests/data/functions/test_get_attribute_host_not_found.yaml index 0f0d9695..b37b9922 100644 --- a/translator/toscalib/tests/data/functions/test_get_attribute_host_not_found.yaml +++ b/translator/toscalib/tests/data/functions/test_get_attribute_host_not_found.yaml @@ -3,14 +3,15 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 description: > TOSCA template for testing get_attribute with HOST keyword. -node_templates: - server: - type: tosca.nodes.Compute - properties: - num_cpus: 2 - interfaces: - tosca.interfaces.node.lifecycle.Standard: - configure: - implementation: configure.sh - inputs: - ip_address: { get_attribute: [ HOST, private_address ] } +topology_template: + node_templates: + server: + type: tosca.nodes.Compute + properties: + num_cpus: 2 + interfaces: + tosca.interfaces.node.lifecycle.Standard: + configure: + implementation: configure.sh + inputs: + ip_address: { get_attribute: [ HOST, private_address ] } diff --git a/translator/toscalib/tests/data/functions/test_get_attribute_illegal_host_in_outputs.yaml b/translator/toscalib/tests/data/functions/test_get_attribute_illegal_host_in_outputs.yaml index fdb4a660..45ff5b07 100644 --- a/translator/toscalib/tests/data/functions/test_get_attribute_illegal_host_in_outputs.yaml +++ b/translator/toscalib/tests/data/functions/test_get_attribute_illegal_host_in_outputs.yaml @@ -3,12 +3,13 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 description: > TOSCA template for testing get_attribute with HOST keyword. -node_templates: - server: - type: tosca.nodes.Compute - properties: - num_cpus: 2 +topology_template: + node_templates: + server: + type: tosca.nodes.Compute + properties: + num_cpus: 2 -outputs: - ip_address: - value: { get_attribute: [ HOST, private_address ] } + outputs: + ip_address: + value: { get_attribute: [ HOST, private_address ] } diff --git a/translator/toscalib/tests/data/functions/test_get_attribute_unknown_attribute_name.yaml b/translator/toscalib/tests/data/functions/test_get_attribute_unknown_attribute_name.yaml index f57eb192..25c2ad93 100644 --- a/translator/toscalib/tests/data/functions/test_get_attribute_unknown_attribute_name.yaml +++ b/translator/toscalib/tests/data/functions/test_get_attribute_unknown_attribute_name.yaml @@ -4,22 +4,23 @@ description: > Tosca template for testing unknown attribute name in get_attribute function. -inputs: - image_id: - type: string +topology_template: + inputs: + image_id: + type: string -node_templates: - server: - type: tosca.nodes.Compute - properties: - num_cpus: 2 - interfaces: - tosca.interfaces.node.lifecycle.Standard: - configure: - implementation: start_server.sh - inputs: - image_id: { get_input: image_id } + node_templates: + server: + type: tosca.nodes.Compute + properties: + num_cpus: 2 + interfaces: + tosca.interfaces.node.lifecycle.Standard: + configure: + implementation: start_server.sh + inputs: + image_id: { get_input: image_id } -outputs: - ip_address: - value: { get_attribute: [ server, unknown_attribute ] } + outputs: + ip_address: + value: { get_attribute: [ server, unknown_attribute ] } diff --git a/translator/toscalib/tests/data/functions/test_get_attribute_unknown_node_template_name.yaml b/translator/toscalib/tests/data/functions/test_get_attribute_unknown_node_template_name.yaml index edc2e4a3..901c859c 100644 --- a/translator/toscalib/tests/data/functions/test_get_attribute_unknown_node_template_name.yaml +++ b/translator/toscalib/tests/data/functions/test_get_attribute_unknown_node_template_name.yaml @@ -4,22 +4,23 @@ description: > Tosca template for testing unknown node template name in get_attribute function. -inputs: - image_id: - type: string +topology_template: + inputs: + image_id: + type: string -node_templates: - server: - type: tosca.nodes.Compute - properties: - num_cpus: 2 - interfaces: - tosca.interfaces.node.lifecycle.Standard: - configure: - implementation: start_server.sh - inputs: - image_id: { get_input: image_id } + node_templates: + server: + type: tosca.nodes.Compute + properties: + num_cpus: 2 + interfaces: + tosca.interfaces.node.lifecycle.Standard: + configure: + implementation: start_server.sh + inputs: + image_id: { get_input: image_id } -outputs: - ip_address: - value: { get_attribute: [ unknown_node_template, private_address ] } + outputs: + ip_address: + value: { get_attribute: [ unknown_node_template, private_address ] } diff --git a/translator/toscalib/tests/data/functions/test_unknown_capability_property.yaml b/translator/toscalib/tests/data/functions/test_unknown_capability_property.yaml index 0ab95508..c2154b35 100644 --- a/translator/toscalib/tests/data/functions/test_unknown_capability_property.yaml +++ b/translator/toscalib/tests/data/functions/test_unknown_capability_property.yaml @@ -3,32 +3,33 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 description: > Tosca template for testing an unknown capability property. -node_templates: - server: - type: tosca.nodes.Compute - properties: - num_cpus: 2 - dbms: - type: tosca.nodes.DBMS - properties: - dbms_root_password: 1234 - dbms_port: 3672 +topology_template: + node_templates: + server: + type: tosca.nodes.Compute + properties: + num_cpus: 2 + dbms: + type: tosca.nodes.DBMS + properties: + dbms_root_password: 1234 + dbms_port: 3672 - database: - type: tosca.nodes.Database - properties: - db_name: my_db - db_user: abcd - db_password: 1234 - capabilities: - database_endpoint: - properties: - port: { get_property: [ dbms, dbms_port ] } - requirements: - - host: dbms - interfaces: - tosca.interfaces.node.lifecycle.Standard: - configure: - implementation: database_configure.sh - inputs: - db_port: { get_property: [ SELF, database_endpoint, unknown ] } + database: + type: tosca.nodes.Database + properties: + db_name: my_db + db_user: abcd + db_password: 1234 + capabilities: + database_endpoint: + properties: + port: { get_property: [ dbms, dbms_port ] } + requirements: + - host: dbms + interfaces: + tosca.interfaces.node.lifecycle.Standard: + configure: + implementation: database_configure.sh + inputs: + db_port: { get_property: [ SELF, database_endpoint, unknown ] } diff --git a/translator/toscalib/tests/data/functions/test_unknown_input_in_interface.yaml b/translator/toscalib/tests/data/functions/test_unknown_input_in_interface.yaml index 4002efbc..e80d8070 100644 --- a/translator/toscalib/tests/data/functions/test_unknown_input_in_interface.yaml +++ b/translator/toscalib/tests/data/functions/test_unknown_input_in_interface.yaml @@ -4,14 +4,15 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 description: > Tosca template for testing an unknown input. -node_templates: - server: - type: tosca.nodes.Compute - properties: - num_cpus: 2 - interfaces: - tosca.interfaces.node.lifecycle.Standard: - configure: - implementation: start_server.sh - inputs: - image_id: { get_input: image_id } +topology_template: + node_templates: + server: + type: tosca.nodes.Compute + properties: + num_cpus: 2 + interfaces: + tosca.interfaces.node.lifecycle.Standard: + configure: + implementation: start_server.sh + inputs: + image_id: { get_input: image_id } diff --git a/translator/toscalib/tests/data/functions/test_unknown_input_in_property.yaml b/translator/toscalib/tests/data/functions/test_unknown_input_in_property.yaml index bb3628b6..dd9c3bcb 100644 --- a/translator/toscalib/tests/data/functions/test_unknown_input_in_property.yaml +++ b/translator/toscalib/tests/data/functions/test_unknown_input_in_property.yaml @@ -3,8 +3,9 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 description: > Tosca template for testing an unknown input. -node_templates: - server: - type: tosca.nodes.Compute - properties: - num_cpus: { get_input: cpus } +topology_template: + node_templates: + server: + type: tosca.nodes.Compute + properties: + num_cpus: { get_input: cpus } diff --git a/translator/toscalib/tests/data/network/tosca_one_server_one_network.yaml b/translator/toscalib/tests/data/network/tosca_one_server_one_network.yaml index 2ff60b5d..d96a605c 100644 --- a/translator/toscalib/tests/data/network/tosca_one_server_one_network.yaml +++ b/translator/toscalib/tests/data/network/tosca_one_server_one_network.yaml @@ -3,39 +3,39 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 description: > TOSCA simple profile with 1 network and 1 attached server -inputs: - network_name: - type: string - description: Network name +topology_template: + inputs: + network_name: + type: string + description: Network name -node_templates: - my_server: - type: tosca.nodes.Compute - properties: - disk_size: 10 - num_cpus: 1 - mem_size: 512 - capabilities: - os: - properties: - architecture: x86_64 - type: Linux - distribution: CirrOS - version: 0.3.2 + node_templates: + my_server: + type: tosca.nodes.Compute + properties: + disk_size: 10 + num_cpus: 1 + mem_size: 512 + capabilities: + os: + properties: + architecture: x86_64 + type: Linux + distribution: CirrOS + version: 0.3.2 - my_network: - type: tosca.nodes.network.Network - properties: - ip_version: 4 - cidr: '192.168.0.0/24' - network_name: { get_input: network_name } - start_ip: '192.168.0.50' - end_ip: '192.168.0.200' - gateway_ip: '192.168.0.1' - - my_port: - type: tosca.nodes.network.Port - requirements: - - binding: my_server - - link: my_network + my_network: + type: tosca.nodes.network.Network + properties: + ip_version: 4 + cidr: '192.168.0.0/24' + network_name: { get_input: network_name } + start_ip: '192.168.0.50' + end_ip: '192.168.0.200' + gateway_ip: '192.168.0.1' + my_port: + type: tosca.nodes.network.Port + requirements: + - binding: my_server + - link: my_network diff --git a/translator/toscalib/tests/data/network/tosca_one_server_three_networks.yaml b/translator/toscalib/tests/data/network/tosca_one_server_three_networks.yaml index 5fd7387d..de54f27f 100644 --- a/translator/toscalib/tests/data/network/tosca_one_server_three_networks.yaml +++ b/translator/toscalib/tests/data/network/tosca_one_server_three_networks.yaml @@ -3,60 +3,60 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 description: > TOSCA simple profile with 3 networks and 1 attached server -node_templates: - my_server: - type: tosca.nodes.Compute - properties: - disk_size: 10 - num_cpus: 1 - mem_size: 512 - capabilities: - os: - properties: - architecture: x86_64 - type: Linux - distribution: CirrOS - version: 0.3.2 +topology_template: + node_templates: + my_server: + type: tosca.nodes.Compute + properties: + disk_size: 10 + num_cpus: 1 + mem_size: 512 + capabilities: + os: + properties: + architecture: x86_64 + type: Linux + distribution: CirrOS + version: 0.3.2 - my_network1: - type: tosca.nodes.network.Network - properties: - cidr: '192.168.1.0/24' - network_name: net1 + my_network1: + type: tosca.nodes.network.Network + properties: + cidr: '192.168.1.0/24' + network_name: net1 - my_network2: - type: tosca.nodes.network.Network - properties: - cidr: '192.168.2.0/24' - network_name: net2 + my_network2: + type: tosca.nodes.network.Network + properties: + cidr: '192.168.2.0/24' + network_name: net2 - my_network3: - type: tosca.nodes.network.Network - properties: - cidr: '192.168.3.0/24' - network_name: net3 + my_network3: + type: tosca.nodes.network.Network + properties: + cidr: '192.168.3.0/24' + network_name: net3 - my_port1: - type: tosca.nodes.network.Port - properties: - order: 0 - requirements: - - binding: my_server - - link: my_network1 + my_port1: + type: tosca.nodes.network.Port + properties: + order: 0 + requirements: + - binding: my_server + - link: my_network1 - my_port2: - type: tosca.nodes.network.Port - properties: - order: 1 - requirements: - - binding: my_server - - link: my_network2 - - my_port3: - type: tosca.nodes.network.Port - properties: - order: 2 - requirements: - - binding: my_server - - link: my_network3 + my_port2: + type: tosca.nodes.network.Port + properties: + order: 1 + requirements: + - binding: my_server + - link: my_network2 + my_port3: + type: tosca.nodes.network.Port + properties: + order: 2 + requirements: + - binding: my_server + - link: my_network3 diff --git a/translator/toscalib/tests/data/network/tosca_server_on_existing_network.yaml b/translator/toscalib/tests/data/network/tosca_server_on_existing_network.yaml index 9be3428f..e84a725e 100644 --- a/translator/toscalib/tests/data/network/tosca_server_on_existing_network.yaml +++ b/translator/toscalib/tests/data/network/tosca_server_on_existing_network.yaml @@ -3,34 +3,34 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 description: > TOSCA simple profile with 1 server attached to existing network -inputs: - network_name: - type: string - description: Network name +topology_template: + inputs: + network_name: + type: string + description: Network name -node_templates: - my_server: - type: tosca.nodes.Compute - properties: - disk_size: 10 - num_cpus: 1 - mem_size: 512 - capabilities: - os: - properties: - architecture: x86_64 - type: Linux - distribution: CirrOS - version: 0.3.2 + node_templates: + my_server: + type: tosca.nodes.Compute + properties: + disk_size: 10 + num_cpus: 1 + mem_size: 512 + capabilities: + os: + properties: + architecture: x86_64 + type: Linux + distribution: CirrOS + version: 0.3.2 - my_network: - type: tosca.nodes.network.Network - properties: - network_name: { get_input: network_name } - - my_port: - type: tosca.nodes.network.Port - requirements: - - binding: my_server - - link: my_network + my_network: + type: tosca.nodes.network.Network + properties: + network_name: { get_input: network_name } + my_port: + type: tosca.nodes.network.Port + requirements: + - binding: my_server + - link: my_network diff --git a/translator/toscalib/tests/data/network/tosca_two_servers_one_network.yaml b/translator/toscalib/tests/data/network/tosca_two_servers_one_network.yaml index 29cc9eda..3ce67a18 100644 --- a/translator/toscalib/tests/data/network/tosca_two_servers_one_network.yaml +++ b/translator/toscalib/tests/data/network/tosca_two_servers_one_network.yaml @@ -3,70 +3,70 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 description: > TOSCA simple profile with 1 network and 2 attached servers -inputs: - network_name: - type: string - description: Network name - network_cidr: - type: string - default: 10.0.0.0/24 - description: CIDR for the network - network_start_ip: - type: string - default: 10.0.0.100 - description: Start IP for the allocation pool - network_end_ip: - type: string - default: 10.0.0.150 - description: End IP for the allocation pool +topology_template: + inputs: + network_name: + type: string + description: Network name + network_cidr: + type: string + default: 10.0.0.0/24 + description: CIDR for the network + network_start_ip: + type: string + default: 10.0.0.100 + description: Start IP for the allocation pool + network_end_ip: + type: string + default: 10.0.0.150 + description: End IP for the allocation pool -node_templates: - my_server: - type: tosca.nodes.Compute - properties: - disk_size: 10 - num_cpus: 1 - mem_size: 512 - capabilities: - os: - properties: - architecture: x86_64 - type: Linux - distribution: CirrOS - version: 0.3.2 + node_templates: + my_server: + type: tosca.nodes.Compute + properties: + disk_size: 10 + num_cpus: 1 + mem_size: 512 + capabilities: + os: + properties: + architecture: x86_64 + type: Linux + distribution: CirrOS + version: 0.3.2 - my_server2: - type: tosca.nodes.Compute - properties: - disk_size: 10 - num_cpus: 1 - mem_size: 512 - capabilities: - os: - properties: - architecture: x86_64 - type: Linux - distribution: CirrOS - version: 0.3.2 + my_server2: + type: tosca.nodes.Compute + properties: + disk_size: 10 + num_cpus: 1 + mem_size: 512 + capabilities: + os: + properties: + architecture: x86_64 + type: Linux + distribution: CirrOS + version: 0.3.2 - my_network: - type: tosca.nodes.network.Network - properties: - ip_version: 4 - cidr: { get_input: network_cidr } - network_name: { get_input: network_name } - start_ip: { get_input: network_start_ip } - end_ip: { get_input: network_end_ip } + my_network: + type: tosca.nodes.network.Network + properties: + ip_version: 4 + cidr: { get_input: network_cidr } + network_name: { get_input: network_name } + start_ip: { get_input: network_start_ip } + end_ip: { get_input: network_end_ip } - my_port: - type: tosca.nodes.network.Port - requirements: - - binding: my_server - - link: my_network - - my_port2: - type: tosca.nodes.network.Port - requirements: - - binding: my_server2 - - link: my_network + my_port: + type: tosca.nodes.network.Port + requirements: + - binding: my_server + - link: my_network + my_port2: + type: tosca.nodes.network.Port + requirements: + - binding: my_server2 + - link: my_network diff --git a/translator/toscalib/tests/data/storage/tosca_blockstorage_with_attachment.yaml b/translator/toscalib/tests/data/storage/tosca_blockstorage_with_attachment.yaml index d8821ce3..455cc45a 100644 --- a/translator/toscalib/tests/data/storage/tosca_blockstorage_with_attachment.yaml +++ b/translator/toscalib/tests/data/storage/tosca_blockstorage_with_attachment.yaml @@ -3,55 +3,56 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 description: > TOSCA simple profile with server and attached block storage. -inputs: - cpus: - type: integer - description: Number of CPUs for the server. - constraints: - - valid_values: [ 1, 2, 4, 8 ] - storage_size: - type: integer - default: 1 GB - description: Size of the storage to be created. - storage_snapshot_id: - type: string - description: > - Some identifier that represents an existing snapshot that should be used when creating the block storage. - storage_location: - type: string - description: > - The relative location (e.g., path on the file system), which provides the root location to address an attached node. +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + storage_size: + type: integer + default: 1 GB + description: Size of the storage to be created. + storage_snapshot_id: + type: string + description: > + Some identifier that represents an existing snapshot that should be used when creating the block storage. + storage_location: + type: string + description: > + The relative location (e.g., path on the file system), which provides the root location to address an attached node. -node_templates: - my_server: - type: tosca.nodes.Compute - properties: - # compute properties (flavor) - disk_size: 10 GB - num_cpus: { get_input: cpus } - mem_size: 4096 MB - capabilities: - os: - properties: - architecture: x86_64 - type: Linux - distribution: Fedora - version: 18 - requirements: - - attachment: my_storage - type: AttachesTo - properties: - location: { get_input: storage_location } - my_storage: - type: tosca.nodes.BlockStorage - properties: - size: { get_input: storage_size } - snapshot_id: { get_input: storage_snapshot_id } + node_templates: + my_server: + type: tosca.nodes.Compute + properties: + # compute properties (flavor) + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 MB + capabilities: + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18 + requirements: + - attachment: my_storage + type: AttachesTo + properties: + location: { get_input: storage_location } + my_storage: + type: tosca.nodes.BlockStorage + properties: + size: { get_input: storage_size } + snapshot_id: { get_input: storage_snapshot_id } -outputs: - private_ip: - description: Private IP address of the newly created compute instance. - value: { get_attribute: [my_server, private_address] } - volume_id: - description: The volume id of the block storage instance. - value: { get_attribute: [my_storage, volume_id] } + outputs: + private_ip: + description: Private IP address of the newly created compute instance. + value: { get_attribute: [my_server, private_address] } + volume_id: + description: The volume id of the block storage instance. + value: { get_attribute: [my_storage, volume_id] } diff --git a/translator/toscalib/tests/data/storage/tosca_blockstorage_with_attachment_notation1.yaml b/translator/toscalib/tests/data/storage/tosca_blockstorage_with_attachment_notation1.yaml index 572a14b7..ee7db38b 100644 --- a/translator/toscalib/tests/data/storage/tosca_blockstorage_with_attachment_notation1.yaml +++ b/translator/toscalib/tests/data/storage/tosca_blockstorage_with_attachment_notation1.yaml @@ -3,69 +3,70 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 description: > TOSCA simple profile with server and attached block storage. -inputs: - cpus: - type: integer - description: Number of CPUs for the server. - constraints: - - valid_values: [ 1, 2, 4, 8 ] - storage_size: - type: integer - default: 1 GB - description: Size of the storage to be created. - storage_snapshot_id: - type: string - description: > - Some identifier that represents an existing snapshot that should be used when creating the block storage. - storage_location: - type: string - description: > - The relative location (e.g., path on the file system), which provides the root location to address an attached node. +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + storage_size: + type: integer + default: 1 GB + description: Size of the storage to be created. + storage_snapshot_id: + type: string + description: > + Some identifier that represents an existing snapshot that should be used when creating the block storage. + storage_location: + type: string + description: > + The relative location (e.g., path on the file system), which provides the root location to address an attached node. -node_templates: - my_web_app_tier_1: - type: tosca.nodes.Compute - properties: - # compute properties (flavor) - disk_size: 10 GB - num_cpus: { get_input: cpus } - mem_size: 4096 MB - capabilities: - os: - properties: - architecture: x86_64 - type: Linux - distribution: Fedora - version: 18 - requirements: - - attachment: my_storage - type: MyAttachTo + node_templates: + my_web_app_tier_1: + type: tosca.nodes.Compute + properties: + # compute properties (flavor) + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 MB + capabilities: + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18 + requirements: + - attachment: my_storage + type: MyAttachTo - my_web_app_tier_2: - type: tosca.nodes.Compute - properties: - # compute properties (flavor) - disk_size: 10 GB - num_cpus: { get_input: cpus } - mem_size: 4096 MB - capabilities: - os: - properties: - architecture: x86_64 - type: Linux - distribution: Fedora - version: 18 - requirements: - - attachment: my_storage - type: MyAttachTo - properties: - location: /some_other_data_location + my_web_app_tier_2: + type: tosca.nodes.Compute + properties: + # compute properties (flavor) + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 MB + capabilities: + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18 + requirements: + - attachment: my_storage + type: MyAttachTo + properties: + location: /some_other_data_location - my_storage: - type: tosca.nodes.BlockStorage - properties: - size: { get_input: storage_size } - snapshot_id: { get_input: storage_snapshot_id } + my_storage: + type: tosca.nodes.BlockStorage + properties: + size: { get_input: storage_size } + snapshot_id: { get_input: storage_snapshot_id } relationship_types: MyAttachTo: diff --git a/translator/toscalib/tests/data/storage/tosca_blockstorage_with_attachment_notation2.yaml b/translator/toscalib/tests/data/storage/tosca_blockstorage_with_attachment_notation2.yaml index 08b75ce6..953232df 100644 --- a/translator/toscalib/tests/data/storage/tosca_blockstorage_with_attachment_notation2.yaml +++ b/translator/toscalib/tests/data/storage/tosca_blockstorage_with_attachment_notation2.yaml @@ -3,78 +3,79 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 description: > TOSCA simple profile with server and attached block storage. -inputs: - cpus: - type: integer - description: Number of CPUs for the server. - constraints: - - valid_values: [ 1, 2, 4, 8 ] - storage_size: - type: integer - default: 1 GB - description: Size of the storage to be created. - storage_snapshot_id: - type: string - description: > - Some identifier that represents an existing snapshot that should be used when creating the block storage. - storage_location: - type: string - description: > - The relative location (e.g., path on the file system), which provides the root location to address an attached node. +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + storage_size: + type: integer + default: 1 GB + description: Size of the storage to be created. + storage_snapshot_id: + type: string + description: > + Some identifier that represents an existing snapshot that should be used when creating the block storage. + storage_location: + type: string + description: > + The relative location (e.g., path on the file system), which provides the root location to address an attached node. -node_templates: - my_web_app_tier_1: - type: tosca.nodes.Compute - properties: - # compute properties (flavor) - disk_size: 10 GB - num_cpus: { get_input: cpus } - mem_size: 4096 MB - capabilities: - os: - properties: - architecture: x86_64 - type: Linux - distribution: Fedora - version: 18 - requirements: - - attachment: my_storage - template: storage_attachesto_1 + node_templates: + my_web_app_tier_1: + type: tosca.nodes.Compute + properties: + # compute properties (flavor) + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 MB + capabilities: + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18 + requirements: + - attachment: my_storage + template: storage_attachesto_1 - my_web_app_tier_2: - type: tosca.nodes.Compute - properties: - # compute properties (flavor) - disk_size: 10 GB - num_cpus: { get_input: cpus } - mem_size: 4096 MB - capabilities: - os: - properties: - architecture: x86_64 - type: Linux - distribution: Fedora - version: 18 - requirements: - - attachment: my_storage - template: storage_attachesto_2 + my_web_app_tier_2: + type: tosca.nodes.Compute + properties: + # compute properties (flavor) + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 MB + capabilities: + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18 + requirements: + - attachment: my_storage + template: storage_attachesto_2 - my_storage: - type: tosca.nodes.BlockStorage - properties: - size: { get_input: storage_size } - snapshot_id: { get_input: storage_snapshot_id } + my_storage: + type: tosca.nodes.BlockStorage + properties: + size: { get_input: storage_size } + snapshot_id: { get_input: storage_snapshot_id } -relationship_templates: - storage_attachesto_1: - type: MyAttachTo - properties: - location: /my_data_location + relationship_templates: + storage_attachesto_1: + type: MyAttachTo + properties: + location: /my_data_location - storage_attachesto_2: - type: MyAttachTo - properties: - location: /some_other_data_location + storage_attachesto_2: + type: MyAttachTo + properties: + location: /some_other_data_location relationship_types: MyAttachTo: diff --git a/translator/toscalib/tests/data/storage/tosca_multiple_blockstorage_with_attachment.yaml b/translator/toscalib/tests/data/storage/tosca_multiple_blockstorage_with_attachment.yaml index 17ad6e29..09fef004 100644 --- a/translator/toscalib/tests/data/storage/tosca_multiple_blockstorage_with_attachment.yaml +++ b/translator/toscalib/tests/data/storage/tosca_multiple_blockstorage_with_attachment.yaml @@ -3,75 +3,76 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 description: > TOSCA simple profile with server and attached block storage. -inputs: - cpus: - type: integer - description: Number of CPUs for the server. - constraints: - - valid_values: [ 1, 2, 4, 8 ] - storage_size: - type: integer - default: 1 GB - description: Size of the storage to be created. - storage_snapshot_id: - type: string - description: Some identifier that represents an existing snapshot that should be used when creating the block storage. - storage_location: - type: string - description: The relative location (e.g., path on the file system), which provides the root location to address an attached node. +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + storage_size: + type: integer + default: 1 GB + description: Size of the storage to be created. + storage_snapshot_id: + type: string + description: Some identifier that represents an existing snapshot that should be used when creating the block storage. + storage_location: + type: string + description: The relative location (e.g., path on the file system), which provides the root location to address an attached node. -node_templates: - my_server: - type: tosca.nodes.Compute - properties: - # compute properties (flavor) - disk_size: 10 GB - num_cpus: { get_input: cpus } - mem_size: 4096 MB - capabilities: - os: - properties: - architecture: x86_64 - type: Linux - distribution: Fedora - version: 18 - requirements: - - attachment: my_storage - type: AttachesTo - properties: - location: { get_input: storage_location } - my_storage: - type: tosca.nodes.BlockStorage - properties: - size: { get_input: storage_size } - snapshot_id: { get_input: storage_snapshot_id } + node_templates: + my_server: + type: tosca.nodes.Compute + properties: + # compute properties (flavor) + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 MB + capabilities: + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18 + requirements: + - attachment: my_storage + type: AttachesTo + properties: + location: { get_input: storage_location } + my_storage: + type: tosca.nodes.BlockStorage + properties: + size: { get_input: storage_size } + snapshot_id: { get_input: storage_snapshot_id } - my_server2: - type: tosca.nodes.Compute - properties: - # compute properties (flavor) - disk_size: 10 GB - num_cpus: { get_input: cpus } - mem_size: 4096 MB - capabilities: - os: - properties: - architecture: x86_64 - type: Linux - distribution: Fedora - version: 18 - requirements: - - attachment: my_storage2 - type: AttachesTo - properties: - location: { get_input: storage_location } - my_storage2: - type: tosca.nodes.BlockStorage - properties: - size: { get_input: storage_size } - snapshot_id: { get_input: storage_snapshot_id } + my_server2: + type: tosca.nodes.Compute + properties: + # compute properties (flavor) + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 MB + capabilities: + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18 + requirements: + - attachment: my_storage2 + type: AttachesTo + properties: + location: { get_input: storage_location } + my_storage2: + type: tosca.nodes.BlockStorage + properties: + size: { get_input: storage_size } + snapshot_id: { get_input: storage_snapshot_id } -outputs: - private_ip: - description: Private IP address of the newly created compute instance. - value: { get_attribute: [my_server, private_address] } + outputs: + private_ip: + description: Private IP address of the newly created compute instance. + value: { get_attribute: [my_server, private_address] } diff --git a/translator/toscalib/tests/data/storage/tosca_single_object_store.yaml b/translator/toscalib/tests/data/storage/tosca_single_object_store.yaml index 9f0ed2fd..afc99096 100644 --- a/translator/toscalib/tests/data/storage/tosca_single_object_store.yaml +++ b/translator/toscalib/tests/data/storage/tosca_single_object_store.yaml @@ -3,14 +3,15 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 description: > Tosca template for testing a objectstorage template. -inputs: - objectstore_name: - type: string +topology_template: + inputs: + objectstore_name: + type: string -node_templates: - obj_store_server: - type: tosca.nodes.ObjectStorage - properties: - store_name: { get_input: objectstore_name } - store_size: 1024 - store_maxsize: 1 GB + node_templates: + obj_store_server: + type: tosca.nodes.ObjectStorage + properties: + store_name: { get_input: objectstore_name } + store_size: 1024 + store_maxsize: 1 GB diff --git a/translator/toscalib/tests/data/test_invalid_template_version.yaml b/translator/toscalib/tests/data/test_invalid_template_version.yaml index c1951456..8c8b6ce7 100644 --- a/translator/toscalib/tests/data/test_invalid_template_version.yaml +++ b/translator/toscalib/tests/data/test_invalid_template_version.yaml @@ -3,8 +3,9 @@ tosca_definitions_version: tosca_xyz description: > Test template with an invalid template version. -node_templates: - server: - type: tosca.nodes.Compute - properties: - num_cpus: 2 \ No newline at end of file +topology_template: + node_templates: + server: + type: tosca.nodes.Compute + properties: + num_cpus: 2 \ No newline at end of file diff --git a/translator/toscalib/tests/data/test_no_inputs_in_template.yaml b/translator/toscalib/tests/data/test_no_inputs_in_template.yaml index d6481cb9..8774b562 100644 --- a/translator/toscalib/tests/data/test_no_inputs_in_template.yaml +++ b/translator/toscalib/tests/data/test_no_inputs_in_template.yaml @@ -3,10 +3,11 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 description: > Tosca template for testing a template with no inputs. -node_templates: - server: - type: tosca.nodes.Compute - properties: - num_cpus: 2 +topology_template: + node_templates: + server: + type: tosca.nodes.Compute + properties: + num_cpus: 2 -outputs: + outputs: diff --git a/translator/toscalib/tests/data/test_no_outputs_in_template.yaml b/translator/toscalib/tests/data/test_no_outputs_in_template.yaml index 76bbc6cc..f031e98a 100644 --- a/translator/toscalib/tests/data/test_no_outputs_in_template.yaml +++ b/translator/toscalib/tests/data/test_no_outputs_in_template.yaml @@ -3,10 +3,11 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 description: > Tosca template for testing a template with no outputs. -inputs: +topology_template: + inputs: -node_templates: - server: - type: tosca.nodes.Compute - properties: - num_cpus: 2 + node_templates: + server: + type: tosca.nodes.Compute + properties: + num_cpus: 2 diff --git a/translator/toscalib/tests/data/test_requirements.yaml b/translator/toscalib/tests/data/test_requirements.yaml index 6a9a1089..3b8e151e 100644 --- a/translator/toscalib/tests/data/test_requirements.yaml +++ b/translator/toscalib/tests/data/test_requirements.yaml @@ -6,48 +6,49 @@ description: > imports: - custom_types/wordpress.yaml -node_templates: - my_app: - description: > - Specify multiple requirement via node and relationship keyword, - as an explicit relationship. Also demonstrates relationship with - type keyword and without it as an in-line reference. - type: tosca.nodes.WebApplication.WordPress - requirements: - - req1: - node: my_webserver - relationship: tosca.relationships.HostedOn - - req2: - node: mysql_database - relationship: - type: tosca.relationships.ConnectsTo - mysql_database: - description: Specify requirement via a capability as an implicit relationship. - type: tosca.nodes.Database - requirements: - - host: my_dbms - my_dbms: - type: tosca.nodes.DBMS - my_webserver: - type: tosca.nodes.WebServer - my_server: - description: > - Specify requirement via a relationship template, as an explicit relationship. - type: tosca.nodes.Compute - properties: - num_cpus: 2 - requirements: - - req1: - node: my_storage - relationship: storage_attachment - my_storage: - type: tosca.nodes.BlockStorage - properties: - size: 1 - snapshot_id: id +topology_template: + node_templates: + my_app: + description: > + Specify multiple requirement via node and relationship keyword, + as an explicit relationship. Also demonstrates relationship with + type keyword and without it as an in-line reference. + type: tosca.nodes.WebApplication.WordPress + requirements: + - req1: + node: my_webserver + relationship: tosca.relationships.HostedOn + - req2: + node: mysql_database + relationship: + type: tosca.relationships.ConnectsTo + mysql_database: + description: Specify requirement via a capability as an implicit relationship. + type: tosca.nodes.Database + requirements: + - host: my_dbms + my_dbms: + type: tosca.nodes.DBMS + my_webserver: + type: tosca.nodes.WebServer + my_server: + description: > + Specify requirement via a relationship template, as an explicit relationship. + type: tosca.nodes.Compute + properties: + num_cpus: 2 + requirements: + - req1: + node: my_storage + relationship: storage_attachment + my_storage: + type: tosca.nodes.BlockStorage + properties: + size: 1 + snapshot_id: id -relationship_templates: - storage_attachment: - type: tosca.relationships.AttachesTo - properties: - location: /temp \ No newline at end of file + relationship_templates: + storage_attachment: + type: tosca.relationships.AttachesTo + properties: + location: /temp \ No newline at end of file diff --git a/translator/toscalib/tests/data/test_tosca_normative_type_by_shortname.yaml b/translator/toscalib/tests/data/test_tosca_normative_type_by_shortname.yaml index e4675f69..d251f017 100644 --- a/translator/toscalib/tests/data/test_tosca_normative_type_by_shortname.yaml +++ b/translator/toscalib/tests/data/test_tosca_normative_type_by_shortname.yaml @@ -3,30 +3,31 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 description: > TOSCA simple profile with short type name for Compute. -inputs: - cpus: - type: integer - description: Number of CPUs for the server. - constraints: - - valid_values: [ 1, 2, 4, 8 ] +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] -node_templates: - server: - type: Compute - properties: - # compute properties (flavor) - disk_size: 10 GB - num_cpus: { get_input: cpus } - mem_size: 4096 MB - capabilities: - os: - properties: - architecture: x86_64 - type: Linux - distribution: Fedora - version: 18 + node_templates: + server: + type: Compute + properties: + # compute properties (flavor) + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 MB + capabilities: + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18 -outputs: - server_address: - description: IP address of server instance. - value: { get_attribute: [server, private_address] } + outputs: + server_address: + description: IP address of server instance. + value: { get_attribute: [server, private_address] } diff --git a/translator/toscalib/tests/data/test_tosca_top_level_error1.yaml b/translator/toscalib/tests/data/test_tosca_top_level_error1.yaml index 51ba8643..805f6036 100644 --- a/translator/toscalib/tests/data/test_tosca_top_level_error1.yaml +++ b/translator/toscalib/tests/data/test_tosca_top_level_error1.yaml @@ -1,30 +1,31 @@ description: > TOSCA simple profile missing version section. -inputs: - cpus: - type: integer - description: Number of CPUs for the server. - constraints: - - valid_values: [ 1, 2, 4, 8 ] +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] -node_templates: - server: - type: tosca.nodes.Compute - properties: - # compute properties (flavor) - disk_size: 10 GB - num_cpus: { get_input: cpus } - mem_size: 4096 MB - capabilities: - os: - properties: - architecture: x86_64 - type: Linux - distribution: Fedora - version: 18 + node_templates: + server: + type: tosca.nodes.Compute + properties: + # compute properties (flavor) + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 MB + capabilities: + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18 -outputs: - server_address: - description: IP address of server instance. - value: { get_property: [server, private_address] } + outputs: + server_address: + description: IP address of server instance. + value: { get_property: [server, private_address] } diff --git a/translator/toscalib/tests/data/test_tosca_top_level_error2.yaml b/translator/toscalib/tests/data/test_tosca_top_level_error2.yaml index 104e7cab..437c0eb6 100644 --- a/translator/toscalib/tests/data/test_tosca_top_level_error2.yaml +++ b/translator/toscalib/tests/data/test_tosca_top_level_error2.yaml @@ -3,30 +3,31 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 description: > TOSCA simple profile with invalid top-level key: 'node_template'. -inputs: - cpus: - type: integer - description: Number of CPUs for the server. - constraints: - - valid_values: [ 1, 2, 4, 8 ] +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] -node_template: - server: - type: tosca.nodes.Compute - properties: - # compute properties (flavor) - disk_size: 10 GB - num_cpus: { get_input: cpus } - mem_size: 4096 MB - capabilities: - os: - properties: - architecture: x86_64 - type: Linux - distribution: Fedora - version: 18 + node_template: + server: + type: tosca.nodes.Compute + properties: + # compute properties (flavor) + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 MB + capabilities: + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18 -outputs: - server_address: - description: IP address of server instance. - value: { get_property: [server, private_address] } + outputs: + server_address: + description: IP address of server instance. + value: { get_property: [server, private_address] } diff --git a/translator/toscalib/tests/data/tosca_elk.yaml b/translator/toscalib/tests/data/tosca_elk.yaml index 23df46ca..a47231f0 100644 --- a/translator/toscalib/tests/data/tosca_elk.yaml +++ b/translator/toscalib/tests/data/tosca_elk.yaml @@ -37,181 +37,183 @@ dsl_definitions: implementation: rsyslog/pre_configure_source.py inputs: host: { get_attribute: [ TARGET, private_address ]} -inputs: - my_cpus: - type: integer - description: Number of CPUs for the server. - constraints: - - valid_values: [ 1, 2, 4, 8 ] - github_url: - type: string - description: The URL to download nodejs. - default: https://github.com/mmm/testnode.git - search_api_port: - type: integer - description: The default elasticsearch http client port. - default: 9200 - constraints: - - in_range: [ 9200, 9300 ] -node_templates: - nodejs: - type: tosca.nodes.SoftwareComponent.Nodejs - properties: - github_url: { get_input: github_url } - requirements: - - host: app_server - interfaces: - tosca.interfaces.node.lifecycle.Standard: - create: nodejs/create.sh - configure: - implementation: nodejs/config.sh - inputs: - github_url: { get_property: [ SELF, github_url ] } - start: nodejs/start.sh - mongo_db: - type: tosca.nodes.Database - requirements: - - host: mongo_dbms - mongo_dbms: - type: tosca.nodes.DBMS - requirements: - - host: mongo_server - properties: - dbms_port: 27017 - interfaces: - tosca.interfaces.node.lifecycle.Standard: - create: mongodb/create.sh - configure: mongodb/config.sh - start: mongodb/start.sh - elasticsearch: - type: tosca.nodes.SoftwareComponent.Elasticsearch - requirements: - - host: elasticsearch_server - properties: - search_api_port: { get_input: search_api_port } - capabilities: - search_endpoint: - properties: - port: { get_input: search_api_port } - kibana: - type: tosca.nodes.SoftwareComponent.Kibana - requirements: - - host: kibana_server - - search_endpoint: elasticsearch - logstash: - type: tosca.nodes.SoftwareComponent.Logstash - requirements: - - host: logstash_server - - search_endpoint: elasticsearch - interfaces: - tosca.interfaces.relationship.Configure: - pre_configure_source: - implementation: pre_configure_source.py - inputs: - host: { get_attribute: [ TARGET, private_address ] } - port: { get_attribute: [ TARGET, port ] } - interfaces: - tosca.interfaces.node.lifecycle.Standard: - create: lostash/create.sh - configure: logstash/config.sh - start: logstash/start.sh - app_collectd: - type: tosca.nodes.SoftwareComponent.Collectd - requirements: - - host: app_server - - collectd_endpoint: logstash - interfaces: *collectd_interface - app_rsyslog: - type: tosca.nodes.SoftwareComponent.Rsyslog - requirements: - - host: app_server - - rsyslog_endpoint: logstash - interfaces: *rsyslog_interface - mongodb_collectd: - type: tosca.nodes.SoftwareComponent.Collectd - requirements: - - host: mongo_server - - collectd_endpoint: logstash - interfaces: *collectd_interface - mongodb_rsyslog: - type: tosca.nodes.SoftwareComponent.Rsyslog - requirements: - - host: mongo_server - - rsyslog_endpoint: logstash - interfaces: *rsyslog_interface - elasticsearch_collectd: - type: tosca.nodes.SoftwareComponent.Collectd - requirements: - - host: elasticsearch_server - - collectd_endpoint: logstash - interfaces: *collectd_interface - elasticsearch_rsyslog: - type: tosca.nodes.SoftwareComponent.Rsyslog - requirements: - - host: logstash_server - - rsyslog_endpoint: logstash - interfaces: *rsyslog_interface - logstash_collectd: - type: tosca.nodes.SoftwareComponent.Collectd - requirements: - - host: logstash_server - - collectd_endpoint: logstash - interfaces: *collectd_interface - logstash_rsyslog: - type: tosca.nodes.SoftwareComponent.Rsyslog - requirements: - - host: elasticsearch_server - - rsyslog_endpoint: logstash - interfaces: *rsyslog_interface +topology_template: + inputs: + my_cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + github_url: + type: string + description: The URL to download nodejs. + default: https://github.com/mmm/testnode.git + search_api_port: + type: integer + description: The default elasticsearch http client port. + default: 9200 + constraints: + - in_range: [ 9200, 9300 ] - mongo_server: - type: tosca.nodes.Compute - properties: *ubuntu_node - capabilities: - os: - properties: *os_capabilities - app_server: - type: tosca.nodes.Compute - properties: *ubuntu_node - capabilities: - os: - properties: *os_capabilities - elasticsearch_server: - type: tosca.nodes.Compute - properties: *ubuntu_node - capabilities: - os: - properties: *os_capabilities - logstash_server: - type: tosca.nodes.Compute - properties: *ubuntu_node - capabilities: - os: - properties: *os_capabilities - kibana_server: - type: tosca.nodes.Compute - properties: *ubuntu_node - capabilities: - os: - properties: *os_capabilities + node_templates: + nodejs: + type: tosca.nodes.SoftwareComponent.Nodejs + properties: + github_url: { get_input: github_url } + requirements: + - host: app_server + interfaces: + tosca.interfaces.node.lifecycle.Standard: + create: nodejs/create.sh + configure: + implementation: nodejs/config.sh + inputs: + github_url: { get_property: [ SELF, github_url ] } + start: nodejs/start.sh + mongo_db: + type: tosca.nodes.Database + requirements: + - host: mongo_dbms + mongo_dbms: + type: tosca.nodes.DBMS + requirements: + - host: mongo_server + properties: + dbms_port: 27017 + interfaces: + tosca.interfaces.node.lifecycle.Standard: + create: mongodb/create.sh + configure: mongodb/config.sh + start: mongodb/start.sh + elasticsearch: + type: tosca.nodes.SoftwareComponent.Elasticsearch + requirements: + - host: elasticsearch_server + properties: + search_api_port: { get_input: search_api_port } + capabilities: + search_endpoint: + properties: + port: { get_input: search_api_port } + kibana: + type: tosca.nodes.SoftwareComponent.Kibana + requirements: + - host: kibana_server + - search_endpoint: elasticsearch + logstash: + type: tosca.nodes.SoftwareComponent.Logstash + requirements: + - host: logstash_server + - search_endpoint: elasticsearch + interfaces: + tosca.interfaces.relationship.Configure: + pre_configure_source: + implementation: pre_configure_source.py + inputs: + host: { get_attribute: [ TARGET, private_address ] } + port: { get_attribute: [ TARGET, port ] } + interfaces: + tosca.interfaces.node.lifecycle.Standard: + create: lostash/create.sh + configure: logstash/config.sh + start: logstash/start.sh + app_collectd: + type: tosca.nodes.SoftwareComponent.Collectd + requirements: + - host: app_server + - collectd_endpoint: logstash + interfaces: *collectd_interface + app_rsyslog: + type: tosca.nodes.SoftwareComponent.Rsyslog + requirements: + - host: app_server + - rsyslog_endpoint: logstash + interfaces: *rsyslog_interface + mongodb_collectd: + type: tosca.nodes.SoftwareComponent.Collectd + requirements: + - host: mongo_server + - collectd_endpoint: logstash + interfaces: *collectd_interface + mongodb_rsyslog: + type: tosca.nodes.SoftwareComponent.Rsyslog + requirements: + - host: mongo_server + - rsyslog_endpoint: logstash + interfaces: *rsyslog_interface + elasticsearch_collectd: + type: tosca.nodes.SoftwareComponent.Collectd + requirements: + - host: elasticsearch_server + - collectd_endpoint: logstash + interfaces: *collectd_interface + elasticsearch_rsyslog: + type: tosca.nodes.SoftwareComponent.Rsyslog + requirements: + - host: logstash_server + - rsyslog_endpoint: logstash + interfaces: *rsyslog_interface + logstash_collectd: + type: tosca.nodes.SoftwareComponent.Collectd + requirements: + - host: logstash_server + - collectd_endpoint: logstash + interfaces: *collectd_interface + logstash_rsyslog: + type: tosca.nodes.SoftwareComponent.Rsyslog + requirements: + - host: elasticsearch_server + - rsyslog_endpoint: logstash + interfaces: *rsyslog_interface -outputs: - nodejs_url: - description: URL for the nodejs server. - value: { get_attribute: [ app_server, private_address ] } - mongodb_url: - description: URL for the mongodb server. - value: { get_attribute: [ mongo_server, private_address ] } - mongodb_port: - description: Port for the mongodb server. - value: { get_property: [ mongo_dbms, dbms_port ] } - elasticsearch_url: - description: URL for the elasticsearch server. - value: { get_attribute: [ elasticsearch_server, private_address ] } - logstash_url: - description: URL for the logstash server. - value: { get_attribute: [ logstash_server, private_address ] } - kibana_url: - description: URL for the kibana server. - value: { get_attribute: [ kibana_server, private_address ] } + mongo_server: + type: tosca.nodes.Compute + properties: *ubuntu_node + capabilities: + os: + properties: *os_capabilities + app_server: + type: tosca.nodes.Compute + properties: *ubuntu_node + capabilities: + os: + properties: *os_capabilities + elasticsearch_server: + type: tosca.nodes.Compute + properties: *ubuntu_node + capabilities: + os: + properties: *os_capabilities + logstash_server: + type: tosca.nodes.Compute + properties: *ubuntu_node + capabilities: + os: + properties: *os_capabilities + kibana_server: + type: tosca.nodes.Compute + properties: *ubuntu_node + capabilities: + os: + properties: *os_capabilities + + outputs: + nodejs_url: + description: URL for the nodejs server. + value: { get_attribute: [ app_server, private_address ] } + mongodb_url: + description: URL for the mongodb server. + value: { get_attribute: [ mongo_server, private_address ] } + mongodb_port: + description: Port for the mongodb server. + value: { get_property: [ mongo_dbms, dbms_port ] } + elasticsearch_url: + description: URL for the elasticsearch server. + value: { get_attribute: [ elasticsearch_server, private_address ] } + logstash_url: + description: URL for the logstash server. + value: { get_attribute: [ logstash_server, private_address ] } + kibana_url: + description: URL for the kibana server. + value: { get_attribute: [ kibana_server, private_address ] } diff --git a/translator/toscalib/tests/data/tosca_nodejs_mongodb_two_instances.yaml b/translator/toscalib/tests/data/tosca_nodejs_mongodb_two_instances.yaml index c2e32f2b..024ab5f4 100644 --- a/translator/toscalib/tests/data/tosca_nodejs_mongodb_two_instances.yaml +++ b/translator/toscalib/tests/data/tosca_nodejs_mongodb_two_instances.yaml @@ -18,68 +18,68 @@ dsl_definitions: distribution: Ubuntu version: 14.04 -inputs: - my_cpus: - type: integer - description: Number of CPUs for the server. - constraints: - - valid_values: [ 1, 2, 4, 8 ] - default: 1 - github_url: - type: string - description: The URL to download nodejs. - default: https://github.com/sample.git +topology_template: + inputs: + my_cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + default: 1 + github_url: + type: string + description: The URL to download nodejs. + default: https://github.com/sample.git -node_templates: - nodejs: - type: tosca.nodes.SoftwareComponent.Nodejs - properties: - github_url: https://github.com/sample.git - requirements: - - host: app_server - interfaces: - tosca.interfaces.node.lifecycle.Standard: - create: nodejs/create.sh - configure: - implementation: nodejs/config.sh - inputs: - github_url: { get_property: [ SELF, github_url ] } - mongodb_ip: { get_attribute: [mongo_server, private_address] } - start: nodejs/start.sh + node_templates: + nodejs: + type: tosca.nodes.SoftwareComponent.Nodejs + properties: + github_url: https://github.com/sample.git + requirements: + - host: app_server + interfaces: + tosca.interfaces.node.lifecycle.Standard: + create: nodejs/create.sh + configure: + implementation: nodejs/config.sh + inputs: + github_url: { get_property: [ SELF, github_url ] } + mongodb_ip: { get_attribute: [mongo_server, private_address] } + start: nodejs/start.sh - mongo_dbms: - type: tosca.nodes.DBMS - requirements: - - host: mongo_server - properties: - dbms_port: 27017 - interfaces: - tosca.interfaces.node.lifecycle.Standard: - create: mongodb/create.sh - configure: - implementation: mongodb/config.sh - inputs: - mongodb_ip: { get_attribute: [mongo_server, private_address] } - start: mongodb/start.sh + mongo_dbms: + type: tosca.nodes.DBMS + requirements: + - host: mongo_server + properties: + dbms_port: 27017 + interfaces: + tosca.interfaces.node.lifecycle.Standard: + create: mongodb/create.sh + configure: + implementation: mongodb/config.sh + inputs: + mongodb_ip: { get_attribute: [mongo_server, private_address] } + start: mongodb/start.sh - mongo_server: - type: tosca.nodes.Compute - properties: *ubuntu_node - capabilities: - os: - properties: *os_capabilities - app_server: - type: tosca.nodes.Compute - properties: *ubuntu_node - capabilities: - os: - properties: *os_capabilities - -outputs: - nodejs_url: - description: URL for the nodejs server, http://:3000 - value: { get_attribute: [app_server, private_address] } - mongodb_url: - description: URL for the mongodb server. - value: { get_attribute: [mongo_server, private_address] } + mongo_server: + type: tosca.nodes.Compute + properties: *ubuntu_node + capabilities: + os: + properties: *os_capabilities + app_server: + type: tosca.nodes.Compute + properties: *ubuntu_node + capabilities: + os: + properties: *os_capabilities + outputs: + nodejs_url: + description: URL for the nodejs server, http://:3000 + value: { get_attribute: [app_server, private_address] } + mongodb_url: + description: URL for the mongodb server. + value: { get_attribute: [mongo_server, private_address] } diff --git a/translator/toscalib/tests/data/tosca_single_instance_wordpress.yaml b/translator/toscalib/tests/data/tosca_single_instance_wordpress.yaml index ecb798b5..a409a6c6 100644 --- a/translator/toscalib/tests/data/tosca_single_instance_wordpress.yaml +++ b/translator/toscalib/tests/data/tosca_single_instance_wordpress.yaml @@ -6,111 +6,112 @@ description: > imports: - custom_types/wordpress.yaml -inputs: - cpus: - type: integer - description: Number of CPUs for the server. - constraints: - - valid_values: [ 1, 2, 4, 8 ] - db_name: - type: string - description: The name of the database. - default: wordpress - db_user: - type: string - description: The user name of the DB user. - db_pwd: - type: string - description: The WordPress database admin account password. - db_root_pwd: - type: string - description: Root password for MySQL. - db_port: - type: integer - description: Port for the MySQL database. - default: 3306 +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + db_name: + type: string + description: The name of the database. + default: wordpress + db_user: + type: string + description: The user name of the DB user. + db_pwd: + type: string + description: The WordPress database admin account password. + db_root_pwd: + type: string + description: Root password for MySQL. + db_port: + type: integer + description: Port for the MySQL database. + default: 3306 -node_templates: - wordpress: - type: tosca.nodes.WebApplication.WordPress - requirements: - - host: webserver - - database_endpoint: mysql_database - interfaces: - tosca.interfaces.node.lifecycle.Standard: - create: wordpress/wordpress_install.sh - configure: - implementation: wordpress/wordpress_configure.sh - inputs: - wp_db_name: { get_property: [ mysql_database, db_name ] } - wp_db_user: { get_property: [ mysql_database, db_user ] } - wp_db_password: { get_property: [ mysql_database, db_password ] } - wp_db_port: { get_property: [ SELF, database_endpoint, port ] } + node_templates: + wordpress: + type: tosca.nodes.WebApplication.WordPress + requirements: + - host: webserver + - database_endpoint: mysql_database + interfaces: + tosca.interfaces.node.lifecycle.Standard: + create: wordpress/wordpress_install.sh + configure: + implementation: wordpress/wordpress_configure.sh + inputs: + wp_db_name: { get_property: [ mysql_database, db_name ] } + wp_db_user: { get_property: [ mysql_database, db_user ] } + wp_db_password: { get_property: [ mysql_database, db_password ] } + wp_db_port: { get_property: [ SELF, database_endpoint, port ] } - mysql_database: - type: tosca.nodes.Database - properties: - db_name: { get_input: db_name } - db_user: { get_input: db_user } - db_password: { get_input: db_pwd } - capabilities: - database_endpoint: - properties: - port: { get_input: db_port } - requirements: - - host: mysql_dbms - interfaces: - tosca.interfaces.node.lifecycle.Standard: - configure: - implementation: mysql/mysql_database_configure.sh - inputs: - db_name: { get_property: [ SELF, db_name ] } - db_user: { get_property: [ SELF, db_user ] } - db_password: { get_property: [ SELF, db_password ] } - db_root_password: { get_property: [ mysql_dbms, dbms_root_password ] } - db_port: { get_property: [ SELF, database_endpoint, port ] } - mysql_dbms: - type: tosca.nodes.DBMS - properties: - dbms_root_password: { get_input: db_root_pwd } - dbms_port: { get_input: db_port } - requirements: - - host: server - interfaces: - tosca.interfaces.node.lifecycle.Standard: - create: mysql/mysql_dbms_install.sh - start: mysql/mysql_dbms_start.sh - configure: - implementation: mysql/mysql_dbms_configure.sh - inputs: - db_user: { get_input: db_user } - db_root_password: { get_property: [ mysql_dbms, dbms_root_password ] } + mysql_database: + type: tosca.nodes.Database + properties: + db_name: { get_input: db_name } + db_user: { get_input: db_user } + db_password: { get_input: db_pwd } + capabilities: + database_endpoint: + properties: + port: { get_input: db_port } + requirements: + - host: mysql_dbms + interfaces: + tosca.interfaces.node.lifecycle.Standard: + configure: + implementation: mysql/mysql_database_configure.sh + inputs: + db_name: { get_property: [ SELF, db_name ] } + db_user: { get_property: [ SELF, db_user ] } + db_password: { get_property: [ SELF, db_password ] } + db_root_password: { get_property: [ mysql_dbms, dbms_root_password ] } + db_port: { get_property: [ SELF, database_endpoint, port ] } + mysql_dbms: + type: tosca.nodes.DBMS + properties: + dbms_root_password: { get_input: db_root_pwd } + dbms_port: { get_input: db_port } + requirements: + - host: server + interfaces: + tosca.interfaces.node.lifecycle.Standard: + create: mysql/mysql_dbms_install.sh + start: mysql/mysql_dbms_start.sh + configure: + implementation: mysql/mysql_dbms_configure.sh + inputs: + db_user: { get_input: db_user } + db_root_password: { get_property: [ mysql_dbms, dbms_root_password ] } - webserver: - type: tosca.nodes.WebServer - requirements: - - host: server - interfaces: - tosca.interfaces.node.lifecycle.Standard: - create: webserver/webserver_install.sh - start: webserver/webserver_start.sh + webserver: + type: tosca.nodes.WebServer + requirements: + - host: server + interfaces: + tosca.interfaces.node.lifecycle.Standard: + create: webserver/webserver_install.sh + start: webserver/webserver_start.sh - server: - type: tosca.nodes.Compute - properties: - # compute properties (flavor) - disk_size: 10 GB - num_cpus: { get_input: cpus } - mem_size: 4096 MB - capabilities: - os: - properties: - architecture: x86_64 - type: Linux - distribution: Fedora - version: 18 + server: + type: tosca.nodes.Compute + properties: + # compute properties (flavor) + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 MB + capabilities: + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18 -outputs: - website_url: - description: URL for Wordpress wiki. - value: { get_attribute: [server, private_address] } + outputs: + website_url: + description: URL for Wordpress wiki. + value: { get_attribute: [server, private_address] } diff --git a/translator/toscalib/topology_template.py b/translator/toscalib/topology_template.py index ac36e4cd..df29dae5 100644 --- a/translator/toscalib/topology_template.py +++ b/translator/toscalib/topology_template.py @@ -119,7 +119,10 @@ class TopologyTemplate(object): pass def _tpl_description(self): - return self.tpl[DESCRIPTION].rstrip() + description = self.tpl.get(DESCRIPTION) + if description: + description = description.rstrip() + return description def _tpl_inputs(self): return self.tpl.get(INPUTS) or {} diff --git a/translator/toscalib/tosca_template.py b/translator/toscalib/tosca_template.py index f64be34b..72290354 100644 --- a/translator/toscalib/tosca_template.py +++ b/translator/toscalib/tosca_template.py @@ -17,28 +17,22 @@ import os from translator.toscalib.common.exception import InvalidTemplateVersion from translator.toscalib.common.exception import MissingRequiredFieldError from translator.toscalib.common.exception import UnknownFieldError -from translator.toscalib import functions -from translator.toscalib.nodetemplate import NodeTemplate -from translator.toscalib.parameters import Input -from translator.toscalib.parameters import Output -from translator.toscalib.relationship_template import RelationshipTemplate +from translator.toscalib.topology_template import TopologyTemplate from translator.toscalib.tpl_relationship_graph import ToscaGraph - import translator.toscalib.utils.yamlparser # TOSCA template key names SECTIONS = (DEFINITION_VERSION, DEFAULT_NAMESPACE, TEMPLATE_NAME, - TEMPLATE_AUTHOR, TEMPLATE_VERSION, DESCRIPTION, IMPORTS, - DSL_DEFINITIONS, INPUTS, NODE_TEMPLATES, RELATIONSHIP_TEMPLATES, - NODE_TYPES, RELATIONSHIP_TYPES, CAPABILITY_TYPES, ARTIFACT_TYPES, - OUTPUTS, GROUPS, DATATYPE_DEFINITIONS) = \ + TOPOLOGY_TEMPLATE, TEMPLATE_AUTHOR, TEMPLATE_VERSION, + DESCRIPTION, IMPORTS, DSL_DEFINITIONS, NODE_TYPES, + RELATIONSHIP_TYPES, CAPABILITY_TYPES, ARTIFACT_TYPES, + DATATYPE_DEFINITIONS) = \ ('tosca_definitions_version', 'tosca_default_namespace', - 'template_name', 'template_author', 'template_version', - 'description', 'imports', 'dsl_definitions', 'inputs', - 'node_templates', 'relationship_templates', 'node_types', - 'relationship_types', 'capability_types', 'artifact_types', - 'outputs', 'groups', 'datatype_definitions') + 'template_name', 'topology_template', 'template_author', + 'template_version', 'description', 'imports', 'dsl_definitions', + 'node_types', 'relationship_types', 'capability_types', + 'artifact_types', 'datatype_definitions') log = logging.getLogger("tosca.model") @@ -56,58 +50,28 @@ class ToscaTemplate(object): self._validate_field() self.version = self._tpl_version() self.description = self._tpl_description() + self.topology_template = self._topology_template() self.inputs = self._inputs() self.relationship_templates = self._relationship_templates() self.nodetemplates = self._nodetemplates() self.outputs = self._outputs() self.graph = ToscaGraph(self.nodetemplates) - self._process_intrinsic_functions() + + def _topology_template(self): + return TopologyTemplate(self._tpl_topology_template(), + self._get_all_custom_defs()) def _inputs(self): - inputs = [] - for name, attrs in self._tpl_inputs().items(): - input = Input(name, attrs) - input.validate() - inputs.append(input) - return inputs + return self.topology_template.inputs def _nodetemplates(self): - custom_defs = {} - node_types = self._get_custom_types(NODE_TYPES) - if node_types: - custom_defs.update(node_types) - data_types = self._get_custom_types(DATATYPE_DEFINITIONS) - if data_types: - custom_defs.update(data_types) - capability_types = self._get_custom_types(CAPABILITY_TYPES) - if capability_types: - custom_defs.update(capability_types) - nodetemplates = [] - tpls = self._tpl_nodetemplates() - for name in tpls: - tpl = NodeTemplate(name, tpls, custom_defs, - self.relationship_templates) - tpl.validate(self) - nodetemplates.append(tpl) - return nodetemplates + return self.topology_template.nodetemplates def _relationship_templates(self): - custom_defs = self._get_custom_types(RELATIONSHIP_TYPES) - - rel_templates = [] - tpls = self._tpl_relationship_templates() - for name in tpls: - tpl = RelationshipTemplate(tpls[name], name, custom_defs) - rel_templates.append(tpl) - return rel_templates + return self.topology_template.relationship_templates def _outputs(self): - outputs = [] - for name, attrs in self._tpl_outputs().items(): - output = Output(name, attrs) - output.validate() - outputs.append(output) - return outputs + return self.topology_template.outputs def _tpl_version(self): return self.tpl[DEFINITION_VERSION] @@ -119,11 +83,21 @@ class ToscaTemplate(object): if IMPORTS in self.tpl: return self.tpl[IMPORTS] - def _tpl_inputs(self): - return self.tpl.get(INPUTS) or {} + def _tpl_relationship_types(self): + return self._get_custom_types(RELATIONSHIP_TYPES) - def _tpl_nodetemplates(self): - return self.tpl[NODE_TEMPLATES] + def _tpl_topology_template(self): + return self.tpl.get(TOPOLOGY_TEMPLATE) + + def _get_all_custom_defs(self): + types = [NODE_TYPES, CAPABILITY_TYPES, RELATIONSHIP_TYPES, + DATATYPE_DEFINITIONS] + custom_defs = {} + for type in types: + custom_def = self._get_custom_types(type) + if custom_def: + custom_defs.update(custom_def) + return custom_defs def _get_custom_types(self, type_definition): # Handle custom types defined in outer template file @@ -147,15 +121,6 @@ class ToscaTemplate(object): custom_defs.update(inner_custom_types) return custom_defs - def _tpl_relationship_templates(self): - return self.tpl.get(RELATIONSHIP_TEMPLATES) or {} - - def _tpl_relationship_types(self): - return self._get_custom_types(RELATIONSHIP_TYPES) - - def _tpl_outputs(self): - return self.tpl.get(OUTPUTS) or {} - def _validate_field(self): try: version = self._tpl_version() @@ -167,38 +132,6 @@ class ToscaTemplate(object): if name not in SECTIONS: raise UnknownFieldError(what='Template', field=name) - def _process_intrinsic_functions(self): - """Process intrinsic functions - - Current implementation processes functions within node template - properties, requirements, interfaces inputs and template outputs. - """ - for node_template in self.nodetemplates: - for prop in node_template.get_properties_objects(): - prop.value = functions.get_function(self, - node_template, - prop.value) - for interface in node_template.interfaces: - if interface.inputs: - for name, value in interface.inputs.items(): - interface.inputs[name] = functions.get_function( - self, - node_template, - value) - if node_template.requirements: - for req in node_template.requirements: - if 'properties' in req: - for key, value in req['properties'].items(): - req['properties'][key] = functions.get_function( - self, - req, - value) - - for output in self.outputs: - func = functions.get_function(self, self.outputs, output.value) - if isinstance(func, functions.GetAttribute): - output.attrs[output.VALUE] = func - def _validate_version(self, version): if version not in self.VALID_TEMPLATE_VERSIONS: raise InvalidTemplateVersion(