diff --git a/translator/hot/tosca/tests/test_tosca_compute.py b/translator/hot/tosca/tests/test_tosca_compute.py index 298f40f1..e13e3551 100644 --- a/translator/hot/tosca/tests/test_tosca_compute.py +++ b/translator/hot/tosca/tests/test_tosca_compute.py @@ -39,17 +39,17 @@ class ToscaComputeTest(TestCase): def _compare_properties(self, hotprops, expectedprops): return all(item in hotprops.items() for item in expectedprops.items()) - def test_node_compute_with_properties_and_capabilities(self): + def test_node_compute_with_host_and_os_capabilities(self): tpl_snippet = ''' node_templates: server: type: tosca.nodes.Compute - properties: - # compute properties (flavor) - disk_size: 10 - num_cpus: 4 - mem_size: 4096 capabilities: + host: + properties: + disk_size: 10 + num_cpus: 4 + mem_size: 4096 os: properties: architecture: x86_64 @@ -68,12 +68,12 @@ class ToscaComputeTest(TestCase): node_templates: server: type: tosca.nodes.Compute - properties: - # compute properties (flavor) - disk_size: 10 - num_cpus: 4 - mem_size: 4096 capabilities: + host: + properties: + disk_size: 10 + num_cpus: 4 + mem_size: 4096 #left intentionally ''' expectedprops = {'flavor': 'm1.large', @@ -82,13 +82,11 @@ class ToscaComputeTest(TestCase): tpl_snippet, expectedprops) - def test_node_compute_without_properties(self): + def test_node_compute_without_host_capabilities(self): tpl_snippet = ''' node_templates: server: type: tosca.nodes.Compute - properties: - #left intentionally capabilities: os: properties: diff --git a/translator/hot/tosca/tosca_compute.py b/translator/hot/tosca/tosca_compute.py index 82891cb7..d75933ba 100755 --- a/translator/hot/tosca/tosca_compute.py +++ b/translator/hot/tosca/tosca_compute.py @@ -69,10 +69,10 @@ class ToscaCompute(HotResource): def handle_properties(self): self.properties.update(self.translate_compute_flavor_and_image( - self.nodetemplate.get_properties_objects(), + self.nodetemplate.get_capability('host'), self.nodetemplate.get_capability('os'))) self.properties = self.translate_compute_flavor_and_image( - self.nodetemplate.get_properties_objects(), + self.nodetemplate.get_capability('host'), self.nodetemplate.get_capability('os')) self.properties['user_data_format'] = 'SOFTWARE_CONFIG' # TODO(anyone): handle user key @@ -80,16 +80,18 @@ class ToscaCompute(HotResource): self.properties['key_name'] = 'userkey' # To be reorganized later based on new development in Glance and Graffiti - def translate_compute_flavor_and_image(self, properties, os_capability): + def translate_compute_flavor_and_image(self, + host_capability, + os_capability): hot_properties = {} - tosca_props = {} + host_cap_props = {} os_cap_props = {} image = None flavor = None - if properties: - for prop in properties: - tosca_props[prop.name] = prop.value - flavor = self._best_flavor(tosca_props) + if host_capability: + for prop in host_capability.get_properties_objects(): + host_cap_props[prop.name] = prop.value + flavor = self._best_flavor(host_cap_props) if os_capability: for prop in os_capability.get_properties_objects(): os_cap_props[prop.name] = prop.value diff --git a/translator/toscalib/elements/TOSCA_definition.yaml b/translator/toscalib/elements/TOSCA_definition.yaml index 178f8785..e1e5f0fa 100644 --- a/translator/toscalib/elements/TOSCA_definition.yaml +++ b/translator/toscalib/elements/TOSCA_definition.yaml @@ -46,29 +46,6 @@ tosca.nodes.Root: tosca.nodes.Compute: derived_from: tosca.nodes.Root - properties: - num_cpus: - required: no - type: integer - constraints: - - greater_or_equal: 1 - description: > - Number of (actual or virtual) CPUs associated with the Compute node. - disk_size: - required: no - type: scalar-unit.size - constraints: - - greater_or_equal: 0 MB - description: > - Size of the local disk, available to applications running on the - Compute node. - mem_size: - required: no - type: scalar-unit.size - constraints: - - greater_or_equal: 0 MB - description: > - Size of memory, available to applications running on the Compute node. attributes: private_address: type: string @@ -420,6 +397,22 @@ tosca.capabilities.Node: tosca.capabilities.Container: derived_from: tosca.capabilities.Root + properties: + num_cpus: + required: no + type: integer + constraints: + - greater_or_equal: 1 + disk_size: + required: no + type: scalar-unit.size + constraints: + - greater_or_equal: 0 MB + mem_size: + required: no + type: scalar-unit.size + constraints: + - greater_or_equal: 0 MB tosca.capabilities.Endpoint: derived_from: tosca.capabilities.Root 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 9250bad2..5d3bc5f0 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 @@ -33,8 +33,10 @@ topology_template: wordpress: type: tosca.nodes.WebApplication.WordPress requirements: - - host: webserver - - database_endpoint: mysql_database + - host: + node: webserver + - database_endpoint: + node: mysql_database interfaces: tosca.interfaces.node.lifecycle.Standard: create: Scripts/WordPress/install.sh @@ -52,7 +54,8 @@ topology_template: db_user: { get_input: db_user } db_password: { get_input: db_pwd } requirements: - - host: mysql_dbms + - host: + node: mysql_dbms interfaces: tosca.interfaces.node.lifecycle.Standard: configure: @@ -69,7 +72,8 @@ topology_template: dbms_root_password: { get_input: db_root_pwd } dbms_port: { get_input: db_port } requirements: - - host: server + - host: + node: server interfaces: tosca.interfaces.node.lifecycle.Standard: create: Scripts/MYSQLDBMS/install.sh @@ -82,26 +86,26 @@ topology_template: webserver: type: tosca.nodes.WebServer requirements: - - host: server + - host: + node: 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 + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 MB + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18 outputs: website_url: 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 bbb00156..3b3757e7 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 @@ -7,9 +7,10 @@ topology_template: node_templates: server: type: tosca.nodes.Compute - properties: - num_cpus: 2 - + capabilities: + host: + properties: + num_cpus: 2 dbms: type: tosca.nodes.DBMS requirements: @@ -20,7 +21,6 @@ topology_template: implementation: configure.sh inputs: ip_address: { get_attribute: [ HOST, private_address ] } - database: type: tosca.nodes.Database requirements: 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 b37b9922..e06a539e 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 @@ -7,11 +7,14 @@ topology_template: node_templates: server: type: tosca.nodes.Compute - properties: - num_cpus: 2 + capabilities: + host: + 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 45ff5b07..0733e4b0 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 @@ -7,8 +7,10 @@ topology_template: node_templates: server: type: tosca.nodes.Compute - properties: - num_cpus: 2 + capabilities: + host: + properties: + num_cpus: 2 outputs: ip_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 25c2ad93..53efad37 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 @@ -12,8 +12,10 @@ topology_template: node_templates: server: type: tosca.nodes.Compute - properties: - num_cpus: 2 + capabilities: + host: + properties: + num_cpus: 2 interfaces: tosca.interfaces.node.lifecycle.Standard: configure: 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 901c859c..555dd281 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 @@ -12,8 +12,10 @@ topology_template: node_templates: server: type: tosca.nodes.Compute - properties: - num_cpus: 2 + capabilities: + host: + properties: + num_cpus: 2 interfaces: tosca.interfaces.node.lifecycle.Standard: configure: 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 c2154b35..c623811c 100644 --- a/translator/toscalib/tests/data/functions/test_unknown_capability_property.yaml +++ b/translator/toscalib/tests/data/functions/test_unknown_capability_property.yaml @@ -7,14 +7,15 @@ topology_template: node_templates: server: type: tosca.nodes.Compute - properties: - num_cpus: 2 + capabilities: + host: + properties: + num_cpus: 2 dbms: type: tosca.nodes.DBMS properties: dbms_root_password: 1234 dbms_port: 3672 - database: type: tosca.nodes.Database properties: 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 e80d8070..141284c0 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 @@ -8,8 +8,10 @@ topology_template: node_templates: server: type: tosca.nodes.Compute - properties: - num_cpus: 2 + capabilities: + host: + properties: + num_cpus: 2 interfaces: tosca.interfaces.node.lifecycle.Standard: configure: 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 dd9c3bcb..63f8c6e1 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 @@ -5,7 +5,9 @@ description: > topology_template: node_templates: - server: - type: tosca.nodes.Compute + obj_store_server: + type: tosca.nodes.ObjectStorage properties: - num_cpus: { get_input: cpus } + store_name: { get_input: objectstore_name } + store_size: 1024 + store_maxsize: 1 GB diff --git a/translator/toscalib/tests/data/hot_output/hot_single_server.yaml b/translator/toscalib/tests/data/hot_output/hot_single_server.yaml index 6196310d..75d7d9be 100644 --- a/translator/toscalib/tests/data/hot_output/hot_single_server.yaml +++ b/translator/toscalib/tests/data/hot_output/hot_single_server.yaml @@ -18,7 +18,7 @@ resources: server: type: OS::Nova::Server properties: - flavor: null + flavor: m1.medium image: fedora-amd64-heat-config key_name: userkey user_data_format: SOFTWARE_CONFIG 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 ddfb0ec1..a24eda5c 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 @@ -12,18 +12,18 @@ topology_template: node_templates: my_server: type: tosca.nodes.Compute - properties: - disk_size: 10 - num_cpus: 1 - mem_size: 512 capabilities: + host: + properties: + disk_size: 10 + num_cpus: 1 + mem_size: 512 os: properties: architecture: x86_64 type: Linux distribution: CirrOS version: 0.3.2 - my_network: type: tosca.nodes.network.Network properties: @@ -33,7 +33,6 @@ topology_template: 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: 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 21520c09..ecdfd9bf 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 @@ -7,11 +7,12 @@ topology_template: node_templates: my_server: type: tosca.nodes.Compute - properties: - disk_size: 10 - num_cpus: 1 - mem_size: 512 capabilities: + host: + properties: + disk_size: 10 + num_cpus: 1 + mem_size: 512 os: properties: architecture: x86_64 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 1561550d..56968e91 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 @@ -12,23 +12,22 @@ topology_template: node_templates: my_server: type: tosca.nodes.Compute - properties: - disk_size: 10 - num_cpus: 1 - mem_size: 512 capabilities: + host: + properties: + disk_size: 10 + num_cpus: 1 + mem_size: 512 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: 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 3650122d..f31ae999 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 @@ -24,32 +24,32 @@ topology_template: node_templates: my_server: type: tosca.nodes.Compute - properties: - disk_size: 10 - num_cpus: 1 - mem_size: 512 capabilities: + host: + properties: + disk_size: 10 + num_cpus: 1 + mem_size: 512 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: + host: + properties: + disk_size: 10 + num_cpus: 1 + mem_size: 512 os: properties: architecture: x86_64 type: Linux distribution: CirrOS version: 0.3.2 - my_network: type: tosca.nodes.network.Network properties: @@ -58,7 +58,6 @@ topology_template: 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: @@ -66,7 +65,6 @@ topology_template: node: my_server - link: node: my_network - my_port2: type: tosca.nodes.network.Port requirements: 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 b8eca9fe..e4d55c7f 100644 --- a/translator/toscalib/tests/data/storage/tosca_blockstorage_with_attachment.yaml +++ b/translator/toscalib/tests/data/storage/tosca_blockstorage_with_attachment.yaml @@ -26,12 +26,12 @@ topology_template: 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: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 MB os: properties: architecture: x86_64 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 0cbf4769..9d6ad2b0 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 @@ -26,12 +26,12 @@ topology_template: 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: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 MB os: properties: architecture: x86_64 @@ -45,12 +45,12 @@ topology_template: 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: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 MB os: properties: architecture: x86_64 @@ -63,7 +63,6 @@ topology_template: relationship: MyAttachTo properties: location: /some_other_data_location - my_storage: type: tosca.nodes.BlockStorage properties: 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 d3fb7ecf..554a5cba 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 @@ -26,12 +26,12 @@ topology_template: 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: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 MB os: properties: architecture: x86_64 @@ -45,12 +45,12 @@ topology_template: 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: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 MB os: properties: architecture: x86_64 @@ -61,7 +61,6 @@ topology_template: - local_storage: node: my_storage relationship: storage_attachesto_2 - my_storage: type: tosca.nodes.BlockStorage properties: 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 93635afa..d7f07734 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 @@ -24,12 +24,12 @@ topology_template: 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: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 MB os: properties: architecture: x86_64 @@ -51,12 +51,12 @@ topology_template: my_server2: type: tosca.nodes.Compute - properties: - # compute properties (flavor) - disk_size: 10 GB - num_cpus: { get_input: cpus } - mem_size: 4096 MB capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 MB os: properties: architecture: x86_64 diff --git a/translator/toscalib/tests/data/test_invalid_template_version.yaml b/translator/toscalib/tests/data/test_invalid_template_version.yaml index 8c8b6ce7..86dce79c 100644 --- a/translator/toscalib/tests/data/test_invalid_template_version.yaml +++ b/translator/toscalib/tests/data/test_invalid_template_version.yaml @@ -7,5 +7,8 @@ topology_template: node_templates: server: type: tosca.nodes.Compute - properties: - num_cpus: 2 \ No newline at end of file + capabilities: + host: + properties: + num_cpus: 2 + 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 8774b562..1478739b 100644 --- a/translator/toscalib/tests/data/test_no_inputs_in_template.yaml +++ b/translator/toscalib/tests/data/test_no_inputs_in_template.yaml @@ -7,7 +7,9 @@ topology_template: node_templates: server: type: tosca.nodes.Compute - properties: - num_cpus: 2 + capabilities: + host: + properties: + num_cpus: 2 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 f031e98a..3bbb8d1b 100644 --- a/translator/toscalib/tests/data/test_no_outputs_in_template.yaml +++ b/translator/toscalib/tests/data/test_no_outputs_in_template.yaml @@ -9,5 +9,7 @@ topology_template: node_templates: server: type: tosca.nodes.Compute - properties: - num_cpus: 2 + capabilities: + host: + properties: + num_cpus: 2 diff --git a/translator/toscalib/tests/data/test_requirements.yaml b/translator/toscalib/tests/data/test_requirements.yaml index d80fe1d9..9c694726 100644 --- a/translator/toscalib/tests/data/test_requirements.yaml +++ b/translator/toscalib/tests/data/test_requirements.yaml @@ -37,8 +37,10 @@ topology_template: description: > Specify requirement via a relationship template, as an explicit relationship. type: tosca.nodes.Compute - properties: - num_cpus: 2 + capabilities: + host: + properties: + num_cpus: 2 requirements: - req1: node: my_storage 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 d251f017..0042ae12 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 @@ -14,12 +14,12 @@ topology_template: node_templates: server: type: Compute - properties: - # compute properties (flavor) - disk_size: 10 GB - num_cpus: { get_input: cpus } - mem_size: 4096 MB capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 MB os: properties: architecture: x86_64 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 805f6036..9b926bb9 100644 --- a/translator/toscalib/tests/data/test_tosca_top_level_error1.yaml +++ b/translator/toscalib/tests/data/test_tosca_top_level_error1.yaml @@ -12,12 +12,12 @@ topology_template: 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: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 MB os: properties: architecture: x86_64 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 437c0eb6..b9a4972b 100644 --- a/translator/toscalib/tests/data/test_tosca_top_level_error2.yaml +++ b/translator/toscalib/tests/data/test_tosca_top_level_error2.yaml @@ -14,12 +14,12 @@ topology_template: 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: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 MB os: properties: architecture: x86_64 diff --git a/translator/toscalib/tests/data/topology_template/subsystem.yaml b/translator/toscalib/tests/data/topology_template/subsystem.yaml index 774839b3..8b05d7ad 100644 --- a/translator/toscalib/tests/data/topology_template/subsystem.yaml +++ b/translator/toscalib/tests/data/topology_template/subsystem.yaml @@ -55,11 +55,12 @@ topology_template: server: type: tosca.nodes.Compute - properties: - disk_size: 10 GB - num_cpus: { get_input: my_cpus } - mem_size: 4096 MB capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: my_cpus } + mem_size: 4096 MB os: properties: architecture: x86_64 diff --git a/translator/toscalib/tests/data/tosca_elk.yaml b/translator/toscalib/tests/data/tosca_elk.yaml index d2b388e0..d438f66a 100644 --- a/translator/toscalib/tests/data/tosca_elk.yaml +++ b/translator/toscalib/tests/data/tosca_elk.yaml @@ -15,8 +15,7 @@ imports: - custom_types/rsyslog.yaml dsl_definitions: - ubuntu_node: &ubuntu_node - # compute properties (flavor) + host_capabilities: &host_capabilities disk_size: 10 GB num_cpus: 1 mem_size: 4096 MB @@ -176,32 +175,37 @@ topology_template: start: Scripts/rsyslog/start.sh app_server: type: tosca.nodes.Compute - properties: *ubuntu_node capabilities: + host: + properties: *host_capabilities os: properties: *os_capabilities mongo_server: type: tosca.nodes.Compute - properties: *ubuntu_node capabilities: + host: + properties: *host_capabilities os: properties: *os_capabilities elasticsearch_server: type: tosca.nodes.Compute - properties: *ubuntu_node capabilities: + host: + properties: *host_capabilities os: properties: *os_capabilities logstash_server: type: tosca.nodes.Compute - properties: *ubuntu_node capabilities: + host: + properties: *host_capabilities os: properties: *os_capabilities kibana_server: type: tosca.nodes.Compute - properties: *ubuntu_node capabilities: + host: + properties: *host_capabilities os: properties: *os_capabilities 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 d4b7777a..92d151cb 100644 --- a/translator/toscalib/tests/data/tosca_nodejs_mongodb_two_instances.yaml +++ b/translator/toscalib/tests/data/tosca_nodejs_mongodb_two_instances.yaml @@ -7,16 +7,15 @@ imports: - custom_types/nodejs.yaml dsl_definitions: - ubuntu_node: &ubuntu_node - # compute properties (flavor) - disk_size: 10 GB - num_cpus: 1 - mem_size: 4096 MB - os_capabilities: &os_capabilities - architecture: x86_64 - type: Linux - distribution: Ubuntu - version: 14.04 + host_capabilities: &host_capabilities + disk_size: 10 GB + num_cpus: 1 + mem_size: 4096 MB + os_capabilities: &os_capabilities + architecture: x86_64 + type: Linux + distribution: Ubuntu + version: 14.04 topology_template: inputs: @@ -50,7 +49,6 @@ topology_template: 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: @@ -68,17 +66,18 @@ topology_template: inputs: mongodb_ip: { get_attribute: [mongo_server, private_address] } start: mongodb/start.sh - mongo_server: type: tosca.nodes.Compute - properties: *ubuntu_node capabilities: + host: + properties: *host_capabilities os: properties: *os_capabilities app_server: type: tosca.nodes.Compute - properties: *ubuntu_node capabilities: + host: + properties: *host_capabilities os: properties: *os_capabilities diff --git a/translator/toscalib/tests/data/tosca_single_instance_wordpress.yaml b/translator/toscalib/tests/data/tosca_single_instance_wordpress.yaml index c3195f41..324f9178 100644 --- a/translator/toscalib/tests/data/tosca_single_instance_wordpress.yaml +++ b/translator/toscalib/tests/data/tosca_single_instance_wordpress.yaml @@ -103,15 +103,14 @@ topology_template: 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: 1 - mem_size: 4096 MB capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 MB os: properties: architecture: x86_64 diff --git a/translator/toscalib/tests/data/tosca_single_server.yaml b/translator/toscalib/tests/data/tosca_single_server.yaml index be719018..cf17163a 100644 --- a/translator/toscalib/tests/data/tosca_single_server.yaml +++ b/translator/toscalib/tests/data/tosca_single_server.yaml @@ -14,12 +14,13 @@ topology_template: node_templates: server: type: tosca.nodes.Compute - properties: - # compute properties (flavor) - disk_size: 10 - num_cpus: { get_input: cpus } - mem_size: 4096 capabilities: + host: + properties: + # compute properties (flavor) + disk_size: 10 + num_cpus: { get_input: cpus } + mem_size: 4096 os: properties: architecture: x86_64 diff --git a/translator/toscalib/tests/test_scalar_unit.py b/translator/toscalib/tests/test_scalar_unit.py index 965d1426..8a5ddb4c 100644 --- a/translator/toscalib/tests/test_scalar_unit.py +++ b/translator/toscalib/tests/test_scalar_unit.py @@ -26,8 +26,10 @@ class ScalarUnitPositiveTest(TestCase): dict(tpl_snippet=''' server: type: tosca.nodes.Compute - properties: - mem_size: 1024 + capabilities: + host: + properties: + mem_size: 1024 ''', expected=1024) ), @@ -37,8 +39,10 @@ class ScalarUnitPositiveTest(TestCase): dict(tpl_snippet=''' server: type: tosca.nodes.Compute - properties: - mem_size: 1024 MB + capabilities: + host: + properties: + mem_size: 1024 MB ''', expected='1024 MB') ), @@ -48,8 +52,10 @@ class ScalarUnitPositiveTest(TestCase): dict(tpl_snippet=''' server: type: tosca.nodes.Compute - properties: - mem_size: 1 GB + capabilities: + host: + properties: + mem_size: 1 GB ''', expected='1 GB') ), @@ -59,8 +65,10 @@ class ScalarUnitPositiveTest(TestCase): dict(tpl_snippet=''' server: type: tosca.nodes.Compute - properties: - mem_size: 1tiB + capabilities: + host: + properties: + mem_size: 1tiB ''', expected='1tiB') ), @@ -70,8 +78,10 @@ class ScalarUnitPositiveTest(TestCase): dict(tpl_snippet=''' server: type: tosca.nodes.Compute - properties: - mem_size: 1 GIB + capabilities: + host: + properties: + mem_size: 1 GIB ''', expected='1 GIB') ), @@ -81,8 +91,10 @@ class ScalarUnitPositiveTest(TestCase): dict(tpl_snippet=''' server: type: tosca.nodes.Compute - properties: - mem_size: 1 tib + capabilities: + host: + properties: + mem_size: 1 tib ''', expected='1 tib') ), @@ -92,7 +104,7 @@ class ScalarUnitPositiveTest(TestCase): tpl = self.tpl_snippet nodetemplates = yamlparser.simple_parse(tpl) nodetemplate = NodeTemplate('server', nodetemplates) - props = nodetemplate.get_properties() + props = nodetemplate.get_capability('host').get_properties() if props and 'mem_size' in props.keys(): prop = props['mem_size'] self.assertIsNone(prop.validate()) diff --git a/translator/toscalib/tests/test_toscadef.py b/translator/toscalib/tests/test_toscadef.py index 2ff93501..ed0cb4dc 100644 --- a/translator/toscalib/tests/test_toscadef.py +++ b/translator/toscalib/tests/test_toscadef.py @@ -20,6 +20,7 @@ component_type = NodeType('tosca.nodes.SoftwareComponent') network_type = NodeType('tosca.nodes.network.Network') network_port_type = NodeType('tosca.nodes.network.Port') webserver_type = NodeType('tosca.nodes.WebServer') +database_type = NodeType('tosca.nodes.Database') class ToscaDefTest(TestCase): @@ -68,6 +69,7 @@ class ToscaDefTest(TestCase): 'tosca.capabilities.Endpoint', 'initiator') self.assertEqual(None, endpoint_prop_def) + os_props = self._get_capability_properties_def_objects( compute_type.get_capabilities_objects(), 'tosca.capabilities.OperatingSystem') @@ -76,6 +78,13 @@ class ToscaDefTest(TestCase): sorted([p.name for p in os_props])) self.assertTrue([p.required for p in os_props if p.name == 'type']) + host_props = self._get_capability_properties_def_objects( + compute_type.get_capabilities_objects(), + 'tosca.capabilities.Container') + self.assertEqual( + ['disk_size', 'mem_size', 'num_cpus'], + sorted([p.name for p in host_props])) + def _get_capability_properties_def_objects(self, caps, type): properties_def = None for cap in caps: @@ -102,8 +111,8 @@ class ToscaDefTest(TestCase): def test_properties_def(self): self.assertEqual( - ['disk_size', 'mem_size', 'num_cpus'], - sorted(compute_type.get_properties_def().keys())) + ['db_name', 'db_password', 'db_user'], + sorted(database_type.get_properties_def().keys())) def test_attributes_def(self): self.assertEqual( diff --git a/translator/toscalib/tests/test_toscatpl.py b/translator/toscalib/tests/test_toscatpl.py index b9991609..8d1d461e 100644 --- a/translator/toscalib/tests/test_toscatpl.py +++ b/translator/toscalib/tests/test_toscatpl.py @@ -222,7 +222,8 @@ class ToscaTemplateTest(TestCase): if node_tpl.name == 'mongo_server': self.assertEqual( ['disk_size', 'mem_size', 'num_cpus'], - sorted(node_tpl.get_properties().keys())) + sorted(node_tpl.get_capability('host'). + get_properties().keys())) def test_template_requirements(self): """Test different formats of requirements diff --git a/translator/toscalib/tests/test_toscatplvalidation.py b/translator/toscalib/tests/test_toscatplvalidation.py index 23d9ef74..a5e6829e 100644 --- a/translator/toscalib/tests/test_toscatplvalidation.py +++ b/translator/toscalib/tests/test_toscatplvalidation.py @@ -142,12 +142,12 @@ class ToscaTemplateValidationTest(TestCase): tpl_snippet = ''' node_templates: server: - properties: - # compute properties (flavor) - disk_size: 10 - num_cpus: 4 - mem_size: 4096 capabilities: + host: + properties: + disk_size: 10 + num_cpus: 4 + mem_size: 4096 os: properties: architecture: x86_64 @@ -289,12 +289,13 @@ class ToscaTemplateValidationTest(TestCase): server: type: tosca.nodes.Compute properties: - # compute properties (flavor) - disk_size: 10 - num_cpus: { get_input: cpus } - mem_size: 4096 os_image: F18_x86_64 capabilities: + host: + properties: + disk_size: 10 + num_cpus: { get_input: cpus } + mem_size: 4096 os: properties: architecture: x86_64 @@ -433,12 +434,12 @@ class ToscaTemplateValidationTest(TestCase): node_templates: server: type: tosca.nodes.Compute - properties: - # compute properties (flavor) - disk_size: 10 - num_cpus: { get_input: cpus } - mem_size: 4096 capabilities: + host: + properties: + disk_size: 10 + num_cpus: { get_input: cpus } + mem_size: 4096 os: properties: architecture: x86_64 @@ -481,12 +482,12 @@ class ToscaTemplateValidationTest(TestCase): node_templates: server: type: tosca.nodes.Compute - properties: - # compute properties (flavor) - disk_size: 10 - num_cpus: { get_input: cpus } - mem_size: 4096 capabilities: + host: + properties: + disk_size: 10 + num_cpus: { get_input: cpus } + mem_size: 4096 os: properties: architecture: x86_64 diff --git a/translator/toscalib/topology_template.py b/translator/toscalib/topology_template.py index 2d5a5391..f40727ac 100644 --- a/translator/toscalib/topology_template.py +++ b/translator/toscalib/topology_template.py @@ -180,6 +180,19 @@ class TopologyTemplate(object): self, req, value) + if node_template.get_capabilities_objects(): + for cap in node_template.get_capabilities_objects(): + if cap.get_properties_objects(): + for prop in cap.get_properties_objects(): + propvalue = functions.get_function( + self, + node_template, + prop.value) + if isinstance(propvalue, functions.GetInput): + propvalue = propvalue.result() + for p, v in cap._properties.items(): + if p == prop.name: + cap._properties[p] = propvalue for output in self.outputs: func = functions.get_function(self, self.outputs, output.value) if isinstance(func, functions.GetAttribute):