From b678c5bfea0f1b142c2a4a5bdee1e3309a021887 Mon Sep 17 00:00:00 2001 From: zhipengh Date: Tue, 22 Dec 2015 15:04:53 +0800 Subject: [PATCH] JIRA:PARSER-15 Provide Standalone Heat-Translator Liberty Pypi Packages --- tosca2heat/heat-translator-0.3.0/.coveragerc | 7 + tosca2heat/heat-translator-0.3.0/.mailmap | 3 + tosca2heat/heat-translator-0.3.0/.testr.conf | 7 + tosca2heat/heat-translator-0.3.0/AUTHORS | 44 + tosca2heat/heat-translator-0.3.0/CONTRIBUTING.rst | 16 + tosca2heat/heat-translator-0.3.0/ChangeLog | 258 +++++ tosca2heat/heat-translator-0.3.0/HACKING.rst | 4 + tosca2heat/heat-translator-0.3.0/LICENSE | 175 +++ tosca2heat/heat-translator-0.3.0/MANIFEST.in | 6 + tosca2heat/heat-translator-0.3.0/PKG-INFO | 68 ++ tosca2heat/heat-translator-0.3.0/README.rst | 47 + tosca2heat/heat-translator-0.3.0/babel.cfg | 1 + .../heat-translator-0.3.0/doc/source/conf.py | 75 ++ .../doc/source/contributing.rst | 1 + .../heat-translator-0.3.0/doc/source/index.rst | 29 + .../doc/source/installation.rst | 15 + .../heat-translator-0.3.0/doc/source/usage.rst | 71 ++ .../heat_translator.egg-info/PKG-INFO | 68 ++ .../heat_translator.egg-info/SOURCES.txt | 187 ++++ .../heat_translator.egg-info/dependency_links.txt | 1 + .../heat_translator.egg-info/entry_points.txt | 9 + .../heat_translator.egg-info/not-zip-safe | 1 + .../heat_translator.egg-info/pbr.json | 1 + .../heat_translator.egg-info/requires.txt | 7 + .../heat_translator.egg-info/top_level.txt | 1 + .../heat-translator-0.3.0/heat_translator.py | 20 + .../heat_translator_logging.conf | 43 + .../heat-translator-0.3.0/openstack-common.conf | 6 + tosca2heat/heat-translator-0.3.0/requirements.txt | 10 + tosca2heat/heat-translator-0.3.0/setup.cfg | 59 ++ tosca2heat/heat-translator-0.3.0/setup.py | 29 + .../heat-translator-0.3.0/test-requirements.txt | 14 + tosca2heat/heat-translator-0.3.0/tox.ini | 37 + .../heat-translator-0.3.0/translator/__init__.py | 19 + .../translator/common/__init__.py | 0 .../translator/common/exception.py | 48 + .../translator/common/utils.py | 266 +++++ .../translator/conf/__init__.py | 36 + .../translator/conf/config.py | 67 ++ .../translator/conf/translator.conf | 4 + .../translator/custom/__init__.py | 0 .../translator/custom/hot/__init__.py | 0 .../translator/custom/hot/tosca_collectd.py | 30 + .../translator/custom/hot/tosca_elasticsearch.py | 30 + .../translator/custom/hot/tosca_kibana.py | 30 + .../translator/custom/hot/tosca_logstash.py | 30 + .../translator/custom/hot/tosca_nodejs.py | 30 + .../custom/hot/tosca_paypalpizzastore.py | 30 + .../translator/custom/hot/tosca_rsyslog.py | 30 + .../translator/custom/hot/tosca_wordpress.py | 30 + .../translator/hot/__init__.py | 0 .../translator/hot/syntax/__init__.py | 0 .../translator/hot/syntax/hot_output.py | 25 + .../translator/hot/syntax/hot_parameter.py | 47 + .../translator/hot/syntax/hot_resource.py | 308 ++++++ .../translator/hot/syntax/hot_template.py | 78 ++ .../translator/hot/tests/__init__.py | 0 .../translator/hot/tests/test_hot_parameter.py | 44 + .../translator/hot/tests/test_translate_inputs.py | 351 +++++++ .../translator/hot/tests/test_translate_outputs.py | 50 + .../translator/hot/tosca/__init__.py | 0 .../translator/hot/tosca/tests/__init__.py | 0 .../hot/tosca/tests/test_tosca_blockstorage.py | 84 ++ .../hot/tosca/tests/test_tosca_compute.py | 253 +++++ .../hot/tosca/tests/test_tosca_objectstore.py | 71 ++ .../translator/hot/tosca/tosca_block_storage.py | 69 ++ .../hot/tosca/tosca_block_storage_attachment.py | 48 + .../translator/hot/tosca/tosca_compute.py | 274 +++++ .../translator/hot/tosca/tosca_database.py | 30 + .../translator/hot/tosca/tosca_dbms.py | 30 + .../translator/hot/tosca/tosca_network_network.py | 120 +++ .../translator/hot/tosca/tosca_network_port.py | 117 +++ .../translator/hot/tosca/tosca_object_storage.py | 58 + .../hot/tosca/tosca_software_component.py | 30 + .../translator/hot/tosca/tosca_web_application.py | 30 + .../translator/hot/tosca/tosca_webserver.py | 30 + .../translator/hot/tosca_translator.py | 64 ++ .../translator/hot/translate_inputs.py | 153 +++ .../translator/hot/translate_node_templates.py | 408 +++++++ .../translator/hot/translate_outputs.py | 42 + .../translator/osc/__init__.py | 0 .../translator/osc/osc_plugin.py | 41 + .../heat-translator-0.3.0/translator/osc/utils.py | 45 + .../translator/osc/v1/__init__.py | 0 .../translator/osc/v1/translate.py | 94 ++ .../heat-translator-0.3.0/translator/shell.py | 157 +++ .../translator/tests/__init__.py | 0 .../heat-translator-0.3.0/translator/tests/base.py | 53 + .../tests/data/artifacts/collectd/config.py | 25 + .../tests/data/artifacts/collectd/create.sh | 5 + .../tests/data/artifacts/collectd/start.sh | 4 + .../tests/data/artifacts/elasticsearch/create.sh | 14 + .../tests/data/artifacts/elasticsearch/start.sh | 4 + .../tests/data/artifacts/kibana/config.sh | 7 + .../tests/data/artifacts/kibana/create.sh | 12 + .../tests/data/artifacts/kibana/start.sh | 4 + .../data/artifacts/logstash/configure_collectd.py | 28 + .../artifacts/logstash/configure_elasticsearch.py | 26 + .../data/artifacts/logstash/configure_rsyslog.py | 25 + .../tests/data/artifacts/logstash/create.sh | 20 + .../tests/data/artifacts/logstash/start.sh | 4 + .../tests/data/artifacts/mongodb/config.sh | 7 + .../tests/data/artifacts/mongodb/create.sh | 14 + .../data/artifacts/mongodb/create_database.sh | 5 + .../tests/data/artifacts/mongodb/start.sh | 5 + .../artifacts/mysql/mysql_database_configure.sh | 8 + .../data/artifacts/mysql/mysql_dbms_configure.sh | 5 + .../data/artifacts/mysql/mysql_dbms_install.sh | 9 + .../tests/data/artifacts/mysql/mysql_dbms_start.sh | 2 + .../tests/data/artifacts/nodejs/config.sh | 28 + .../tests/data/artifacts/nodejs/create.sh | 7 + .../tests/data/artifacts/nodejs/start.sh | 3 + .../tests/data/artifacts/rsyslog/config.sh | 30 + .../tests/data/artifacts/rsyslog/create.sh | 5 + .../tests/data/artifacts/rsyslog/start.sh | 4 + .../data/artifacts/webserver/webserver_install.sh | 5 + .../data/artifacts/webserver/webserver_start.sh | 2 + .../artifacts/wordpress/wordpress_configure.sh | 4 + .../data/artifacts/wordpress/wordpress_install.sh | 5 + .../translator/tests/data/csar_elk.zip | Bin 0 -> 17488 bytes .../translator/tests/data/csar_hello_world.zip | Bin 0 -> 936 bytes .../tests/data/csar_metadata_not_yaml.zip | Bin 0 -> 936 bytes .../translator/tests/data/csar_not_zip.zip | 1 + .../tests/data/csar_single_instance_wordpress.zip | Bin 0 -> 5967 bytes .../data/csar_wordpress_invalid_import_path.zip | Bin 0 -> 5971 bytes .../data/csar_wordpress_invalid_script_url.zip | Bin 0 -> 6034 bytes .../tests/data/csar_wrong_metadata_file.zip | Bin 0 -> 873 bytes .../tests/data/custom_types/collectd.yaml | 13 + .../tests/data/custom_types/elasticsearch.yaml | 12 + .../translator/tests/data/custom_types/kibana.yaml | 14 + .../tests/data/custom_types/logstash.yaml | 25 + .../custom_types/paypalpizzastore_nodejs_app.yaml | 29 + .../tests/data/custom_types/rsyslog.yaml | 13 + .../tests/data/custom_types/wordpress.yaml | 19 + .../translator/tests/data/hot_output/hot_elk.yaml | 555 ++++++++++ .../tests/data/hot_output/hot_elk_from_csar.yaml | 555 ++++++++++ .../tests/data/hot_output/hot_hello_world.yaml | 15 + .../tests/data/hot_output/hot_host_assignment.yaml | 137 +++ .../hot_nodejs_mongodb_two_instances.yaml | 187 ++++ .../hot_output/hot_single_instance_wordpress.yaml | 202 ++++ .../hot_single_instance_wordpress_from_csar.yaml | 200 ++++ .../data/hot_output/hot_single_object_store.yaml | 21 + .../tests/data/hot_output/hot_single_server.yaml | 37 + ...hot_single_server_with_defaults_with_input.yaml | 37 + ..._single_server_with_defaults_without_input.yaml | 37 + .../data/hot_output/hot_software_component.yaml | 59 ++ .../tests/data/hot_output/hot_web_application.yaml | 100 ++ .../network/hot_one_server_one_network.yaml | 45 + .../network/hot_one_server_three_networks.yaml | 72 ++ .../network/hot_server_on_existing_network.yaml | 28 + .../network/hot_two_servers_one_network.yaml | 74 ++ .../storage/hot_blockstorage_with_attachment.yaml | 72 ++ ...lockstorage_with_attachment_notation1_alt1.yaml | 94 ++ ...lockstorage_with_attachment_notation1_alt2.yaml | 94 ++ ...lockstorage_with_attachment_notation2_alt1.yaml | 98 ++ ...lockstorage_with_attachment_notation2_alt2.yaml | 98 ++ ...blockstorage_with_custom_relationship_type.yaml | 73 ++ ...ot_blockstorage_with_relationship_template.yaml | 66 ++ ...multiple_blockstorage_with_attachment_alt1.yaml | 111 ++ ...multiple_blockstorage_with_attachment_alt2.yaml | 111 ++ .../data/network/tosca_one_server_one_network.yaml | 43 + .../network/tosca_one_server_three_networks.yaml | 64 ++ .../network/tosca_server_on_existing_network.yaml | 39 + .../network/tosca_two_servers_one_network.yaml | 79 ++ .../tosca_blockstorage_with_attachment.yaml | 61 ++ ...sca_blockstorage_with_attachment_notation1.yaml | 87 ++ ...sca_blockstorage_with_attachment_notation2.yaml | 99 ++ ...blockstorage_with_custom_relationship_type.yaml | 64 ++ ...ca_blockstorage_with_relationship_template.yaml | 59 ++ ...osca_multiple_blockstorage_with_attachment.yaml | 93 ++ .../data/storage/tosca_single_object_store.yaml | 17 + .../tests/data/test_host_assignment.yaml | 80 ++ .../translator/tests/data/tosca_elk.yaml | 219 ++++ .../translator/tests/data/tosca_helloworld.yaml | 23 + .../tests/data/tosca_helloworld_invalid.yaml | 23 + .../data/tosca_nodejs_mongodb_two_instances.yaml | 96 ++ .../data/tosca_single_instance_wordpress.yaml | 120 +++ ...stance_wordpress_with_local_abspath_import.yaml | 125 +++ ..._single_instance_wordpress_with_url_import.yaml | 120 +++ .../translator/tests/data/tosca_single_server.yaml | 32 + .../data/tosca_single_server_with_defaults.yaml | 35 + .../tests/data/tosca_software_component.yaml | 40 + .../tests/data/tosca_web_application.yaml | 56 + .../translator/tests/test_conf.py | 57 + .../translator/tests/test_shell.py | 116 ++ .../translator/tests/test_template.py | 63 ++ .../translator/tests/test_tosca_hot_translation.py | 503 +++++++++ .../translator/tests/test_utils.py | 239 +++++ tosca2heat/tosca-parser-0.3.0/.coveragerc | 7 + tosca2heat/tosca-parser-0.3.0/.mailmap | 3 + tosca2heat/tosca-parser-0.3.0/.testr.conf | 7 + tosca2heat/tosca-parser-0.3.0/AUTHORS | 41 + tosca2heat/tosca-parser-0.3.0/CONTRIBUTING.rst | 16 + tosca2heat/tosca-parser-0.3.0/ChangeLog | 276 +++++ tosca2heat/tosca-parser-0.3.0/HACKING.rst | 4 + tosca2heat/tosca-parser-0.3.0/LICENSE | 175 +++ tosca2heat/tosca-parser-0.3.0/MANIFEST.in | 6 + tosca2heat/tosca-parser-0.3.0/PKG-INFO | 63 ++ tosca2heat/tosca-parser-0.3.0/README.rst | 43 + tosca2heat/tosca-parser-0.3.0/babel.cfg | 1 + tosca2heat/tosca-parser-0.3.0/doc/source/conf.py | 75 ++ .../tosca-parser-0.3.0/doc/source/contributing.rst | 1 + tosca2heat/tosca-parser-0.3.0/doc/source/index.rst | 27 + .../tosca-parser-0.3.0/doc/source/installation.rst | 9 + tosca2heat/tosca-parser-0.3.0/doc/source/usage.rst | 16 + .../tosca-parser-0.3.0/openstack-common.conf | 6 + tosca2heat/tosca-parser-0.3.0/requirements.txt | 9 + tosca2heat/tosca-parser-0.3.0/setup.cfg | 55 + tosca2heat/tosca-parser-0.3.0/setup.py | 29 + .../tosca-parser-0.3.0/test-requirements.txt | 14 + .../tosca_parser.egg-info/PKG-INFO | 63 ++ .../tosca_parser.egg-info/SOURCES.txt | 230 ++++ .../tosca_parser.egg-info/dependency_links.txt | 1 + .../tosca_parser.egg-info/entry_points.txt | 3 + .../tosca_parser.egg-info/not-zip-safe | 1 + .../tosca_parser.egg-info/pbr.json | 1 + .../tosca_parser.egg-info/requires.txt | 6 + .../tosca_parser.egg-info/top_level.txt | 1 + tosca2heat/tosca-parser-0.3.0/tosca_parser.py | 32 + .../tosca-parser-0.3.0/toscaparser/__init__.py | 19 + .../tosca-parser-0.3.0/toscaparser/capabilities.py | 45 + .../toscaparser/common/__init__.py | 0 .../toscaparser/common/exception.py | 180 ++++ .../tosca-parser-0.3.0/toscaparser/dataentity.py | 163 +++ .../toscaparser/elements/TOSCA_definition_1_0.yaml | 778 ++++++++++++++ .../toscaparser/elements/__init__.py | 0 .../toscaparser/elements/artifacttype.py | 45 + .../toscaparser/elements/attribute_definition.py | 20 + .../toscaparser/elements/capabilitytype.py | 72 ++ .../toscaparser/elements/constraints.py | 597 +++++++++++ .../toscaparser/elements/datatype.py | 56 + .../toscaparser/elements/entity_type.py | 115 ++ .../toscaparser/elements/interfaces.py | 76 ++ .../toscaparser/elements/nodetype.py | 202 ++++ .../toscaparser/elements/policytype.py | 45 + .../toscaparser/elements/property_definition.py | 48 + .../toscaparser/elements/relationshiptype.py | 33 + .../toscaparser/elements/scalarunit.py | 129 +++ .../toscaparser/elements/statefulentitytype.py | 83 ++ .../toscaparser/entity_template.py | 287 +++++ .../tosca-parser-0.3.0/toscaparser/functions.py | 416 ++++++++ .../tosca-parser-0.3.0/toscaparser/groups.py | 27 + .../tosca-parser-0.3.0/toscaparser/imports.py | 208 ++++ .../tosca-parser-0.3.0/toscaparser/nodetemplate.py | 260 +++++ .../tosca-parser-0.3.0/toscaparser/parameters.py | 114 ++ .../toscaparser/prereq/__init__.py | 0 .../tosca-parser-0.3.0/toscaparser/prereq/csar.py | 286 +++++ .../tosca-parser-0.3.0/toscaparser/properties.py | 76 ++ .../toscaparser/relationship_template.py | 68 ++ tosca2heat/tosca-parser-0.3.0/toscaparser/shell.py | 106 ++ .../toscaparser/tests/__init__.py | 0 .../toscaparser/tests/artifacts/collectd/config.py | 25 + .../toscaparser/tests/artifacts/collectd/create.sh | 5 + .../toscaparser/tests/artifacts/collectd/start.sh | 4 + .../tests/artifacts/elasticsearch/create.sh | 14 + .../tests/artifacts/elasticsearch/start.sh | 4 + .../toscaparser/tests/artifacts/kibana/config.sh | 7 + .../toscaparser/tests/artifacts/kibana/create.sh | 12 + .../toscaparser/tests/artifacts/kibana/start.sh | 4 + .../tests/artifacts/logstash/configure_collectd.py | 28 + .../artifacts/logstash/configure_elasticsearch.py | 26 + .../tests/artifacts/logstash/configure_rsyslog.py | 25 + .../toscaparser/tests/artifacts/logstash/create.sh | 20 + .../toscaparser/tests/artifacts/logstash/start.sh | 4 + .../toscaparser/tests/artifacts/mongodb/config.sh | 7 + .../toscaparser/tests/artifacts/mongodb/create.sh | 14 + .../tests/artifacts/mongodb/create_database.sh | 5 + .../toscaparser/tests/artifacts/mongodb/start.sh | 5 + .../artifacts/mysql/mysql_database_configure.sh | 8 + .../tests/artifacts/mysql/mysql_dbms_configure.sh | 5 + .../tests/artifacts/mysql/mysql_dbms_install.sh | 9 + .../tests/artifacts/mysql/mysql_dbms_start.sh | 2 + .../toscaparser/tests/artifacts/nodejs/config.sh | 28 + .../toscaparser/tests/artifacts/nodejs/create.sh | 7 + .../toscaparser/tests/artifacts/nodejs/start.sh | 3 + .../toscaparser/tests/artifacts/rsyslog/config.sh | 30 + .../toscaparser/tests/artifacts/rsyslog/create.sh | 5 + .../toscaparser/tests/artifacts/rsyslog/start.sh | 4 + .../tests/artifacts/webserver/webserver_install.sh | 5 + .../tests/artifacts/webserver/webserver_start.sh | 2 + .../artifacts/wordpress/wordpress_configure.sh | 4 + .../tests/artifacts/wordpress/wordpress_install.sh | 5 + .../tosca-parser-0.3.0/toscaparser/tests/base.py | 67 ++ .../toscaparser/tests/data/CSAR/csar_elk.csar | Bin 0 -> 17488 bytes .../toscaparser/tests/data/CSAR/csar_elk.zip | Bin 0 -> 17488 bytes .../tests/data/CSAR/csar_hello_world.zip | Bin 0 -> 936 bytes .../tests/data/CSAR/csar_invalid_entry_def.zip | Bin 0 -> 940 bytes .../tests/data/CSAR/csar_metadata_not_yaml.zip | Bin 0 -> 936 bytes .../tests/data/CSAR/csar_missing_metadata.zip | Bin 0 -> 933 bytes .../tests/data/CSAR/csar_no_metadata_file.zip | Bin 0 -> 496 bytes .../toscaparser/tests/data/CSAR/csar_not_zip.zip | 1 + .../toscaparser/tests/data/CSAR/csar_wordpress.zip | Bin 0 -> 5967 bytes .../CSAR/csar_wordpress_invalid_import_path.zip | Bin 0 -> 5971 bytes .../CSAR/csar_wordpress_invalid_import_url.zip | Bin 0 -> 6043 bytes .../CSAR/csar_wordpress_invalid_script_path.zip | Bin 0 -> 5969 bytes .../CSAR/csar_wordpress_invalid_script_url.zip | Bin 0 -> 6043 bytes .../csar_wordpress_with_url_import_and_script.zip | Bin 0 -> 6046 bytes .../tests/data/CSAR/csar_wrong_metadata_file.zip | Bin 0 -> 873 bytes .../data/CSAR/tosca_elk/Definitions/collectd.yaml | 13 + .../CSAR/tosca_elk/Definitions/elasticsearch.yaml | 11 + .../data/CSAR/tosca_elk/Definitions/kibana.yaml | 16 + .../data/CSAR/tosca_elk/Definitions/logstash.yaml | 25 + .../Definitions/paypalpizzastore_nodejs_app.yaml | 29 + .../data/CSAR/tosca_elk/Definitions/rsyslog.yaml | 13 + .../data/CSAR/tosca_elk/Definitions/tosca_elk.yaml | 217 ++++ .../data/CSAR/tosca_elk/Python/collectd/config.py | 25 + .../Python/logstash/configure_collectd.py | 28 + .../Python/logstash/configure_elasticsearch.py | 26 + .../tosca_elk/Python/logstash/configure_rsyslog.py | 25 + .../tests/data/CSAR/tosca_elk/README.txt | 5 + .../data/CSAR/tosca_elk/Scripts/collectd/create.sh | 5 + .../data/CSAR/tosca_elk/Scripts/collectd/start.sh | 4 + .../CSAR/tosca_elk/Scripts/elasticsearch/create.sh | 14 + .../CSAR/tosca_elk/Scripts/elasticsearch/start.sh | 4 + .../data/CSAR/tosca_elk/Scripts/kibana/config.sh | 7 + .../data/CSAR/tosca_elk/Scripts/kibana/create.sh | 12 + .../data/CSAR/tosca_elk/Scripts/kibana/start.sh | 4 + .../data/CSAR/tosca_elk/Scripts/logstash/create.sh | 20 + .../data/CSAR/tosca_elk/Scripts/logstash/start.sh | 4 + .../data/CSAR/tosca_elk/Scripts/mongodb/config.sh | 7 + .../data/CSAR/tosca_elk/Scripts/mongodb/create.sh | 14 + .../tosca_elk/Scripts/mongodb/create_database.sh | 5 + .../data/CSAR/tosca_elk/Scripts/mongodb/start.sh | 5 + .../data/CSAR/tosca_elk/Scripts/nodejs/config.sh | 28 + .../data/CSAR/tosca_elk/Scripts/nodejs/create.sh | 7 + .../data/CSAR/tosca_elk/Scripts/nodejs/start.sh | 3 + .../data/CSAR/tosca_elk/Scripts/rsyslog/config.sh | 30 + .../data/CSAR/tosca_elk/Scripts/rsyslog/create.sh | 5 + .../data/CSAR/tosca_elk/Scripts/rsyslog/start.sh | 4 + .../data/CSAR/tosca_elk/TOSCA-Metadata/TOSCA.meta | 4 + .../tosca_single_instance_wordpress.yaml | 109 ++ .../Definitions/wordpress.yaml | 19 + .../tosca_single_instance_wordpress/README.txt | 22 + .../Scripts/MYSQLDBMS/configure.sh | 5 + .../Scripts/MYSQLDBMS/install.sh | 9 + .../Scripts/MYSQLDBMS/start.sh | 2 + .../Scripts/MYSQLDatabase/configure.sh | 8 + .../Scripts/WebServer/install.sh | 5 + .../Scripts/WebServer/start.sh | 2 + .../Scripts/WordPress/configure.sh | 4 + .../Scripts/WordPress/install.sh | 5 + .../TOSCA-Metadata/TOSCA.meta | 5 + .../tests/data/custom_types/collectd.yaml | 13 + .../tests/data/custom_types/elasticsearch.yaml | 12 + .../tests/data/custom_types/kibana.yaml | 14 + .../tests/data/custom_types/logstash.yaml | 25 + .../tests/data/custom_types/nested_rsyslog.yaml | 17 + .../data/custom_types/nested_test_wordpress.yaml | 23 + .../custom_types/paypalpizzastore_nodejs_app.yaml | 29 + .../tests/data/custom_types/rsyslog.yaml | 13 + .../tests/data/custom_types/wordpress.yaml | 19 + .../tests/data/datatypes/custom_datatype_def.yaml | 48 + .../test_custom_datatypes_in_current_template.yaml | 65 ++ ...est_custom_datatypes_nested_datatype_error.yaml | 25 + .../datatypes/test_custom_datatypes_positive.yaml | 24 + .../test_custom_datatypes_value_error.yaml | 18 + .../functions/test_get_attribute_host_keyword.yaml | 33 + .../test_get_attribute_host_not_found.yaml | 20 + ...test_get_attribute_illegal_host_in_outputs.yaml | 17 + .../test_get_attribute_unknown_attribute_name.yaml | 28 + ...t_get_attribute_unknown_node_template_name.yaml | 28 + .../functions/test_invalid_function_signature.yaml | 34 + .../test_unknown_capability_property.yaml | 36 + .../functions/test_unknown_input_in_interface.yaml | 20 + .../functions/test_unknown_input_in_property.yaml | 13 + .../tests/data/test_instance_nested_imports.yaml | 22 + .../tests/data/test_invalid_section_names.yaml | 25 + .../tests/data/test_invalid_template_version.yaml | 14 + .../data/test_multiple_validation_errors.yaml | 125 +++ .../tests/data/test_no_inputs_in_template.yaml | 17 + .../tests/data/test_no_outputs_in_template.yaml | 15 + .../toscaparser/tests/data/test_requirements.yaml | 67 ++ .../test_tosca_normative_type_by_shortname.yaml | 33 + .../tests/data/test_tosca_top_level_error1.yaml | 31 + .../tests/data/test_tosca_top_level_error2.yaml | 33 + .../tests/data/topology_template/definitions.yaml | 54 + .../tests/data/topology_template/subsystem.yaml | 85 ++ .../tests/data/topology_template/system.yaml | 51 + .../toscaparser/tests/data/tosca_elk.yaml | 217 ++++ .../toscaparser/tests/data/tosca_helloworld.yaml | 23 + .../data/tosca_single_instance_wordpress.yaml | 121 +++ ...stance_wordpress_with_local_abspath_import.yaml | 122 +++ ..._single_instance_wordpress_with_url_import.yaml | 120 +++ .../v1.0/network/tosca_one_server_one_network.yaml | 43 + .../network/tosca_one_server_three_networks.yaml | 64 ++ .../network/tosca_server_on_existing_network.yaml | 39 + .../network/tosca_two_servers_one_network.yaml | 79 ++ .../tosca_blockstorage_with_attachment.yaml | 61 ++ ...sca_blockstorage_with_attachment_notation1.yaml | 87 ++ ...sca_blockstorage_with_attachment_notation2.yaml | 99 ++ ...blockstorage_with_custom_relationship_type.yaml | 64 ++ ...ca_blockstorage_with_relationship_template.yaml | 59 ++ ...osca_multiple_blockstorage_with_attachment.yaml | 93 ++ .../v1.0/storage/tosca_single_object_store.yaml | 17 + .../v1.0/tosca_nodejs_mongodb_two_instances.yaml | 96 ++ .../spec_samples/v1.0/tosca_single_server.yaml | 32 + .../toscaparser/tests/test_constraints.py | 357 +++++++ .../toscaparser/tests/test_datatypes.py | 327 ++++++ .../toscaparser/tests/test_exception.py | 42 + .../toscaparser/tests/test_functions.py | 204 ++++ .../toscaparser/tests/test_prereq.py | 230 ++++ .../toscaparser/tests/test_properties.py | 236 +++++ .../toscaparser/tests/test_scalarunit.py | 355 +++++++ .../toscaparser/tests/test_shell.py | 57 + .../toscaparser/tests/test_topology_template.py | 160 +++ .../toscaparser/tests/test_toscadef.py | 335 ++++++ .../toscaparser/tests/test_toscatpl.py | 544 ++++++++++ .../toscaparser/tests/test_toscatplvalidation.py | 1109 ++++++++++++++++++++ .../toscaparser/tests/test_utils.py | 60 ++ .../tests/test_validate_tosca_version.py | 132 +++ .../toscaparser/topology_template.py | 222 ++++ .../toscaparser/tosca_template.py | 211 ++++ .../toscaparser/tpl_relationship_graph.py | 46 + .../toscaparser/utils/__init__.py | 0 .../toscaparser/utils/gettextutils.py | 22 + .../toscaparser/utils/urlutils.py | 61 ++ .../toscaparser/utils/validateutils.py | 165 +++ .../toscaparser/utils/yamlparser.py | 89 ++ tosca2heat/tosca-parser-0.3.0/tox.ini | 37 + 419 files changed, 26052 insertions(+) create mode 100644 tosca2heat/heat-translator-0.3.0/.coveragerc create mode 100644 tosca2heat/heat-translator-0.3.0/.mailmap create mode 100644 tosca2heat/heat-translator-0.3.0/.testr.conf create mode 100644 tosca2heat/heat-translator-0.3.0/AUTHORS create mode 100644 tosca2heat/heat-translator-0.3.0/CONTRIBUTING.rst create mode 100644 tosca2heat/heat-translator-0.3.0/ChangeLog create mode 100644 tosca2heat/heat-translator-0.3.0/HACKING.rst create mode 100644 tosca2heat/heat-translator-0.3.0/LICENSE create mode 100644 tosca2heat/heat-translator-0.3.0/MANIFEST.in create mode 100644 tosca2heat/heat-translator-0.3.0/PKG-INFO create mode 100644 tosca2heat/heat-translator-0.3.0/README.rst create mode 100644 tosca2heat/heat-translator-0.3.0/babel.cfg create mode 100755 tosca2heat/heat-translator-0.3.0/doc/source/conf.py create mode 100644 tosca2heat/heat-translator-0.3.0/doc/source/contributing.rst create mode 100644 tosca2heat/heat-translator-0.3.0/doc/source/index.rst create mode 100644 tosca2heat/heat-translator-0.3.0/doc/source/installation.rst create mode 100644 tosca2heat/heat-translator-0.3.0/doc/source/usage.rst create mode 100644 tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/PKG-INFO create mode 100644 tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/SOURCES.txt create mode 100644 tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/dependency_links.txt create mode 100644 tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/entry_points.txt create mode 100644 tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/not-zip-safe create mode 100644 tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/pbr.json create mode 100644 tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/requires.txt create mode 100644 tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/top_level.txt create mode 100644 tosca2heat/heat-translator-0.3.0/heat_translator.py create mode 100644 tosca2heat/heat-translator-0.3.0/heat_translator_logging.conf create mode 100644 tosca2heat/heat-translator-0.3.0/openstack-common.conf create mode 100644 tosca2heat/heat-translator-0.3.0/requirements.txt create mode 100644 tosca2heat/heat-translator-0.3.0/setup.cfg create mode 100644 tosca2heat/heat-translator-0.3.0/setup.py create mode 100644 tosca2heat/heat-translator-0.3.0/test-requirements.txt create mode 100644 tosca2heat/heat-translator-0.3.0/tox.ini create mode 100644 tosca2heat/heat-translator-0.3.0/translator/__init__.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/common/__init__.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/common/exception.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/common/utils.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/conf/__init__.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/conf/config.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/conf/translator.conf create mode 100644 tosca2heat/heat-translator-0.3.0/translator/custom/__init__.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/custom/hot/__init__.py create mode 100755 tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_collectd.py create mode 100755 tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_elasticsearch.py create mode 100755 tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_kibana.py create mode 100755 tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_logstash.py create mode 100755 tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_nodejs.py create mode 100755 tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_paypalpizzastore.py create mode 100755 tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_rsyslog.py create mode 100755 tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_wordpress.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/hot/__init__.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/hot/syntax/__init__.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/hot/syntax/hot_output.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/hot/syntax/hot_parameter.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/hot/syntax/hot_resource.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/hot/syntax/hot_template.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/hot/tests/__init__.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/hot/tests/test_hot_parameter.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/hot/tests/test_translate_inputs.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/hot/tests/test_translate_outputs.py create mode 100755 tosca2heat/heat-translator-0.3.0/translator/hot/tosca/__init__.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tests/__init__.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tests/test_tosca_blockstorage.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tests/test_tosca_compute.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tests/test_tosca_objectstore.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_block_storage.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_block_storage_attachment.py create mode 100755 tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_compute.py create mode 100755 tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_database.py create mode 100755 tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_dbms.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_network_network.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_network_port.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_object_storage.py create mode 100755 tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_software_component.py create mode 100755 tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_web_application.py create mode 100755 tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_webserver.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/hot/tosca_translator.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/hot/translate_inputs.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/hot/translate_node_templates.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/hot/translate_outputs.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/osc/__init__.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/osc/osc_plugin.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/osc/utils.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/osc/v1/__init__.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/osc/v1/translate.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/shell.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/__init__.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/base.py create mode 100755 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/collectd/config.py create mode 100755 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/collectd/create.sh create mode 100755 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/collectd/start.sh create mode 100755 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/elasticsearch/create.sh create mode 100755 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/elasticsearch/start.sh create mode 100755 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/kibana/config.sh create mode 100755 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/kibana/create.sh create mode 100755 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/kibana/start.sh create mode 100755 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/logstash/configure_collectd.py create mode 100755 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/logstash/configure_elasticsearch.py create mode 100755 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/logstash/configure_rsyslog.py create mode 100755 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/logstash/create.sh create mode 100755 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/logstash/start.sh create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mongodb/config.sh create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mongodb/create.sh create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mongodb/create_database.sh create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mongodb/start.sh create mode 100755 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mysql/mysql_database_configure.sh create mode 100755 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mysql/mysql_dbms_configure.sh create mode 100755 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mysql/mysql_dbms_install.sh create mode 100755 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mysql/mysql_dbms_start.sh create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/nodejs/config.sh create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/nodejs/create.sh create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/nodejs/start.sh create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/rsyslog/config.sh create mode 100755 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/rsyslog/create.sh create mode 100755 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/rsyslog/start.sh create mode 100755 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/webserver/webserver_install.sh create mode 100755 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/webserver/webserver_start.sh create mode 100755 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/wordpress/wordpress_configure.sh create mode 100755 tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/wordpress/wordpress_install.sh create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_elk.zip create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_hello_world.zip create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_metadata_not_yaml.zip create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_not_zip.zip create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_single_instance_wordpress.zip create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_wordpress_invalid_import_path.zip create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_wordpress_invalid_script_url.zip create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_wrong_metadata_file.zip create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/collectd.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/elasticsearch.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/kibana.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/logstash.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/paypalpizzastore_nodejs_app.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/rsyslog.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/wordpress.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_elk.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_elk_from_csar.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_hello_world.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_host_assignment.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_nodejs_mongodb_two_instances.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_single_instance_wordpress.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_single_instance_wordpress_from_csar.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_single_object_store.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_single_server.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_single_server_with_defaults_with_input.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_single_server_with_defaults_without_input.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_software_component.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_web_application.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/network/hot_one_server_one_network.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/network/hot_one_server_three_networks.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/network/hot_server_on_existing_network.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/network/hot_two_servers_one_network.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment_notation1_alt1.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment_notation1_alt2.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment_notation2_alt1.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment_notation2_alt2.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_custom_relationship_type.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_relationship_template.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_multiple_blockstorage_with_attachment_alt1.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_multiple_blockstorage_with_attachment_alt2.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/network/tosca_one_server_one_network.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/network/tosca_one_server_three_networks.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/network/tosca_server_on_existing_network.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/network/tosca_two_servers_one_network.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_blockstorage_with_attachment.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_blockstorage_with_attachment_notation1.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_blockstorage_with_attachment_notation2.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_blockstorage_with_custom_relationship_type.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_blockstorage_with_relationship_template.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_multiple_blockstorage_with_attachment.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_single_object_store.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/test_host_assignment.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_elk.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_helloworld.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_helloworld_invalid.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_nodejs_mongodb_two_instances.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_single_instance_wordpress.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_single_instance_wordpress_with_local_abspath_import.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_single_instance_wordpress_with_url_import.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_single_server.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_single_server_with_defaults.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_software_component.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_web_application.yaml create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/test_conf.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/test_shell.py create mode 100755 tosca2heat/heat-translator-0.3.0/translator/tests/test_template.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/test_tosca_hot_translation.py create mode 100644 tosca2heat/heat-translator-0.3.0/translator/tests/test_utils.py create mode 100644 tosca2heat/tosca-parser-0.3.0/.coveragerc create mode 100644 tosca2heat/tosca-parser-0.3.0/.mailmap create mode 100644 tosca2heat/tosca-parser-0.3.0/.testr.conf create mode 100644 tosca2heat/tosca-parser-0.3.0/AUTHORS create mode 100644 tosca2heat/tosca-parser-0.3.0/CONTRIBUTING.rst create mode 100644 tosca2heat/tosca-parser-0.3.0/ChangeLog create mode 100644 tosca2heat/tosca-parser-0.3.0/HACKING.rst create mode 100644 tosca2heat/tosca-parser-0.3.0/LICENSE create mode 100644 tosca2heat/tosca-parser-0.3.0/MANIFEST.in create mode 100644 tosca2heat/tosca-parser-0.3.0/PKG-INFO create mode 100644 tosca2heat/tosca-parser-0.3.0/README.rst create mode 100644 tosca2heat/tosca-parser-0.3.0/babel.cfg create mode 100755 tosca2heat/tosca-parser-0.3.0/doc/source/conf.py create mode 100644 tosca2heat/tosca-parser-0.3.0/doc/source/contributing.rst create mode 100644 tosca2heat/tosca-parser-0.3.0/doc/source/index.rst create mode 100644 tosca2heat/tosca-parser-0.3.0/doc/source/installation.rst create mode 100644 tosca2heat/tosca-parser-0.3.0/doc/source/usage.rst create mode 100644 tosca2heat/tosca-parser-0.3.0/openstack-common.conf create mode 100644 tosca2heat/tosca-parser-0.3.0/requirements.txt create mode 100644 tosca2heat/tosca-parser-0.3.0/setup.cfg create mode 100644 tosca2heat/tosca-parser-0.3.0/setup.py create mode 100644 tosca2heat/tosca-parser-0.3.0/test-requirements.txt create mode 100644 tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/PKG-INFO create mode 100644 tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/SOURCES.txt create mode 100644 tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/dependency_links.txt create mode 100644 tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/entry_points.txt create mode 100644 tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/not-zip-safe create mode 100644 tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/pbr.json create mode 100644 tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/requires.txt create mode 100644 tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/top_level.txt create mode 100644 tosca2heat/tosca-parser-0.3.0/tosca_parser.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/__init__.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/capabilities.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/common/__init__.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/common/exception.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/dataentity.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/elements/TOSCA_definition_1_0.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/elements/__init__.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/elements/artifacttype.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/elements/attribute_definition.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/elements/capabilitytype.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/elements/constraints.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/elements/datatype.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/elements/entity_type.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/elements/interfaces.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/elements/nodetype.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/elements/policytype.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/elements/property_definition.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/elements/relationshiptype.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/elements/scalarunit.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/elements/statefulentitytype.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/entity_template.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/functions.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/groups.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/imports.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/nodetemplate.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/parameters.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/prereq/__init__.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/prereq/csar.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/properties.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/relationship_template.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/shell.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/__init__.py create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/collectd/config.py create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/collectd/create.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/collectd/start.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/elasticsearch/create.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/elasticsearch/start.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/kibana/config.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/kibana/create.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/kibana/start.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/logstash/configure_collectd.py create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/logstash/configure_elasticsearch.py create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/logstash/configure_rsyslog.py create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/logstash/create.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/logstash/start.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mongodb/config.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mongodb/create.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mongodb/create_database.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mongodb/start.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mysql/mysql_database_configure.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mysql/mysql_dbms_configure.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mysql/mysql_dbms_install.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mysql/mysql_dbms_start.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/nodejs/config.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/nodejs/create.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/nodejs/start.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/rsyslog/config.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/rsyslog/create.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/rsyslog/start.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/webserver/webserver_install.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/webserver/webserver_start.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/wordpress/wordpress_configure.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/wordpress/wordpress_install.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/base.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_elk.csar create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_elk.zip create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_hello_world.zip create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_invalid_entry_def.zip create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_metadata_not_yaml.zip create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_missing_metadata.zip create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_no_metadata_file.zip create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_not_zip.zip create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_wordpress.zip create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_wordpress_invalid_import_path.zip create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_wordpress_invalid_import_url.zip create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_wordpress_invalid_script_path.zip create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_wordpress_invalid_script_url.zip create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_wordpress_with_url_import_and_script.zip create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_wrong_metadata_file.zip create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/collectd.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/elasticsearch.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/kibana.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/logstash.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/paypalpizzastore_nodejs_app.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/rsyslog.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/tosca_elk.yaml create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Python/collectd/config.py create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Python/logstash/configure_collectd.py create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Python/logstash/configure_elasticsearch.py create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Python/logstash/configure_rsyslog.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/README.txt create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/collectd/create.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/collectd/start.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/elasticsearch/create.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/elasticsearch/start.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/kibana/config.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/kibana/create.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/kibana/start.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/logstash/create.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/logstash/start.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/mongodb/config.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/mongodb/create.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/mongodb/create_database.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/mongodb/start.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/nodejs/config.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/nodejs/create.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/nodejs/start.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/rsyslog/config.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/rsyslog/create.sh create mode 100755 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/rsyslog/start.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/TOSCA-Metadata/TOSCA.meta create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Definitions/tosca_single_instance_wordpress.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Definitions/wordpress.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/README.txt create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/configure.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/install.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/start.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDatabase/configure.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WebServer/install.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WebServer/start.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WordPress/configure.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WordPress/install.sh create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/TOSCA-Metadata/TOSCA.meta create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/collectd.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/elasticsearch.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/kibana.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/logstash.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/nested_rsyslog.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/nested_test_wordpress.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/paypalpizzastore_nodejs_app.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/rsyslog.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/wordpress.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/datatypes/custom_datatype_def.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/datatypes/test_custom_datatypes_in_current_template.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/datatypes/test_custom_datatypes_nested_datatype_error.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/datatypes/test_custom_datatypes_positive.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/datatypes/test_custom_datatypes_value_error.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_get_attribute_host_keyword.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_get_attribute_host_not_found.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_get_attribute_illegal_host_in_outputs.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_get_attribute_unknown_attribute_name.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_get_attribute_unknown_node_template_name.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_invalid_function_signature.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_unknown_capability_property.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_unknown_input_in_interface.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_unknown_input_in_property.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_instance_nested_imports.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_invalid_section_names.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_invalid_template_version.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_multiple_validation_errors.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_no_inputs_in_template.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_no_outputs_in_template.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_requirements.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_tosca_normative_type_by_shortname.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_tosca_top_level_error1.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_tosca_top_level_error2.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/topology_template/definitions.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/topology_template/subsystem.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/topology_template/system.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/tosca_elk.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/tosca_helloworld.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/tosca_single_instance_wordpress.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/tosca_single_instance_wordpress_with_local_abspath_import.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/tosca_single_instance_wordpress_with_url_import.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/network/tosca_one_server_one_network.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/network/tosca_one_server_three_networks.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/network/tosca_server_on_existing_network.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/network/tosca_two_servers_one_network.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_attachment.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_attachment_notation1.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_attachment_notation2.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_custom_relationship_type.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_relationship_template.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_multiple_blockstorage_with_attachment.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_single_object_store.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/tosca_nodejs_mongodb_two_instances.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/tosca_single_server.yaml create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_constraints.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_datatypes.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_exception.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_functions.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_prereq.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_properties.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_scalarunit.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_shell.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_topology_template.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_toscadef.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_toscatpl.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_toscatplvalidation.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_utils.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_validate_tosca_version.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/topology_template.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tosca_template.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/tpl_relationship_graph.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/utils/__init__.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/utils/gettextutils.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/utils/urlutils.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/utils/validateutils.py create mode 100644 tosca2heat/tosca-parser-0.3.0/toscaparser/utils/yamlparser.py create mode 100644 tosca2heat/tosca-parser-0.3.0/tox.ini diff --git a/tosca2heat/heat-translator-0.3.0/.coveragerc b/tosca2heat/heat-translator-0.3.0/.coveragerc new file mode 100644 index 0000000..6c9ae08 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/.coveragerc @@ -0,0 +1,7 @@ +[run] +branch = True +source = translator +omit = translator/openstack/* + +[report] +ignore_errors = True diff --git a/tosca2heat/heat-translator-0.3.0/.mailmap b/tosca2heat/heat-translator-0.3.0/.mailmap new file mode 100644 index 0000000..cc92f17 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/.mailmap @@ -0,0 +1,3 @@ +# Format is: +# +# \ No newline at end of file diff --git a/tosca2heat/heat-translator-0.3.0/.testr.conf b/tosca2heat/heat-translator-0.3.0/.testr.conf new file mode 100644 index 0000000..fb62267 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/.testr.conf @@ -0,0 +1,7 @@ +[DEFAULT] +test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ + OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ + OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \ + ${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION +test_id_option=--load-list $IDFILE +test_list_option=--list \ No newline at end of file diff --git a/tosca2heat/heat-translator-0.3.0/AUTHORS b/tosca2heat/heat-translator-0.3.0/AUTHORS new file mode 100644 index 0000000..7a4b006 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/AUTHORS @@ -0,0 +1,44 @@ +Andrew F. Ly +Atsushi SAKAI +Ben Martin +Bharath Thiruveedula +Bill Huber +Brad Topol +Christian Berendt +Dharmesh Bhakta +Dimitri Mazmanov +FeihuJiang +Haiyang DING +Idan Moyal +Jeff Feng +Jeremy Stanley +Julio Ruano +Kanagaraj Manickam +Longgeek +Madhurya +Matt Rutkowski +Meena +Michael Brewer +Michael Sambol +Monty Taylor +Oleksii Chuprykov +Rohan Shah +Sahdev Zala +Serg Melikyan +Sergey Lukjanov +Simeon Monov +Sirushti Murugesan +Steve Martinelli +Ton Ngo +Vahid Hashemian +Victor HU +Yaoguo Jiang +Zach Sais +Zachary Sais +ddaskal +huruifeng +jiangyaoguo +narengan +spzala +srinivas_tadepalli +tonanhngo diff --git a/tosca2heat/heat-translator-0.3.0/CONTRIBUTING.rst b/tosca2heat/heat-translator-0.3.0/CONTRIBUTING.rst new file mode 100644 index 0000000..e12c422 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/CONTRIBUTING.rst @@ -0,0 +1,16 @@ +If you would like to contribute to the development of OpenStack, +you must follow the steps in this page: + + http://docs.openstack.org/infra/manual/developers.html + +Once those steps have been completed, changes to OpenStack +should be submitted for review via the Gerrit tool, following +the workflow documented at: + + http://docs.openstack.org/infra/manual/developers.html#development-workflow + +Pull requests submitted through GitHub will be ignored. + +Bugs should be filed on Launchpad, not GitHub: + + https://bugs.launchpad.net/heat-translator \ No newline at end of file diff --git a/tosca2heat/heat-translator-0.3.0/ChangeLog b/tosca2heat/heat-translator-0.3.0/ChangeLog new file mode 100644 index 0000000..555b752 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/ChangeLog @@ -0,0 +1,258 @@ +CHANGES +======= + +0.3.0 +----- + +* Provide an option to store translated output in a file +* Update usage documentation +* Add capability to only validate template in OSC plug-in +* Provide option to only validate template +* Add support to fetch flavor details from nova +* Updated from global requirements +* Create initial test coverage +* Fix broken unittests due to tosca-parser 0.3.0 release +* Updated from global requirements +* Updated from global requirements +* Correc the usage example +* Update README +* Added checking for invalid or malformed command line parameters +* Refactor dynamic types mapping feature to use importlib + +0.2.0 +----- + +* Fix a bug in OSC related to URL handling +* Do not use logging conf on shell +* Update documentation to cover new features +* Handle URLs and import parameters in OSC +* Fix custom import issues when using shell environments +* Create command line entry point +* Update temporary URLs to github URLs +* Add translation of CSAR archives +* Handle URLs for input templates and imports +* Update README +* Fix translation issue with interface inputs and functions +* Update trove classifier +* Allow for dynamic class loading of target types +* Change ignore-errors to ignore_errors +* Updated from global requirements +* Update doc references +* Move tosca library test data under translator tests +* Updated from global requirements +* Enable Translator with new TOSCA library (6) +* Supporting logging in heat-translator with config file +* Remove CSAR files from translator +* Enable Translator with new TOSCA library (5) +* Enable Translator with new TOSCA library (4) +* Enable Translator with new TOSCA library (3) +* Enable Translator with new TOSCA library (2) +* Enable Translator with new TOSCA library (1) +* Add TOSCA parser as new requirement + +0.1.0 +----- + +* MemoryUnit Incorrectly normalizes to uppercase +* Implement SoftwareComponent and WebApplication normative types +* Validation of TOSCA version +* scalar-unit data type support as template input parameters +* Corrected checking required properties of OS capabilities in UT +* Validation for TOSCA second to below levels in template +* Fix two typos on heat-translator documentation +* Modified to get closest flavor based on minimal/no inputs +* Set property to be required by default +* Update TOSCA artifacts type +* Separate implementation of custom types and base types +* supporting short versions of requirements +* Add full support for PortDef data type +* Update network examples to the spec (1) +* Update TOSCA wordpress custom definition +* Update the 4th and 5th block storage examples (1) +* Add missing storage examples from the spec +* Update the 6th block storage example from the spec (1) +* Remove the circular dependency in network examples +* Update the first block storage example to the spec (1) +* Update object store definition and example +* Sync single server example with latest spec +* Sync network examples with the spec +* Remove py26 env +* Fix translation of block storage +* Updated from global requirements +* Add a unit test for nodejs-mongodb template translation +* Update TOSCA version per spec +* Prepare ELK TOSCA Template for Translation into HOT (6) +* Add app in the nodejs mongodb template +* Update TOSCA credential datatype +* Update TOSCA relationship inheritance +* Update TOSCA translator installation doc +* Update TOSCA relationship valid targets +* Document usage of translator with OSC +* Added directory structure in README.rst +* Add a unit test for ELK translation +* Annotate TOSCA scripts +* Prepare ELK TOSCA Template for Translation into HOT (5) +* Updated from global requirements +* Implement tosca.scalar-unit +* Update TOSCA base type definition file with version +* Prepare ELK TOSCA Template for Translation into HOT (4) +* Added translation to the tosca network module +* Added translation in dataentity module +* Fix typos in ELK CSAR readme file +* Updated from global requirements +* Adding unit test coverage for the validate method +* Implement artifact type definition +* Add support for parameters to translate template +* Added the missing testcases for Tosca translator +* Add handler for ConnectsTo relationship +* Prepare ELK TOSCA Template for Translation into HOT (3) +* Update TOSCA ELK scripts +* Adding an empty template test for simple_parse() +* Add unit testcases for toscalib_elements_constraints.py +* Fixed spelling mistake +* Fixing an error message which was not translated +* Add the ability to set output file +* Create an OSC plugin for heat-translator +* Resolve interfaces by symbolic name not by type +* TOSCA: Database and DBMS node properties update +* TOSCA: fix indentation in elk CSAR +* TOSCA: create csar for monitoring use case +* Installer scripts should not run simultaneously on the same server +* Prepare ELK TOSCA Template for Translation into HOT (2) +* TOSCA: Update memory size per spec changes +* Adding test coverage for HotParameter +* Fix host server assignment for resources with multi-node dependency +* Heat-Translator: Update README with new IRC Channel +* Added a unit test to cover diff_dicts in utils.py +* Fix installation package name +* Prepare ELK TOSCA Template for Translation into HOT +* TOSCA: interfaces for relationship templates +* TOSCA: fix Python34 UnicodeDecodeError +* Pick up new plugins for ELK +* Heat translator plugins for new TOSCA custom types +* TOSCA: keep the license formatting consistent +* TOSCA: Create a test CLI program +* Fix typos in tosca_elk.yaml file +* TOSCA: use the artifacts directory for scripts +* TOSCA: Correct duplicate Block Storage description +* Implement tosca.capabilities.Container +* TOSCA: minor updates in TOSCA def file per spec +* TOSCA: rename sample template file +* Create a unit test for wordpress specification in TOSCA +* Update the TOSCA monitoring use case +* Update TOSCA requirements for template and type +* Apply topology_template to tosca_template +* Inital Implementation of topology template +* Add test templates for topology template +* Update code base to be hacking compatible +* Update requirements and test-requirements +* Update README.rst to point to correct urls +* Update heat-translator's documentation theme +* Added unit test to verify num vals in str_to_num +* Implementation of tosca.node.ObjectStorage +* Implementation of CompareUtils class +* Added a unit test for convert_unit_size_to_num +* Added unit test to cover ValueError in str_to_num +* Update definition of tosca.nodes.WebServer +* TOSCA: organize test templates +* Fixes few nits in the network features code +* Create dictionary returning methods for certain class properties +* The output template is close to HOT template +* Rename TOSCA AttachTo relationship +* Fix coverage so that it works for this repo +* TOSCA: Handle memory units +* TOSCA: Create new utils module with memory units +* Add TOSCA networking features +* TOSCA: Update README source code link +* Follow the hosting chain to find the host server +* Add scripts for logstash, elasticsearch, kibana +* Add scripts to set up monitoring +* Update set of scripts for mongodb and nodejs +* tosca data type validation for float and timestamp +* TOSCA: Handle custom capability type definition +* Return input default value on get_input evaluation +* Replace ip_address attribute with public_address and private_address +* checking input parameter not None before accessing +* TOSCA: Add missing artifacts references +* Change name-value pairs to name-object pairs in the dictoinary +* validating reference properties in translate_input.py +* Add support for properties_def as a dictionary +* added _validate_capabilities_properties function & UT +* Adding tosca.capabilities.Scalable in TOSCA_definitions.yaml +* Apply TOSCA OS capability to compute node +* TOSCA: consider nodejs as web server only +* TOSCA: remove misleading key Entry-Definitions +* Use TOSCA properties from capabilities definition +* Remove Stackforge from README +* New custom type, unit test and template for use case +* Add TOSCA networking definiton +* Update TOSCA interfaces naming +* Separate TOSCA capabilities definition from assignment +* Remove unused TOSCA type variables +* TOSCA: Do not import individual exception classes +* Add missing TOSCA type keywords +* Update TOSCA compute requirement +* Validate TOSCA template version +* Update TOSCA version +* Add scalar unit type +* Handle TOSCA relationship with 'type' keyword +* Handle custom datatypes in current template +* Change definition for tosca.capabilities.Endpoint +* Remove Tosca.capabilities.feature per specs changes +* add blockstorage attachment notation +* Remove redundant TOSCA nodejs requirement +* Change TOSCA interfaces keyword 'input' to 'inputs' +* Add TOSCA service template for monitoring +* Minor tweaks +* Main translation code to handle parameters +* Add new support for get_attribute +* Add support for datatypes +* Rename TOSCA node property relationship to relationships +* Add a debug env for tox +* Sort TOSCA relation output for a match to expected test result +* Create relationship between TOSCA nodes per updated specs +* Fix .gitreview after rename/transfer +* Fix errors in templates and base types +* Workflow documentation is now in infra-manual +* get_attribute HOST keyword +* Handle get_attribute in Tosca outputs +* Add support for list and map types +* Check for tosca keyword in the TOSCA type +* Create a TOSCA CSAR for Wordpress template +* Represent memory unit in string +* Remove extraneous vim editor configuration comments +* Provide implementation to parse monitoring template in TOSCA library +* Allow Tosca templates with no inputs/outputs +* Extended intrinsic functions support +* Remove README.md as duplicate for .rst one +* Work toward Python 3.4 support and testing +* Add missing TOSCA template keynames +* Update README and other doc files +* Clean up heat-translator documentation +* Revert use of olsosphinx library +* add docs job to tox.ini +* Check tosca node requirements +* Add Schema parent class for Property, Input, Output +* Implement TOSCA Block Storage +* Allow use of TOSCA types by short name in the TOSCA template +* Add type attributes +* Enhance the validation of tosca +* Enhanced tosca validation +* Added a module for intrinsic function +* Support importing TOSCA custom node types +* Update the Babel module version +* TOSCA generator top level code +* TOSCA generator translation for individual TOSCA type +* TOSCA generator template syntax +* Remove tosca node template inheritance from node type +* Add missing parameter for the tosca property +* TOSCA parser +* TOSCA definition types for TOSCA library +* Add .gitreview file and apply cookiecutter template +* Delete testattrs.pyc +* Delete test4.pyc +* Delete test3.pyc +* Delete test2.pyc +* Delete squaretest.pyc +* First code drop on data modeling +* Initial commit diff --git a/tosca2heat/heat-translator-0.3.0/HACKING.rst b/tosca2heat/heat-translator-0.3.0/HACKING.rst new file mode 100644 index 0000000..9c60464 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/HACKING.rst @@ -0,0 +1,4 @@ +heat-translator Style Commandments +=============================================== + +Read the OpenStack Style Commandments http://docs.openstack.org/developer/hacking/ \ No newline at end of file diff --git a/tosca2heat/heat-translator-0.3.0/LICENSE b/tosca2heat/heat-translator-0.3.0/LICENSE new file mode 100644 index 0000000..67db858 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/LICENSE @@ -0,0 +1,175 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. diff --git a/tosca2heat/heat-translator-0.3.0/MANIFEST.in b/tosca2heat/heat-translator-0.3.0/MANIFEST.in new file mode 100644 index 0000000..90f8a7a --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/MANIFEST.in @@ -0,0 +1,6 @@ +include AUTHORS +include ChangeLog +exclude .gitignore +exclude .gitreview + +global-exclude *.pyc \ No newline at end of file diff --git a/tosca2heat/heat-translator-0.3.0/PKG-INFO b/tosca2heat/heat-translator-0.3.0/PKG-INFO new file mode 100644 index 0000000..5917638 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/PKG-INFO @@ -0,0 +1,68 @@ +Metadata-Version: 1.1 +Name: heat-translator +Version: 0.3.0 +Summary: Tool to translate non-heat templates to Heat Orchestration Template. +Home-page: http://www.openstack.org/ +Author: OpenStack +Author-email: openstack-dev@lists.openstack.org +License: UNKNOWN +Description: =============== + Heat-Translator + =============== + + Overview + -------- + + Heat-Translator is an Openstack project and licensed under Apache 2. It is a + command line tool which takes non-Heat templates as an input and produces a + Heat Orchestration Template (HOT) which can be deployed by Heat. Currently the + development and testing is done with an aim to translate OASIS Topology and + Orchestration Specification for Cloud Applications (TOSCA) templates to + HOT. However, the tool is designed to be easily extended to use with any + format other than TOSCA. + + Architecture + ------------ + + Heat-Translator project takes a non-Heat template (e.g. TOSCA flat YAML + template or template embedded in TOSCA Cloud Service Archive (CSAR) format) as + an input, calls an appropriate Parser (e.g. TOSCA Parser) per the type of input + template to parse it and create an in-memory graph, maps it to Heat resources + and then produces a Heat Orchestration Template (HOT) as an output. + + How To Use + ---------- + Please refer to `doc/source/usage.rst `_ + + Directory Structure + ------------------- + + Three main directories related to the heat-translator are: + + 1. hot: It is the generator, that has logic of converting TOSCA in memory graph to HOT yaml files. + 2. common: It has all the file that can support the execution of parser and generator. + 3. tests: It contains test programs and more importantly several templates which are used for testing. + + Project Info + ------------ + + * License: Apache License, Version 2.0 + * Documentation: http://docs.openstack.org/developer/heat-translator/ + * Launchpad: https://launchpad.net/heat-translator + * Blueprints: https://blueprints.launchpad.net/heat-translator + * Bugs: https://bugs.launchpad.net/heat-translator + * Source: http://git.openstack.org/cgit/openstack/heat-translator/ + * IRC Channel: #openstack-heat-translator + + +Platform: UNKNOWN +Classifier: Environment :: OpenStack +Classifier: Intended Audience :: Information Technology +Classifier: Intended Audience :: System Administrators +Classifier: License :: OSI Approved :: Apache Software License +Classifier: Operating System :: POSIX :: Linux +Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 2 +Classifier: Programming Language :: Python :: 2.7 +Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3.4 diff --git a/tosca2heat/heat-translator-0.3.0/README.rst b/tosca2heat/heat-translator-0.3.0/README.rst new file mode 100644 index 0000000..1bad459 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/README.rst @@ -0,0 +1,47 @@ +=============== +Heat-Translator +=============== + +Overview +-------- + +Heat-Translator is an Openstack project and licensed under Apache 2. It is a +command line tool which takes non-Heat templates as an input and produces a +Heat Orchestration Template (HOT) which can be deployed by Heat. Currently the +development and testing is done with an aim to translate OASIS Topology and +Orchestration Specification for Cloud Applications (TOSCA) templates to +HOT. However, the tool is designed to be easily extended to use with any +format other than TOSCA. + +Architecture +------------ + +Heat-Translator project takes a non-Heat template (e.g. TOSCA flat YAML +template or template embedded in TOSCA Cloud Service Archive (CSAR) format) as +an input, calls an appropriate Parser (e.g. TOSCA Parser) per the type of input +template to parse it and create an in-memory graph, maps it to Heat resources +and then produces a Heat Orchestration Template (HOT) as an output. + +How To Use +---------- +Please refer to `doc/source/usage.rst `_ + +Directory Structure +------------------- + +Three main directories related to the heat-translator are: + +1. hot: It is the generator, that has logic of converting TOSCA in memory graph to HOT yaml files. +2. common: It has all the file that can support the execution of parser and generator. +3. tests: It contains test programs and more importantly several templates which are used for testing. + +Project Info +------------ + +* License: Apache License, Version 2.0 +* Documentation: http://docs.openstack.org/developer/heat-translator/ +* Launchpad: https://launchpad.net/heat-translator +* Blueprints: https://blueprints.launchpad.net/heat-translator +* Bugs: https://bugs.launchpad.net/heat-translator +* Source: http://git.openstack.org/cgit/openstack/heat-translator/ +* IRC Channel: #openstack-heat-translator diff --git a/tosca2heat/heat-translator-0.3.0/babel.cfg b/tosca2heat/heat-translator-0.3.0/babel.cfg new file mode 100644 index 0000000..efceab8 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/babel.cfg @@ -0,0 +1 @@ +[python: **.py] diff --git a/tosca2heat/heat-translator-0.3.0/doc/source/conf.py b/tosca2heat/heat-translator-0.3.0/doc/source/conf.py new file mode 100755 index 0000000..23aa050 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/doc/source/conf.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import sys + +sys.path.insert(0, os.path.abspath('../..')) +# -- General configuration ---------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = [ + 'sphinx.ext.autodoc', + #'sphinx.ext.intersphinx', + 'oslosphinx' +] + +# autodoc generation is a bit aggressive and a nuisance when doing heavy +# text edit cycles. +# execute "export SPHINX_DEBUG=1" in your terminal to disable + +# The suffix of source filenames. +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'heat-translator' +copyright = u'2013, OpenStack Foundation' + +# If true, '()' will be appended to :func: etc. cross-reference text. +add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +add_module_names = True + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# -- Options for HTML output -------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. Major themes that come with +# Sphinx are currently 'default' and 'sphinxdoc'. +# html_theme_path = ["."] +# html_theme = 'default' +# html_static_path = ['static'] + +# Output file base name for HTML help builder. +htmlhelp_basename = '%sdoc' % project + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass +# [howto/manual]). +latex_documents = [ + ('index', + '%s.tex' % project, + u'%s Documentation' % project, + u'OpenStack Foundation', 'manual'), +] + +# Example configuration for intersphinx: refer to the Python standard library. +#intersphinx_mapping = {'http://docs.python.org/': None} diff --git a/tosca2heat/heat-translator-0.3.0/doc/source/contributing.rst b/tosca2heat/heat-translator-0.3.0/doc/source/contributing.rst new file mode 100644 index 0000000..8cb3146 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/doc/source/contributing.rst @@ -0,0 +1 @@ +.. include:: ../../CONTRIBUTING.rst \ No newline at end of file diff --git a/tosca2heat/heat-translator-0.3.0/doc/source/index.rst b/tosca2heat/heat-translator-0.3.0/doc/source/index.rst new file mode 100644 index 0000000..dd3f04f --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/doc/source/index.rst @@ -0,0 +1,29 @@ +.. heat-translator documentation master file, created by + sphinx-quickstart on Tue Jul 9 22:26:36 2013. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to heat-translator's documentation! +=========================================== + +The heat-translator tool is aimed to translate non-heat templates to OpenStack +Heat Orchestration Template (HOT). Initially the tool is aimed to translate +OASIS Topology and Orchestration Specification for Cloud Applications (TOSCA) +to HOT. However, the tool can be easily extended to support any non-heat +template format to produce HOT. + +Contents: + +.. toctree:: + :maxdepth: 2 + + installation + usage + contributing + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/tosca2heat/heat-translator-0.3.0/doc/source/installation.rst b/tosca2heat/heat-translator-0.3.0/doc/source/installation.rst new file mode 100644 index 0000000..71c5237 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/doc/source/installation.rst @@ -0,0 +1,15 @@ +============ +Installation +============ + +Assuming that OpenStackClient (OSC) is available in your environment, you can easily install Heat-Translator to use with OSC by following three steps:: + + git clone https://github.com/openstack/heat-translator + cd heat-translator + sudo python setup.py install + +You can also clone the project and use it without any specific OpenStack environment set up as below:: + + git clone https://github.com/openstack/heat-translator + +Heat-Translator can be installed via PyPI package as well. Refer to https://pypi.python.org/pypi/heat-translator for available packages. diff --git a/tosca2heat/heat-translator-0.3.0/doc/source/usage.rst b/tosca2heat/heat-translator-0.3.0/doc/source/usage.rst new file mode 100644 index 0000000..c2c9b5a --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/doc/source/usage.rst @@ -0,0 +1,71 @@ +===== +Usage +===== + +Use Heat-Translator with OpenStackClient (OSC) +---------------------------------------------- +Assuming that OpenStackClient (OSC) is available in your environment, you can easily install Heat-Translator to use with OSC by following three steps:: + + git clone https://github.com/openstack/heat-translator + cd heat-translator + sudo python setup.py install + +Alternatively, you can install a particular release of Heat-Translator as available at https://pypi.python.org/pypi/heat-translator. + +Once installation is complete, Heat-Translator is ready to use. Currently you can use it in following three ways. + +Translate and get output on command line. For example: :: + + openstack translate template --template-file /home/openstack/heat-translator/translator/tests/data/tosca_helloworld.yaml --template-type tosca + +Translate and save output of translated file to a desired destination. For example: :: + + openstack translate template --template-file /home/openstack/heat-translator/translator/tests/data/tosca_helloworld.yaml --template-type tosca --output-file /tmp/hot_hello_world.yaml + +Do not translate but only validate template file. For example: :: + + openstack translate template --template-file /home/openstack/heat-translator/translator/tests/data/tosca_helloworld.yaml --template-type tosca --validate-only=true + +You can learn more about available options by running following help command:: + + openstack help translate template + + +Use Heat-Translator on its own +------------------------------ +Heat-Translator can be used without any specific OpenStack environment set up as below:: + + git clone https://github.com/openstack/heat-translator + python heat_translator.py --template-file== --template-type= --parameters="purpose=test" + +The heat_translator.py test program is at the root level of the project. The program has currently tested with TOSCA templates. +It requires two arguments:: + +1. Path to the file that needs to be translated. The file, flat yaml template or CSAR, can be specified as a local file in your +system or via URL. +2. Type of translation (e.g. tosca) + +For example, a TOSCA hello world template can be translated by running the following command from the project location:: + + python heat_translator.py --template-file=translator/tests/data/tosca_helloworld.yaml --template-type=tosca + +This should produce a translated Heat Orchestration Template on the command line. The translated content can be saved to a desired file by setting --output-file=. +For example: :: + + python heat_translator.py --template-file=translator/tests/data/tosca_helloworld.yaml --template-type=tosca --output-file=/tmp/hot_helloworld.yaml + +An optional argument can be provided to handle user inputs parameters. Also, a template file can only be validated instead of translation by using --validate-only=true +optional argument. The command below shows an example usage:: + + python heat_translator.py --template-file== --template-type= --validate-only=true + +Alternatively, you can install a particular release of Heat-Translator as available at https://pypi.python.org/pypi/heat-translator. +In this case, you can simply run translation via CLI entry point:: + heat-translator --template-file=translator/tests/data/tosca_helloworld.yaml --template-type=tosca + +When deploy the translated template with Heat, please keep in mind that you have image registered in the Glance. The Heat-Translator +project sets flavor and image from a pre-defined set of values (as listed in /home/openstack/heat-translator/translator/hot/tosca/tosca_compute.py) +with the best possible match to the constraints defined in the TOSCA template. If there is no possible match found, a null value is set for now. +Per the future plan, an image and flavor will be provided from an online repository. + + diff --git a/tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/PKG-INFO b/tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/PKG-INFO new file mode 100644 index 0000000..5917638 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/PKG-INFO @@ -0,0 +1,68 @@ +Metadata-Version: 1.1 +Name: heat-translator +Version: 0.3.0 +Summary: Tool to translate non-heat templates to Heat Orchestration Template. +Home-page: http://www.openstack.org/ +Author: OpenStack +Author-email: openstack-dev@lists.openstack.org +License: UNKNOWN +Description: =============== + Heat-Translator + =============== + + Overview + -------- + + Heat-Translator is an Openstack project and licensed under Apache 2. It is a + command line tool which takes non-Heat templates as an input and produces a + Heat Orchestration Template (HOT) which can be deployed by Heat. Currently the + development and testing is done with an aim to translate OASIS Topology and + Orchestration Specification for Cloud Applications (TOSCA) templates to + HOT. However, the tool is designed to be easily extended to use with any + format other than TOSCA. + + Architecture + ------------ + + Heat-Translator project takes a non-Heat template (e.g. TOSCA flat YAML + template or template embedded in TOSCA Cloud Service Archive (CSAR) format) as + an input, calls an appropriate Parser (e.g. TOSCA Parser) per the type of input + template to parse it and create an in-memory graph, maps it to Heat resources + and then produces a Heat Orchestration Template (HOT) as an output. + + How To Use + ---------- + Please refer to `doc/source/usage.rst `_ + + Directory Structure + ------------------- + + Three main directories related to the heat-translator are: + + 1. hot: It is the generator, that has logic of converting TOSCA in memory graph to HOT yaml files. + 2. common: It has all the file that can support the execution of parser and generator. + 3. tests: It contains test programs and more importantly several templates which are used for testing. + + Project Info + ------------ + + * License: Apache License, Version 2.0 + * Documentation: http://docs.openstack.org/developer/heat-translator/ + * Launchpad: https://launchpad.net/heat-translator + * Blueprints: https://blueprints.launchpad.net/heat-translator + * Bugs: https://bugs.launchpad.net/heat-translator + * Source: http://git.openstack.org/cgit/openstack/heat-translator/ + * IRC Channel: #openstack-heat-translator + + +Platform: UNKNOWN +Classifier: Environment :: OpenStack +Classifier: Intended Audience :: Information Technology +Classifier: Intended Audience :: System Administrators +Classifier: License :: OSI Approved :: Apache Software License +Classifier: Operating System :: POSIX :: Linux +Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 2 +Classifier: Programming Language :: Python :: 2.7 +Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3.4 diff --git a/tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/SOURCES.txt b/tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/SOURCES.txt new file mode 100644 index 0000000..b945891 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/SOURCES.txt @@ -0,0 +1,187 @@ +.coveragerc +.mailmap +.testr.conf +AUTHORS +CONTRIBUTING.rst +ChangeLog +HACKING.rst +LICENSE +MANIFEST.in +README.rst +babel.cfg +heat_translator.py +heat_translator_logging.conf +openstack-common.conf +requirements.txt +setup.cfg +setup.py +test-requirements.txt +tox.ini +doc/source/conf.py +doc/source/contributing.rst +doc/source/index.rst +doc/source/installation.rst +doc/source/usage.rst +heat_translator.egg-info/PKG-INFO +heat_translator.egg-info/SOURCES.txt +heat_translator.egg-info/dependency_links.txt +heat_translator.egg-info/entry_points.txt +heat_translator.egg-info/not-zip-safe +heat_translator.egg-info/pbr.json +heat_translator.egg-info/requires.txt +heat_translator.egg-info/top_level.txt +translator/__init__.py +translator/shell.py +translator/common/__init__.py +translator/common/exception.py +translator/common/utils.py +translator/conf/__init__.py +translator/conf/config.py +translator/conf/translator.conf +translator/custom/__init__.py +translator/custom/hot/__init__.py +translator/custom/hot/tosca_collectd.py +translator/custom/hot/tosca_elasticsearch.py +translator/custom/hot/tosca_kibana.py +translator/custom/hot/tosca_logstash.py +translator/custom/hot/tosca_nodejs.py +translator/custom/hot/tosca_paypalpizzastore.py +translator/custom/hot/tosca_rsyslog.py +translator/custom/hot/tosca_wordpress.py +translator/hot/__init__.py +translator/hot/tosca_translator.py +translator/hot/translate_inputs.py +translator/hot/translate_node_templates.py +translator/hot/translate_outputs.py +translator/hot/syntax/__init__.py +translator/hot/syntax/hot_output.py +translator/hot/syntax/hot_parameter.py +translator/hot/syntax/hot_resource.py +translator/hot/syntax/hot_template.py +translator/hot/tests/__init__.py +translator/hot/tests/test_hot_parameter.py +translator/hot/tests/test_translate_inputs.py +translator/hot/tests/test_translate_outputs.py +translator/hot/tosca/__init__.py +translator/hot/tosca/tosca_block_storage.py +translator/hot/tosca/tosca_block_storage_attachment.py +translator/hot/tosca/tosca_compute.py +translator/hot/tosca/tosca_database.py +translator/hot/tosca/tosca_dbms.py +translator/hot/tosca/tosca_network_network.py +translator/hot/tosca/tosca_network_port.py +translator/hot/tosca/tosca_object_storage.py +translator/hot/tosca/tosca_software_component.py +translator/hot/tosca/tosca_web_application.py +translator/hot/tosca/tosca_webserver.py +translator/hot/tosca/tests/__init__.py +translator/hot/tosca/tests/test_tosca_blockstorage.py +translator/hot/tosca/tests/test_tosca_compute.py +translator/hot/tosca/tests/test_tosca_objectstore.py +translator/osc/__init__.py +translator/osc/osc_plugin.py +translator/osc/utils.py +translator/osc/v1/__init__.py +translator/osc/v1/translate.py +translator/tests/__init__.py +translator/tests/base.py +translator/tests/test_conf.py +translator/tests/test_shell.py +translator/tests/test_template.py +translator/tests/test_tosca_hot_translation.py +translator/tests/test_utils.py +translator/tests/data/csar_elk.zip +translator/tests/data/csar_hello_world.zip +translator/tests/data/csar_metadata_not_yaml.zip +translator/tests/data/csar_not_zip.zip +translator/tests/data/csar_single_instance_wordpress.zip +translator/tests/data/csar_wordpress_invalid_import_path.zip +translator/tests/data/csar_wordpress_invalid_script_url.zip +translator/tests/data/csar_wrong_metadata_file.zip +translator/tests/data/test_host_assignment.yaml +translator/tests/data/tosca_elk.yaml +translator/tests/data/tosca_helloworld.yaml +translator/tests/data/tosca_helloworld_invalid.yaml +translator/tests/data/tosca_nodejs_mongodb_two_instances.yaml +translator/tests/data/tosca_single_instance_wordpress.yaml +translator/tests/data/tosca_single_instance_wordpress_with_local_abspath_import.yaml +translator/tests/data/tosca_single_instance_wordpress_with_url_import.yaml +translator/tests/data/tosca_single_server.yaml +translator/tests/data/tosca_single_server_with_defaults.yaml +translator/tests/data/tosca_software_component.yaml +translator/tests/data/tosca_web_application.yaml +translator/tests/data/artifacts/collectd/config.py +translator/tests/data/artifacts/collectd/create.sh +translator/tests/data/artifacts/collectd/start.sh +translator/tests/data/artifacts/elasticsearch/create.sh +translator/tests/data/artifacts/elasticsearch/start.sh +translator/tests/data/artifacts/kibana/config.sh +translator/tests/data/artifacts/kibana/create.sh +translator/tests/data/artifacts/kibana/start.sh +translator/tests/data/artifacts/logstash/configure_collectd.py +translator/tests/data/artifacts/logstash/configure_elasticsearch.py +translator/tests/data/artifacts/logstash/configure_rsyslog.py +translator/tests/data/artifacts/logstash/create.sh +translator/tests/data/artifacts/logstash/start.sh +translator/tests/data/artifacts/mongodb/config.sh +translator/tests/data/artifacts/mongodb/create.sh +translator/tests/data/artifacts/mongodb/create_database.sh +translator/tests/data/artifacts/mongodb/start.sh +translator/tests/data/artifacts/mysql/mysql_database_configure.sh +translator/tests/data/artifacts/mysql/mysql_dbms_configure.sh +translator/tests/data/artifacts/mysql/mysql_dbms_install.sh +translator/tests/data/artifacts/mysql/mysql_dbms_start.sh +translator/tests/data/artifacts/nodejs/config.sh +translator/tests/data/artifacts/nodejs/create.sh +translator/tests/data/artifacts/nodejs/start.sh +translator/tests/data/artifacts/rsyslog/config.sh +translator/tests/data/artifacts/rsyslog/create.sh +translator/tests/data/artifacts/rsyslog/start.sh +translator/tests/data/artifacts/webserver/webserver_install.sh +translator/tests/data/artifacts/webserver/webserver_start.sh +translator/tests/data/artifacts/wordpress/wordpress_configure.sh +translator/tests/data/artifacts/wordpress/wordpress_install.sh +translator/tests/data/custom_types/collectd.yaml +translator/tests/data/custom_types/elasticsearch.yaml +translator/tests/data/custom_types/kibana.yaml +translator/tests/data/custom_types/logstash.yaml +translator/tests/data/custom_types/paypalpizzastore_nodejs_app.yaml +translator/tests/data/custom_types/rsyslog.yaml +translator/tests/data/custom_types/wordpress.yaml +translator/tests/data/hot_output/hot_elk.yaml +translator/tests/data/hot_output/hot_elk_from_csar.yaml +translator/tests/data/hot_output/hot_hello_world.yaml +translator/tests/data/hot_output/hot_host_assignment.yaml +translator/tests/data/hot_output/hot_nodejs_mongodb_two_instances.yaml +translator/tests/data/hot_output/hot_single_instance_wordpress.yaml +translator/tests/data/hot_output/hot_single_instance_wordpress_from_csar.yaml +translator/tests/data/hot_output/hot_single_object_store.yaml +translator/tests/data/hot_output/hot_single_server.yaml +translator/tests/data/hot_output/hot_single_server_with_defaults_with_input.yaml +translator/tests/data/hot_output/hot_single_server_with_defaults_without_input.yaml +translator/tests/data/hot_output/hot_software_component.yaml +translator/tests/data/hot_output/hot_web_application.yaml +translator/tests/data/hot_output/network/hot_one_server_one_network.yaml +translator/tests/data/hot_output/network/hot_one_server_three_networks.yaml +translator/tests/data/hot_output/network/hot_server_on_existing_network.yaml +translator/tests/data/hot_output/network/hot_two_servers_one_network.yaml +translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment.yaml +translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment_notation1_alt1.yaml +translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment_notation1_alt2.yaml +translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment_notation2_alt1.yaml +translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment_notation2_alt2.yaml +translator/tests/data/hot_output/storage/hot_blockstorage_with_custom_relationship_type.yaml +translator/tests/data/hot_output/storage/hot_blockstorage_with_relationship_template.yaml +translator/tests/data/hot_output/storage/hot_multiple_blockstorage_with_attachment_alt1.yaml +translator/tests/data/hot_output/storage/hot_multiple_blockstorage_with_attachment_alt2.yaml +translator/tests/data/network/tosca_one_server_one_network.yaml +translator/tests/data/network/tosca_one_server_three_networks.yaml +translator/tests/data/network/tosca_server_on_existing_network.yaml +translator/tests/data/network/tosca_two_servers_one_network.yaml +translator/tests/data/storage/tosca_blockstorage_with_attachment.yaml +translator/tests/data/storage/tosca_blockstorage_with_attachment_notation1.yaml +translator/tests/data/storage/tosca_blockstorage_with_attachment_notation2.yaml +translator/tests/data/storage/tosca_blockstorage_with_custom_relationship_type.yaml +translator/tests/data/storage/tosca_blockstorage_with_relationship_template.yaml +translator/tests/data/storage/tosca_multiple_blockstorage_with_attachment.yaml +translator/tests/data/storage/tosca_single_object_store.yaml \ No newline at end of file diff --git a/tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/dependency_links.txt b/tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/entry_points.txt b/tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/entry_points.txt new file mode 100644 index 0000000..b0b1081 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/entry_points.txt @@ -0,0 +1,9 @@ +[console_scripts] +heat-translator = translator.shell:main + +[openstack.cli.extension] +translator = translator.osc.osc_plugin + +[openstack.translator.v1] +translate_template = translator.osc.v1.translate:TranslateTemplate + diff --git a/tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/not-zip-safe b/tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/not-zip-safe new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/not-zip-safe @@ -0,0 +1 @@ + diff --git a/tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/pbr.json b/tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/pbr.json new file mode 100644 index 0000000..d25af9b --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/pbr.json @@ -0,0 +1 @@ +{"git_version": "ab4979a", "is_release": true} \ No newline at end of file diff --git a/tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/requires.txt b/tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/requires.txt new file mode 100644 index 0000000..04623eb --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/requires.txt @@ -0,0 +1,7 @@ +pbr>=1.6 +Babel>=1.3 +cliff>=1.15.0 +PyYAML>=3.1.0 +python-dateutil>=2.4.2 +six>=1.9.0 +tosca-parser>=0.3.0 diff --git a/tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/top_level.txt b/tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/top_level.txt new file mode 100644 index 0000000..3b6719f --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/heat_translator.egg-info/top_level.txt @@ -0,0 +1 @@ +translator diff --git a/tosca2heat/heat-translator-0.3.0/heat_translator.py b/tosca2heat/heat-translator-0.3.0/heat_translator.py new file mode 100644 index 0000000..80a435b --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/heat_translator.py @@ -0,0 +1,20 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +# Keep this file around for backwards compatibility, and make it call the +# new translator's shell file instead, as it's now packaged + +from translator import shell as translator_shell + +if __name__ == '__main__': + translator_shell.main() diff --git a/tosca2heat/heat-translator-0.3.0/heat_translator_logging.conf b/tosca2heat/heat-translator-0.3.0/heat_translator_logging.conf new file mode 100644 index 0000000..e01a889 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/heat_translator_logging.conf @@ -0,0 +1,43 @@ + +[loggers] +keys=root,heat-translator + +[handlers] +keys=RotatingFileHandler,SysLogHandler,NullHandler + +[formatters] +keys=form01 + +[logger_root] +level=DEBUG +handlers=NullHandler + +[logger_heat-translator] +level=INFO +#one can be removed based on requirements +handlers=SysLogHandler, RotatingFileHandler +qualname=heat-translator +propagate=1 + +[handler_RotatingFileHandler] +class=handlers.RotatingFileHandler +level=INFO +formatter=form01 +#rotation happens after 100MB +args=('/tmp/heat-translator.log', 'a', 100000000, 5, 'utf8') + +[handler_SysLogHandler] +class=handlers.SysLogHandler +formatter=form01 +level=INFO +args=('/dev/log', handlers.SysLogHandler.LOG_SYSLOG) + +[handler_NullHandler] +class=NullHandler +formatter=form01 +level=DEBUG +args=() + +[formatter_form01] +format = %(asctime)s - %(name)s - %(levelname)s - %(filename)s : %(message)s +datefmt = diff --git a/tosca2heat/heat-translator-0.3.0/openstack-common.conf b/tosca2heat/heat-translator-0.3.0/openstack-common.conf new file mode 100644 index 0000000..d359e40 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/openstack-common.conf @@ -0,0 +1,6 @@ +[DEFAULT] + +# The list of modules to copy from oslo-incubator.git + +# The base module to hold the copy of openstack.common +base=translator \ No newline at end of file diff --git a/tosca2heat/heat-translator-0.3.0/requirements.txt b/tosca2heat/heat-translator-0.3.0/requirements.txt new file mode 100644 index 0000000..50d48f9 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/requirements.txt @@ -0,0 +1,10 @@ +# The order of packages is significant, because pip processes them in the order +# of appearance. Changing the order has an impact on the overall integration +# process, which may cause wedges in the gate later. +pbr>=1.6 +Babel>=1.3 +cliff>=1.15.0 # Apache-2.0 +PyYAML>=3.1.0 +python-dateutil>=2.4.2 +six>=1.9.0 +tosca-parser>=0.3.0 diff --git a/tosca2heat/heat-translator-0.3.0/setup.cfg b/tosca2heat/heat-translator-0.3.0/setup.cfg new file mode 100644 index 0000000..c94dcbe --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/setup.cfg @@ -0,0 +1,59 @@ +[metadata] +name = heat-translator +summary = Tool to translate non-heat templates to Heat Orchestration Template. +description-file = + README.rst +author = OpenStack +author-email = openstack-dev@lists.openstack.org +home-page = http://www.openstack.org/ +classifier = + Environment :: OpenStack + Intended Audience :: Information Technology + Intended Audience :: System Administrators + License :: OSI Approved :: Apache Software License + Operating System :: POSIX :: Linux + Programming Language :: Python + Programming Language :: Python :: 2 + Programming Language :: Python :: 2.7 + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.4 + +[files] +packages = + translator + +[entry_points] +openstack.cli.extension = + translator = translator.osc.osc_plugin +openstack.translator.v1 = + translate_template = translator.osc.v1.translate:TranslateTemplate +console_scripts = + heat-translator = translator.shell:main + +[build_sphinx] +source-dir = doc/source +build-dir = doc/build +all_files = 1 + +[upload_sphinx] +upload-dir = doc/build/html + +[compile_catalog] +directory = translator/locale +domain = translator + +[update_catalog] +domain = translator +output_dir = translator/locale +input_file = translator/locale/translator.pot + +[extract_messages] +keywords = _ gettext ngettext l_ lazy_gettext +mapping_file = babel.cfg +output_file = translator/locale/translator.pot + +[egg_info] +tag_date = 0 +tag_build = +tag_svn_revision = 0 + diff --git a/tosca2heat/heat-translator-0.3.0/setup.py b/tosca2heat/heat-translator-0.3.0/setup.py new file mode 100644 index 0000000..782bb21 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/setup.py @@ -0,0 +1,29 @@ +# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT +import setuptools + +# In python < 2.7.4, a lazy loading of package `pbr` will break +# setuptools if some other modules registered functions in `atexit`. +# solution from: http://bugs.python.org/issue15881#msg170215 +try: + import multiprocessing # noqa +except ImportError: + pass + +setuptools.setup( + setup_requires=['pbr>=1.8'], + pbr=True) diff --git a/tosca2heat/heat-translator-0.3.0/test-requirements.txt b/tosca2heat/heat-translator-0.3.0/test-requirements.txt new file mode 100644 index 0000000..c4dc2b9 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/test-requirements.txt @@ -0,0 +1,14 @@ +# The order of packages is significant, because pip processes them in the order +# of appearance. Changing the order has an impact on the overall integration +# process, which may cause wedges in the gate later. +hacking<0.11,>=0.10.0 +coverage>=3.6 +discover +fixtures>=1.3.1 +oslotest>=1.10.0 # Apache-2.0 +oslosphinx!=3.4.0,>=2.5.0 # Apache-2.0 +python-subunit>=0.0.18 +sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 +testrepository>=0.0.18 +testscenarios>=0.4 +testtools>=1.4.0 diff --git a/tosca2heat/heat-translator-0.3.0/tox.ini b/tosca2heat/heat-translator-0.3.0/tox.ini new file mode 100644 index 0000000..3649c0a --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/tox.ini @@ -0,0 +1,37 @@ +[tox] +minversion = 1.6 +envlist = py27,py34,pypy,pep8 +skipsdist = True + +[testenv] +usedevelop = True +install_command = pip install -U {opts} {packages} +setenv = + VIRTUAL_ENV={envdir} +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt +commands = python setup.py test --slowest --testr-args='{posargs}' + +[testenv:pep8] +commands = flake8 + +[testenv:venv] +commands = {posargs} + +[testenv:cover] +commands = python setup.py test --coverage --coverage-package-name=translator --testr-args='{posargs}' + +[testenv:docs] +commands = python setup.py build_sphinx + +[testenv:debug] +commands = oslo_debug_helper -t translator/tests {posargs} + +[flake8] +# H803 skipped on purpose per list discussion. +# E123, E125 skipped as they are invalid PEP-8. + +show-source = True +ignore = E123,E125,H803 +builtins = _ +exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build diff --git a/tosca2heat/heat-translator-0.3.0/translator/__init__.py b/tosca2heat/heat-translator-0.3.0/translator/__init__.py new file mode 100644 index 0000000..3c2a807 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/__init__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import pbr.version + + +__version__ = pbr.version.VersionInfo( + 'heat-translator').version_string() diff --git a/tosca2heat/heat-translator-0.3.0/translator/common/__init__.py b/tosca2heat/heat-translator-0.3.0/translator/common/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tosca2heat/heat-translator-0.3.0/translator/common/exception.py b/tosca2heat/heat-translator-0.3.0/translator/common/exception.py new file mode 100644 index 0000000..be86116 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/common/exception.py @@ -0,0 +1,48 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +''' +Exceptions for the TOSCA Translator package. +''' + +from toscaparser.common.exception import TOSCAException +from toscaparser.utils.gettextutils import _ + + +class ConfFileParseError(TOSCAException): + msg_fmt = _('%(message)s') + + +class ConfOptionNotDefined(TOSCAException): + msg_fmt = _('Option %(key)s in section %(section)s ' + 'is not defined in conf file') + + +class ConfSectionNotDefined(TOSCAException): + msg_fmt = _('Section %(section)s is not defined in conf file') + + +class ToscaModImportError(TOSCAException): + msg_fmt = _('Unable to import module %(mod_name)s. ' + 'Check to see that it exists and has no ' + 'language definition errors.') + + +class ToscaClassImportError(TOSCAException): + msg_fmt = _('Unable to import class %(name)s in ' + 'module %(mod_name)s. Check to see that it ' + 'exists and has no language definition errors.') + + +class ToscaClassAttributeError(TOSCAException): + msg_fmt = _('Class attribute referenced not found. ' + '%(message)s. Check to see that it is defined.') diff --git a/tosca2heat/heat-translator-0.3.0/translator/common/utils.py b/tosca2heat/heat-translator-0.3.0/translator/common/utils.py new file mode 100644 index 0000000..6d0d9e1 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/common/utils.py @@ -0,0 +1,266 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +import logging +import math +import numbers +import os +import re +from six.moves.urllib.parse import urlparse +import yaml + +from toscaparser.utils.gettextutils import _ +import toscaparser.utils.yamlparser + +YAML_ORDER_PARSER = toscaparser.utils.yamlparser.simple_ordered_parse +log = logging.getLogger('tosca') +log = logging.getLogger('heat-translator') + + +class MemoryUnit(object): + + UNIT_SIZE_DEFAULT = 'B' + UNIT_SIZE_DICT = {'B': 1, 'kB': 1000, 'KiB': 1024, 'MB': 1000000, + 'MiB': 1048576, 'GB': 1000000000, + 'GiB': 1073741824, 'TB': 1000000000000, + 'TiB': 1099511627776} + + @staticmethod + def convert_unit_size_to_num(size, unit=None): + """Convert given size to a number representing given unit. + + If unit is None, convert to a number representing UNIT_SIZE_DEFAULT + :param size: unit size e.g. 1 TB + :param unit: unit to be converted to e.g GB + :return: converted number e.g. 1000 for 1 TB size and unit GB + """ + if unit: + unit = MemoryUnit.validate_unit(unit) + else: + unit = MemoryUnit.UNIT_SIZE_DEFAULT + log.info(_('A memory unit is not provided for size; using the ' + 'default unit %(default)s') % {'default': 'B'}) + regex = re.compile('(\d*)\s*(\w*)') + result = regex.match(str(size)).groups() + if result[1]: + unit_size = MemoryUnit.validate_unit(result[1]) + converted = int(str_to_num(result[0]) + * MemoryUnit.UNIT_SIZE_DICT[unit_size] + * math.pow(MemoryUnit.UNIT_SIZE_DICT + [unit], -1)) + log.info(_('Given size %(size)s is converted to %(num)s ' + '%(unit)s') % {'size': size, + 'num': converted, 'unit': unit}) + else: + converted = (str_to_num(result[0])) + return converted + + @staticmethod + def validate_unit(unit): + if unit in MemoryUnit.UNIT_SIZE_DICT.keys(): + return unit + else: + for key in MemoryUnit.UNIT_SIZE_DICT.keys(): + if key.upper() == unit.upper(): + return key + + msg = _('Provided unit "{0}" is not valid. The valid units are' + ' {1}').format(unit, MemoryUnit.UNIT_SIZE_DICT.keys()) + log.warning(msg) + raise ValueError(msg) + + +class CompareUtils(object): + + MISMATCH_VALUE1_LABEL = "" + MISMATCH_VALUE2_LABEL = "" + ORDERLESS_LIST_KEYS = ['allowed_values', 'depends_on'] + + @staticmethod + def compare_dicts(dict1, dict2): + """Return False if not equal, True if both are equal.""" + + if dict1 is None and dict2 is None: + return True + if dict1 is None or dict2 is None: + return False + + both_equal = True + for dict1_item, dict2_item in zip(dict1.items(), dict2.items()): + if dict1_item != dict2_item: + msg = (_("%(label1)s: %(item1)s \n is not equal to \n:" + "%(label2)s: %(item2)s") + % {'label1': CompareUtils.MISMATCH_VALUE2_LABEL, + 'item1': dict1_item, + 'label2': CompareUtils.MISMATCH_VALUE1_LABEL, + 'item2': dict2_item}) + log.warning(msg) + both_equal = False + break + return both_equal + + @staticmethod + def compare_hot_yamls(generated_yaml, expected_yaml): + hot_translated_dict = YAML_ORDER_PARSER(generated_yaml) + hot_expected_dict = YAML_ORDER_PARSER(expected_yaml) + return CompareUtils.compare_dicts(hot_translated_dict, + hot_expected_dict) + + @staticmethod + def reorder(dic): + '''Canonicalize list items in the dictionary for ease of comparison. + + For properties whose value is a list in which the order does not + matter, some pre-processing is required to bring those lists into a + canonical format. We use sorting just to make sure such differences + in ordering would not cause to a mismatch. + ''' + + if type(dic) is not dict: + return None + + reordered = {} + for key in dic.keys(): + value = dic[key] + if type(value) is dict: + reordered[key] = CompareUtils.reorder(value) + elif type(value) is list \ + and key in CompareUtils.ORDERLESS_LIST_KEYS: + reordered[key] = sorted(value) + else: + reordered[key] = value + return reordered + + @staticmethod + def diff_dicts(dict1, dict2, reorder=True): + '''Compares two dictionaries and returns their differences. + + Returns a dictionary of mismatches between the two dictionaries. + An empty dictionary is returned if two dictionaries are equivalent. + The reorder parameter indicates whether reordering is required + before comparison or not. + ''' + + if reorder: + dict1 = CompareUtils.reorder(dict1) + dict2 = CompareUtils.reorder(dict2) + + if dict1 is None and dict2 is None: + return {} + if dict1 is None or dict2 is None: + return {CompareUtils.MISMATCH_VALUE1_LABEL: dict1, + CompareUtils.MISMATCH_VALUE2_LABEL: dict2} + + diff = {} + keys1 = set(dict1.keys()) + keys2 = set(dict2.keys()) + for key in keys1.union(keys2): + if key in keys1 and key not in keys2: + diff[key] = {CompareUtils.MISMATCH_VALUE1_LABEL: dict1[key], + CompareUtils.MISMATCH_VALUE2_LABEL: None} + elif key not in keys1 and key in keys2: + diff[key] = {CompareUtils.MISMATCH_VALUE1_LABEL: None, + CompareUtils.MISMATCH_VALUE2_LABEL: dict2[key]} + else: + val1 = dict1[key] + val2 = dict2[key] + if val1 != val2: + if type(val1) is dict and type(val2) is dict: + diff[key] = CompareUtils.diff_dicts(val1, val2, False) + else: + diff[key] = {CompareUtils.MISMATCH_VALUE1_LABEL: val1, + CompareUtils.MISMATCH_VALUE2_LABEL: val2} + return diff + + +class YamlUtils(object): + + @staticmethod + def get_dict(yaml_file): + '''Returns the dictionary representation of the given YAML spec.''' + try: + return yaml.load(open(yaml_file)) + except IOError: + return None + + @staticmethod + def compare_yamls(yaml1_file, yaml2_file): + '''Returns true if two dictionaries are equivalent, false otherwise.''' + dict1 = YamlUtils.get_dict(yaml1_file) + dict2 = YamlUtils.get_dict(yaml2_file) + return CompareUtils.compare_dicts(dict1, dict2) + + @staticmethod + def compare_yaml_dict(yaml_file, dic): + '''Returns true if yaml matches the dictionary, false otherwise.''' + return CompareUtils.compare_dicts(YamlUtils.get_dict(yaml_file), dic) + + +class TranslationUtils(object): + + @staticmethod + def compare_tosca_translation_with_hot(tosca_file, hot_file, params): + '''Verify tosca translation against the given hot specification. + + inputs: + tosca_file: relative local path or URL to the tosca input file + hot_file: relative path to expected hot output + params: dictionary of parameter name value pairs + + Returns as a dictionary the difference between the HOT translation + of the given tosca_file and the given hot_file. + ''' + + from toscaparser.tosca_template import ToscaTemplate + from translator.hot.tosca_translator import TOSCATranslator + + tosca_tpl = os.path.normpath(os.path.join( + os.path.dirname(os.path.abspath(__file__)), tosca_file)) + a_file = os.path.isfile(tosca_tpl) + if not a_file: + tosca_tpl = tosca_file + + expected_hot_tpl = os.path.join( + os.path.dirname(os.path.abspath(__file__)), hot_file) + + tosca = ToscaTemplate(tosca_tpl, params, a_file) + translate = TOSCATranslator(tosca, params) + + output = translate.translate() + output_dict = toscaparser.utils.yamlparser.simple_parse(output) + expected_output_dict = YamlUtils.get_dict(expected_hot_tpl) + return CompareUtils.diff_dicts(output_dict, expected_output_dict) + + +class UrlUtils(object): + + @staticmethod + def validate_url(path): + """Validates whether the given path is a URL or not. + + If the given path includes a scheme (http, https, ftp, ...) and a net + location (a domain name such as www.github.com) it is validated as a + URL. + """ + parsed = urlparse(path) + return bool(parsed.scheme) and bool(parsed.netloc) + + +def str_to_num(value): + """Convert a string representation of a number into a numeric type.""" + if isinstance(value, numbers.Number): + return value + try: + return int(value) + except ValueError: + return float(value) diff --git a/tosca2heat/heat-translator-0.3.0/translator/conf/__init__.py b/tosca2heat/heat-translator-0.3.0/translator/conf/__init__.py new file mode 100644 index 0000000..2c61252 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/conf/__init__.py @@ -0,0 +1,36 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +''' Initialize the global configuration for the translator ''' + +import os + +from translator.conf.config import ConfigProvider + +CONF_FILENAME = 'translator.conf' + + +def init_global_conf(): + '''Initialize the configuration provider. + + Allows the configuration to be shared throughout the translator code. + The file used is translator.conf, and is within the conf/ directory. It + is a standard ini format, and is prcessed using the ConfigParser module. + + ''' + conf_path = os.path.dirname(os.path.abspath(__file__)) + conf_file = os.path.join(conf_path, CONF_FILENAME) + ConfigProvider._load_config(conf_file) + + +init_global_conf() diff --git a/tosca2heat/heat-translator-0.3.0/translator/conf/config.py b/tosca2heat/heat-translator-0.3.0/translator/conf/config.py new file mode 100644 index 0000000..4e8fe87 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/conf/config.py @@ -0,0 +1,67 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +''' Provide a global configuration for the TOSCA translator''' + +from six.moves import configparser + +from toscaparser.utils.gettextutils import _ +import translator.common.exception as exception + + +class ConfigProvider(object): + '''Global config proxy that wraps a ConfigParser object. + + Allows for class based access to config values. Should only be initialized + once using the corresponding translator.conf file in the conf directory. + + ''' + + # List that captures all of the conf file sections. + # Append any new sections to this list. + _sections = ['DEFAULT'] + _translator_config = None + + @classmethod + def _load_config(cls, conf_file): + '''Private method only to be called once from the __init__ module''' + + cls._translator_config = configparser.ConfigParser() + try: + cls._translator_config.read(conf_file) + except configparser.ParsingError: + msg = _('Unable to parse translator.conf file.' + 'Check to see that it exists in the conf directory.') + raise exception.ConfFileParseError(message=msg) + + @classmethod + def get_value(cls, section, key): + try: + value = cls._translator_config.get(section, key) + except configparser.NoOptionError: + raise exception.ConfOptionNotDefined(key=key, section=section) + except configparser.NoSectionError: + raise exception.ConfSectionNotDefined(section=section) + + return value + + @classmethod + def get_all_values(cls): + values = [] + for section in cls._sections: + try: + values.extend(cls._translator_config.items(section=section)) + except configparser.NoOptionError: + raise exception.ConfSectionNotDefined(section=section) + + return values diff --git a/tosca2heat/heat-translator-0.3.0/translator/conf/translator.conf b/tosca2heat/heat-translator-0.3.0/translator/conf/translator.conf new file mode 100644 index 0000000..6ebf292 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/conf/translator.conf @@ -0,0 +1,4 @@ +[DEFAULT] + +# Relative path location for custom types +custom_types_location=translator/custom/hot \ No newline at end of file diff --git a/tosca2heat/heat-translator-0.3.0/translator/custom/__init__.py b/tosca2heat/heat-translator-0.3.0/translator/custom/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tosca2heat/heat-translator-0.3.0/translator/custom/hot/__init__.py b/tosca2heat/heat-translator-0.3.0/translator/custom/hot/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_collectd.py b/tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_collectd.py new file mode 100755 index 0000000..ec517d0 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_collectd.py @@ -0,0 +1,30 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from translator.hot.syntax.hot_resource import HotResource + +# Name used to dynamically load appropriate map class. +TARGET_CLASS_NAME = 'ToscaCollectd' + + +class ToscaCollectd(HotResource): + '''Translate TOSCA node type tosca.nodes.SoftwareComponent.Collectd.''' + + toscatype = 'tosca.nodes.SoftwareComponent.Collectd' + + def __init__(self, nodetemplate): + super(ToscaCollectd, self).__init__(nodetemplate) + pass + + def handle_properties(self): + pass diff --git a/tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_elasticsearch.py b/tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_elasticsearch.py new file mode 100755 index 0000000..34d7670 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_elasticsearch.py @@ -0,0 +1,30 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from translator.hot.syntax.hot_resource import HotResource + +# Name used to dynamically load appropriate map class. +TARGET_CLASS_NAME = 'ToscaElasticsearch' + + +class ToscaElasticsearch(HotResource): + '''Translate TOSCA type tosca.nodes.SoftwareComponent.Elasticsearch.''' + + toscatype = 'tosca.nodes.SoftwareComponent.Elasticsearch' + + def __init__(self, nodetemplate): + super(ToscaElasticsearch, self).__init__(nodetemplate) + pass + + def handle_properties(self): + pass diff --git a/tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_kibana.py b/tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_kibana.py new file mode 100755 index 0000000..71f3402 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_kibana.py @@ -0,0 +1,30 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from translator.hot.syntax.hot_resource import HotResource + +# Name used to dynamically load appropriate map class. +TARGET_CLASS_NAME = 'ToscaKibana' + + +class ToscaKibana(HotResource): + '''Translate TOSCA node type tosca.nodes.SoftwareComponent.Kibana.''' + + toscatype = 'tosca.nodes.SoftwareComponent.Kibana' + + def __init__(self, nodetemplate): + super(ToscaKibana, self).__init__(nodetemplate) + pass + + def handle_properties(self): + pass diff --git a/tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_logstash.py b/tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_logstash.py new file mode 100755 index 0000000..39859e0 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_logstash.py @@ -0,0 +1,30 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from translator.hot.syntax.hot_resource import HotResource + +# Name used to dynamically load appropriate map class. +TARGET_CLASS_NAME = 'ToscaLogstash' + + +class ToscaLogstash(HotResource): + '''Translate TOSCA node type tosca.nodes.SoftwareComponent.Logstash.''' + + toscatype = 'tosca.nodes.SoftwareComponent.Logstash' + + def __init__(self, nodetemplate): + super(ToscaLogstash, self).__init__(nodetemplate) + pass + + def handle_properties(self): + pass diff --git a/tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_nodejs.py b/tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_nodejs.py new file mode 100755 index 0000000..2102af5 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_nodejs.py @@ -0,0 +1,30 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from translator.hot.syntax.hot_resource import HotResource + +# Name used to dynamically load appropriate map class. +TARGET_CLASS_NAME = 'ToscaNodejs' + + +class ToscaNodejs(HotResource): + '''Translate TOSCA node type tosca.nodes.SoftwareComponent.Nodejs.''' + + toscatype = 'tosca.nodes.SoftwareComponent.Nodejs' + + def __init__(self, nodetemplate): + super(ToscaNodejs, self).__init__(nodetemplate) + pass + + def handle_properties(self): + pass diff --git a/tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_paypalpizzastore.py b/tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_paypalpizzastore.py new file mode 100755 index 0000000..ae3865b --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_paypalpizzastore.py @@ -0,0 +1,30 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from translator.hot.syntax.hot_resource import HotResource + +# Name used to dynamically load appropriate map class. +TARGET_CLASS_NAME = 'ToscaPaypalPizzaStore' + + +class ToscaPaypalPizzaStore(HotResource): + '''Translate TOSCA type tosca.nodes.WebApplication.PayPalPizzaStore.''' + + toscatype = 'tosca.nodes.WebApplication.PayPalPizzaStore' + + def __init__(self, nodetemplate): + super(ToscaPaypalPizzaStore, self).__init__(nodetemplate) + pass + + def handle_properties(self): + pass diff --git a/tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_rsyslog.py b/tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_rsyslog.py new file mode 100755 index 0000000..9604d3c --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_rsyslog.py @@ -0,0 +1,30 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from translator.hot.syntax.hot_resource import HotResource + +# Name used to dynamically load appropriate map class. +TARGET_CLASS_NAME = 'ToscaRsyslog' + + +class ToscaRsyslog(HotResource): + '''Translate TOSCA node type tosca.nodes.SoftwareComponent.Rsyslog.''' + + toscatype = 'tosca.nodes.SoftwareComponent.Rsyslog' + + def __init__(self, nodetemplate): + super(ToscaRsyslog, self).__init__(nodetemplate) + pass + + def handle_properties(self): + pass diff --git a/tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_wordpress.py b/tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_wordpress.py new file mode 100755 index 0000000..c20fe6a --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/custom/hot/tosca_wordpress.py @@ -0,0 +1,30 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from translator.hot.syntax.hot_resource import HotResource + +# Name used to dynamically load appropriate map class. +TARGET_CLASS_NAME = 'ToscaWordpress' + + +class ToscaWordpress(HotResource): + '''Translate TOSCA node type tosca.nodes.WebApplication.WordPress.''' + + toscatype = 'tosca.nodes.WebApplication.WordPress' + + def __init__(self, nodetemplate): + super(ToscaWordpress, self).__init__(nodetemplate) + pass + + def handle_properties(self): + pass diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/__init__.py b/tosca2heat/heat-translator-0.3.0/translator/hot/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/syntax/__init__.py b/tosca2heat/heat-translator-0.3.0/translator/hot/syntax/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/syntax/hot_output.py b/tosca2heat/heat-translator-0.3.0/translator/hot/syntax/hot_output.py new file mode 100644 index 0000000..ad77fb3 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/syntax/hot_output.py @@ -0,0 +1,25 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +class HotOutput(object): + '''Attributes for HOT output section.''' + + def __init__(self, name, value, description=None): + self.name = name + self.value = value + self.description = description + + def get_dict_output(self): + return {self.name: {'value': self.value, + 'description': self.description}} diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/syntax/hot_parameter.py b/tosca2heat/heat-translator-0.3.0/translator/hot/syntax/hot_parameter.py new file mode 100644 index 0000000..02c27da --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/syntax/hot_parameter.py @@ -0,0 +1,47 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from collections import OrderedDict + +KEYS = (TYPE, DESCRIPTION, DEFAULT, CONSTRAINTS, HIDDEN, LABEL) = \ + ('type', 'description', 'default', 'constraints', 'hidden', 'label') + + +class HotParameter(object): + '''Attributes for HOT parameter section.''' + + def __init__(self, name, type, label=None, description=None, default=None, + hidden=None, constraints=None): + self.name = name + self.type = type + self.label = label + self.description = description + self.default = default + self.hidden = hidden + self.constraints = constraints + + def get_dict_output(self): + param_sections = OrderedDict() + param_sections[TYPE] = self.type + if self.label: + param_sections[LABEL] = self.label + if self.description: + param_sections[DESCRIPTION] = self.description + if self.default: + param_sections[DEFAULT] = self.default + if self.hidden: + param_sections[HIDDEN] = self.hidden + if self.constraints: + param_sections[CONSTRAINTS] = self.constraints + + return {self.name: param_sections} diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/syntax/hot_resource.py b/tosca2heat/heat-translator-0.3.0/translator/hot/syntax/hot_resource.py new file mode 100644 index 0000000..3ca9b03 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/syntax/hot_resource.py @@ -0,0 +1,308 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from collections import OrderedDict +import six + +from toscaparser.functions import GetInput +from toscaparser.nodetemplate import NodeTemplate +from toscaparser.utils.gettextutils import _ + + +SECTIONS = (TYPE, PROPERTIES, MEDADATA, DEPENDS_ON, UPDATE_POLICY, + DELETION_POLICY) = \ + ('type', 'properties', 'metadata', + 'depends_on', 'update_policy', 'deletion_policy') + + +class HotResource(object): + '''Base class for TOSCA node type translation to Heat resource type.''' + + def __init__(self, nodetemplate, name=None, type=None, properties=None, + metadata=None, depends_on=None, + update_policy=None, deletion_policy=None): + self.nodetemplate = nodetemplate + if name: + self.name = name + else: + self.name = nodetemplate.name + self.type = type + self.properties = properties or {} + # special case for HOT softwareconfig + if type == 'OS::Heat::SoftwareConfig': + self.properties['group'] = 'script' + self.metadata = metadata + + # The difference between depends_on and depends_on_nodes is + # that depends_on defines dependency in the context of the + # HOT template and it is used during the template output. + # Depends_on_nodes defines the direct dependency between the + # tosca nodes and is not used during the output of the + # HOT template but for internal processing only. When a tosca + # node depends on another node it will be always added to + # depends_on_nodes but not always to depends_on. For example + # if the source of dependency is a server, the dependency will + # be added as properties.get_resource and not depends_on + if depends_on: + self.depends_on = depends_on + self.depends_on_nodes = depends_on + else: + self.depends_on = [] + self.depends_on_nodes = [] + self.update_policy = update_policy + self.deletion_policy = deletion_policy + self.group_dependencies = {} + # if hide_resource is set to true, then this resource will not be + # generated in the output yaml. + self.hide_resource = False + + def handle_properties(self): + # the property can hold a value or the intrinsic function get_input + # for value, copy it + # for get_input, convert to get_param + for prop in self.nodetemplate.get_properties_objects(): + pass + + def handle_life_cycle(self): + hot_resources = [] + deploy_lookup = {} + # TODO(anyone): sequence for life cycle needs to cover different + # scenarios and cannot be fixed or hard coded here + interfaces_deploy_sequence = ['create', 'configure', 'start'] + + # create HotResource for each interface used for deployment: + # create, start, configure + # ignore the other interfaces + # observe the order: create, start, configure + # use the current HotResource for the first interface in this order + + # hold the original name since it will be changed during + # the transformation + node_name = self.name + reserve_current = 'NONE' + interfaces_actual = [] + for interface in self.nodetemplate.interfaces: + interfaces_actual.append(interface.name) + for operation in interfaces_deploy_sequence: + if operation in interfaces_actual: + reserve_current = operation + break + + # create the set of SoftwareDeployment and SoftwareConfig for + # the interface operations + hosting_server = None + if self.nodetemplate.requirements is not None: + hosting_server = self._get_hosting_server() + for interface in self.nodetemplate.interfaces: + if interface.name in interfaces_deploy_sequence: + config_name = node_name + '_' + interface.name + '_config' + deploy_name = node_name + '_' + interface.name + '_deploy' + hot_resources.append( + HotResource(self.nodetemplate, + config_name, + 'OS::Heat::SoftwareConfig', + {'config': + {'get_file': interface.implementation}})) + + # hosting_server is None if requirements is None + hosting_on_server = (hosting_server.name if + hosting_server else None) + if interface.name == reserve_current: + deploy_resource = self + self.name = deploy_name + self.type = 'OS::Heat::SoftwareDeployment' + self.properties = {'config': {'get_resource': config_name}, + 'server': {'get_resource': + hosting_on_server}} + deploy_lookup[interface.name] = self + else: + sd_config = {'config': {'get_resource': config_name}, + 'server': {'get_resource': + hosting_on_server}} + deploy_resource = \ + HotResource(self.nodetemplate, + deploy_name, + 'OS::Heat::SoftwareDeployment', + sd_config) + hot_resources.append(deploy_resource) + deploy_lookup[interface.name] = deploy_resource + lifecycle_inputs = self._get_lifecycle_inputs(interface) + if lifecycle_inputs: + deploy_resource.properties['input_values'] = \ + lifecycle_inputs + + # Add dependencies for the set of HOT resources in the sequence defined + # in interfaces_deploy_sequence + # TODO(anyone): find some better way to encode this implicit sequence + group = {} + for op, hot in deploy_lookup.items(): + # position to determine potential preceding nodes + op_index = interfaces_deploy_sequence.index(op) + for preceding_op in \ + reversed(interfaces_deploy_sequence[:op_index]): + preceding_hot = deploy_lookup.get(preceding_op) + if preceding_hot: + hot.depends_on.append(preceding_hot) + hot.depends_on_nodes.append(preceding_hot) + group[preceding_hot] = hot + break + + # save this dependency chain in the set of HOT resources + self.group_dependencies.update(group) + for hot in hot_resources: + hot.group_dependencies.update(group) + + return hot_resources + + def handle_connectsto(self, tosca_source, tosca_target, hot_source, + hot_target, config_location, operation): + # The ConnectsTo relationship causes a configuration operation in + # the target. + # This hot resource is the software config portion in the HOT template + # This method adds the matching software deployment with the proper + # target server and dependency + if config_location == 'target': + hosting_server = hot_target._get_hosting_server() + hot_depends = hot_target + elif config_location == 'source': + hosting_server = self._get_hosting_server() + hot_depends = hot_source + deploy_name = tosca_source.name + '_' + tosca_target.name + \ + '_connect_deploy' + sd_config = {'config': {'get_resource': self.name}, + 'server': {'get_resource': hosting_server.name}} + deploy_resource = \ + HotResource(self.nodetemplate, + deploy_name, + 'OS::Heat::SoftwareDeployment', + sd_config, + depends_on=[hot_depends]) + connect_inputs = self._get_connect_inputs(config_location, operation) + if connect_inputs: + deploy_resource.properties['input_values'] = connect_inputs + + return deploy_resource + + def handle_expansion(self): + pass + + def handle_hosting(self): + # handle hosting server for the OS:HEAT::SoftwareDeployment + # from the TOSCA nodetemplate, traverse the relationship chain + # down to the server + if self.type == 'OS::Heat::SoftwareDeployment': + # skip if already have hosting + # If type is NodeTemplate, look up corresponding HotResrouce + host_server = self.properties.get('server') + if host_server is None or not host_server['get_resource']: + raise Exception(_("Internal Error: expecting host " + "in software deployment")) + elif isinstance(host_server['get_resource'], NodeTemplate): + self.properties['server']['get_resource'] = \ + host_server['get_resource'].name + + def top_of_chain(self): + dependent = self.group_dependencies.get(self) + if dependent is None: + return self + else: + return dependent.top_of_chain() + + def get_dict_output(self): + resource_sections = OrderedDict() + resource_sections[TYPE] = self.type + if self.properties: + resource_sections[PROPERTIES] = self.properties + if self.metadata: + resource_sections[MEDADATA] = self.metadata + if self.depends_on: + resource_sections[DEPENDS_ON] = [] + for depend in self.depends_on: + resource_sections[DEPENDS_ON].append(depend.name) + if self.update_policy: + resource_sections[UPDATE_POLICY] = self.update_policy + if self.deletion_policy: + resource_sections[DELETION_POLICY] = self.deletion_policy + + return {self.name: resource_sections} + + def _get_lifecycle_inputs(self, interface): + # check if this lifecycle operation has input values specified + # extract and convert to HOT format + if isinstance(interface.value, six.string_types): + # the interface has a static string + return {} + else: + # the interface is a dict {'implemenation': xxx, 'input': yyy} + inputs = interface.value.get('inputs') + deploy_inputs = {} + if inputs: + for name, value in six.iteritems(inputs): + deploy_inputs[name] = value + return deploy_inputs + + def _get_connect_inputs(self, config_location, operation): + if config_location == 'target': + inputs = operation.get('pre_configure_target').get('inputs') + elif config_location == 'source': + inputs = operation.get('pre_configure_source').get('inputs') + deploy_inputs = {} + if inputs: + for name, value in six.iteritems(inputs): + deploy_inputs[name] = value + return deploy_inputs + + def _get_hosting_server(self, node_template=None): + # find the server that hosts this software by checking the + # requirements and following the hosting chain + this_node_template = self.nodetemplate \ + if node_template is None else node_template + for requirement in this_node_template.requirements: + for requirement_name, assignment in six.iteritems(requirement): + for check_node in this_node_template.related_nodes: + # check if the capability is Container + if isinstance(assignment, dict): + node_name = assignment.get('node') + else: + node_name = assignment + if node_name and node_name == check_node.name: + if self._is_container_type(requirement_name, + check_node): + return check_node + elif check_node.related_nodes: + return self._get_hosting_server(check_node) + return None + + def _is_container_type(self, requirement_name, node): + # capability is a list of dict + # For now just check if it's type tosca.nodes.Compute + # TODO(anyone): match up requirement and capability + if node.type == 'tosca.nodes.Compute': + return True + else: + return False + + def get_hot_attribute(self, attribute, args): + # this is a place holder and should be implemented by the subclass + # if translation is needed for the particular attribute + raise Exception(_("No translation in TOSCA type {0} for attribute " + "{1}").format(self.nodetemplate.type, attribute)) + + def _get_tosca_props(self, properties): + tosca_props = {} + for prop in self.nodetemplate.get_properties_objects(): + if isinstance(prop.value, GetInput): + tosca_props[prop.name] = {'get_param': prop.value.input_name} + else: + tosca_props[prop.name] = prop.value + return tosca_props diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/syntax/hot_template.py b/tosca2heat/heat-translator-0.3.0/translator/hot/syntax/hot_template.py new file mode 100644 index 0000000..5cc97c6 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/syntax/hot_template.py @@ -0,0 +1,78 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from collections import OrderedDict +import textwrap +import yaml + + +class HotTemplate(object): + '''Container for full Heat Orchestration template.''' + + SECTIONS = (VERSION, DESCRIPTION, PARAMETER_GROUPS, PARAMETERS, + RESOURCES, OUTPUTS, MAPPINGS) = \ + ('heat_template_version', 'description', 'parameter_groups', + 'parameters', 'resources', 'outputs', '__undefined__') + + VERSIONS = (LATEST,) = ('2013-05-23',) + + def __init__(self): + self.resources = [] + self.outputs = [] + self.parameters = [] + self.description = "" + + def represent_ordereddict(self, dumper, data): + nodes = [] + for key, value in data.items(): + node_key = dumper.represent_data(key) + node_value = dumper.represent_data(value) + nodes.append((node_key, node_value)) + return yaml.nodes.MappingNode(u'tag:yaml.org,2002:map', nodes) + + def output_to_yaml(self): + dict_output = OrderedDict() + # Version + version_string = self.VERSION + ": " + self.LATEST + "\n\n" + + # Description + desc_str = "" + if self.description: + # Wrap the text to a new line if the line exceeds 80 characters. + wrapped_txt = "\n ".join(textwrap.wrap(self.description, 80)) + desc_str = self.DESCRIPTION + ": >\n " + wrapped_txt + "\n\n" + + # Parameters + all_params = OrderedDict() + for parameter in self.parameters: + all_params.update(parameter.get_dict_output()) + dict_output.update({self.PARAMETERS: all_params}) + + # Resources + all_resources = OrderedDict() + for resource in self.resources: + if not resource.hide_resource: + all_resources.update(resource.get_dict_output()) + dict_output.update({self.RESOURCES: all_resources}) + + # Outputs + all_outputs = OrderedDict() + for output in self.outputs: + all_outputs.update(output.get_dict_output()) + dict_output.update({self.OUTPUTS: all_outputs}) + + yaml.add_representer(OrderedDict, self.represent_ordereddict) + yaml_string = yaml.dump(dict_output, default_flow_style=False) + # get rid of the '' from yaml.dump around numbers + yaml_string = yaml_string.replace('\'', '') + return version_string + desc_str + yaml_string diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/tests/__init__.py b/tosca2heat/heat-translator-0.3.0/translator/hot/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/tests/test_hot_parameter.py b/tosca2heat/heat-translator-0.3.0/translator/hot/tests/test_hot_parameter.py new file mode 100644 index 0000000..8d3f535 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/tests/test_hot_parameter.py @@ -0,0 +1,44 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from collections import OrderedDict + +from toscaparser.tests.base import TestCase +from translator.hot.syntax.hot_parameter import CONSTRAINTS +from translator.hot.syntax.hot_parameter import DEFAULT +from translator.hot.syntax.hot_parameter import DESCRIPTION +from translator.hot.syntax.hot_parameter import HIDDEN +from translator.hot.syntax.hot_parameter import HotParameter +from translator.hot.syntax.hot_parameter import LABEL +from translator.hot.syntax.hot_parameter import TYPE + +TEST_CONSTRAINTS = {'equal': 'allowed_values', 'greater_than': 'range'} + + +class HotParameterTest(TestCase): + + # This test ensures the variables set during the creation of a HotParameter + # object are returned in an OrderedDict when calling get_dict_output(). + def test_dict_output(self): + name = 'HotParameterTest' + hot_parameter = HotParameter(name, 'Type', + label='Label', + description='Description', + default='Default', + hidden=True, + constraints=TEST_CONSTRAINTS) + expected_dict = OrderedDict([(TYPE, 'Type'), (LABEL, 'Label'), + (DESCRIPTION, 'Description'), + (DEFAULT, 'Default'), (HIDDEN, True), + (CONSTRAINTS, TEST_CONSTRAINTS)]) + + self.assertEqual(hot_parameter.get_dict_output()[name], expected_dict) diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/tests/test_translate_inputs.py b/tosca2heat/heat-translator-0.3.0/translator/hot/tests/test_translate_inputs.py new file mode 100644 index 0000000..2b302ab --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/tests/test_translate_inputs.py @@ -0,0 +1,351 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +from collections import OrderedDict +from toscaparser.parameters import Input +from toscaparser.tests.base import TestCase +from toscaparser.utils.gettextutils import _ +import toscaparser.utils.yamlparser +from translator.common.utils import CompareUtils +from translator.hot.translate_inputs import TranslateInputs + + +class ToscaTemplateInputValidationTest(TestCase): + + def _translate_input_test(self, tpl_snippet, input_params, + expectedmessage=None, + expected_hot_params=None): + inputs_dict = (toscaparser.utils.yamlparser. + simple_parse(tpl_snippet)['inputs']) + inputs = [] + for name, attrs in inputs_dict.items(): + input = Input(name, attrs) + inputs.append(input) + + translateinput = TranslateInputs(inputs, input_params) + try: + resulted_hot_params = translateinput.translate() + if expected_hot_params: + self._compare_hot_params(resulted_hot_params, + expected_hot_params) + except Exception as err: + self.assertEqual(expectedmessage, err.__str__()) + + def _compare_hot_params(self, resulted_hot_params, + expected_hot_params): + for expected_param in expected_hot_params: + for resulted_param_obj in resulted_hot_params: + resulted_param = resulted_param_obj.get_dict_output() + result = CompareUtils.compare_dicts(expected_param, + resulted_param) + if not result: + raise Exception(_("hot input and resulted input " + "params are not equal.")) + + def test_invalid_input_type(self): + tpl_snippet = ''' + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + ''' + + input_params = {'cpus': '0.3'} + expectedmessage = _('"0.3" is not an integer.') + self._translate_input_test(tpl_snippet, input_params, + expectedmessage) + + def test_invalid_input_constraints_for_equal(self): + tpl_snippet = ''' + inputs: + num_cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - equal: 1 + ''' + + input_params = {'num_cpus': '0'} + expectedmessage = _('The value "0" of property "num_cpus" is not ' + 'equal to "1".') + self._translate_input_test(tpl_snippet, input_params, expectedmessage) + + def test_invalid_input_constraints_for_greater_or_equal(self): + tpl_snippet = ''' + inputs: + num_cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - greater_or_equal: 1 + ''' + + input_params = {'num_cpus': '0'} + expectedmessage = _('The value "0" of property "num_cpus" must be ' + 'greater than or equal to "1".') + self._translate_input_test(tpl_snippet, input_params, expectedmessage) + + def test_invalid_input_constraints_for_greater_than(self): + tpl_snippet = ''' + inputs: + num_cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - greater_than: 1 + ''' + + input_params = {'num_cpus': '0'} + expectedmessage = _('The value "0" of property "num_cpus" must be ' + 'greater than "1".') + self._translate_input_test(tpl_snippet, input_params, expectedmessage) + + def test_invalid_input_constraints_for_less_than(self): + tpl_snippet = ''' + inputs: + num_cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - less_than: 8 + ''' + + input_params = {'num_cpus': '8'} + expectedmessage = _('The value "8" of property "num_cpus" must be ' + 'less than "8".') + self._translate_input_test(tpl_snippet, input_params, expectedmessage) + + def test_invalid_input_constraints_for_less_or_equal(self): + tpl_snippet = ''' + inputs: + num_cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - less_or_equal: 8 + ''' + + input_params = {'num_cpus': '9'} + expectedmessage = _('The value "9" of property "num_cpus" must be ' + 'less than or equal to "8".') + self._translate_input_test(tpl_snippet, input_params, expectedmessage) + + def test_invalid_input_constraints_for_valid_values(self): + tpl_snippet = ''' + inputs: + num_cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + ''' + + input_params = {'num_cpus': '3'} + expectedmessage = _('The value "3" of property "num_cpus" is not ' + 'valid. Expected a value from "[1, 2, 4, 8]".') + self._translate_input_test(tpl_snippet, input_params, expectedmessage) + + def test_invalid_input_constraints_for_in_range(self): + tpl_snippet = ''' + inputs: + num_cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - in_range: [ 1, 8 ] + ''' + + input_params = {'num_cpus': '10'} + expectedmessage = _('The value "10" of property "num_cpus" is out of ' + 'range "(min:1, max:8)".') + self._translate_input_test(tpl_snippet, input_params, expectedmessage) + + def test_invalid_input_constraints_for_min_length(self): + tpl_snippet = ''' + inputs: + user_name: + type: string + description: Name of the user. + constraints: + - min_length: 8 + ''' + + input_params = {'user_name': 'abcd'} + expectedmessage = _('Length of value "abcd" of property "user_name" ' + 'must be at least "8".') + self._translate_input_test(tpl_snippet, input_params, expectedmessage) + + def test_invalid_input_constraints_for_max_length(self): + tpl_snippet = ''' + inputs: + user_name: + type: string + description: Name of the user. + constraints: + - max_length: 6 + ''' + + input_params = {'user_name': 'abcdefg'} + expectedmessage = _('Length of value "abcdefg" of property ' + '"user_name" must be no greater than "6".') + self._translate_input_test(tpl_snippet, input_params, expectedmessage) + + def test_invalid_input_constraints_for_pattern(self): + tpl_snippet = ''' + inputs: + user_name: + type: string + description: Name of the user. + constraints: + - pattern: '^\w+$' + ''' + + input_params = {'user_name': '1-abc'} + expectedmessage = _('The value "1-abc" of property "user_name" does ' + 'not match pattern "^\\w+$".') + self._translate_input_test(tpl_snippet, input_params, expectedmessage) + + def test_valid_input_storage_size(self): + tpl_snippet = ''' + inputs: + storage_size: + type: scalar-unit.size + description: size of the storage volume. + ''' + + expectedmessage = _('both equal.') + input_params = {'storage_size': '2 GB'} + expected_hot_params = [{'storage_size': + OrderedDict([('type', 'number'), + ('description', + 'size of the storage volume.'), + ('default', 2)])}] + self._translate_input_test(tpl_snippet, input_params, + expectedmessage, expected_hot_params) + + """ TOSCA 2000 MB => 2 GB HOT conversion""" + input_params = {'storage_size': '2000 MB'} + expected_hot_params = [{'storage_size': + OrderedDict([('type', 'number'), + ('description', + 'size of the storage volume.'), + ('default', 2)])}] + self._translate_input_test(tpl_snippet, input_params, + expectedmessage, expected_hot_params) + + """ TOSCA 2048 MB => 2 GB HOT conversion""" + input_params = {'storage_size': '2048 MB'} + expected_hot_params = [{'storage_size': + OrderedDict([('type', 'number'), + ('description', + 'size of the storage volume.'), + ('default', 2)])}] + self._translate_input_test(tpl_snippet, input_params, + expectedmessage, expected_hot_params) + + """ TOSCA 2 MB => 1 GB HOT conversion""" + input_params = {'storage_size': '2 MB'} + expected_hot_params = [{'storage_size': + OrderedDict([('type', 'number'), + ('description', + 'size of the storage volume.'), + ('default', 1)])}] + self._translate_input_test(tpl_snippet, input_params, + expectedmessage, expected_hot_params) + + """ TOSCA 1024 MB => 1 GB HOT conversion""" + input_params = {'storage_size': '1024 MB'} + expected_hot_params = [{'storage_size': + OrderedDict([('type', 'number'), + ('description', + 'size of the storage volume.'), + ('default', 1)])}] + self._translate_input_test(tpl_snippet, input_params, + expectedmessage, expected_hot_params) + + """ TOSCA 1024 MiB => 1 GB HOT conversion""" + input_params = {'storage_size': '1024 MiB'} + expected_hot_params = [{'storage_size': + OrderedDict([('type', 'number'), + ('description', + 'size of the storage volume.'), + ('default', 1)])}] + self._translate_input_test(tpl_snippet, input_params, + expectedmessage, expected_hot_params) + + def test_invalid_input_storage_size(self): + tpl_snippet = ''' + inputs: + storage_size: + type: scalar-unit.size + description: size of the storage volume. + ''' + + input_params = {'storage_size': '0 MB'} + expectedmsg = _("Unit value should be > 0.") + self._translate_input_test(tpl_snippet, input_params, expectedmsg) + + input_params = {'storage_size': '-2 MB'} + expectedmsg = _('"-2 MB" is not a valid scalar-unit.') + self._translate_input_test(tpl_snippet, input_params, expectedmsg) + + def test_invalid_input_type_version(self): + tpl_snippet = ''' + inputs: + version: + type: version + ''' + + input_params = {'version': '0.a'} + expectedmessage = _('Value of TOSCA version property ' + '"0.a" is invalid.') + self._translate_input_test(tpl_snippet, input_params, + expectedmessage) + + input_params = {'version': '0.0.0.abc'} + expectedmessage = _('Value of TOSCA version property ' + '"0.0.0.abc" is invalid.') + self._translate_input_test(tpl_snippet, input_params, + expectedmessage) + + def test_valid_input_type_version(self): + tpl_snippet = ''' + inputs: + version: + type: version + default: 12 + ''' + + expectedmessage = _('both equal.') + input_params = {'version': '18'} + expected_hot_params = [{'version': + OrderedDict([('type', 'string'), + ('default', '18.0')])}] + self._translate_input_test(tpl_snippet, input_params, expectedmessage, + expected_hot_params) + + input_params = {'version': '18.0'} + expected_hot_params = [{'version': + OrderedDict([('type', 'string'), + ('default', '18.0')])}] + self._translate_input_test(tpl_snippet, input_params, expectedmessage, + expected_hot_params) + + input_params = {'version': '18.0.1'} + expected_hot_params = [{'version': + OrderedDict([('type', 'string'), + ('default', '18.0.1')])}] + self._translate_input_test(tpl_snippet, input_params, expectedmessage, + expected_hot_params) diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/tests/test_translate_outputs.py b/tosca2heat/heat-translator-0.3.0/translator/hot/tests/test_translate_outputs.py new file mode 100644 index 0000000..955150e --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/tests/test_translate_outputs.py @@ -0,0 +1,50 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import os +from toscaparser.tests.base import TestCase +from toscaparser.tosca_template import ToscaTemplate +import toscaparser.utils.yamlparser +from translator.hot.tosca_translator import TOSCATranslator + + +class ToscaTemplateOutputTest(TestCase): + + def test_translate_output(self): + tosca_tpl = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "../../tests/data/" + "tosca_nodejs_mongodb_two_instances.yaml") + tosca = ToscaTemplate(tosca_tpl) + translate = TOSCATranslator(tosca, []) + hot_translation = translate.translate() + + expected_output = {'nodejs_url': + {'description': 'URL for the nodejs ' + 'server, http://:3000', + 'value': + {'get_attr': + ['app_server', 'networks', 'private', 0]}}, + 'mongodb_url': + {'description': 'URL for the mongodb server.', + 'value': + {'get_attr': + ['mongo_server', 'networks', 'private', 0]}}} + + hot_translation_dict = \ + toscaparser.utils.yamlparser.simple_parse(hot_translation) + + outputs = hot_translation_dict.get('outputs') + for resource_name in outputs: + translated_value = outputs.get(resource_name) + expected_value = expected_output.get(resource_name) + self.assertEqual(translated_value, expected_value) diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/__init__.py b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/__init__.py new file mode 100755 index 0000000..e69de29 diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tests/__init__.py b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tests/test_tosca_blockstorage.py b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tests/test_tosca_blockstorage.py new file mode 100644 index 0000000..d4fffe1 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tests/test_tosca_blockstorage.py @@ -0,0 +1,84 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from toscaparser.common.exception import InvalidPropertyValueError +from toscaparser.nodetemplate import NodeTemplate +from toscaparser.tests.base import TestCase +from toscaparser.utils.gettextutils import _ +import toscaparser.utils.yamlparser +from translator.hot.tosca.tosca_block_storage import ToscaBlockStorage + + +class ToscaBlockStoreTest(TestCase): + + def _tosca_blockstore_test(self, tpl_snippet, expectedprops): + nodetemplates = (toscaparser.utils.yamlparser. + simple_parse(tpl_snippet)['node_templates']) + name = list(nodetemplates.keys())[0] + try: + nodetemplate = NodeTemplate(name, nodetemplates) + tosca_block_store = ToscaBlockStorage(nodetemplate) + tosca_block_store.handle_properties() + if not self._compare_properties(tosca_block_store.properties, + expectedprops): + raise Exception(_("Hot Properties are not" + " same as expected properties")) + except Exception: + # for time being rethrowing. Will be handled future based + # on new development + raise + + def _compare_properties(self, hotprops, expectedprops): + return all(item in hotprops.items() for item in expectedprops.items()) + + def test_node_blockstorage_with_properties(self): + tpl_snippet = ''' + node_templates: + my_storage: + type: tosca.nodes.BlockStorage + properties: + size: 1024 MiB + snapshot_id: abc + ''' + expectedprops = {'snapshot_id': 'abc', + 'size': 1} + self._tosca_blockstore_test( + tpl_snippet, + expectedprops) + + tpl_snippet = ''' + node_templates: + my_storage: + type: tosca.nodes.BlockStorage + properties: + size: 124 MB + snapshot_id: abc + ''' + expectedprops = {'snapshot_id': 'abc', + 'size': 1} + self._tosca_blockstore_test( + tpl_snippet, + expectedprops) + + def test_node_blockstorage_with_invalid_size_property(self): + tpl_snippet = ''' + node_templates: + my_storage: + type: tosca.nodes.BlockStorage + properties: + size: 0 MB + snapshot_id: abc + ''' + expectedprops = {} + self.assertRaises(InvalidPropertyValueError, + lambda: self._tosca_blockstore_test(tpl_snippet, + expectedprops)) diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tests/test_tosca_compute.py b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tests/test_tosca_compute.py new file mode 100644 index 0000000..f956344 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tests/test_tosca_compute.py @@ -0,0 +1,253 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import json +import mock +from mock import patch + +from toscaparser.nodetemplate import NodeTemplate +from toscaparser.tests.base import TestCase +from toscaparser.utils.gettextutils import _ +import toscaparser.utils.yamlparser +from translator.hot.tosca.tosca_compute import ToscaCompute + + +class ToscaComputeTest(TestCase): + + def _tosca_compute_test(self, tpl_snippet, expectedprops): + nodetemplates = (toscaparser.utils.yamlparser. + simple_parse(tpl_snippet)['node_templates']) + name = list(nodetemplates.keys())[0] + try: + nodetemplate = NodeTemplate(name, nodetemplates) + nodetemplate.validate() + toscacompute = ToscaCompute(nodetemplate) + toscacompute.handle_properties() + if not self._compare_properties(toscacompute.properties, + expectedprops): + raise Exception(_("Hot Properties are not" + " same as expected properties")) + except Exception: + # for time being rethrowing. Will be handled future based + # on new development in Glance and Graffiti + raise + + def _compare_properties(self, hotprops, expectedprops): + return all(item in hotprops.items() for item in expectedprops.items()) + + def test_node_compute_with_host_and_os_capabilities(self): + tpl_snippet = ''' + node_templates: + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: 4 + mem_size: 4 GB + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18.0 + ''' + expectedprops = {'flavor': 'm1.large', + 'image': 'fedora-amd64-heat-config'} + self._tosca_compute_test( + tpl_snippet, + expectedprops) + + def test_node_compute_without_os_capabilities(self): + tpl_snippet = ''' + node_templates: + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: 4 + mem_size: 4 GB + #left intentionally + ''' + expectedprops = {'flavor': 'm1.large', + 'image': None} + self._tosca_compute_test( + tpl_snippet, + expectedprops) + + def test_node_compute_without_host_capabilities(self): + tpl_snippet = ''' + node_templates: + server: + type: tosca.nodes.Compute + capabilities: + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18.0 + ''' + expectedprops = {'flavor': None, + 'image': 'fedora-amd64-heat-config'} + self._tosca_compute_test( + tpl_snippet, + expectedprops) + + def test_node_compute_without_properties_and_os_capabilities(self): + tpl_snippet = ''' + node_templates: + server: + type: tosca.nodes.Compute + properties: + #left intentionally + capabilities: + #left intentionally + ''' + expectedprops = {'flavor': None, + 'image': None} + self._tosca_compute_test( + tpl_snippet, + expectedprops) + + def test_node_compute_with_only_type(self): + tpl_snippet = ''' + node_templates: + server: + type: tosca.nodes.Compute + ''' + expectedprops = {'flavor': None, + 'image': None} + self._tosca_compute_test( + tpl_snippet, + expectedprops) + + def test_node_compute_host_capabilities_without_properties(self): + tpl_snippet = ''' + node_templates: + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + #left intentionally + ''' + expectedprops = {'flavor': 'm1.nano'} + self._tosca_compute_test( + tpl_snippet, + expectedprops) + + def test_node_compute_host_capabilities_without_disk_size(self): + tpl_snippet = ''' + node_templates: + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + num_cpus: 4 + mem_size: 4 GB + ''' + expectedprops = {'flavor': 'm1.large'} + self._tosca_compute_test( + tpl_snippet, + expectedprops) + + def test_node_compute_host_capabilities_without_mem_size(self): + tpl_snippet = ''' + node_templates: + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + num_cpus: 4 + disk_size: 10 GB + ''' + expectedprops = {'flavor': 'm1.large'} + self._tosca_compute_test( + tpl_snippet, + expectedprops) + + def test_node_compute_host_capabilities_without_mem_size_disk_size(self): + tpl_snippet = ''' + node_templates: + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + num_cpus: 4 + ''' + expectedprops = {'flavor': 'm1.large'} + self._tosca_compute_test( + tpl_snippet, + expectedprops) + + @patch('requests.post') + @patch('requests.get') + @patch('os.getenv') + def test_node_compute_with_nova_flavor(self, mock_os_getenv, + mock_get, mock_post): + tpl_snippet = ''' + node_templates: + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + num_cpus: 1 + disk_size: 1 GB + mem_size: 1 GB + ''' + with patch('translator.hot.tosca.tosca_compute.ToscaCompute.' + '_check_for_env_variables') as mock_check_env: + mock_check_env.return_value = True + mock_os_getenv.side_effect = ['demo', 'demo', + 'demo', 'http://abc.com/5000/'] + mock_ks_response = mock.MagicMock() + mock_ks_response.status_code = 200 + mock_ks_content = { + 'access': { + 'token': { + 'id': 'd1dfa603-3662-47e0-b0b6-3ae7914bdf76' + }, + 'serviceCatalog': [{ + 'type': 'compute', + 'endpoints': [{ + 'publicURL': 'http://abc.com' + }] + }] + } + } + mock_ks_response.content = json.dumps(mock_ks_content) + mock_nova_response = mock.MagicMock() + mock_nova_response.status_code = 200 + mock_flavor_content = { + 'flavors': [{ + 'name': 'm1.mock_flavor', + 'ram': 1024, + 'disk': 1, + 'vcpus': 1 + }] + } + mock_nova_response.content = \ + json.dumps(mock_flavor_content) + mock_post.return_value = mock_ks_response + mock_get.return_value = mock_nova_response + expectedprops = {'flavor': 'm1.mock_flavor'} + self._tosca_compute_test( + tpl_snippet, + expectedprops) diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tests/test_tosca_objectstore.py b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tests/test_tosca_objectstore.py new file mode 100644 index 0000000..4c42794 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tests/test_tosca_objectstore.py @@ -0,0 +1,71 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from toscaparser.nodetemplate import NodeTemplate +from toscaparser.tests.base import TestCase +from toscaparser.utils.gettextutils import _ +import toscaparser.utils.yamlparser +from translator.hot.tosca.tosca_object_storage import ToscaObjectStorage + + +class ToscaObjectStoreTest(TestCase): + + def _tosca_objectstore_test(self, tpl_snippet, expectedprops): + nodetemplates = (toscaparser.utils.yamlparser. + simple_parse(tpl_snippet)['node_templates']) + name = list(nodetemplates.keys())[0] + try: + nodetemplate = NodeTemplate(name, nodetemplates) + tosca_object_store = ToscaObjectStorage(nodetemplate) + tosca_object_store.handle_properties() + if not self._compare_properties(tosca_object_store.properties, + expectedprops): + raise Exception(_("Hot Properties are not" + " same as expected properties")) + except Exception: + # for time being rethrowing. Will be handled future based + # on new development + raise + + def _compare_properties(self, hotprops, expectedprops): + return all(item in hotprops.items() for item in expectedprops.items()) + + def test_node_objectstorage_with_properties(self): + tpl_snippet = ''' + node_templates: + server: + type: tosca.nodes.ObjectStorage + properties: + name: test + size: 1024 KB + maxsize: 1 MB + ''' + expectedprops = {'name': 'test', + 'X-Container-Meta': {'Quota-Bytes': 1000000}} + self._tosca_objectstore_test( + tpl_snippet, + expectedprops) + + def test_node_objectstorage_with_few_properties(self): + tpl_snippet = ''' + node_templates: + server: + type: tosca.nodes.ObjectStorage + properties: + name: test + size: 1024 B + ''' + expectedprops = {'name': 'test', + 'X-Container-Meta': {'Quota-Bytes': 1024}} + self._tosca_objectstore_test( + tpl_snippet, + expectedprops) diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_block_storage.py b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_block_storage.py new file mode 100644 index 0000000..482db3e --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_block_storage.py @@ -0,0 +1,69 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import logging +from toscaparser.common.exception import InvalidPropertyValueError +from toscaparser.elements.scalarunit import ScalarUnit_Size +from toscaparser.functions import GetInput +from toscaparser.utils.gettextutils import _ +from translator.hot.syntax.hot_resource import HotResource + +log = logging.getLogger("tosca") + +# Name used to dynamically load appropriate map class. +TARGET_CLASS_NAME = 'ToscaBlockStorage' + + +class ToscaBlockStorage(HotResource): + '''Translate TOSCA node type tosca.nodes.BlockStorage.''' + + toscatype = 'tosca.nodes.BlockStorage' + + def __init__(self, nodetemplate): + super(ToscaBlockStorage, self).__init__(nodetemplate, + type='OS::Cinder::Volume') + pass + + def handle_properties(self): + tosca_props = {} + for prop in self.nodetemplate.get_properties_objects(): + if isinstance(prop.value, GetInput): + tosca_props[prop.name] = {'get_param': prop.value.input_name} + else: + if prop.name == "size": + size_value = (ScalarUnit_Size(prop.value). + get_num_from_scalar_unit('GiB')) + if size_value == 0: + # OpenStack Heat expects size in GB + raise InvalidPropertyValueError( + what=_('Cinder Volume Size unit should be in GBs')) + elif int(size_value) < size_value: + size_value = int(size_value) + 1 + log.warning(_("Cinder unit value should be in " + "multiples of GBs. so corrected " + " %(prop_val)s to %(size_value)s GB.") + % {'prop_val': prop.value, + 'size_value': size_value}) + tosca_props[prop.name] = int(size_value) + else: + tosca_props[prop.name] = prop.value + self.properties = tosca_props + + def get_hot_attribute(self, attribute, args): + attr = {} + # Convert from a TOSCA attribute for a nodetemplate to a HOT + # attribute for the matching resource. Unless there is additional + # runtime support, this should be a one to one mapping. + if attribute == 'volume_id': + attr['get_resource'] = args[0] + return attr diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_block_storage_attachment.py b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_block_storage_attachment.py new file mode 100644 index 0000000..715d5b3 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_block_storage_attachment.py @@ -0,0 +1,48 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from toscaparser.functions import GetInput +from translator.hot.syntax.hot_resource import HotResource + +# Name used to dynamically load appropriate map class. +TARGET_CLASS_NAME = 'ToscaBlockStorageAttachment' + + +class ToscaBlockStorageAttachment(HotResource): + '''Translate TOSCA relationship AttachesTo for Compute and BlockStorage.''' + + toscatype = 'tosca.nodes.BlockStorageAttachment' + + def __init__(self, template, nodetemplates, instance_uuid, volume_id): + super(ToscaBlockStorageAttachment, + self).__init__(template, type='OS::Cinder::VolumeAttachment') + self.nodetemplates = nodetemplates + self.instance_uuid = {'get_resource': instance_uuid} + self.volume_id = {'get_resource': volume_id} + + def handle_properties(self): + tosca_props = {} + for prop in self.nodetemplate.get_properties_objects(): + if isinstance(prop.value, GetInput): + tosca_props[prop.name] = {'get_param': prop.value.input_name} + else: + tosca_props[prop.name] = prop.value + self.properties = tosca_props + # instance_uuid and volume_id for Cinder volume attachment + self.properties['instance_uuid'] = self.instance_uuid + self.properties['volume_id'] = self.volume_id + if 'location' in self.properties: + self.properties['mountpoint'] = self.properties.pop('location') + + def handle_life_cycle(self): + pass diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_compute.py b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_compute.py new file mode 100755 index 0000000..137418d --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_compute.py @@ -0,0 +1,274 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import json +import logging +import os +import requests + +from toscaparser.utils.validateutils import TOSCAVersionProperty +import translator.common.utils +from translator.hot.syntax.hot_resource import HotResource +log = logging.getLogger('tosca') + +# Name used to dynamically load appropriate map class. +TARGET_CLASS_NAME = 'ToscaCompute' + +# Required environment variables to create novaclient object. +ENV_VARIABLES = ['OS_AUTH_URL', 'OS_PASSWORD', 'OS_USERNAME', 'OS_TENANT_NAME'] + +# A design issue to be resolved is how to translate the generic TOSCA server +# properties to OpenStack flavors and images. At the Atlanta design summit, +# there was discussion on using Glance to store metadata and Graffiti to +# describe artifacts. We will follow these projects to see if they can be +# leveraged for this TOSCA translation. +# For development purpose at this time, we temporarily hardcode a list of +# flavors and images here +FLAVORS = {'m1.xlarge': {'mem_size': 16384, 'disk_size': 160, 'num_cpus': 8}, + 'm1.large': {'mem_size': 8192, 'disk_size': 80, 'num_cpus': 4}, + 'm1.medium': {'mem_size': 4096, 'disk_size': 40, 'num_cpus': 2}, + 'm1.small': {'mem_size': 2048, 'disk_size': 20, 'num_cpus': 1}, + 'm1.tiny': {'mem_size': 512, 'disk_size': 1, 'num_cpus': 1}, + 'm1.micro': {'mem_size': 128, 'disk_size': 0, 'num_cpus': 1}, + 'm1.nano': {'mem_size': 64, 'disk_size': 0, 'num_cpus': 1}} + +IMAGES = {'ubuntu-software-config-os-init': {'architecture': 'x86_64', + 'type': 'Linux', + 'distribution': 'Ubuntu', + 'version': '14.04'}, + 'ubuntu-12.04-software-config-os-init': {'architecture': 'x86_64', + 'type': 'Linux', + 'distribution': 'Ubuntu', + 'version': '12.04'}, + 'fedora-amd64-heat-config': {'architecture': 'x86_64', + 'type': 'Linux', + 'distribution': 'Fedora', + 'version': '18.0'}, + 'F18-x86_64-cfntools': {'architecture': 'x86_64', + 'type': 'Linux', + 'distribution': 'Fedora', + 'version': '19'}, + 'Fedora-x86_64-20-20131211.1-sda': {'architecture': 'x86_64', + 'type': 'Linux', + 'distribution': 'Fedora', + 'version': '20'}, + 'cirros-0.3.1-x86_64-uec': {'architecture': 'x86_64', + 'type': 'Linux', + 'distribution': 'CirrOS', + 'version': '0.3.1'}, + 'cirros-0.3.2-x86_64-uec': {'architecture': 'x86_64', + 'type': 'Linux', + 'distribution': 'CirrOS', + 'version': '0.3.2'}, + 'rhel-6.5-test-image': {'architecture': 'x86_64', + 'type': 'Linux', + 'distribution': 'RHEL', + 'version': '6.5'}} + + +class ToscaCompute(HotResource): + '''Translate TOSCA node type tosca.nodes.Compute.''' + + toscatype = 'tosca.nodes.Compute' + + def __init__(self, nodetemplate): + super(ToscaCompute, self).__init__(nodetemplate, + type='OS::Nova::Server') + # List with associated hot port resources with this server + self.assoc_port_resources = [] + pass + + def handle_properties(self): + self.properties = self.translate_compute_flavor_and_image( + self.nodetemplate.get_capability('host'), + self.nodetemplate.get_capability('os')) + self.properties['user_data_format'] = 'SOFTWARE_CONFIG' + # TODO(anyone): handle user key + # hardcoded here for testing + self.properties['key_name'] = 'userkey' + + # To be reorganized later based on new development in Glance and Graffiti + def translate_compute_flavor_and_image(self, + host_capability, + os_capability): + hot_properties = {} + host_cap_props = {} + os_cap_props = {} + image = None + flavor = None + 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 + image = self._best_image(os_cap_props) + hot_properties['flavor'] = flavor + hot_properties['image'] = image + # TODO(anyone): consider adding the flavor or image as a template + # parameter if no match is found. + return hot_properties + + def _check_for_env_variables(self): + return set(ENV_VARIABLES) < set(os.environ.keys()) + + def _create_nova_flavor_dict(self): + '''Populates and returns the flavors dict using Nova ReST API''' + + tenant_name = os.getenv('OS_TENANT_NAME') + username = os.getenv('OS_USERNAME') + password = os.getenv('OS_PASSWORD') + auth_url = os.getenv('OS_AUTH_URL') + + auth_dict = { + "auth": { + "tenantName": tenant_name, + "passwordCredentials": { + "username": username, + "password": password + } + } + } + headers = {'Content-Type': 'application/json'} + keystone_response = requests.post(auth_url + '/tokens', + data=json.dumps(auth_dict), + headers=headers) + if keystone_response.status_code != 200: + return None + access_dict = json.loads(keystone_response.content) + access_token = access_dict['access']['token']['id'] + service_catalog = access_dict['access']['serviceCatalog'] + nova_url = '' + for service in service_catalog: + if service['type'] == 'compute': + nova_url = service['endpoints'][0]['publicURL'] + if not nova_url: + return None + nova_response = requests.get(nova_url + '/flavors/detail', + headers={'X-Auth-Token': access_token}) + if nova_response.status_code != 200: + return None + flavors = json.loads(nova_response.content)['flavors'] + flavor_dict = dict() + for flavor in flavors: + flavor_name = str(flavor['name']) + flavor_dict[flavor_name] = { + 'mem_size': flavor['ram'], + 'disk_size': flavor['disk'], + 'num_cpus': flavor['vcpus'], + } + return flavor_dict + + def _best_flavor(self, properties): + # Check whether user exported all required environment variables. + flavors = FLAVORS + if self._check_for_env_variables(): + resp = self._create_nova_flavor_dict() + if resp: + flavors = resp + + # start with all flavors + match_all = flavors.keys() + + # TODO(anyone): Handle the case where the value contains something like + # get_input instead of a value. + # flavors that fit the CPU count + cpu = properties.get('num_cpus') + match_cpu = self._match_flavors(match_all, flavors, 'num_cpus', cpu) + + # flavors that fit the mem size + mem = properties.get('mem_size') + if mem: + mem = translator.common.utils.MemoryUnit.convert_unit_size_to_num( + mem, 'MB') + match_cpu_mem = self._match_flavors(match_cpu, flavors, + 'mem_size', mem) + # flavors that fit the disk size + disk = properties.get('disk_size') + if disk: + disk = translator.common.utils.MemoryUnit.\ + convert_unit_size_to_num(disk, 'GB') + match_cpu_mem_disk = self._match_flavors(match_cpu_mem, flavors, + 'disk_size', disk) + # if multiple match, pick the flavor with the least memory + # the selection can be based on other heuristic, e.g. pick one with the + # least total resource + if len(match_cpu_mem_disk) > 1: + return self._least_flavor(match_cpu_mem_disk, flavors, 'mem_size') + elif len(match_cpu_mem_disk) == 1: + return match_cpu_mem_disk[0] + else: + return None + + def _best_image(self, properties): + match_all = IMAGES.keys() + architecture = properties.get('architecture') + match_arch = self._match_images(match_all, IMAGES, + 'architecture', architecture) + type = properties.get('type') + match_type = self._match_images(match_arch, IMAGES, 'type', type) + distribution = properties.get('distribution') + match_distribution = self._match_images(match_type, IMAGES, + 'distribution', + distribution) + version = properties.get('version') + version = TOSCAVersionProperty(version).get_version() + match_version = self._match_images(match_distribution, IMAGES, + 'version', version) + + if len(match_version): + return list(match_version)[0] + + def _match_flavors(self, this_list, this_dict, attr, size): + '''Return from this list all flavors matching the attribute size.''' + if not size: + return list(this_list) + matching_flavors = [] + for flavor in this_list: + if isinstance(size, int): + if this_dict[flavor][attr] >= size: + matching_flavors.append(flavor) + return matching_flavors + + def _least_flavor(self, this_list, this_dict, attr): + '''Return from this list the flavor with the smallest attr.''' + least_flavor = this_list[0] + for flavor in this_list: + if this_dict[flavor][attr] < this_dict[least_flavor][attr]: + least_flavor = flavor + return least_flavor + + def _match_images(self, this_list, this_dict, attr, prop): + if not prop: + return this_list + matching_images = [] + for image in this_list: + if this_dict[image][attr].lower() == str(prop).lower(): + matching_images.append(image) + return matching_images + + def get_hot_attribute(self, attribute, args): + attr = {} + # Convert from a TOSCA attribute for a nodetemplate to a HOT + # attribute for the matching resource. Unless there is additional + # runtime support, this should be a one to one mapping. + + # Note: We treat private and public IP addresses equally, but + # this will change in the future when TOSCA starts to support + # multiple private/public IP addresses. + if attribute == 'private_address' or \ + attribute == 'public_address': + attr['get_attr'] = [self.name, 'networks', 'private', 0] + + return attr diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_database.py b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_database.py new file mode 100755 index 0000000..26c9d4d --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_database.py @@ -0,0 +1,30 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from translator.hot.syntax.hot_resource import HotResource + +# Name used to dynamically load appropriate map class. +TARGET_CLASS_NAME = 'ToscaDatabase' + + +class ToscaDatabase(HotResource): + '''Translate TOSCA node type tosca.nodes.Database.''' + + toscatype = 'tosca.nodes.Database' + + def __init__(self, nodetemplate): + super(ToscaDatabase, self).__init__(nodetemplate) + pass + + def handle_properties(self): + pass diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_dbms.py b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_dbms.py new file mode 100755 index 0000000..38c31bd --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_dbms.py @@ -0,0 +1,30 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from translator.hot.syntax.hot_resource import HotResource + +# Name used to dynamically load appropriate map class. +TARGET_CLASS_NAME = 'ToscaDbms' + + +class ToscaDbms(HotResource): + '''Translate TOSCA node type tosca.nodes.DBMS.''' + + toscatype = 'tosca.nodes.DBMS' + + def __init__(self, nodetemplate): + super(ToscaDbms, self).__init__(nodetemplate) + pass + + def handle_properties(self): + pass diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_network_network.py b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_network_network.py new file mode 100644 index 0000000..909c1b7 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_network_network.py @@ -0,0 +1,120 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from toscaparser.common.exception import InvalidPropertyValueError +from translator.hot.syntax.hot_resource import HotResource + +# Name used to dynamically load appropriate map class. +TARGET_CLASS_NAME = 'ToscaNetwork' + + +class ToscaNetwork(HotResource): + '''Translate TOSCA node type tosca.nodes.network.Network.''' + + toscatype = 'tosca.nodes.network.Network' + SUBNET_SUFFIX = '_subnet' + NETWORK_PROPS = ['network_name', 'network_id', 'segmentation_id'] + SUBNET_PROPS = ['ip_version', 'cidr', 'start_ip', 'end_ip', 'gateway_ip'] + + existing_resource_id = None + + def __init__(self, nodetemplate): + super(ToscaNetwork, self).__init__(nodetemplate, + type='OS::Neutron::Net') + pass + + def handle_properties(self): + tosca_props = self._get_tosca_props( + self.nodetemplate.get_properties_objects()) + + net_props = {} + for key, value in tosca_props.items(): + if key in self.NETWORK_PROPS: + if key == 'network_name': + # If CIDR is specified network_name should + # be used as the name for the new network. + if 'cidr' in tosca_props.keys(): + net_props['name'] = value + # If CIDR is not specified network_name will be used + # to lookup existing network. If network_id is specified + # together with network_name then network_id should be + # used to lookup the network instead + elif 'network_id' not in tosca_props.keys(): + self.hide_resource = True + self.existing_resource_id = value + break + elif key == 'network_id': + self.hide_resource = True + self.existing_resource_id = value + break + elif key == 'segmentation_id': + net_props['segmentation_id'] = \ + tosca_props['segmentation_id'] + # Hardcode to vxlan for now until we add the network type + # and physical network to the spec. + net_props['value_specs'] = {'provider:segmentation_id': + value, 'provider:network_type': + 'vxlan'} + self.properties = net_props + + def handle_expansion(self): + # If the network resource should not be output (they are hidden), + # there is no need to generate subnet resource + if self.hide_resource: + return + + tosca_props = self._get_tosca_props( + self.nodetemplate.get_properties_objects()) + + subnet_props = {} + + ip_pool_start = None + ip_pool_end = None + + for key, value in tosca_props.items(): + if key in self.SUBNET_PROPS: + if key == 'start_ip': + ip_pool_start = value + elif key == 'end_ip': + ip_pool_end = value + elif key == 'dhcp_enabled': + subnet_props['enable_dhcp'] = value + else: + subnet_props[key] = value + + if 'network_id' in tosca_props: + subnet_props['network'] = tosca_props['network_id'] + else: + subnet_props['network'] = '{ get_resource: %s }' % (self.name) + + # Handle allocation pools + # Do this only if both start_ip and end_ip are provided + # If one of them is missing throw an exception. + if ip_pool_start and ip_pool_end: + allocation_pool = {} + allocation_pool['start'] = ip_pool_start + allocation_pool['end'] = ip_pool_end + allocation_pools = [allocation_pool] + subnet_props['allocation_pools'] = allocation_pools + elif ip_pool_start: + raise InvalidPropertyValueError(what=_('start_ip')) + elif ip_pool_end: + raise InvalidPropertyValueError(what=_('end_ip')) + + subnet_resource_name = self.name + self.SUBNET_SUFFIX + + hot_resources = [HotResource(self.nodetemplate, + type='OS::Neutron::Subnet', + name=subnet_resource_name, + properties=subnet_props)] + return hot_resources diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_network_port.py b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_network_port.py new file mode 100644 index 0000000..f5f0b25 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_network_port.py @@ -0,0 +1,117 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from translator.hot.syntax.hot_resource import HotResource + +# Name used to dynamically load appropriate map class. +TARGET_CLASS_NAME = 'ToscaNetworkPort' + + +class ToscaNetworkPort(HotResource): + '''Translate TOSCA node type tosca.nodes.network.Port.''' + + toscatype = 'tosca.nodes.network.Port' + + def __init__(self, nodetemplate): + super(ToscaNetworkPort, self).__init__(nodetemplate, + type='OS::Neutron::Port') + # Default order + self.order = 0 + pass + + def _generate_networks_for_compute(self, port_resources): + '''Generate compute networks property list from the port resources.''' + networks = [] + for resource in port_resources: + networks.append({'port': '{ get_resource: %s }' % (resource.name)}) + return networks + + def _insert_sorted_resource(self, resources, resource): + '''Insert a resource in the list of resources and keep the order.''' + lo = 0 + hi = len(resources) + while lo < hi: + mid = (lo + hi) // 2 + if resource.order < resources[mid].order: + hi = mid + else: + lo = mid + 1 + resources.insert(lo, resource) + + def handle_properties(self): + tosca_props = self._get_tosca_props( + self.nodetemplate.get_properties_objects()) + port_props = {} + for key, value in tosca_props.items(): + if key == 'ip_address': + fixed_ip = [] + fixed_ip['ip_address'] = value + fixed_ip['subnet'] = '' + port_props['fixed_ips'] = [fixed_ip] + elif key == 'order': + self.order = value + # TODO(sdmonov): Need to implement the properties below + elif key == 'is_default': + pass + elif key == 'ip_range_start': + pass + elif key == 'ip_range_end': + pass + else: + port_props[key] = value + + # Get the nodetype relationships + relationships = {relation.type: node for relation, node in + self.nodetemplate.relationships.items()} + + # Check for LinksTo relations. If found add a network property with + # the network name into the port + links_to = None + if 'tosca.relationships.network.LinksTo' in relationships: + links_to = relationships['tosca.relationships.network.LinksTo'] + + network_resource = None + for hot_resource in self.depends_on_nodes: + if links_to.name == hot_resource.name: + network_resource = hot_resource + self.depends_on.remove(hot_resource) + break + + if network_resource.existing_resource_id: + port_props['network'] =\ + str(network_resource.existing_resource_id) + else: + port_props['network'] = '{ get_resource: %s }'\ + % (links_to.name) + + # Check for BindsTo relationship. If found add network to the networks + # property of the corresponding compute resource + binds_to = None + if 'tosca.relationships.network.BindsTo' in relationships: + binds_to = relationships['tosca.relationships.network.BindsTo'] + compute_resource = None + for hot_resource in self.depends_on_nodes: + if binds_to.name == hot_resource.name: + compute_resource = hot_resource + self.depends_on.remove(hot_resource) + break + if compute_resource: + port_resources = compute_resource.assoc_port_resources + self._insert_sorted_resource(port_resources, self) + # TODO(sdmonov): Using generate networks every time we add a + # network is not the fastest way to do the things. We should + # do this only once at the end. + networks = self._generate_networks_for_compute(port_resources) + compute_resource.properties['networks'] = networks + + self.properties = port_props diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_object_storage.py b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_object_storage.py new file mode 100644 index 0000000..ed283b2 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_object_storage.py @@ -0,0 +1,58 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from toscaparser.elements.scalarunit import ScalarUnit_Size +from translator.hot.syntax.hot_resource import HotResource + +# Name used to dynamically load appropriate map class. +TARGET_CLASS_NAME = 'ToscaObjectStorage' + + +class ToscaObjectStorage(HotResource): + '''Translate TOSCA node type tosca.nodes.ObjectStorage.''' + + toscatype = 'tosca.nodes.ObjectStorage' + + def __init__(self, nodetemplate): + super(ToscaObjectStorage, self).__init__(nodetemplate, + type='OS::Swift::Container') + pass + + def handle_properties(self): + tosca_props = self._get_tosca_props( + self.nodetemplate.get_properties_objects()) + objectstore_props = {} + container_quota = {} + skip_check = False + + for key, value in tosca_props.items(): + if key == "name": + objectstore_props["name"] = value + elif key == "size" or key == "maxsize": + # currently heat is not supporting dynamically increase + # the container quota-size. + # if both defined in tosca template, consider store_maxsize. + if skip_check: + continue + quota_size = None + if "maxsize" in tosca_props.keys(): + quota_size = tosca_props["maxsize"] + else: + quota_size = tosca_props["size"] + container_quota["Quota-Bytes"] = \ + ScalarUnit_Size(quota_size).get_num_from_scalar_unit() + objectstore_props["X-Container-Meta"] = container_quota + skip_check = True + + objectstore_props["X-Container-Read"] = '".r:*"' + self.properties = objectstore_props diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_software_component.py b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_software_component.py new file mode 100755 index 0000000..044de43 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_software_component.py @@ -0,0 +1,30 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from translator.hot.syntax.hot_resource import HotResource + +# Name used to dynamically load appropriate map class. +TARGET_CLASS_NAME = 'ToscaSoftwareComponent' + + +class ToscaSoftwareComponent(HotResource): + '''Translate TOSCA node type tosca.nodes.SoftwareComponent.''' + + toscatype = 'tosca.nodes.SoftwareComponent' + + def __init__(self, nodetemplate): + super(ToscaSoftwareComponent, self).__init__(nodetemplate) + pass + + def handle_properties(self): + pass diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_web_application.py b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_web_application.py new file mode 100755 index 0000000..d0a9c5d --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_web_application.py @@ -0,0 +1,30 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from translator.hot.syntax.hot_resource import HotResource + +# Name used to dynamically load appropriate map class. +TARGET_CLASS_NAME = 'ToscaWebApplication' + + +class ToscaWebApplication(HotResource): + '''Translate TOSCA node type tosca.nodes.WebApplication.''' + + toscatype = 'tosca.nodes.WebApplication' + + def __init__(self, nodetemplate): + super(ToscaWebApplication, self).__init__(nodetemplate) + pass + + def handle_properties(self): + pass diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_webserver.py b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_webserver.py new file mode 100755 index 0000000..83bda80 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca/tosca_webserver.py @@ -0,0 +1,30 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from translator.hot.syntax.hot_resource import HotResource + +# Name used to dynamically load appropriate map class. +TARGET_CLASS_NAME = 'ToscaWebserver' + + +class ToscaWebserver(HotResource): + '''Translate TOSCA node type tosca.nodes.WebServer.''' + + toscatype = 'tosca.nodes.WebServer' + + def __init__(self, nodetemplate): + super(ToscaWebserver, self).__init__(nodetemplate) + pass + + def handle_properties(self): + pass diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/tosca_translator.py b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca_translator.py new file mode 100644 index 0000000..74da6ce --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/tosca_translator.py @@ -0,0 +1,64 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import logging +from translator.hot.syntax.hot_template import HotTemplate +from translator.hot.translate_inputs import TranslateInputs +from translator.hot.translate_node_templates import TranslateNodeTemplates +from translator.hot.translate_outputs import TranslateOutputs + + +class TOSCATranslator(object): + '''Invokes translation methods.''' + + log = logging.getLogger('heat-translator') + + def __init__(self, tosca, parsed_params): + super(TOSCATranslator, self).__init__() + self.tosca = tosca + self.hot_template = HotTemplate() + self.parsed_params = parsed_params + self.node_translator = None + + def translate(self): + self._resolve_input() + self.hot_template.description = self.tosca.description + self.hot_template.parameters = self._translate_inputs() + self.node_translator = TranslateNodeTemplates(self.tosca, + self.hot_template) + self.hot_template.resources = self.node_translator.translate() + self.hot_template.outputs = self._translate_outputs() + return self.hot_template.output_to_yaml() + + def _translate_inputs(self): + translator = TranslateInputs(self.tosca.inputs, self.parsed_params) + return translator.translate() + + def _translate_outputs(self): + translator = TranslateOutputs(self.tosca.outputs, self.node_translator) + return translator.translate() + + # check all properties for all node and ensure they are resolved + # to actual value + def _resolve_input(self): + for n in self.tosca.nodetemplates: + for node_prop in n.get_properties_objects(): + if isinstance(node_prop.value, dict): + try: + self.parsed_params[node_prop.value['get_input']] + except Exception: + msg = (_('Must specify all input values in \ + TOSCA template, missing %s') % + node_prop.value['get_input']) + self.log.warning(msg) + raise ValueError(msg) diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/translate_inputs.py b/tosca2heat/heat-translator-0.3.0/translator/hot/translate_inputs.py new file mode 100644 index 0000000..ea9f990 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/translate_inputs.py @@ -0,0 +1,153 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import logging +from toscaparser.dataentity import DataEntity +from toscaparser.elements.scalarunit import ScalarUnit_Size +from toscaparser.utils.gettextutils import _ +from toscaparser.utils.validateutils import TOSCAVersionProperty +from translator.hot.syntax.hot_parameter import HotParameter + + +INPUT_CONSTRAINTS = (CONSTRAINTS, DESCRIPTION, LENGTH, RANGE, + MIN, MAX, ALLOWED_VALUES, ALLOWED_PATTERN) = \ + ('constraints', 'description', 'length', 'range', + 'min', 'max', 'allowed_values', 'allowed_pattern') + +TOSCA_CONSTRAINT_OPERATORS = (EQUAL, GREATER_THAN, GREATER_OR_EQUAL, LESS_THAN, + LESS_OR_EQUAL, IN_RANGE, VALID_VALUES, LENGTH, + MIN_LENGTH, MAX_LENGTH, PATTERN) = \ + ('equal', 'greater_than', 'greater_or_equal', + 'less_than', 'less_or_equal', 'in_range', + 'valid_values', 'length', 'min_length', + 'max_length', 'pattern') + +TOSCA_TO_HOT_CONSTRAINTS_ATTRS = {'equal': 'allowed_values', + 'greater_than': 'range', + 'greater_or_equal': 'range', + 'less_than': 'range', + 'less_or_equal': 'range', + 'in_range': 'range', + 'valid_values': 'allowed_values', + 'length': 'length', + 'min_length': 'length', + 'max_length': 'length', + 'pattern': 'allowed_pattern'} + +TOSCA_TO_HOT_INPUT_TYPES = {'string': 'string', + 'integer': 'number', + 'float': 'number', + 'boolean': 'boolean', + 'timestamp': 'string', + 'scalar-unit.size': 'number', + 'version': 'string', + 'null': 'string', + 'PortDef': 'number'} + +log = logging.getLogger('heat-translator') + + +class TranslateInputs(object): + '''Translate TOSCA Inputs to Heat Parameters.''' + + def __init__(self, inputs, parsed_params): + self.inputs = inputs + self.parsed_params = parsed_params + + def translate(self): + return self._translate_inputs() + + def _translate_inputs(self): + hot_inputs = [] + hot_default = None + for input in self.inputs: + hot_input_type = TOSCA_TO_HOT_INPUT_TYPES[input.type] + + if input.name in self.parsed_params: + hot_default = DataEntity.validate_datatype( + input.type, self.parsed_params[input.name]) + elif input.default is not None: + hot_default = DataEntity.validate_datatype(input.type, + input.default) + else: + log.warning(_("Need to specify a value " + "for input {0}").format(input.name)) + raise Exception(_("Need to specify a value " + "for input {0}").format(input.name)) + if input.type == "scalar-unit.size": + # Assumption here is to use this scalar-unit.size for size of + # cinder volume in heat templates and will be in GB. + # should add logic to support other types if needed. + input_value = hot_default + hot_default = (ScalarUnit_Size(hot_default). + get_num_from_scalar_unit('GiB')) + if hot_default == 0: + log.warning(_('Unit value should be > 0.')) + raise Exception(_( + 'Unit value should be > 0.')) + elif int(hot_default) < hot_default: + hot_default = int(hot_default) + 1 + log.warning(_("Cinder unit value should be in multiples" + " of GBs. So corrected %(input_value)s " + "to %(hot_default)s GB.") + % {'input_value': input_value, + 'hot_default': hot_default}) + if input.type == 'version': + hot_default = TOSCAVersionProperty(hot_default).get_version() + + hot_constraints = [] + if input.constraints: + for constraint in input.constraints: + constraint.validate(hot_default) + hc, hvalue = self._translate_constraints( + constraint.constraint_key, constraint.constraint_value) + hot_constraints.append({hc: hvalue}) + + hot_inputs.append(HotParameter(name=input.name, + type=hot_input_type, + description=input.description, + default=hot_default, + constraints=hot_constraints)) + return hot_inputs + + def _translate_constraints(self, name, value): + hot_constraint = TOSCA_TO_HOT_CONSTRAINTS_ATTRS[name] + + # Offset used to support less_than and greater_than. + # TODO(anyone): when parser supports float, verify this works + offset = 1 + + if name == EQUAL: + hot_value = [value] + elif name == GREATER_THAN: + hot_value = {"min": value + offset} + elif name == GREATER_OR_EQUAL: + hot_value = {"min": value} + elif name == LESS_THAN: + hot_value = {"max": value - offset} + elif name == LESS_OR_EQUAL: + hot_value = {"max": value} + elif name == IN_RANGE: + # value is list type here + min_value = min(value) + max_value = max(value) + hot_value = {"min": min_value, "max": max_value} + elif name == LENGTH: + hot_value = {"min": value, "max": value} + elif name == MIN_LENGTH: + hot_value = {"min": value} + elif name == MAX_LENGTH: + hot_value = {"max": value} + else: + hot_value = value + return hot_constraint, hot_value diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/translate_node_templates.py b/tosca2heat/heat-translator-0.3.0/translator/hot/translate_node_templates.py new file mode 100644 index 0000000..152603d --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/translate_node_templates.py @@ -0,0 +1,408 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import importlib +import logging +import os +import six + +from toscaparser.functions import GetAttribute +from toscaparser.functions import GetInput +from toscaparser.functions import GetProperty +from toscaparser.relationship_template import RelationshipTemplate +from translator.common.exception import ToscaClassAttributeError +from translator.common.exception import ToscaClassImportError +from translator.common.exception import ToscaModImportError +from translator.conf.config import ConfigProvider as translatorConfig +from translator.hot.syntax.hot_resource import HotResource +from translator.hot.tosca.tosca_block_storage_attachment import ( + ToscaBlockStorageAttachment + ) + +########################### +# Module utility Functions +# for dynamic class loading +########################### + + +def _generate_type_map(): + '''Generate TOSCA translation types map. + + Load user defined classes from location path specified in conf file. + Base classes are located within the tosca directory. + + ''' + + # Base types directory + BASE_PATH = 'translator/hot/tosca' + + # Custom types directory defined in conf file + custom_path = translatorConfig.get_value('DEFAULT', + 'custom_types_location') + + # First need to load the parent module, for example 'contrib.hot', + # for all of the dynamically loaded classes. + classes = [] + _load_classes((BASE_PATH, custom_path), classes) + try: + types_map = {clazz.toscatype: clazz for clazz in classes} + except AttributeError as e: + raise ToscaClassAttributeError(message=e.message) + + return types_map + + +def _load_classes(locations, classes): + '''Dynamically load all the classes from the given locations.''' + + for cls_path in locations: + # Use the absolute path of the class path + abs_path = os.path.dirname(os.path.abspath(__file__)) + abs_path = abs_path.replace('translator/hot', cls_path) + + # Grab all the tosca type module files in the given path + mod_files = [f for f in os.listdir(abs_path) if f.endswith('.py') + and not f.startswith('__init__') + and f.startswith('tosca_')] + + # For each module, pick out the target translation class + for f in mod_files: + # NOTE: For some reason the existing code does not use the map to + # instantiate ToscaBlockStorageAttachment. Don't add it to the map + # here until the dependent code is fixed to use the map. + if f == 'tosca_block_storage_attachment.py': + continue + + mod_name = cls_path + '/' + f.strip('.py') + mod_name = mod_name.replace('/', '.') + try: + mod = importlib.import_module(mod_name) + target_name = getattr(mod, 'TARGET_CLASS_NAME') + clazz = getattr(mod, target_name) + classes.append(clazz) + except ImportError: + raise ToscaModImportError(mod_name=mod_name) + except AttributeError: + if target_name: + raise ToscaClassImportError(name=target_name, + mod_name=mod_name) + else: + # TARGET_CLASS_NAME is not defined in module. + # Re-raise the exception + raise + +################## +# Module constants +################## + +SECTIONS = (TYPE, PROPERTIES, REQUIREMENTS, INTERFACES, LIFECYCLE, INPUT) = \ + ('type', 'properties', 'requirements', + 'interfaces', 'lifecycle', 'input') + +# TODO(anyone): the following requirement names should not be hard-coded +# in the translator. Since they are basically arbitrary names, we have to get +# them from TOSCA type definitions. +# To be fixed with the blueprint: +# https://blueprints.launchpad.net/heat-translator/+spec/tosca-custom-types +REQUIRES = (CONTAINER, DEPENDENCY, DATABASE_ENDPOINT, CONNECTION, HOST) = \ + ('container', 'dependency', 'database_endpoint', + 'connection', 'host') + +INTERFACES_STATE = (CREATE, START, CONFIGURE, START, DELETE) = \ + ('create', 'stop', 'configure', 'start', 'delete') + + +TOSCA_TO_HOT_REQUIRES = {'container': 'server', 'host': 'server', + 'dependency': 'depends_on', "connects": 'depends_on'} + +TOSCA_TO_HOT_PROPERTIES = {'properties': 'input'} +log = logging.getLogger('heat-translator') + +TOSCA_TO_HOT_TYPE = _generate_type_map() + + +class TranslateNodeTemplates(object): + '''Translate TOSCA NodeTemplates to Heat Resources.''' + + def __init__(self, tosca, hot_template): + self.tosca = tosca + self.nodetemplates = self.tosca.nodetemplates + self.hot_template = hot_template + # list of all HOT resources generated + self.hot_resources = [] + # mapping between TOSCA nodetemplate and HOT resource + self.hot_lookup = {} + + def translate(self): + return self._translate_nodetemplates() + + def _recursive_handle_properties(self, resource): + '''Recursively handle the properties of the depends_on_nodes nodes.''' + # Use of hashtable (dict) here should be faster? + if resource in self.processed_resources: + return + self.processed_resources.append(resource) + for depend_on in resource.depends_on_nodes: + self._recursive_handle_properties(depend_on) + + resource.handle_properties() + + def _translate_nodetemplates(self): + + suffix = 0 + # Copy the TOSCA graph: nodetemplate + for node in self.nodetemplates: + hot_node = TOSCA_TO_HOT_TYPE[node.type](node) + self.hot_resources.append(hot_node) + self.hot_lookup[node] = hot_node + + # BlockStorage Attachment is a special case, + # which doesn't match to Heat Resources 1 to 1. + if node.type == "tosca.nodes.Compute": + volume_name = None + requirements = node.requirements + if requirements: + # Find the name of associated BlockStorage node + for requires in requirements: + for value in requires.values(): + if isinstance(value, dict): + for node_name in value.values(): + for n in self.nodetemplates: + if n.name == node_name: + volume_name = node_name + break + else: # unreachable code ! + for n in self.nodetemplates: + if n.name == node_name: + volume_name = node_name + break + + suffix = suffix + 1 + attachment_node = self._get_attachment_node(node, + suffix, + volume_name) + if attachment_node: + self.hot_resources.append(attachment_node) + + # Handle life cycle operations: this may expand each node + # into multiple HOT resources and may change their name + lifecycle_resources = [] + for resource in self.hot_resources: + expanded = resource.handle_life_cycle() + if expanded: + lifecycle_resources += expanded + self.hot_resources += lifecycle_resources + + # Handle configuration from ConnectsTo relationship in the TOSCA node: + # this will generate multiple HOT resources, set of 2 for each + # configuration + connectsto_resources = [] + for node in self.nodetemplates: + for requirement in node.requirements: + for endpoint, details in six.iteritems(requirement): + relation = None + if isinstance(details, dict): + target = details.get('node') + relation = details.get('relationship') + else: + target = details + if (target and relation and + not isinstance(relation, six.string_types)): + interfaces = relation.get('interfaces') + connectsto_resources += \ + self._create_connect_configs(node, + target, + interfaces) + self.hot_resources += connectsto_resources + + # Copy the initial dependencies based on the relationship in + # the TOSCA template + for node in self.nodetemplates: + for node_depend in node.related_nodes: + # if the source of dependency is a server and the + # relationship type is 'tosca.relationships.HostedOn', + # add dependency as properties.server + if node_depend.type == 'tosca.nodes.Compute' and \ + node.related[node_depend].type == \ + node.type_definition.HOSTEDON: + self.hot_lookup[node].properties['server'] = \ + {'get_resource': self.hot_lookup[node_depend].name} + # for all others, add dependency as depends_on + else: + self.hot_lookup[node].depends_on.append( + self.hot_lookup[node_depend].top_of_chain()) + + self.hot_lookup[node].depends_on_nodes.append( + self.hot_lookup[node_depend].top_of_chain()) + + # handle hosting relationship + for resource in self.hot_resources: + resource.handle_hosting() + + # handle built-in properties of HOT resources + # if a resource depends on other resources, + # their properties need to be handled first. + # Use recursion to handle the properties of the + # dependent nodes in correct order + self.processed_resources = [] + for resource in self.hot_resources: + self._recursive_handle_properties(resource) + + # handle resources that need to expand to more than one HOT resource + expansion_resources = [] + for resource in self.hot_resources: + expanded = resource.handle_expansion() + if expanded: + expansion_resources += expanded + self.hot_resources += expansion_resources + + # Resolve function calls: GetProperty, GetAttribute, GetInput + # at this point, all the HOT resources should have been created + # in the graph. + for resource in self.hot_resources: + # traverse the reference chain to get the actual value + inputs = resource.properties.get('input_values') + if inputs: + for name, value in six.iteritems(inputs): + if isinstance(value, GetAttribute): + # for the attribute + # get the proper target type to perform the translation + args = value.result() + target = args[0] + hot_target = self.find_hot_resource(target) + + inputs[name] = hot_target.get_hot_attribute(args[1], + args) + else: + if isinstance(value, GetProperty) or \ + isinstance(value, GetInput): + inputs[name] = value.result() + + return self.hot_resources + + def _get_attachment_node(self, node, suffix, volume_name): + attach = False + ntpl = self.nodetemplates + for key, value in node.relationships.items(): + if key.is_derived_from('tosca.relationships.AttachesTo'): + if value.is_derived_from('tosca.nodes.BlockStorage'): + attach = True + if attach: + relationship_tpl = None + for req in node.requirements: + for key, val in req.items(): + attach = val + relship = val.get('relationship') + for rkey, rval in val.items(): + if relship and isinstance(relship, dict): + for rkey, rval in relship.items(): + if rkey == 'type': + relationship_tpl = val + attach = rval + elif rkey == 'template': + rel_tpl_list = \ + (self.tosca.topology_template. + _tpl_relationship_templates()) + relationship_tpl = rel_tpl_list[rval] + attach = rval + else: + continue + elif isinstance(relship, str): + attach = relship + relationship_tpl = val + relationship_templates = \ + self.tosca._tpl_relationship_templates() + if 'relationship' in relationship_tpl and \ + attach not in \ + self.tosca._tpl_relationship_types() and \ + attach in relationship_templates: + relationship_tpl['relationship'] = \ + relationship_templates[attach] + break + if relationship_tpl: + rval_new = attach + "_" + str(suffix) + att = RelationshipTemplate( + relationship_tpl, rval_new, + self.tosca._tpl_relationship_types()) + hot_node = ToscaBlockStorageAttachment(att, ntpl, + node.name, + volume_name + ) + return hot_node + + def find_hot_resource(self, name): + for resource in self.hot_resources: + if resource.name == name: + return resource + + def _find_tosca_node(self, tosca_name): + for node in self.nodetemplates: + if node.name == tosca_name: + return node + + def _find_hot_resource_for_tosca(self, tosca_name): + for node in self.nodetemplates: + if node.name == tosca_name: + return self.hot_lookup[node] + + def _create_connect_configs(self, source_node, target_name, + connect_interfaces): + connectsto_resources = [] + if connect_interfaces: + for iname, interface in six.iteritems(connect_interfaces): + connectsto_resources += \ + self._create_connect_config(source_node, target_name, + interface) + return connectsto_resources + + def _create_connect_config(self, source_node, target_name, + connect_interface): + connectsto_resources = [] + target_node = self._find_tosca_node(target_name) + # the configuration can occur on the source or the target + connect_config = connect_interface.get('pre_configure_target') + if connect_config is not None: + config_location = 'target' + else: + connect_config = connect_interface.get('pre_configure_source') + if connect_config is not None: + config_location = 'source' + else: + msg = _("Template error: " + "no configuration found for ConnectsTo " + "in {1}").format(self.nodetemplate.name) + log.warning(msg) + raise Exception(msg) + config_name = source_node.name + '_' + target_name + '_connect_config' + implement = connect_config.get('implementation') + if config_location == 'target': + hot_config = HotResource(target_node, + config_name, + 'OS::Heat::SoftwareConfig', + {'config': {'get_file': implement}}) + elif config_location == 'source': + hot_config = HotResource(source_node, + config_name, + 'OS::Heat::SoftwareConfig', + {'config': {'get_file': implement}}) + connectsto_resources.append(hot_config) + hot_target = self._find_hot_resource_for_tosca(target_name) + hot_source = self._find_hot_resource_for_tosca(source_node.name) + connectsto_resources.append(hot_config. + handle_connectsto(source_node, + target_node, + hot_source, + hot_target, + config_location, + connect_interface)) + return connectsto_resources diff --git a/tosca2heat/heat-translator-0.3.0/translator/hot/translate_outputs.py b/tosca2heat/heat-translator-0.3.0/translator/hot/translate_outputs.py new file mode 100644 index 0000000..d707722 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/hot/translate_outputs.py @@ -0,0 +1,42 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from translator.hot.syntax.hot_output import HotOutput + + +class TranslateOutputs(object): + '''Translate TOSCA Outputs to Heat Outputs.''' + + def __init__(self, outputs, node_translator): + self.outputs = outputs + self.nodes = node_translator + + def translate(self): + return self._translate_outputs() + + def _translate_outputs(self): + hot_outputs = [] + for output in self.outputs: + if output.value.name == 'get_attribute': + get_parameters = output.value.args + hot_target = self.nodes.find_hot_resource(get_parameters[0]) + hot_value = hot_target.get_hot_attribute(get_parameters[1], + get_parameters) + hot_outputs.append(HotOutput(output.name, + hot_value, + output.description)) + else: + hot_outputs.append(HotOutput(output.name, + output.value, + output.description)) + return hot_outputs diff --git a/tosca2heat/heat-translator-0.3.0/translator/osc/__init__.py b/tosca2heat/heat-translator-0.3.0/translator/osc/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tosca2heat/heat-translator-0.3.0/translator/osc/osc_plugin.py b/tosca2heat/heat-translator-0.3.0/translator/osc/osc_plugin.py new file mode 100644 index 0000000..6d3d25a --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/osc/osc_plugin.py @@ -0,0 +1,41 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from translator.osc import utils + +DEFAULT_TRANSLATOR_API_VERSION = '1' +API_VERSION_OPTION = 'os_translator_api_version' +API_NAME = 'translator' +API_VERSIONS = { + '1': 'translator.v1.client.Client', +} + + +def make_client(instance): + # NOTE(stevemar): We don't need a client because + # heat-translator itself is a command line tool + pass + + +def build_option_parser(parser): + """Hook to add global options.""" + + parser.add_argument( + '--os-translator-api-version', + metavar='', + default=utils.env( + 'OS_TRANSLATOR_API_VERSION', + default=DEFAULT_TRANSLATOR_API_VERSION), + help='Translator API version, default=' + + DEFAULT_TRANSLATOR_API_VERSION + + ' (Env: OS_TRANSLATOR_API_VERSION)') + return parser diff --git a/tosca2heat/heat-translator-0.3.0/translator/osc/utils.py b/tosca2heat/heat-translator-0.3.0/translator/osc/utils.py new file mode 100644 index 0000000..e8a6814 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/osc/utils.py @@ -0,0 +1,45 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# + +"""Common client utilities""" + +import argparse +import os + + +def env(*vars, **kwargs): + """Search for the first defined of possibly many env vars + + Returns the first environment variable defined in vars, or + returns the default defined in kwargs. + """ + for v in vars: + value = os.environ.get(v, None) + if value: + return value + return kwargs.get('default', '') + + +class KeyValueAction(argparse.Action): + """A custom action to parse arguments as key=value pairs. """ + + def __call__(self, parser, namespace, values, option_string=None): + # Make sure we have an empty dict rather than None + if getattr(namespace, self.dest, None) is None: + setattr(namespace, self.dest, {}) + + # Add value if an assignment else remove it + if '=' in values: + getattr(namespace, self.dest, {}).update([values.split('=', 1)]) + else: + getattr(namespace, self.dest, {}).pop(values, None) diff --git a/tosca2heat/heat-translator-0.3.0/translator/osc/v1/__init__.py b/tosca2heat/heat-translator-0.3.0/translator/osc/v1/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tosca2heat/heat-translator-0.3.0/translator/osc/v1/translate.py b/tosca2heat/heat-translator-0.3.0/translator/osc/v1/translate.py new file mode 100644 index 0000000..c356042 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/osc/v1/translate.py @@ -0,0 +1,94 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +"""Translate action implementations""" + +import logging.config +import os +import sys + +from cliff import command + +from toscaparser.tosca_template import ToscaTemplate +from translator.common.utils import UrlUtils +from translator.hot.tosca_translator import TOSCATranslator +from translator.osc import utils + + +class TranslateTemplate(command.Command): + """Translate a template""" + + log = logging.getLogger('heat-translator' + '.TranslateTemplate') + auth_required = False + + def get_parser(self, prog_name): + parser = super(TranslateTemplate, self).get_parser(prog_name) + parser.add_argument( + '--template-file', + metavar='', + required=True, + help='Path to the file that needs to be translated.') + parser.add_argument( + '--template-type', + metavar='', + required=True, + choices=['tosca'], + help='Format of the template file.') + parser.add_argument( + '--output-file', + metavar='', + help='Path to place the translated content.') + parser.add_argument( + '--parameter', + metavar='', + action=utils.KeyValueAction, + help='Set a property for this template ' + '(repeat option to set multiple properties)', + ) + parser.add_argument( + '--validate-only', + metavar='', + help='Set to true to only validate a template file.', + default='false') + return parser + + def take_action(self, parsed_args): + self.log.debug('take_action(%s)', parsed_args) + output = None + + if parsed_args.parameter: + parsed_params = parsed_args.parameter + else: + parsed_params = {} + + if parsed_args.template_type == "tosca": + path = parsed_args.template_file + a_file = os.path.isfile(path) + a_url = UrlUtils.validate_url(path) if not a_file else False + if a_file or a_url: + validate = parsed_args.validate_only + if validate and validate.lower() == "true": + ToscaTemplate(path, parsed_params, a_file) + else: + tosca = ToscaTemplate(path, parsed_params, a_file) + translator = TOSCATranslator(tosca, parsed_params) + output = translator.translate() + else: + sys.stdout.write('Could not find template file.') + raise SystemExit + + if output: + if parsed_args.output_file: + with open(parsed_args.output_file, 'w+') as f: + f.write(output) + else: + print(output) diff --git a/tosca2heat/heat-translator-0.3.0/translator/shell.py b/tosca2heat/heat-translator-0.3.0/translator/shell.py new file mode 100644 index 0000000..1c58f58 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/shell.py @@ -0,0 +1,157 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +import logging.config +import os +import sys + +from toscaparser.tosca_template import ToscaTemplate +from toscaparser.utils.gettextutils import _ +from toscaparser.utils.urlutils import UrlUtils +from translator.hot.tosca_translator import TOSCATranslator + +""" +Test the heat-translator translation from command line as: +#heat-translator + --template-file= + --template-type= + --parameters="purpose=test" +Takes three user arguments, +1. type of translation (e.g. tosca) (required) +2. Path to the file that needs to be translated (required) +3. Input parameters (optional) + +In order to use heat-translator to only validate template, +without actual translation, pass --validate-only=true along with +other required arguments. + +""" + +log = logging.getLogger("heat-translator") + + +class TranslatorShell(object): + + SUPPORTED_TYPES = ['tosca'] + + def _validate(self, args): + if len(args) < 2: + msg = _("The program requires minimum two arguments. " + "Please refer to the usage documentation.") + raise ValueError(msg) + if "--template-file=" not in args[0]: + msg = _("The program expects --template-file as first argument. " + "Please refer to the usage documentation.") + raise ValueError(msg) + if "--template-type=" not in args[1]: + msg = _("The program expects --template-type as second argument. " + "Please refer to the usage documentation.") + raise ValueError(msg) + + def main(self, args): + self._validate(args) + path = args[0].split('--template-file=')[1] + # e.g. --template_file=translator/tests/data/tosca_helloworld.yaml + template_type = args[1].split('--template-type=')[1] + # e.g. --template_type=tosca + if not template_type: + raise ValueError(_("Template type is needed. " + "For example, 'tosca'")) + elif template_type not in self.SUPPORTED_TYPES: + raise ValueError(_("%(value)s is not a valid template type.") + % {'value': template_type}) + parsed_params = {} + validate_only = None + output_file = None + if len(args) > 2: + parameters = None + for arg in args: + if "--validate-only=" in arg: + validate_only = arg + if "--parameters=" in arg: + parameters = arg + if "--output-file=" in arg: + output = arg + output_file = output.split('--output-file=')[1] + if parameters: + parsed_params = self._parse_parameters(parameters) + a_file = os.path.isfile(path) + a_url = UrlUtils.validate_url(path) if not a_file else False + if a_file or a_url: + run_only_validation = False + if validate_only: + value = validate_only.split('-validate-only=')[1].lower() + if template_type == 'tosca' and value == 'true': + run_only_validation = True + if run_only_validation: + ToscaTemplate(path, parsed_params, a_file) + else: + heat_tpl = self._translate(template_type, path, parsed_params, + a_file) + if heat_tpl: + self._write_output(heat_tpl, output_file) + else: + raise ValueError(_("The path %(path)s is not a valid file" + " or URL.") % {'path': path}) + + def _parse_parameters(self, parameter_list): + parsed_inputs = {} + if parameter_list.startswith('--parameters'): + # Parameters are semi-colon separated + inputs = parameter_list.split('--parameters=')[1].\ + replace('"', '').split(';') + # Each parameter should be an assignment + for param in inputs: + keyvalue = param.split('=') + # Validate the parameter has both a name and value + if keyvalue.__len__() is 2: + # Assure parameter name is not zero-length or whitespace + stripped_name = keyvalue[0].strip() + if not stripped_name: + raise ValueError(_("'%(param)s' is not a well-formed " + "parameter.") % {'param': param}) + # Add the valid parameter to the dictionary + parsed_inputs[keyvalue[0]] = keyvalue[1] + else: + raise ValueError(_("'%(param)s' is not a well-formed " + "parameter.") % {'param': param}) + else: + raise ValueError(_("'%(list)s' is not a valid parameter list.") + % {'list': parameter_list}) + return parsed_inputs + + def _translate(self, sourcetype, path, parsed_params, a_file): + output = None + if sourcetype == "tosca": + tosca = ToscaTemplate(path, parsed_params, a_file) + translator = TOSCATranslator(tosca, parsed_params) + output = translator.translate() + return output + + def _write_output(self, output, output_file=None): + if output: + if output_file: + with open(output_file, 'w+') as f: + f.write(output) + else: + print(output) + + +def main(args=None): + if args is None: + args = sys.argv[1:] + TranslatorShell().main(args) + + +if __name__ == '__main__': + main() diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/__init__.py b/tosca2heat/heat-translator-0.3.0/translator/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/base.py b/tosca2heat/heat-translator-0.3.0/translator/tests/base.py new file mode 100644 index 0000000..6e93268 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/base.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- + +# Copyright 2010-2011 OpenStack Foundation +# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import os + +import fixtures +import testtools + +_TRUE_VALUES = ('True', 'true', '1', 'yes') + + +class TestCase(testtools.TestCase): + + """Test case base class for all unit tests.""" + + def setUp(self): + """Run before each test method to initialize test environment.""" + + super(TestCase, self).setUp() + test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0) + try: + test_timeout = int(test_timeout) + except ValueError: + # If timeout value is invalid do not set a timeout. + test_timeout = 0 + if test_timeout > 0: + self.useFixture(fixtures.Timeout(test_timeout, gentle=True)) + + self.useFixture(fixtures.NestedTempfile()) + self.useFixture(fixtures.TempHomeDir()) + + if os.environ.get('OS_STDOUT_CAPTURE') in _TRUE_VALUES: + stdout = self.useFixture(fixtures.StringStream('stdout')).stream + self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout)) + if os.environ.get('OS_STDERR_CAPTURE') in _TRUE_VALUES: + stderr = self.useFixture(fixtures.StringStream('stderr')).stream + self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr)) + + self.log_fixture = self.useFixture(fixtures.FakeLogger()) diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/collectd/config.py b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/collectd/config.py new file mode 100755 index 0000000..686bbd1 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/collectd/config.py @@ -0,0 +1,25 @@ +#!/usr/bin/python + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# This script configures collectd to send metric data to the +# logstash server port 25826 +# The environment variable logstash_ip is expected to be set up +import os +with open("/etc/collectd/collectd.conf.d/tosca_elk.conf", "w") as fh: + fh.write(""" + LoadPlugin network + + Server "%s" "25826" + + """ % (os.environ['logstash_ip'])) diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/collectd/create.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/collectd/create.sh new file mode 100755 index 0000000..a483b88 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/collectd/create.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# This script install collectd for monitoring data + +apt-get update +apt-get install -y collectd diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/collectd/start.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/collectd/start.sh new file mode 100755 index 0000000..7e8e033 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/collectd/start.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# This script starts collectd as a service in init.d +service collectd stop +service collectd start diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/elasticsearch/create.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/elasticsearch/create.sh new file mode 100755 index 0000000..c34126c --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/elasticsearch/create.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# This script installs java and elasticsearch + +apt-get update +apt-get install -y openjdk-7-jre-headless + +wget -qO - https://packages.elasticsearch.org/GPG-KEY-elasticsearch | apt-key add - +echo "deb http://packages.elasticsearch.org/elasticsearch/1.5/debian stable main" | tee -a /etc/apt/sources.list + +apt-get update +apt-get install -y elasticsearch + +# set up to run as service +update-rc.d elasticsearch defaults 95 10 diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/elasticsearch/start.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/elasticsearch/start.sh new file mode 100755 index 0000000..bbc0347 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/elasticsearch/start.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# This script starts elasticsearch as a service in init.d +service elasticsearch stop +service elasticsearch start diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/kibana/config.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/kibana/config.sh new file mode 100755 index 0000000..f28215a --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/kibana/config.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# This script configures kibana to connect to the elasticsearch server +# to access data and to export the app url on port 5601: +# The environment variable elasticsearch_ip and kibana_ip are expected +# to be set up. +sed -i 's/localhost/'$elasticsearch_ip'/' /opt/kibana/config/kibana.yml +sed -i 's/0.0.0.0/'$kibana_ip'/' /opt/kibana/config/kibana.yml diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/kibana/create.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/kibana/create.sh new file mode 100755 index 0000000..41914b1 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/kibana/create.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# This script installs kibana and sets it up to run as a service in init.d +cd /opt +wget https://download.elastic.co/kibana/kibana/kibana-4.1.0-linux-x64.tar.gz +tar xzvf kibana-4.1.0-linux-x64.tar.gz +mv kibana-4.1.0-linux-x64 kibana + +# set up to run as service +cd /etc/init.d +wget https://gist.githubusercontent.com/thisismitch/8b15ac909aed214ad04a/raw/bce61d85643c2dcdfbc2728c55a41dab444dca20/kibana4 +chmod +x kibana4 +update-rc.d kibana4 defaults 96 9 diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/kibana/start.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/kibana/start.sh new file mode 100755 index 0000000..5149bb3 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/kibana/start.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# This script starts kibana as a service in init.d +service kibana4 stop +service kibana4 start diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/logstash/configure_collectd.py b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/logstash/configure_collectd.py new file mode 100755 index 0000000..18fdacf --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/logstash/configure_collectd.py @@ -0,0 +1,28 @@ +#!/usr/bin/python + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# This script configures the logstash input using the udp protocol on +# port 25826. This is intended to receive data from collectd from +# any source +with open("/etc/logstash/conf.d/collectd.conf", "w") as fh: + fh.write(""" + input { + udp { + port => 25826 # 25826 is the default for collectd + buffer_size => 1452 # 1452 is the default for collectd + codec => collectd { } + tags => ["metrics"] + type => "collectd" + } + }""") diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/logstash/configure_elasticsearch.py b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/logstash/configure_elasticsearch.py new file mode 100755 index 0000000..2e5389c --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/logstash/configure_elasticsearch.py @@ -0,0 +1,26 @@ +#!/usr/bin/python + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# This script configures the logstash output to forward to elasticsearch +# The environment variable elasticsearch_ip is expected to be set up +import os +with open("/etc/logstash/conf.d/elasticsearch.conf", 'w') as fh: + fh.write(""" + output { + elasticsearch { + action => index + host => "%s" + protocol => "http" + } + }""" % (os.environ['elasticsearch_ip'])) diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/logstash/configure_rsyslog.py b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/logstash/configure_rsyslog.py new file mode 100755 index 0000000..fc610c2 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/logstash/configure_rsyslog.py @@ -0,0 +1,25 @@ +#!/usr/bin/python + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# This script configures the logstash input using the RELP protocol on +# port 2514 This is intended to receive logs from rsyslog from +# any source +with open("/etc/logstash/conf.d/rsyslog.conf", "w") as fh: + fh.write(""" + input { + relp { + port => 2514 + tags => ["logs"] + } + }""") diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/logstash/create.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/logstash/create.sh new file mode 100755 index 0000000..77cc8fd --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/logstash/create.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# This script installs java, logstash and the contrib package for logstash +# install java as prereq + +apt-get update +apt-get install -y openjdk-7-jre-headless +mkdir /etc/logstash + +# install by apt-get from repo +wget -O - http://packages.elasticsearch.org/GPG-KEY-elasticsearch | apt-key add - +echo "deb http://packages.elasticsearch.org/logstash/1.4/debian stable main" | tee -a /etc/apt/sources.list + +apt-get update +apt-get install -y logstash + +# install contrib to get the relp plugin +/opt/logstash/bin/plugin install contrib + +# set up to run as service +update-rc.d logstash defaults 95 10 diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/logstash/start.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/logstash/start.sh new file mode 100755 index 0000000..a73cf61 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/logstash/start.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# Run logstash as service in init.d +service logstash stop +service logstash start diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mongodb/config.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mongodb/config.sh new file mode 100644 index 0000000..78f484e --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mongodb/config.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# Edit the file /etc/mongod.conf, update with real IP of Mongo server +# This script configures the mongodb server to export its service on +# the server IP +# bind_ip = 127.0.0.1 -> bind_ip = +# The environment variable mongodb_ip is expected to be set up +sed -i "s/= 127.0.0.1/= $mongodb_ip,127.0.0.1/" /etc/mongod.conf diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mongodb/create.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mongodb/create.sh new file mode 100644 index 0000000..d84c275 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mongodb/create.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# This script installs mongodb + +apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 +echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.0.list + +apt-get update +apt-get install -y mongodb-org + +#Wait for mongodb initialization +while [[ ! -d "/var/lib/mongodb/_tmp" ]]; do + echo "Waiting for mongodb initialization ..." + sleep 5 +done diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mongodb/create_database.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mongodb/create_database.sh new file mode 100644 index 0000000..16f1358 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mongodb/create_database.sh @@ -0,0 +1,5 @@ +#!/bin/bash +echo "conn = new Mongo();" > setup.js +echo "db = conn.getDB('paypal_pizza');" >> setup.js +echo "db.about.insert({'name': 'PayPal Pizza Store'});" >> setup.js +mongo setup.js diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mongodb/start.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mongodb/start.sh new file mode 100644 index 0000000..ac200a5 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mongodb/start.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# This script starts mongodb +service mongod stop +rm /var/lib/mongodb/mongod.lock +service mongod start diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mysql/mysql_database_configure.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mysql/mysql_database_configure.sh new file mode 100755 index 0000000..092136a --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mysql/mysql_database_configure.sh @@ -0,0 +1,8 @@ +#!/bin/sh +cat << EOF | mysql -u root --password=$db_root_password +CREATE DATABASE $db_name; +GRANT ALL PRIVILEGES ON $db_name.* TO "$db_user"@"localhost" +IDENTIFIED BY "$db_password"; +FLUSH PRIVILEGES; +EXIT +EOF \ No newline at end of file diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mysql/mysql_dbms_configure.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mysql/mysql_dbms_configure.sh new file mode 100755 index 0000000..d4ef6b4 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mysql/mysql_dbms_configure.sh @@ -0,0 +1,5 @@ +#!/bin/sh +sed --regexp-extended "s/(port\s*=\s*)[0-9]*/\1$db_port/g" /tmp/my.cnf +mv -f /tmp/my.cnf /etc/mysql/my.cnf +/etc/init.d/mysql stop +/etc/init.d/mysql start \ No newline at end of file diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mysql/mysql_dbms_install.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mysql/mysql_dbms_install.sh new file mode 100755 index 0000000..38628b9 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mysql/mysql_dbms_install.sh @@ -0,0 +1,9 @@ +#!/bin/bash +#This script installs mysql server + +apt-get update + +debconf-set-selections <<< "mysql-server mysql-server/root_password password $db_root_password" +debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $db_root_password" + +apt-get -y install --fix-missing mysql-server \ No newline at end of file diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mysql/mysql_dbms_start.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mysql/mysql_dbms_start.sh new file mode 100755 index 0000000..3378670 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/mysql/mysql_dbms_start.sh @@ -0,0 +1,2 @@ +#!/bin/sh +/etc/init.d/mysql start \ No newline at end of file diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/nodejs/config.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/nodejs/config.sh new file mode 100644 index 0000000..1e149a2 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/nodejs/config.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# This script installs an app for nodejs: the app intended is the paypal app +# and it is configured to connect to the mongodb server +# The environment variables github_url and mongodb_ip are expected to be set up +export app_dir=/opt/app +git clone $github_url /opt/app +if [ -f /opt/app/package.json ]; then + cd /opt/app/ && npm install + sed -i "s/localhost/$mongodb_ip/" config.json +fi + +cat > /etc/init/nodeapp.conf <> /var/log/nodeapp.log 2>&1 & +end script +EOS diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/nodejs/create.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/nodejs/create.sh new file mode 100644 index 0000000..04fd6c6 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/nodejs/create.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# This script installs nodejs and the prereq + +add-apt-repository ppa:chris-lea/node.js + +apt-get update +apt-get install -y nodejs build-essential diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/nodejs/start.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/nodejs/start.sh new file mode 100644 index 0000000..6939cb7 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/nodejs/start.sh @@ -0,0 +1,3 @@ +#!/bin/bash +# This script starts the nodejs application +start nodeapp diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/rsyslog/config.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/rsyslog/config.sh new file mode 100644 index 0000000..630767d --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/rsyslog/config.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# This script configures the output for rsyslogd to send logs to the +# logstash server port 2514 using the RELP protocol +# The environment variable logstash_ip is expected to be set up +echo "module(load=\"omrelp\") +action(type=\"omrelp\" target=\"$logstash_ip\" port=\"2514\")" > /etc/rsyslog.d/tosca_elk.conf + +# Remove the /dev/xconsole configuration as xconsole +# is not available by default +l=`awk '/=warn.*\|.*\/dev\/xconsole/{print NR - 1}' /etc/rsyslog.d/50-default.conf` +if [ ! -z $l ]; then + l=`expr $l + 1` + line=`cat /etc/rsyslog.d/50-default.conf | head -n $l | tail -1` + if [[ ! $line == \#* ]]; then + l0=`expr $l - 3` + sed -i -r -e "${l0},${l}s/^.{0}/&#/" /etc/rsyslog.d/50-default.conf + fi +fi + +# Enable nodejs logs for rsyslog +if ! grep -q nodeapp "/etc/rsyslog.conf"; then + sed -i 's/\$PrivDropToGroup\ syslog/\$PrivDropToGroup adm/' /etc/rsyslog.conf + echo "\$ModLoad imfile.so +\$InputFileName /var/log/nodeapp.log +\$InputFileTag paypal_pizza: +\$InputFileStateFile stat-nodeapp +\$InputRunFileMonitor +\$InputFilePollInterval 1" >> /etc/rsyslog.conf +fi diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/rsyslog/create.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/rsyslog/create.sh new file mode 100755 index 0000000..affdd6e --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/rsyslog/create.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# This script installs rsyslog and the library for RELP + +apt-get update +apt-get install -y rsyslog rsyslog-relp diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/rsyslog/start.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/rsyslog/start.sh new file mode 100755 index 0000000..3de82d1 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/rsyslog/start.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# This script starts rsyslogd as a service in init.d +service rsyslog stop +service rsyslog start diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/webserver/webserver_install.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/webserver/webserver_install.sh new file mode 100755 index 0000000..4ca9b4e --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/webserver/webserver_install.sh @@ -0,0 +1,5 @@ +#!/bin/sh +#This script installs apache web server + +apt-get update +apt-get install -y apache2 \ No newline at end of file diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/webserver/webserver_start.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/webserver/webserver_start.sh new file mode 100755 index 0000000..e962ca5 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/webserver/webserver_start.sh @@ -0,0 +1,2 @@ +#!/bin/sh +service apache2 start \ No newline at end of file diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/wordpress/wordpress_configure.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/wordpress/wordpress_configure.sh new file mode 100755 index 0000000..5598b4f --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/wordpress/wordpress_configure.sh @@ -0,0 +1,4 @@ +#!/bin/sh +ln -s /usr/share/wordpress /var/www/html/wordpress +gzip -d /usr/share/doc/wordpress/examples/setup-mysql.gz +echo $wp_db_password | bash /usr/share/doc/wordpress/examples/setup-mysql -e $wp_db_name -u $wp_db_user localhost \ No newline at end of file diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/wordpress/wordpress_install.sh b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/wordpress/wordpress_install.sh new file mode 100755 index 0000000..1320443 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/artifacts/wordpress/wordpress_install.sh @@ -0,0 +1,5 @@ +#!/bin/sh +#This script installs wordpress + +apt-get update +apt-get install -y wordpress \ No newline at end of file diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_elk.zip b/tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_elk.zip new file mode 100644 index 0000000000000000000000000000000000000000..5fae801a7538fea7208bedc504f300bcda30efff GIT binary patch literal 17488 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 R01TjCGf?3F5`+N&{6B74f*Ak+ literal 0 HcmV?d00001 diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_hello_world.zip b/tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_hello_world.zip new file mode 100644 index 0000000000000000000000000000000000000000..43ffbbc83003a5b4fa1e04284d080610c9051877 GIT binary patch literal 936 zcmWIWW@Zs#U|`^2XiJlK*F7Nc&47`Cp_GY%L6kv;p(MXJIWayXH76&(JijO>MXxe3 zHzzcNlYu#B!;{cU$Df3jR&X;gvb=@U(4maJG_BymW7dTLBgyp zZ{=FAG`L=N*|__n?cbPN8^e-!s(j4<|1Zgv$vT_sPOz)f!lciQonJSw?DX)lo0cK< z+S}N4vX1tI*hL!C=ah$B%sTL+~Rhv`U0$Q2YGv+BX>@%DjU(Px~E$RHs?W}X`+2pei#+94hlAU_R?AJ=h z9nHQ8jN)1wy(Y7nT%WTz?N1nw5u0P{n!SY^pQ)Z{d)V}2N%8NXZ7*4_tzP)-;`d86 zR?W|^He|&vPTHHHto>HtzSK3wJBzrLd+Hxt*;sot-uctFhV41GQzu(bS}@s4^YPEb zM6vISTk@VouX^=aV_p9=m)*O5i?5%({H@2nf2&;W&hKLk00uu7F!&i5a!cgh!3-$D z4-Ebg|6pfFUEkD_#FWI6M163;&pq)ZbTbg61w6Zt;D_>8VHErhfNTw?RIZFd3#m|`|F@NH$ z$&=&f#ZQ^MD17FO*@syf0=yZSMXxe3 zHzzcNlYu#B!;{d&ZBIf=E4UdLSza>`cnbIL=mavic$(J+{{aN#Qkv54(LjfN}bYbMDks_pr5(5YWBNyzEk zW*;Y>R0|Wgs?Div0j*5y8S|7G_8HENFK3;gmUMpRcGfxeZ1UL$Jl}Z2I2a`t2s}FTbXIs!$jaA~W=)$pJ(B54z?#JYlj7&hk(fVm z*5t|Y^WvvWUKBoa#_Yqa3<2JZOmfV)5}^b*Jb-DEVM`;3i6cp}LXsq!7a&IC3SfxQ z3=9Gce;wJ|4U?aQt1g4?LL66ILRyL4FnSqcWXh1VCFETIy0GTT` AZvX%Q literal 0 HcmV?d00001 diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_not_zip.zip b/tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_not_zip.zip new file mode 100644 index 0000000..43b7f5f --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_not_zip.zip @@ -0,0 +1 @@ +This is an invalid CSAR file. \ No newline at end of file diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_single_instance_wordpress.zip b/tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_single_instance_wordpress.zip new file mode 100644 index 0000000000000000000000000000000000000000..5df7b48333a2480cd6f686e339cb0656fd0d009a GIT binary patch literal 5967 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 literal 0 HcmV?d00001 diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_wordpress_invalid_import_path.zip b/tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_wordpress_invalid_import_path.zip new file mode 100644 index 0000000000000000000000000000000000000000..d6442594363def4ad1dca76b884680e8c375fa15 GIT binary patch literal 5971 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 PZs2zT_+-FA{O|t&l?c`g literal 0 HcmV?d00001 diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_wordpress_invalid_script_url.zip b/tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_wordpress_invalid_script_url.zip new file mode 100644 index 0000000000000000000000000000000000000000..6014f9230474b680a3d5e5db31287f655bd6cf3c GIT binary patch literal 6034 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 literal 0 HcmV?d00001 diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_wrong_metadata_file.zip b/tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_wrong_metadata_file.zip new file mode 100644 index 0000000000000000000000000000000000000000..85d660a037693b3447038e5bc94732679f3ac8d2 GIT binary patch literal 873 zcmWIWW@Zs#U|`^2XiJlK*F7Nc&47`Cp_GY%L6kv;p(MXJIWayXH76&(JijO>MXxe3 zHzzcNlYu#B!;?@DF0J5ZU}Sm8%)kI9N+%u6J7mDq_P&?6Pt9MccnIw>E|)?^OAi|Nmc-E0c9L*PUQjr-ezM8#}*lVA<*6V>c~B>b1AA z>0}-439*Ybrq3x4xyp6OPDR6D+QNme7{nsB3pE<9l&_g2qo}s$%R#4p#Uvr8bDMpf zcv3A)+^ROGvIVpWU7WNxLs|Q+zBs36+(E=V}5F^l_yG{p{~u_UHJU~~0A=7No6 z1RCdnX{2jjNl~S)OKMtXUS>&VeqOPa0@n1v72wUtB*%;^6-j_S1WZ&6TN*)3tY(CU zutL%lhPOaQ;|d{&(F_a%41XQ#fi_@-7tl~pc;PV=GqjN1djiu? + collectd is a daemon which gathers statistics about the system it is running on. + +node_types: + tosca.nodes.SoftwareComponent.Collectd: + derived_from: tosca.nodes.SoftwareComponent + requirements: + - log_endpoint: + capability: tosca.capabilities.Endpoint + node: tosca.nodes.SoftwareComponent.Logstash + relationship: tosca.relationships.ConnectsTo \ No newline at end of file diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/elasticsearch.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/elasticsearch.yaml new file mode 100644 index 0000000..b140a32 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/elasticsearch.yaml @@ -0,0 +1,12 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + Elasticsearch is an open-source search engine built on top of Apache Lucene, + a full-text search-engine library. + +node_types: + tosca.nodes.SoftwareComponent.Elasticsearch: + derived_from: tosca.nodes.SoftwareComponent + capabilities: + search_endpoint: + type: tosca.capabilities.Endpoint diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/kibana.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/kibana.yaml new file mode 100644 index 0000000..5701e69 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/kibana.yaml @@ -0,0 +1,14 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + Kibana is an open source analytics and visualization platform designed to work with Elasticsearch. + You use Kibana to search, view, and interact with data stored in Elasticsearch. + +node_types: + tosca.nodes.SoftwareComponent.Kibana: + derived_from: tosca.nodes.SoftwareComponent + requirements: + - search_endpoint: + capability: tosca.capabilities.Endpoint + node: tosca.nodes.SoftwareComponent.Elasticsearch + relationship: tosca.relationships.ConnectsTo diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/logstash.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/logstash.yaml new file mode 100644 index 0000000..cf60521 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/logstash.yaml @@ -0,0 +1,25 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + Logstash is a tool for receiving, processing and outputting logs. All kinds + of logs. System logs, webserver logs, error logs, application logs, and just + about anything you can throw at it. + +node_types: + tosca.nodes.SoftwareComponent.Logstash: + derived_from: tosca.nodes.SoftwareComponent + requirements: + - search_endpoint: + capability: tosca.capabilities.Endpoint + node: tosca.nodes.SoftwareComponent.Elasticsearch + relationship: + type: tosca.relationships.ConnectsTo + interfaces: + Configure: + pre_configure_source: + inputs: + elasticsearch_ip: + type: string + capabilities: + log_endpoint: + type: tosca.capabilities.Endpoint diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/paypalpizzastore_nodejs_app.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/paypalpizzastore_nodejs_app.yaml new file mode 100644 index 0000000..d62c4c1 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/paypalpizzastore_nodejs_app.yaml @@ -0,0 +1,29 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + Pizza store app that allows you to explore the features provided by PayPal's REST APIs. + More detail can be found at https://github.com/paypal/rest-api-sample-app-nodejs/ + +node_types: + tosca.nodes.WebApplication.PayPalPizzaStore: + derived_from: tosca.nodes.WebApplication + properties: + github_url: + required: no + type: string + description: location of the application on the github. + default: https://github.com/sample.git + requirements: + #WebApplication inherits Computer, so host implied. + - database_connection: + capability: tosca.capabilities.Endpoint.Database + node: tosca.nodes.Database + relationship: tosca.relationships.ConnectsTo + interfaces: + Standard: + configure: + inputs: + github_url: + type: string + mongodb_ip: + type: string diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/rsyslog.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/rsyslog.yaml new file mode 100644 index 0000000..4614ee7 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/rsyslog.yaml @@ -0,0 +1,13 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + RSYSLOG is the Rocket-fast SYStem for LOG processing. + +node_types: + tosca.nodes.SoftwareComponent.Rsyslog: + derived_from: tosca.nodes.SoftwareComponent + requirements: + - log_endpoint: + capability: tosca.capabilities.Endpoint + node: tosca.nodes.SoftwareComponent.Logstash + relationship: tosca.relationships.ConnectsTo diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/wordpress.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/wordpress.yaml new file mode 100644 index 0000000..5899ed9 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/wordpress.yaml @@ -0,0 +1,19 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +node_types: + tosca.nodes.WebApplication.WordPress: + derived_from: tosca.nodes.WebApplication + requirements: + - database_endpoint: + capability: tosca.capabilities.Endpoint.Database + node: tosca.nodes.Database + relationship: tosca.relationships.ConnectsTo + interfaces: + Standard: + inputs: + wp_db_name: + type: string + wp_db_user: + type: string + wp_db_password: + type: string diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_elk.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_elk.yaml new file mode 100644 index 0000000..daa725c --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_elk.yaml @@ -0,0 +1,555 @@ +heat_template_version: 2013-05-23 + +description: > + This TOSCA simple profile deploys nodejs, mongodb, elasticsearch, logstash and + kibana each on a separate server with monitoring enabled for nodejs server where + a sample nodejs application is running. The rsyslog and collectd are installed + on a nodejs server. + +parameters: + github_url: + type: string + description: The URL to download nodejs. + default: http://github.com/paypal/rest-api-sample-app-nodejs.git + + my_cpus: + type: number + description: Number of CPUs for the server. + default: 4 + constraints: + - allowed_values: + - 1 + - 2 + - 4 + - 8 + +resources: + + nodejs_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: nodejs_create_config + server: + get_resource: app_server + + nodejs_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: nodejs/create.sh + group: script + + paypal_pizzastore_configure_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: paypal_pizzastore_configure_config + input_values: + github_url: http://github.com/paypal/rest-api-sample-app-nodejs.git + mongodb_ip: + get_attr: + - mongo_server + - networks + - private + - 0 + server: + get_resource: app_server + depends_on: + - nodejs_create_deploy + - mongo_db_create_deploy + + paypal_pizzastore_configure_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: nodejs/config.sh + group: script + + paypal_pizzastore_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: paypal_pizzastore_start_config + server: + get_resource: app_server + depends_on: + - paypal_pizzastore_configure_deploy + + paypal_pizzastore_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: nodejs/start.sh + group: script + + + mongo_dbms_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: mongo_dbms_create_config + server: + get_resource: mongo_server + + mongo_dbms_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: mongodb/create.sh + group: script + + mongo_dbms_configure_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: mongo_dbms_configure_config + input_values: + mongodb_ip: + get_attr: + - mongo_server + - networks + - private + - 0 + server: + get_resource: mongo_server + depends_on: + - mongo_dbms_create_deploy + + mongo_dbms_configure_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: mongodb/config.sh + group: script + + mongo_dbms_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: mongo_dbms_start_config + server: + get_resource: mongo_server + depends_on: + - mongo_dbms_configure_deploy + + mongo_dbms_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: mongodb/start.sh + group: script + + mongo_db_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: mongo_db_create_config + server: + get_resource: mongo_server + depends_on: + - mongo_dbms_start_deploy + + mongo_db_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: mongodb/create_database.sh + group: script + + + app_collectd_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: app_collectd_create_config + server: + get_resource: app_server + depends_on: + - logstash_start_deploy + + app_collectd_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: collectd/create.sh + group: script + + app_collectd_configure_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: app_collectd_configure_config + input_values: + logstash_ip: + get_attr: + - logstash_server + - networks + - private + - 0 + server: + get_resource: app_server + depends_on: + - app_collectd_create_deploy + + app_collectd_configure_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: collectd/config.py + group: script + + app_collectd_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: app_collectd_start_config + server: + get_resource: app_server + depends_on: + - app_collectd_configure_deploy + + app_collectd_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: collectd/start.sh + group: script + + app_collectd_logstash_connect_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: app_collectd_logstash_connect_config + server: + get_resource: logstash_server + depends_on: + - logstash_create_deploy + + app_collectd_logstash_connect_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: logstash/configure_collectd.py + group: script + + + app_rsyslog_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: app_rsyslog_create_config + server: + get_resource: app_server + depends_on: + - logstash_start_deploy + + app_rsyslog_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: rsyslog/create.sh + group: script + + app_rsyslog_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: app_rsyslog_start_config + server: + get_resource: app_server + depends_on: + - app_rsyslog_configure_deploy + + app_rsyslog_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: rsyslog/start.sh + group: script + + app_rsyslog_configure_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: app_rsyslog_configure_config + input_values: + logstash_ip: + get_attr: + - logstash_server + - networks + - private + - 0 + server: + get_resource: app_server + depends_on: + - app_rsyslog_create_deploy + + app_rsyslog_configure_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: rsyslog/config.sh + group: script + + app_rsyslog_logstash_connect_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: app_rsyslog_logstash_connect_config + server: + get_resource: logstash_server + depends_on: + - logstash_create_deploy + + app_rsyslog_logstash_connect_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: logstash/configure_rsyslog.py + group: script + + + logstash_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: logstash_create_config + server: + get_resource: logstash_server + depends_on: + - elasticsearch_start_deploy + + logstash_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: logstash/create.sh + group: script + + logstash_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: logstash_start_config + server: + get_resource: logstash_server + depends_on: + - logstash_create_deploy + + logstash_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: logstash/start.sh + group: script + + logstash_elasticsearch_connect_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: logstash_elasticsearch_connect_config + input_values: + elasticsearch_ip: + get_attr: + - elasticsearch_server + - networks + - private + - 0 + server: + get_resource: logstash_server + depends_on: + - logstash_create_deploy + + logstash_elasticsearch_connect_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: logstash/configure_elasticsearch.py + group: script + + + elasticsearch_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: elasticsearch_create_config + server: + get_resource: elasticsearch_server + + elasticsearch_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: elasticsearch/create.sh + group: script + + elasticsearch_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: elasticsearch_start_config + server: + get_resource: elasticsearch_server + depends_on: + - elasticsearch_create_deploy + + elasticsearch_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: elasticsearch/start.sh + group: script + + + kibana_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: kibana_create_config + server: + get_resource: kibana_server + depends_on: + - elasticsearch_start_deploy + + kibana_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: kibana/create.sh + group: script + + kibana_configure_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: kibana_configure_config + input_values: + elasticsearch_ip: + get_attr: + - elasticsearch_server + - networks + - private + - 0 + kibana_ip: + get_attr: + - kibana_server + - networks + - private + - 0 + server: + get_resource: kibana_server + depends_on: + - kibana_create_deploy + + kibana_configure_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: kibana/config.sh + group: script + + kibana_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: kibana_start_config + server: + get_resource: kibana_server + depends_on: + - kibana_configure_deploy + + kibana_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: kibana/start.sh + group: script + + + app_server: + type: OS::Nova::Server + properties: + flavor: m1.large + image: ubuntu-software-config-os-init + key_name: userkey + user_data_format: SOFTWARE_CONFIG + + mongo_server: + type: OS::Nova::Server + properties: + flavor: m1.large + image: ubuntu-software-config-os-init + key_name: userkey + user_data_format: SOFTWARE_CONFIG + + logstash_server: + type: OS::Nova::Server + properties: + flavor: m1.large + image: ubuntu-software-config-os-init + key_name: userkey + user_data_format: SOFTWARE_CONFIG + + elasticsearch_server: + type: OS::Nova::Server + properties: + flavor: m1.large + image: ubuntu-software-config-os-init + key_name: userkey + user_data_format: SOFTWARE_CONFIG + + kibana_server: + type: OS::Nova::Server + properties: + flavor: m1.large + image: ubuntu-software-config-os-init + key_name: userkey + user_data_format: SOFTWARE_CONFIG + +outputs: + nodejs_url: + description: URL for the nodejs server, http://:3000 + value: + get_attr: + - app_server + - networks + - private + - 0 + + mongodb_url: + description: URL for the mongodb server. + value: + get_attr: + - mongo_server + - networks + - private + - 0 + + logstash_url: + description: URL for the logstash server. + value: + get_attr: + - logstash_server + - networks + - private + - 0 + + elasticsearch_url: + description: URL for the elasticsearch server. + value: + get_attr: + - elasticsearch_server + - networks + - private + - 0 + + kibana_url: + description: URL for the kibana server. + value: + get_attr: + - kibana_server + - networks + - private + - 0 + diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_elk_from_csar.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_elk_from_csar.yaml new file mode 100644 index 0000000..27427ba --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_elk_from_csar.yaml @@ -0,0 +1,555 @@ +heat_template_version: 2013-05-23 + +description: > + This TOSCA simple profile deploys nodejs, mongodb, elasticsearch, logstash and + kibana each on a separate server with monitoring enabled for nodejs server where + a sample nodejs application is running. The rsyslog and collectd are installed + on a nodejs server. + +parameters: + github_url: + type: string + description: The URL to download nodejs. + default: http://github.com/paypal/rest-api-sample-app-nodejs.git + + my_cpus: + type: number + description: Number of CPUs for the server. + default: 4 + constraints: + - allowed_values: + - 1 + - 2 + - 4 + - 8 + +resources: + + nodejs_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: nodejs_create_config + server: + get_resource: app_server + + nodejs_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/nodejs/create.sh + group: script + + paypal_pizzastore_configure_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: paypal_pizzastore_configure_config + input_values: + github_url: http://github.com/paypal/rest-api-sample-app-nodejs.git + mongodb_ip: + get_attr: + - mongo_server + - networks + - private + - 0 + server: + get_resource: app_server + depends_on: + - nodejs_create_deploy + - mongo_db_create_deploy + + paypal_pizzastore_configure_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/nodejs/config.sh + group: script + + paypal_pizzastore_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: paypal_pizzastore_start_config + server: + get_resource: app_server + depends_on: + - paypal_pizzastore_configure_deploy + + paypal_pizzastore_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/nodejs/start.sh + group: script + + + mongo_dbms_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: mongo_dbms_create_config + server: + get_resource: mongo_server + + mongo_dbms_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/mongodb/create.sh + group: script + + mongo_dbms_configure_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: mongo_dbms_configure_config + input_values: + mongodb_ip: + get_attr: + - mongo_server + - networks + - private + - 0 + server: + get_resource: mongo_server + depends_on: + - mongo_dbms_create_deploy + + mongo_dbms_configure_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/mongodb/config.sh + group: script + + mongo_dbms_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: mongo_dbms_start_config + server: + get_resource: mongo_server + depends_on: + - mongo_dbms_configure_deploy + + mongo_dbms_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/mongodb/start.sh + group: script + + mongo_db_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: mongo_db_create_config + server: + get_resource: mongo_server + depends_on: + - mongo_dbms_start_deploy + + mongo_db_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/mongodb/create_database.sh + group: script + + + app_collectd_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: app_collectd_create_config + server: + get_resource: app_server + depends_on: + - logstash_start_deploy + + app_collectd_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/collectd/create.sh + group: script + + app_collectd_configure_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: app_collectd_configure_config + input_values: + logstash_ip: + get_attr: + - logstash_server + - networks + - private + - 0 + server: + get_resource: app_server + depends_on: + - app_collectd_create_deploy + + app_collectd_configure_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Python/collectd/config.py + group: script + + app_collectd_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: app_collectd_start_config + server: + get_resource: app_server + depends_on: + - app_collectd_configure_deploy + + app_collectd_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/collectd/start.sh + group: script + + app_collectd_logstash_connect_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: app_collectd_logstash_connect_config + server: + get_resource: logstash_server + depends_on: + - logstash_create_deploy + + app_collectd_logstash_connect_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Python/logstash/configure_collectd.py + group: script + + + app_rsyslog_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: app_rsyslog_create_config + server: + get_resource: app_server + depends_on: + - logstash_start_deploy + + app_rsyslog_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/rsyslog/create.sh + group: script + + app_rsyslog_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: app_rsyslog_start_config + server: + get_resource: app_server + depends_on: + - app_rsyslog_configure_deploy + + app_rsyslog_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/rsyslog/start.sh + group: script + + app_rsyslog_configure_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: app_rsyslog_configure_config + input_values: + logstash_ip: + get_attr: + - logstash_server + - networks + - private + - 0 + server: + get_resource: app_server + depends_on: + - app_rsyslog_create_deploy + + app_rsyslog_configure_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/rsyslog/config.sh + group: script + + app_rsyslog_logstash_connect_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: app_rsyslog_logstash_connect_config + server: + get_resource: logstash_server + depends_on: + - logstash_create_deploy + + app_rsyslog_logstash_connect_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Python/logstash/configure_rsyslog.py + group: script + + + logstash_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: logstash_create_config + server: + get_resource: logstash_server + depends_on: + - elasticsearch_start_deploy + + logstash_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/logstash/create.sh + group: script + + logstash_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: logstash_start_config + server: + get_resource: logstash_server + depends_on: + - logstash_create_deploy + + logstash_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/logstash/start.sh + group: script + + logstash_elasticsearch_connect_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: logstash_elasticsearch_connect_config + input_values: + elasticsearch_ip: + get_attr: + - elasticsearch_server + - networks + - private + - 0 + server: + get_resource: logstash_server + depends_on: + - logstash_create_deploy + + logstash_elasticsearch_connect_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Python/logstash/configure_elasticsearch.py + group: script + + + elasticsearch_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: elasticsearch_create_config + server: + get_resource: elasticsearch_server + + elasticsearch_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/elasticsearch/create.sh + group: script + + elasticsearch_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: elasticsearch_start_config + server: + get_resource: elasticsearch_server + depends_on: + - elasticsearch_create_deploy + + elasticsearch_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/elasticsearch/start.sh + group: script + + + kibana_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: kibana_create_config + server: + get_resource: kibana_server + depends_on: + - elasticsearch_start_deploy + + kibana_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/kibana/create.sh + group: script + + kibana_configure_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: kibana_configure_config + input_values: + elasticsearch_ip: + get_attr: + - elasticsearch_server + - networks + - private + - 0 + kibana_ip: + get_attr: + - kibana_server + - networks + - private + - 0 + server: + get_resource: kibana_server + depends_on: + - kibana_create_deploy + + kibana_configure_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/kibana/config.sh + group: script + + kibana_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: kibana_start_config + server: + get_resource: kibana_server + depends_on: + - kibana_configure_deploy + + kibana_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/kibana/start.sh + group: script + + + app_server: + type: OS::Nova::Server + properties: + flavor: m1.large + image: ubuntu-software-config-os-init + key_name: userkey + user_data_format: SOFTWARE_CONFIG + + mongo_server: + type: OS::Nova::Server + properties: + flavor: m1.large + image: ubuntu-software-config-os-init + key_name: userkey + user_data_format: SOFTWARE_CONFIG + + logstash_server: + type: OS::Nova::Server + properties: + flavor: m1.large + image: ubuntu-software-config-os-init + key_name: userkey + user_data_format: SOFTWARE_CONFIG + + elasticsearch_server: + type: OS::Nova::Server + properties: + flavor: m1.large + image: ubuntu-software-config-os-init + key_name: userkey + user_data_format: SOFTWARE_CONFIG + + kibana_server: + type: OS::Nova::Server + properties: + flavor: m1.large + image: ubuntu-software-config-os-init + key_name: userkey + user_data_format: SOFTWARE_CONFIG + +outputs: + nodejs_url: + description: URL for the nodejs server, http://:3000 + value: + get_attr: + - app_server + - networks + - private + - 0 + + mongodb_url: + description: URL for the mongodb server. + value: + get_attr: + - mongo_server + - networks + - private + - 0 + + logstash_url: + description: URL for the logstash server. + value: + get_attr: + - logstash_server + - networks + - private + - 0 + + elasticsearch_url: + description: URL for the elasticsearch server. + value: + get_attr: + - elasticsearch_server + - networks + - private + - 0 + + kibana_url: + description: URL for the kibana server. + value: + get_attr: + - kibana_server + - networks + - private + - 0 + diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_hello_world.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_hello_world.yaml new file mode 100644 index 0000000..60e39dc --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_hello_world.yaml @@ -0,0 +1,15 @@ +heat_template_version: 2013-05-23 + +description: > + Template for deploying a single server with predefined properties. + +parameters: {} +resources: + my_server: + type: OS::Nova::Server + properties: + flavor: m1.medium + image: rhel-6.5-test-image + key_name: userkey + user_data_format: SOFTWARE_CONFIG +outputs: {} \ No newline at end of file diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_host_assignment.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_host_assignment.yaml new file mode 100644 index 0000000..e6172e1 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_host_assignment.yaml @@ -0,0 +1,137 @@ +heat_template_version: 2013-05-23 + +description: > + A template to test host assignment for translated hot resources. + It makes sure if a resource depends on multiple hosts only the + one with the "HostedOn" relationship is picked as the host. In + this template, the translated resource 'app_collectd_create_deploy' + would depend on 'logstash_server' and 'app_server'. But it would + have "HostedOn" relationship with 'app_server', and that server + would be its host. + +parameters: {} +resources: + app_server: + type: OS::Nova::Server + properties: + flavor: m1.medium + image: ubuntu-software-config-os-init + key_name: userkey + user_data_format: SOFTWARE_CONFIG + + logstash_server: + type: OS::Nova::Server + properties: + flavor: m1.medium + image: ubuntu-software-config-os-init + key_name: userkey + user_data_format: SOFTWARE_CONFIG + + app_collectd_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: collectd/create.sh + group: script + + app_collectd_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: app_collectd_create_config + server: + get_resource: app_server + depends_on: + - logstash_start_deploy + + app_collectd_configure_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: collectd/config.py + group: script + + app_collectd_configure_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: app_collectd_configure_config + input_values: + logstash_ip: + get_attr: + - logstash_server + - networks + - private + - 0 + server: + get_resource: app_server + depends_on: + - app_collectd_create_deploy + + app_collectd_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: collectd/start.sh + group: script + + app_collectd_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: app_collectd_start_config + server: + get_resource: app_server + depends_on: + - app_collectd_configure_deploy + + logstash_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: logstash/create.sh + group: script + + logstash_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: logstash_create_config + server: + get_resource: logstash_server + + logstash_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: logstash/start.sh + group: script + + logstash_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: logstash_start_config + server: + get_resource: logstash_server + depends_on: + - logstash_create_deploy + + app_collectd_logstash_connect_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: logstash/configure_collectd.py + group: script + + app_collectd_logstash_connect_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: app_collectd_logstash_connect_config + server: + get_resource: logstash_server + depends_on: + - logstash_create_deploy + +outputs: {} diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_nodejs_mongodb_two_instances.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_nodejs_mongodb_two_instances.yaml new file mode 100644 index 0000000..70711c8 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_nodejs_mongodb_two_instances.yaml @@ -0,0 +1,187 @@ +heat_template_version: 2013-05-23 + +description: > + TOSCA simple profile with nodejs and mongodb. + +parameters: + github_url: + type: string + description: The URL to download nodejs. + default: http://github.com/paypal/rest-api-sample-app-nodejs.git + + my_cpus: + type: number + description: Number of CPUs for the server. + default: 4 + constraints: + - allowed_values: + - 1 + - 2 + - 4 + - 8 + +resources: + mongo_dbms_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: mongo_dbms_create_config + server: + get_resource: mongo_server + + mongo_dbms_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: mongodb/create.sh + group: script + + mongo_dbms_configure_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: mongo_dbms_configure_config + input_values: + mongodb_ip: + get_attr: + - mongo_server + - networks + - private + - 0 + server: + get_resource: mongo_server + depends_on: + - mongo_dbms_create_deploy + + mongo_dbms_configure_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: mongodb/config.sh + group: script + + mongo_dbms_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: mongo_dbms_start_config + server: + get_resource: mongo_server + depends_on: + - mongo_dbms_configure_deploy + + mongo_dbms_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: mongodb/start.sh + group: script + + mongo_db_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: mongo_db_create_config + server: + get_resource: mongo_server + depends_on: + - mongo_dbms_start_deploy + + mongo_db_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: mongodb/create_database.sh + group: script + + nodejs_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: nodejs_create_config + server: + get_resource: app_server + + nodejs_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: nodejs/create.sh + group: script + + paypal_pizzastore_configure_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: paypal_pizzastore_configure_config + input_values: + github_url: http://github.com/paypal/rest-api-sample-app-nodejs.git + mongodb_ip: + get_attr: + - mongo_server + - networks + - private + - 0 + server: + get_resource: app_server + depends_on: + - mongo_db_create_deploy + - nodejs_create_deploy + + paypal_pizzastore_configure_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: nodejs/config.sh + group: script + + paypal_pizzastore_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: paypal_pizzastore_start_config + server: + get_resource: app_server + depends_on: + - paypal_pizzastore_configure_deploy + + paypal_pizzastore_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: nodejs/start.sh + group: script + + mongo_server: + type: OS::Nova::Server + properties: + flavor: m1.medium + image: ubuntu-software-config-os-init + key_name: userkey + user_data_format: SOFTWARE_CONFIG + + app_server: + type: OS::Nova::Server + properties: + flavor: m1.medium + image: ubuntu-software-config-os-init + key_name: userkey + user_data_format: SOFTWARE_CONFIG + +outputs: + mongodb_url: + description: URL for the mongodb server. + value: + get_attr: + - mongo_server + - networks + - private + - 0 + nodejs_url: + description: URL for the nodejs server, http://:3000 + value: + get_attr: + - app_server + - networks + - private + - 0 diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_single_instance_wordpress.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_single_instance_wordpress.yaml new file mode 100644 index 0000000..3fa1f62 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_single_instance_wordpress.yaml @@ -0,0 +1,202 @@ +heat_template_version: 2013-05-23 + +description: > + TOSCA simple profile with wordpress, web server and mysql on the same server. + +parameters: + db_name: + type: string + description: The name of the database. + default: wordpress + db_user: + type: string + description: The user name of the DB user. + default: wp_user + db_pwd: + type: string + description: The WordPress database admin account password. + default: wp_pass + cpus: + type: number + description: Number of CPUs for the server. + default: 8 + constraints: + - allowed_values: + - 1 + - 2 + - 4 + - 8 + db_root_pwd: + type: string + description: Root password for MySQL. + default: passw0rd + db_port: + type: number + description: Port for the MySQL database. + default: 3366 + +resources: + + mysql_dbms_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: mysql/mysql_dbms_install.sh + group: script + + mysql_dbms_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: mysql_dbms_create_config + input_values: + db_root_password: passw0rd + server: + get_resource: server + + mysql_dbms_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: mysql/mysql_dbms_start.sh + group: script + + mysql_dbms_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: mysql_dbms_start_config + server: + get_resource: server + depends_on: + - mysql_dbms_configure_deploy + + mysql_dbms_configure_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: mysql/mysql_dbms_configure.sh + group: script + + mysql_dbms_configure_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: mysql_dbms_configure_config + input_values: + db_port: 3366 + server: + get_resource: server + depends_on: + - mysql_dbms_create_deploy + + mysql_database_configure_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: mysql/mysql_database_configure.sh + group: script + + mysql_database_configure_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: mysql_database_configure_config + input_values: + db_name: wordpress + db_password: wp_pass + db_root_password: passw0rd + db_user: wp_user + server: + get_resource: server + depends_on: + - mysql_dbms_start_deploy + + webserver_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: webserver/webserver_install.sh + group: script + + webserver_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: webserver_create_config + server: + get_resource: server + + webserver_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: webserver/webserver_start.sh + group: script + + webserver_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: webserver_start_config + server: + get_resource: server + depends_on: + - webserver_create_deploy + + wordpress_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: wordpress/wordpress_install.sh + group: script + + wordpress_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: wordpress_create_config + server: + get_resource: server + depends_on: + - webserver_start_deploy + - mysql_database_configure_deploy + + wordpress_configure_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: wordpress/wordpress_configure.sh + group: script + + wordpress_configure_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: wordpress_configure_config + input_values: + wp_db_name: wordpress + wp_db_password: wp_pass + wp_db_user: wp_user + server: + get_resource: server + depends_on: + - wordpress_create_deploy + + server: + type: OS::Nova::Server + properties: + flavor: m1.xlarge + image: ubuntu-software-config-os-init + key_name: userkey + user_data_format: SOFTWARE_CONFIG + +outputs: + website_url: + description: URL for Wordpress wiki. + value: + get_attr: + - server + - networks + - private + - 0 diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_single_instance_wordpress_from_csar.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_single_instance_wordpress_from_csar.yaml new file mode 100644 index 0000000..60b043b --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_single_instance_wordpress_from_csar.yaml @@ -0,0 +1,200 @@ +heat_template_version: 2013-05-23 + +description: > + TOSCA simple profile with wordpress, web server and mysql on the same server. + +parameters: + db_name: + type: string + description: The name of the database. + default: wordpress + db_user: + type: string + description: The user name of the DB user. + default: wp_user + db_pwd: + type: string + description: The WordPress database admin account password. + default: wp_pass + cpus: + type: number + description: Number of CPUs for the server. + default: 8 + constraints: + - allowed_values: + - 1 + - 2 + - 4 + - 8 + db_root_pwd: + type: string + description: Root password for MySQL. + default: passw0rd + db_port: + type: number + description: Port for the MySQL database. + default: 3366 + +resources: + + mysql_dbms_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/MYSQLDBMS/install.sh + group: script + + mysql_dbms_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: mysql_dbms_create_config + server: + get_resource: server + + mysql_dbms_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/MYSQLDBMS/start.sh + group: script + + mysql_dbms_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: mysql_dbms_start_config + server: + get_resource: server + depends_on: + - mysql_dbms_configure_deploy + + mysql_dbms_configure_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/MYSQLDBMS/configure.sh + group: script + + mysql_dbms_configure_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: mysql_dbms_configure_config + input_values: + root_password: passw0rd + server: + get_resource: server + depends_on: + - mysql_dbms_create_deploy + + mysql_database_configure_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/MYSQLDatabase/configure.sh + group: script + + mysql_database_configure_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: mysql_database_configure_config + input_values: + db_name: wordpress + db_password: wp_pass + db_root_password: passw0rd + db_user: wp_user + server: + get_resource: server + depends_on: + - mysql_dbms_start_deploy + + webserver_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/WebServer/install.sh + group: script + + webserver_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: webserver_create_config + server: + get_resource: server + + webserver_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/WebServer/start.sh + group: script + + webserver_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: webserver_start_config + server: + get_resource: server + depends_on: + - webserver_create_deploy + + wordpress_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/WordPress/install.sh + group: script + + wordpress_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: wordpress_create_config + server: + get_resource: server + depends_on: + - webserver_start_deploy + - mysql_database_configure_deploy + + wordpress_configure_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: ../Scripts/WordPress/configure.sh + group: script + + wordpress_configure_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: wordpress_configure_config + input_values: + wp_db_name: wordpress + wp_db_password: wp_pass + wp_db_user: wp_user + server: + get_resource: server + depends_on: + - wordpress_create_deploy + + server: + type: OS::Nova::Server + properties: + flavor: m1.xlarge + image: fedora-amd64-heat-config + key_name: userkey + user_data_format: SOFTWARE_CONFIG + +outputs: + website_url: + description: IP address for Wordpress wiki. + value: + get_attr: + - server + - networks + - private + - 0 diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_single_object_store.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_single_object_store.yaml new file mode 100644 index 0000000..91491e3 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_single_object_store.yaml @@ -0,0 +1,21 @@ +heat_template_version: 2013-05-23 + +description: > + Tosca template for creating an object storage service. + +parameters: + objectstore_name: + type: string + default: myobjstore + +resources: + obj_store_server: + type: OS::Swift::Container + properties: + X-Container-Meta: + Quota-Bytes: 1000000000 + X-Container-Read: ".r:*" + name: + get_param: objectstore_name + +outputs: {} diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_single_server.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_single_server.yaml new file mode 100644 index 0000000..631f509 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_single_server.yaml @@ -0,0 +1,37 @@ +heat_template_version: 2013-05-23 + +description: > + TOSCA simple profile that just defines a single compute instance and selects a + (guest) host Operating System from the Compute node's properties. Note, this + example does not include default values on inputs properties. + +parameters: + cpus: + type: number + description: Number of CPUs for the server. + default: 1 + constraints: + - allowed_values: + - 1 + - 2 + - 4 + - 8 + +resources: + my_server: + type: OS::Nova::Server + properties: + flavor: m1.small + image: ubuntu-12.04-software-config-os-init + key_name: userkey + user_data_format: SOFTWARE_CONFIG + +outputs: + private_ip: + description: The private IP address of the deployed server instance. + value: + get_attr: + - my_server + - networks + - private + - 0 diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_single_server_with_defaults_with_input.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_single_server_with_defaults_with_input.yaml new file mode 100644 index 0000000..deb4fab --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_single_server_with_defaults_with_input.yaml @@ -0,0 +1,37 @@ +heat_template_version: 2013-05-23 + +description: > + TOSCA simple profile that just defines a single compute instance and selects a + (guest) host Operating System from the Compute node's properties. Note, this + example includes default values on inputs properties. + +parameters: + cpus: + type: number + description: Number of CPUs for the server. + default: 1 + constraints: + - allowed_values: + - 1 + - 2 + - 4 + - 8 + +resources: + my_server: + type: OS::Nova::Server + properties: + flavor: m1.small + image: ubuntu-12.04-software-config-os-init + key_name: userkey + user_data_format: SOFTWARE_CONFIG + +outputs: + private_ip: + description: The private IP address of the deployed server instance. + value: + get_attr: + - my_server + - networks + - private + - 0 diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_single_server_with_defaults_without_input.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_single_server_with_defaults_without_input.yaml new file mode 100644 index 0000000..4aa7d1f --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_single_server_with_defaults_without_input.yaml @@ -0,0 +1,37 @@ +heat_template_version: 2013-05-23 + +description: > + TOSCA simple profile that just defines a single compute instance and selects a + (guest) host Operating System from the Compute node's properties. Note, this + example includes default values on inputs properties. + +parameters: + cpus: + type: number + description: Number of CPUs for the server. + default: 4 + constraints: + - allowed_values: + - 1 + - 2 + - 4 + - 8 + +resources: + my_server: + type: OS::Nova::Server + properties: + flavor: m1.large + image: ubuntu-12.04-software-config-os-init + key_name: userkey + user_data_format: SOFTWARE_CONFIG + +outputs: + private_ip: + description: The private IP address of the deployed server instance. + value: + get_attr: + - my_server + - networks + - private + - 0 diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_software_component.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_software_component.yaml new file mode 100644 index 0000000..d7d3cb8 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_software_component.yaml @@ -0,0 +1,59 @@ +heat_template_version: 2013-05-23 + +description: > + TOSCA simple profile with a software component. + +parameters: + cpus: + type: number + description: Number of CPUs for the server. + default: 1 + constraints: + - allowed_values: + - 1 + - 2 + - 4 + - 8 + +resources: + server: + type: OS::Nova::Server + properties: + flavor: m1.small + image: ubuntu-software-config-os-init + key_name: userkey + user_data_format: SOFTWARE_CONFIG + + my_software_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: my_software_create_config + server: + get_resource: server + + my_software_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: software_install.sh + group: script + + my_software_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: my_software_start_config + server: + get_resource: server + depends_on: + - my_software_create_deploy + + my_software_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: software_start.sh + group: script + +outputs: {} diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_web_application.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_web_application.yaml new file mode 100644 index 0000000..9ab5546 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/hot_web_application.yaml @@ -0,0 +1,100 @@ +heat_template_version: 2013-05-23 + +description: > + TOSCA simple profile with a web application. + +parameters: + context_root: + type: string + description: Context root for installing the application. + default: my_web_app + + cpus: + type: number + description: Number of CPUs for the server. + default: 2 + constraints: + - allowed_values: + - 1 + - 2 + - 4 + - 8 + +resources: + server: + type: OS::Nova::Server + properties: + flavor: m1.medium + image: ubuntu-software-config-os-init + key_name: userkey + user_data_format: SOFTWARE_CONFIG + + web_server_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: web_server_create_config + server: + get_resource: server + + web_server_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: web_server_install.sh + group: script + + web_server_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: web_server_start_config + server: + get_resource: server + depends_on: + - web_server_create_deploy + + web_server_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: web_server_start.sh + group: script + + web_app_create_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: web_app_create_config + input_values: + context_root: my_web_app + server: + get_resource: server + depends_on: + - web_server_start_deploy + + web_app_create_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: web_app_install.sh + group: script + + web_app_start_deploy: + type: OS::Heat::SoftwareDeployment + properties: + config: + get_resource: web_app_start_config + server: + get_resource: server + depends_on: + - web_app_create_deploy + + web_app_start_config: + type: OS::Heat::SoftwareConfig + properties: + config: + get_file: web_app_start.sh + group: script + +outputs: {} diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/network/hot_one_server_one_network.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/network/hot_one_server_one_network.yaml new file mode 100644 index 0000000..6267a33 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/network/hot_one_server_one_network.yaml @@ -0,0 +1,45 @@ +heat_template_version: 2013-05-23 + +description: > + TOSCA simple profile with 1 server bound to a new network + +parameters: + network_name: + type: string + description: Network name + default: private_net + +resources: + my_server: + type: OS::Nova::Server + properties: + flavor: m1.small + image: cirros-0.3.2-x86_64-uec + key_name: userkey + networks: + - port: { get_resource: my_port } + user_data_format: SOFTWARE_CONFIG + + my_network: + type: OS::Neutron::Net + properties: + name: + get_param: network_name + + my_network_subnet: + type: OS::Neutron::Subnet + properties: + allocation_pools: + - end: 192.168.0.200 + start: 192.168.0.50 + cidr: 192.168.0.0/24 + gateway_ip: 192.168.0.1 + ip_version: 4 + network: { get_resource: my_network } + + my_port: + type: OS::Neutron::Port + properties: + network: { get_resource: my_network } + +outputs: {} diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/network/hot_one_server_three_networks.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/network/hot_one_server_three_networks.yaml new file mode 100644 index 0000000..0696ba6 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/network/hot_one_server_three_networks.yaml @@ -0,0 +1,72 @@ +heat_template_version: 2013-05-23 + +description: > + TOSCA simple profile with 1 server bound to 3 networks + +parameters: {} + +resources: + my_server: + type: OS::Nova::Server + properties: + flavor: m1.small + image: cirros-0.3.2-x86_64-uec + key_name: userkey + networks: + - port: { get_resource: my_port1 } + - port: { get_resource: my_port2 } + - port: { get_resource: my_port3 } + user_data_format: SOFTWARE_CONFIG + + my_network1: + type: OS::Neutron::Net + properties: + name: net1 + + my_network2: + type: OS::Neutron::Net + properties: + name: net2 + + my_network3: + type: OS::Neutron::Net + properties: + name: net3 + + my_network1_subnet: + type: OS::Neutron::Subnet + properties: + cidr: 192.168.1.0/24 + ip_version: 4 + network: { get_resource: my_network1 } + + my_network2_subnet: + type: OS::Neutron::Subnet + properties: + cidr: 192.168.2.0/24 + ip_version: 4 + network: { get_resource: my_network2 } + + my_network3_subnet: + type: OS::Neutron::Subnet + properties: + cidr: 192.168.3.0/24 + ip_version: 4 + network: { get_resource: my_network3 } + + my_port1: + type: OS::Neutron::Port + properties: + network: { get_resource: my_network1 } + + my_port2: + type: OS::Neutron::Port + properties: + network: { get_resource: my_network2 } + + my_port3: + type: OS::Neutron::Port + properties: + network: { get_resource: my_network3 } + +outputs: {} diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/network/hot_server_on_existing_network.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/network/hot_server_on_existing_network.yaml new file mode 100644 index 0000000..7d70d05 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/network/hot_server_on_existing_network.yaml @@ -0,0 +1,28 @@ +heat_template_version: 2013-05-23 + +description: > + TOSCA simple profile with 1 server bound to an existing network + +parameters: + network_name: + type: string + description: Network name + default: private_net + +resources: + my_server: + type: OS::Nova::Server + properties: + flavor: m1.small + image: cirros-0.3.2-x86_64-uec + key_name: userkey + networks: + - port: { get_resource: my_port } + user_data_format: SOFTWARE_CONFIG + + my_port: + type: OS::Neutron::Port + properties: + network: {get_param: network_name} + +outputs: {} diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/network/hot_two_servers_one_network.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/network/hot_two_servers_one_network.yaml new file mode 100644 index 0000000..15224ea --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/network/hot_two_servers_one_network.yaml @@ -0,0 +1,74 @@ +heat_template_version: 2013-05-23 + +description: > + TOSCA simple profile with 2 servers bound to the 1 network + +parameters: + network_name: + type: string + description: Network name + default: my_private_net + network_cidr: + type: string + description: CIDR for the network + default: 10.0.0.0/24 + network_start_ip: + type: string + description: Start IP for the allocation pool + default: 10.0.0.100 + network_end_ip: + type: string + description: End IP for the allocation pool + default: 10.0.0.150 + +resources: + my_server: + type: OS::Nova::Server + properties: + flavor: m1.small + image: cirros-0.3.2-x86_64-uec + key_name: userkey + networks: + - port: { get_resource: my_port } + user_data_format: SOFTWARE_CONFIG + + my_server2: + type: OS::Nova::Server + properties: + flavor: m1.small + image: cirros-0.3.2-x86_64-uec + key_name: userkey + networks: + - port: { get_resource: my_port2 } + user_data_format: SOFTWARE_CONFIG + + my_network: + type: OS::Neutron::Net + properties: + name: + get_param: network_name + + my_network_subnet: + type: OS::Neutron::Subnet + properties: + allocation_pools: + - end: + get_param: network_end_ip + start: + get_param: network_start_ip + cidr: + get_param: network_cidr + ip_version: 4 + network: { get_resource: my_network } + + my_port: + type: OS::Neutron::Port + properties: + network: { get_resource: my_network } + + my_port2: + type: OS::Neutron::Port + properties: + network: { get_resource: my_network } + +outputs: {} diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment.yaml new file mode 100644 index 0000000..2a8c233 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment.yaml @@ -0,0 +1,72 @@ +heat_template_version: 2013-05-23 + +description: > + TOSCA simple profile with server and attached block storage using the normative + AttachesTo Relationship Type. + +parameters: + cpus: + type: number + description: Number of CPUs for the server. + default: 1 + constraints: + - allowed_values: + - 1 + - 2 + - 4 + - 8 + storage_location: + type: string + description: Block storage mount point (filesystem path). + default: /dev/vdc + storage_size: + type: number + description: Size of the storage to be created. + default: 2 + storage_snapshot_id: + type: string + description: "Optional identifier for an existing snapshot to use when creating storage." + default: ssid + +resources: + my_server: + type: OS::Nova::Server + properties: + flavor: m1.small + image: fedora-amd64-heat-config + key_name: userkey + user_data_format: SOFTWARE_CONFIG + depends_on: + - my_storage + + my_storage: + type: OS::Cinder::Volume + properties: + size: + get_param: storage_size + snapshot_id: + get_param: storage_snapshot_id + + attachesto_1: + type: OS::Cinder::VolumeAttachment + properties: + instance_uuid: + get_resource: my_server + mountpoint: + get_param: storage_location + volume_id: + get_resource: my_storage + +outputs: + private_ip: + description: The private IP address of the newly created compute instance. + value: + get_attr: + - my_server + - networks + - private + - 0 + volume_id: + description: The volume id of the block storage instance. + value: + get_resource: my_storage diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment_notation1_alt1.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment_notation1_alt1.yaml new file mode 100644 index 0000000..c6f8a4d --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment_notation1_alt1.yaml @@ -0,0 +1,94 @@ +heat_template_version: 2013-05-23 + +description: > + TOSCA simple profile with a Single Block Storage node shared by 2-Tier + Application with custom AttachesTo Type and implied relationships. + +parameters: + cpus: + type: number + description: Number of CPUs for the server. + default: 1 + constraints: + - allowed_values: + - 1 + - 2 + - 4 + - 8 + storage_size: + type: number + description: Size of the storage to be created. + default: 1 + storage_snapshot_id: + type: string + description: Optional identifier for an existing snapshot to use when creating storage. + default: ssid + +resources: + my_storage: + type: OS::Cinder::Volume + properties: + size: + get_param: storage_size + snapshot_id: + get_param: storage_snapshot_id + + my_web_app_tier_1: + type: OS::Nova::Server + properties: + flavor: m1.medium + image: fedora-amd64-heat-config + key_name: userkey + user_data_format: SOFTWARE_CONFIG + depends_on: + - my_storage + + myattachesto_1: + type: OS::Cinder::VolumeAttachment + properties: + instance_uuid: + get_resource: my_web_app_tier_1 + mountpoint: /default_location + volume_id: + get_resource: my_storage + + my_web_app_tier_2: + type: OS::Nova::Server + properties: + flavor: m1.medium + image: fedora-amd64-heat-config + key_name: userkey + user_data_format: SOFTWARE_CONFIG + depends_on: + - my_storage + + myattachesto_2: + type: OS::Cinder::VolumeAttachment + properties: + instance_uuid: + get_resource: my_web_app_tier_2 + mountpoint: /some_other_data_location + volume_id: + get_resource: my_storage + +outputs: + private_ip_1: + description: The private IP address of the applications first tier. + value: + get_attr: + - my_web_app_tier_1 + - networks + - private + - 0 + private_ip_2: + description: The private IP address of the applications second tier. + value: + get_attr: + - my_web_app_tier_2 + - networks + - private + - 0 + volume_id: + description: The volume id of the block storage instance. + value: + get_resource: my_storage diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment_notation1_alt2.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment_notation1_alt2.yaml new file mode 100644 index 0000000..e91ac2e --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment_notation1_alt2.yaml @@ -0,0 +1,94 @@ +heat_template_version: 2013-05-23 + +description: > + TOSCA simple profile with a Single Block Storage node shared by 2-Tier + Application with custom AttachesTo Type and implied relationships. + +parameters: + cpus: + type: number + description: Number of CPUs for the server. + default: 1 + constraints: + - allowed_values: + - 1 + - 2 + - 4 + - 8 + storage_size: + type: number + description: Size of the storage to be created. + default: 1 + storage_snapshot_id: + type: string + description: Optional identifier for an existing snapshot to use when creating storage. + default: ssid + +resources: + my_storage: + type: OS::Cinder::Volume + properties: + size: + get_param: storage_size + snapshot_id: + get_param: storage_snapshot_id + + my_web_app_tier_1: + type: OS::Nova::Server + properties: + flavor: m1.medium + image: fedora-amd64-heat-config + key_name: userkey + user_data_format: SOFTWARE_CONFIG + depends_on: + - my_storage + + myattachesto_2: + type: OS::Cinder::VolumeAttachment + properties: + instance_uuid: + get_resource: my_web_app_tier_1 + mountpoint: /default_location + volume_id: + get_resource: my_storage + + my_web_app_tier_2: + type: OS::Nova::Server + properties: + flavor: m1.medium + image: fedora-amd64-heat-config + key_name: userkey + user_data_format: SOFTWARE_CONFIG + depends_on: + - my_storage + + myattachesto_1: + type: OS::Cinder::VolumeAttachment + properties: + instance_uuid: + get_resource: my_web_app_tier_2 + mountpoint: /some_other_data_location + volume_id: + get_resource: my_storage + +outputs: + private_ip_1: + description: The private IP address of the applications first tier. + value: + get_attr: + - my_web_app_tier_1 + - networks + - private + - 0 + private_ip_2: + description: The private IP address of the applications second tier. + value: + get_attr: + - my_web_app_tier_2 + - networks + - private + - 0 + volume_id: + description: The volume id of the block storage instance. + value: + get_resource: my_storage diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment_notation2_alt1.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment_notation2_alt1.yaml new file mode 100644 index 0000000..853716c --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment_notation2_alt1.yaml @@ -0,0 +1,98 @@ +heat_template_version: 2013-05-23 + +description: > + TOSCA simple profile with a single Block Storage node shared by 2-Tier + Application with custom AttachesTo Type and explicit Relationship Templates. + +parameters: + cpus: + type: number + description: Number of CPUs for the server. + default: 1 + constraints: + - allowed_values: + - 1 + - 2 + - 4 + - 8 + storage_location: + type: string + description: Block storage mount point (filesystem path). + default: /dev/vdc + storage_size: + type: number + description: Size of the storage to be created. + default: 1 + storage_snapshot_id: + type: string + description: Optional identifier for an existing snapshot to use when creating storage. + default: ssid + +resources: + my_storage: + type: OS::Cinder::Volume + properties: + size: + get_param: storage_size + snapshot_id: + get_param: storage_snapshot_id + + my_web_app_tier_1: + type: OS::Nova::Server + properties: + flavor: m1.small + image: fedora-amd64-heat-config + key_name: userkey + user_data_format: SOFTWARE_CONFIG + depends_on: + - my_storage + + storage_attachesto_1_2: + type: OS::Cinder::VolumeAttachment + properties: + instance_uuid: + get_resource: my_web_app_tier_1 + mountpoint: /my_data_location + volume_id: + get_resource: my_storage + + my_web_app_tier_2: + type: OS::Nova::Server + properties: + flavor: m1.small + image: fedora-amd64-heat-config + key_name: userkey + user_data_format: SOFTWARE_CONFIG + depends_on: + - my_storage + + storage_attachesto_2_1: + type: OS::Cinder::VolumeAttachment + properties: + instance_uuid: + get_resource: my_web_app_tier_2 + mountpoint: /some_other_data_location + volume_id: + get_resource: my_storage + +outputs: + private_ip_1: + description: The private IP address of the applications first tier. + value: + get_attr: + - my_web_app_tier_1 + - networks + - private + - 0 + private_ip_2: + description: The private IP address of the applications second tier. + value: + get_attr: + - my_web_app_tier_2 + - networks + - private + - 0 + volume_id: + description: The volume id of the block storage instance. + value: + get_resource: my_storage diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment_notation2_alt2.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment_notation2_alt2.yaml new file mode 100644 index 0000000..2e28bc2 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_attachment_notation2_alt2.yaml @@ -0,0 +1,98 @@ +heat_template_version: 2013-05-23 + +description: > + TOSCA simple profile with a single Block Storage node shared by 2-Tier + Application with custom AttachesTo Type and explicit Relationship Templates. + +parameters: + cpus: + type: number + description: Number of CPUs for the server. + default: 1 + constraints: + - allowed_values: + - 1 + - 2 + - 4 + - 8 + storage_location: + type: string + description: Block storage mount point (filesystem path). + default: /dev/vdc + storage_size: + type: number + description: Size of the storage to be created. + default: 1 + storage_snapshot_id: + type: string + description: Optional identifier for an existing snapshot to use when creating storage. + default: ssid + +resources: + my_storage: + type: OS::Cinder::Volume + properties: + size: + get_param: storage_size + snapshot_id: + get_param: storage_snapshot_id + + my_web_app_tier_1: + type: OS::Nova::Server + properties: + flavor: m1.small + image: fedora-amd64-heat-config + key_name: userkey + user_data_format: SOFTWARE_CONFIG + depends_on: + - my_storage + + storage_attachesto_1_1: + type: OS::Cinder::VolumeAttachment + properties: + instance_uuid: + get_resource: my_web_app_tier_1 + mountpoint: /my_data_location + volume_id: + get_resource: my_storage + + my_web_app_tier_2: + type: OS::Nova::Server + properties: + flavor: m1.small + image: fedora-amd64-heat-config + key_name: userkey + user_data_format: SOFTWARE_CONFIG + depends_on: + - my_storage + + storage_attachesto_2_2: + type: OS::Cinder::VolumeAttachment + properties: + instance_uuid: + get_resource: my_web_app_tier_2 + mountpoint: /some_other_data_location + volume_id: + get_resource: my_storage + +outputs: + private_ip_1: + description: The private IP address of the applications first tier. + value: + get_attr: + - my_web_app_tier_1 + - networks + - private + - 0 + private_ip_2: + description: The private IP address of the applications second tier. + value: + get_attr: + - my_web_app_tier_2 + - networks + - private + - 0 + volume_id: + description: The volume id of the block storage instance. + value: + get_resource: my_storage diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_custom_relationship_type.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_custom_relationship_type.yaml new file mode 100644 index 0000000..e16731e --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_custom_relationship_type.yaml @@ -0,0 +1,73 @@ +heat_template_version: 2013-05-23 + +description: > + TOSCA simple profile with server and attached block storage using a custom + AttachesTo Relationship Type. + +parameters: + cpus: + type: number + description: Number of CPUs for the server. + default: 1 + constraints: + - allowed_values: + - 1 + - 2 + - 4 + - 8 + storage_location: + type: string + description: Block storage mount point (filesystem path). + default: /dev/vdc + storage_size: + type: number + description: Size of the storage to be created. + default: 1 + storage_snapshot_id: + type: string + description: Optional identifier for an existing snapshot to use when creating storage. + default: ssid + +resources: + my_server: + type: OS::Nova::Server + properties: + flavor: m1.small + image: fedora-amd64-heat-config + key_name: userkey + user_data_format: SOFTWARE_CONFIG + depends_on: + - my_storage + + my_storage: + type: OS::Cinder::Volume + properties: + size: + get_param: storage_size + snapshot_id: + get_param: storage_snapshot_id + + mycustomattachesto_1: + type: OS::Cinder::VolumeAttachment + properties: + instance_uuid: + get_resource: my_server + volume_id: + get_resource: my_storage + mountpoint: + get_param: storage_location + + +outputs: + private_ip: + description: The private IP address of the newly created compute instance. + value: + get_attr: + - my_server + - networks + - private + - 0 + volume_id: + description: The volume id of the block storage instance. + value: + get_resource: my_storage diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_relationship_template.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_relationship_template.yaml new file mode 100644 index 0000000..869e31b --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_blockstorage_with_relationship_template.yaml @@ -0,0 +1,66 @@ +heat_template_version: 2013-05-23 + +description: > + TOSCA simple profile with server and attached block storage using a named + Relationship Template for the storage attachment. + +parameters: + cpus: + type: number + description: Number of CPUs for the server. + default: 1 + constraints: + - allowed_values: + - 1 + - 2 + - 4 + - 8 + storage_location: + type: string + description: Block storage mount point (filesystem path). + default: /dev/vdc + storage_size: + type: number + description: Size of the storage to be created. + default: 1 + +resources: + my_server: + type: OS::Nova::Server + properties: + flavor: m1.small + image: fedora-amd64-heat-config + key_name: userkey + user_data_format: SOFTWARE_CONFIG + depends_on: + - my_storage + + my_storage: + type: OS::Cinder::Volume + properties: + size: + get_param: storage_size + + storage_attachment_1: + type: OS::Cinder::VolumeAttachment + properties: + instance_uuid: + get_resource: my_server + mountpoint: + get_input: storage_location + volume_id: + get_resource: my_storage + +outputs: + private_ip: + description: The private IP address of the newly created compute instance. + value: + get_attr: + - my_server + - networks + - private + - 0 + volume_id: + description: The volume id of the block storage instance. + value: + get_resource: my_storage diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_multiple_blockstorage_with_attachment_alt1.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_multiple_blockstorage_with_attachment_alt1.yaml new file mode 100644 index 0000000..4de3e46 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_multiple_blockstorage_with_attachment_alt1.yaml @@ -0,0 +1,111 @@ +heat_template_version: 2013-05-23 + +description: > + TOSCA simple profile with 2 servers each with different attached block storage. + +parameters: + cpus: + type: number + description: Number of CPUs for the server. + default: 1 + constraints: + - allowed_values: + - 1 + - 2 + - 4 + - 8 + storage_location: + type: string + description: Block storage mount point (filesystem path). + default: /dev/vdc + storage_size: + type: number + description: Size of the storage to be created. + default: 1 + storage_snapshot_id: + type: string + description: Optional identifier for an existing snapshot to use when creating storage. + default: ssid + +resources: + my_server: + type: OS::Nova::Server + properties: + flavor: m1.medium + image: fedora-amd64-heat-config + key_name: userkey + user_data_format: SOFTWARE_CONFIG + depends_on: + - my_storage + + my_storage: + type: OS::Cinder::Volume + properties: + size: + get_param: storage_size + snapshot_id: + get_param: storage_snapshot_id + + attachesto_1: + type: OS::Cinder::VolumeAttachment + properties: + instance_uuid: + get_resource: my_server + mountpoint: + get_param: storage_location + volume_id: + get_resource: my_storage + + my_server2: + type: OS::Nova::Server + properties: + flavor: m1.medium + image: fedora-amd64-heat-config + key_name: userkey + user_data_format: SOFTWARE_CONFIG + depends_on: + - my_storage2 + + my_storage2: + type: OS::Cinder::Volume + properties: + size: + get_param: storage_size + snapshot_id: + get_param: storage_snapshot_id + + attachesto_2: + type: OS::Cinder::VolumeAttachment + properties: + instance_uuid: + get_resource: my_server2 + mountpoint: + get_param: storage_location + volume_id: + get_resource: my_storage2 + +outputs: + server_ip_1: + description: The private IP address of the applications first server. + value: + get_attr: + - my_server + - networks + - private + - 0 + server_ip_2: + description: The private IP address of the applications second server. + value: + get_attr: + - my_server2 + - networks + - private + - 0 + volume_id_1: + description: The volume id of the first block storage instance. + value: + get_resource: my_storage + volume_id_2: + description: The volume id of the second block storage instance. + value: + get_resource: my_storage2 diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_multiple_blockstorage_with_attachment_alt2.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_multiple_blockstorage_with_attachment_alt2.yaml new file mode 100644 index 0000000..a971073 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/hot_output/storage/hot_multiple_blockstorage_with_attachment_alt2.yaml @@ -0,0 +1,111 @@ +heat_template_version: 2013-05-23 + +description: > + TOSCA simple profile with 2 servers each with different attached block storage. + +parameters: + cpus: + type: number + description: Number of CPUs for the server. + default: 1 + constraints: + - allowed_values: + - 1 + - 2 + - 4 + - 8 + storage_location: + type: string + description: Block storage mount point (filesystem path). + default: /dev/vdc + storage_size: + type: number + description: Size of the storage to be created. + default: 1 + storage_snapshot_id: + type: string + description: Optional identifier for an existing snapshot to use when creating storage. + default: ssid + +resources: + my_server: + type: OS::Nova::Server + properties: + flavor: m1.medium + image: fedora-amd64-heat-config + key_name: userkey + user_data_format: SOFTWARE_CONFIG + depends_on: + - my_storage + + my_storage: + type: OS::Cinder::Volume + properties: + size: + get_param: storage_size + snapshot_id: + get_param: storage_snapshot_id + + attachesto_2: + type: OS::Cinder::VolumeAttachment + properties: + instance_uuid: + get_resource: my_server + mountpoint: + get_param: storage_location + volume_id: + get_resource: my_storage + + my_server2: + type: OS::Nova::Server + properties: + flavor: m1.medium + image: fedora-amd64-heat-config + key_name: userkey + user_data_format: SOFTWARE_CONFIG + depends_on: + - my_storage2 + + my_storage2: + type: OS::Cinder::Volume + properties: + size: + get_param: storage_size + snapshot_id: + get_param: storage_snapshot_id + + attachesto_1: + type: OS::Cinder::VolumeAttachment + properties: + instance_uuid: + get_resource: my_server2 + mountpoint: + get_param: storage_location + volume_id: + get_resource: my_storage2 + +outputs: + server_ip_1: + description: The private IP address of the applications first server. + value: + get_attr: + - my_server + - networks + - private + - 0 + server_ip_2: + description: The private IP address of the applications second server. + value: + get_attr: + - my_server2 + - networks + - private + - 0 + volume_id_1: + description: The volume id of the first block storage instance. + value: + get_resource: my_storage + volume_id_2: + description: The volume id of the second block storage instance. + value: + get_resource: my_storage2 diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/network/tosca_one_server_one_network.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/network/tosca_one_server_one_network.yaml new file mode 100644 index 0000000..8e58fa9 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/network/tosca_one_server_one_network.yaml @@ -0,0 +1,43 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with 1 server bound to a new network + +topology_template: + + inputs: + network_name: + type: string + description: Network name + + node_templates: + my_server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: 1 + mem_size: 512 MB + 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 } + ip_version: 4 + cidr: '192.168.0.0/24' + 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/tosca2heat/heat-translator-0.3.0/translator/tests/data/network/tosca_one_server_three_networks.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/network/tosca_one_server_three_networks.yaml new file mode 100644 index 0000000..d791b17 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/network/tosca_one_server_three_networks.yaml @@ -0,0 +1,64 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with 1 server bound to 3 networks + +topology_template: + + node_templates: + my_server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: 1 + mem_size: 512 MB + 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_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_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 diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/network/tosca_server_on_existing_network.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/network/tosca_server_on_existing_network.yaml new file mode 100644 index 0000000..7fedc13 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/network/tosca_server_on_existing_network.yaml @@ -0,0 +1,39 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with 1 server bound to an existing network + +topology_template: + inputs: + network_name: + type: string + description: Network name + + node_templates: + my_server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: 1 + mem_size: 512 MB + 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: + node: my_server + - link: + node: my_network diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/network/tosca_two_servers_one_network.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/network/tosca_two_servers_one_network.yaml new file mode 100644 index 0000000..1473a8d --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/network/tosca_two_servers_one_network.yaml @@ -0,0 +1,79 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with 2 servers bound to the 1 network + +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 + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: 1 + mem_size: 512 MB + os: + properties: + architecture: x86_64 + type: Linux + distribution: CirrOS + version: 0.3.2 + + my_server2: + type: tosca.nodes.Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: 1 + mem_size: 512 MB + 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_port: + type: tosca.nodes.network.Port + requirements: + - binding: + node: my_server + - link: + node: my_network + + my_port2: + type: tosca.nodes.network.Port + requirements: + - binding: + node: my_server2 + - link: + node: my_network diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_blockstorage_with_attachment.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_blockstorage_with_attachment.yaml new file mode 100644 index 0000000..460fa4c --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_blockstorage_with_attachment.yaml @@ -0,0 +1,61 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with server and attached block storage using the normative AttachesTo Relationship Type. + +topology_template: + + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + storage_size: + type: scalar-unit.size + description: Size of the storage to be created. + default: 1 GB + storage_snapshot_id: + type: string + description: > + Optional identifier for an existing snapshot to use when creating storage. + storage_location: + type: string + description: Block storage mount point (filesystem path). + + node_templates: + my_server: + type: Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 kB + os: + properties: + architecture: x86_64 + type: linux + distribution: fedora + version: 18.0 + requirements: + - local_storage: + node: my_storage + relationship: + type: AttachesTo + properties: + location: { get_input: storage_location } + + my_storage: + type: BlockStorage + properties: + size: { get_input: storage_size } + snapshot_id: { get_input: storage_snapshot_id } + + outputs: + private_ip: + description: The 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/tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_blockstorage_with_attachment_notation1.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_blockstorage_with_attachment_notation1.yaml new file mode 100644 index 0000000..df22d72 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_blockstorage_with_attachment_notation1.yaml @@ -0,0 +1,87 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with a Single Block Storage node shared by 2-Tier Application with custom AttachesTo Type and implied relationships. + +relationship_types: + MyAttachesTo: + derived_from: tosca.relationships.AttachesTo + properties: + location: + type: string + default: /default_location + +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + storage_size: + type: scalar-unit.size + default: 1 GB + description: Size of the storage to be created. + storage_snapshot_id: + type: string + description: > + Optional identifier for an existing snapshot to use when creating storage. + + node_templates: + my_web_app_tier_1: + 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.0 + requirements: + - local_storage: + node: my_storage + relationship: MyAttachesTo + + my_web_app_tier_2: + 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.0 + requirements: + - local_storage: + node: my_storage + relationship: + type: MyAttachesTo + 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 } + + outputs: + private_ip_1: + description: The private IP address of the application's first tier. + value: { get_attribute: [my_web_app_tier_1, private_address] } + private_ip_2: + description: The private IP address of the application's second tier. + value: { get_attribute: [my_web_app_tier_2, private_address] } + volume_id: + description: The volume id of the block storage instance. + value: { get_attribute: [my_storage, volume_id] } diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_blockstorage_with_attachment_notation2.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_blockstorage_with_attachment_notation2.yaml new file mode 100644 index 0000000..cb1c17a --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_blockstorage_with_attachment_notation2.yaml @@ -0,0 +1,99 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with a single Block Storage node shared by 2-Tier Application with custom AttachesTo Type and explicit Relationship Templates. + +relationship_types: + MyAttachesTo: + derived_from: tosca.relationships.AttachesTo + properties: + location: + type: string + default: /default_location + +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + storage_size: + type: scalar-unit.size + default: 1 GB + description: Size of the storage to be created. + storage_snapshot_id: + type: string + description: > + Optional identifier for an existing snapshot to use when creating storage. + storage_location: + type: string + description: > + Block storage mount point (filesystem path). + + node_templates: + + my_web_app_tier_1: + type: tosca.nodes.Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 kB + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18.0 + requirements: + - local_storage: + node: my_storage + relationship: storage_attachesto_1 + + my_web_app_tier_2: + type: tosca.nodes.Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 kB + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18.0 + requirements: + - local_storage: + node: my_storage + relationship: storage_attachesto_2 + + 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: MyAttachesTo + properties: + location: /my_data_location + + storage_attachesto_2: + type: MyAttachesTo + properties: + location: /some_other_data_location + outputs: + private_ip_1: + description: The private IP address of the application's first tier. + value: { get_attribute: [my_web_app_tier_1, private_address] } + private_ip_2: + description: The private IP address of the application's second tier. + value: { get_attribute: [my_web_app_tier_2, private_address] } + volume_id: + description: The volume id of the block storage instance. + value: { get_attribute: [my_storage, volume_id] } diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_blockstorage_with_custom_relationship_type.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_blockstorage_with_custom_relationship_type.yaml new file mode 100644 index 0000000..932f89e --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_blockstorage_with_custom_relationship_type.yaml @@ -0,0 +1,64 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with server and attached block storage using a custom AttachesTo Relationship Type. + +relationship_types: + MyCustomAttachesTo: + derived_from: AttachesTo + +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + storage_size: + type: scalar-unit.size + description: Size of the storage to be created. + default: 1 GB + storage_snapshot_id: + type: string + description: > + Optional identifier for an existing snapshot to use when creating storage. + storage_location: + type: string + description: Block storage mount point (filesystem path). + + node_templates: + my_server: + type: Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4 MB + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18.0 + requirements: + - local_storage: + node: my_storage + # Declare custom AttachesTo type using the 'relationship' keyword + relationship: + type: MyCustomAttachesTo + properties: + location: { get_input: storage_location } + my_storage: + type: BlockStorage + properties: + size: { get_input: storage_size } + snapshot_id: { get_input: storage_snapshot_id } + + outputs: + private_ip: + description: The 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/tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_blockstorage_with_relationship_template.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_blockstorage_with_relationship_template.yaml new file mode 100644 index 0000000..c31a4da --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_blockstorage_with_relationship_template.yaml @@ -0,0 +1,59 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with server and attached block storage using a named Relationship Template for the storage attachment. + +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + storage_size: + type: scalar-unit.size + description: Size of the storage to be created. + default: 1 GB + storage_location: + type: string + description: Block storage mount point (filesystem path). + + node_templates: + my_server: + type: Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4 MB + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18.0 + requirements: + - local_storage: + node: my_storage + # Declare template to use with 'relationship' keyword + relationship: storage_attachment + + my_storage: + type: BlockStorage + properties: + size: { get_input: storage_size } + + relationship_templates: + storage_attachment: + type: AttachesTo + properties: + location: { get_input: storage_location } + + outputs: + private_ip: + description: The 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/tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_multiple_blockstorage_with_attachment.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_multiple_blockstorage_with_attachment.yaml new file mode 100644 index 0000000..aa4647e --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_multiple_blockstorage_with_attachment.yaml @@ -0,0 +1,93 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with 2 servers each with different attached block storage. + +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + storage_size: + type: scalar-unit.size + default: 1 GB + description: Size of the storage to be created. + storage_snapshot_id: + type: string + description: > + Optional identifier for an existing snapshot to use when creating storage. + storage_location: + type: string + description: > + Block storage mount point (filesystem path). + + node_templates: + my_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.0 + requirements: + - local_storage: + node: my_storage + relationship: + 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 + 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.0 + requirements: + - local_storage: + node: my_storage2 + relationship: + 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: + server_ip_1: + description: The private IP address of the application's first server. + value: { get_attribute: [my_server, private_address] } + server_ip_2: + description: The private IP address of the application's second server. + value: { get_attribute: [my_server2, private_address] } + volume_id_1: + description: The volume id of the first block storage instance. + value: { get_attribute: [my_storage, volume_id] } + volume_id_2: + description: The volume id of the second block storage instance. + value: { get_attribute: [my_storage2, volume_id] } diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_single_object_store.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_single_object_store.yaml new file mode 100644 index 0000000..869af48 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/storage/tosca_single_object_store.yaml @@ -0,0 +1,17 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + Tosca template for creating an object storage service. + +topology_template: + inputs: + objectstore_name: + type: string + + node_templates: + obj_store_server: + type: tosca.nodes.ObjectStorage + properties: + name: { get_input: objectstore_name } + size: 1024 kB + maxsize: 1 GB diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/test_host_assignment.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/test_host_assignment.yaml new file mode 100644 index 0000000..acffd24 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/test_host_assignment.yaml @@ -0,0 +1,80 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + A template to test host assignment for translated hot resources. + It makes sure if a resource depends on multiple hosts only the + one with the "HostedOn" relationship is picked as the host. In + this template, the translated resource 'app_collectd_create_deploy' + would depend on 'logstash_server' and 'app_server'. But it would + have "HostedOn" relationship with 'app_server', and that server + would be its host. + +imports: + - custom_types/logstash.yaml + - custom_types/collectd.yaml + - custom_types/rsyslog.yaml + - custom_types/elasticsearch.yaml + +dsl_definitions: + host_capabilities: &host_capabilities + # 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 + +topology_template: + node_templates: + app_collectd: + type: tosca.nodes.SoftwareComponent.Collectd + requirements: + - host: + node: app_server + - log_endpoint: + node: logstash + capability: log_endpoint + relationship: + type: tosca.relationships.ConnectsTo + interfaces: + Configure: + pre_configure_target: + implementation: logstash/configure_collectd.py + interfaces: + Standard: + create: collectd/create.sh + configure: + implementation: collectd/config.py + inputs: + logstash_ip: { get_attribute: [logstash_server, private_address] } + start: collectd/start.sh + + logstash: + type: tosca.nodes.SoftwareComponent.Logstash + requirements: + - host: + node: logstash_server + interfaces: + Standard: + create: logstash/create.sh + start: logstash/start.sh + + app_server: + type: tosca.nodes.Compute + capabilities: + os: + properties: *os_capabilities + host: + properties: *host_capabilities + + logstash_server: + type: tosca.nodes.Compute + capabilities: + os: + properties: *os_capabilities + host: + properties: *host_capabilities + diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_elk.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_elk.yaml new file mode 100644 index 0000000..2576d6e --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_elk.yaml @@ -0,0 +1,219 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + This TOSCA simple profile deploys nodejs, mongodb, elasticsearch, logstash + and kibana each on a separate server with monitoring enabled for nodejs + server where a sample nodejs application is running. The rsyslog and collectd + are installed on a nodejs server. + +imports: + - custom_types/paypalpizzastore_nodejs_app.yaml + - custom_types/elasticsearch.yaml + - custom_types/logstash.yaml + - custom_types/kibana.yaml + - custom_types/collectd.yaml + - custom_types/rsyslog.yaml + +dsl_definitions: + host_capabilities: &host_capabilities + disk_size: 10 GB + num_cpus: { get_input: my_cpus } + mem_size: 4096 MB + os_capabilities: &os_capabilities + architecture: x86_64 + type: Linux + distribution: Ubuntu + version: 14.04 + +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: http://github.com/paypal/rest-api-sample-app-nodejs.git + + node_templates: + paypal_pizzastore: + type: tosca.nodes.WebApplication.PayPalPizzaStore + properties: + github_url: { get_input: github_url } + requirements: + - host: nodejs + - database_connection: mongo_db + interfaces: + Standard: + configure: + implementation: nodejs/config.sh + inputs: + github_url: http://github.com/paypal/rest-api-sample-app-nodejs.git + mongodb_ip: { get_attribute: [mongo_server, private_address] } + start: nodejs/start.sh + nodejs: + type: tosca.nodes.WebServer + requirements: + - host: app_server + interfaces: + Standard: + create: nodejs/create.sh + mongo_db: + type: tosca.nodes.Database + requirements: + - host: mongo_dbms + interfaces: + Standard: + create: mongodb/create_database.sh + mongo_dbms: + type: tosca.nodes.DBMS + requirements: + - host: mongo_server + interfaces: + Standard: + create: mongodb/create.sh + configure: + implementation: mongodb/config.sh + inputs: + mongodb_ip: { get_attribute: [mongo_server, private_address] } + start: mongodb/start.sh + elasticsearch: + type: tosca.nodes.SoftwareComponent.Elasticsearch + requirements: + - host: elasticsearch_server + interfaces: + Standard: + create: elasticsearch/create.sh + start: elasticsearch/start.sh + logstash: + type: tosca.nodes.SoftwareComponent.Logstash + requirements: + - host: logstash_server + - search_endpoint: + node: elasticsearch + capability: search_endpoint + relationship: + type: tosca.relationships.ConnectsTo + interfaces: + Configure: + pre_configure_source: + implementation: logstash/configure_elasticsearch.py + inputs: + elasticsearch_ip: { get_attribute: [elasticsearch_server, private_address] } + interfaces: + Standard: + create: logstash/create.sh + start: logstash/start.sh + kibana: + type: tosca.nodes.SoftwareComponent.Kibana + requirements: + - host: kibana_server + - search_endpoint: + node: elasticsearch + capability: search_endpoint + interfaces: + Standard: + create: kibana/create.sh + configure: + implementation: kibana/config.sh + inputs: + elasticsearch_ip: { get_attribute: [elasticsearch_server, private_address] } + kibana_ip: { get_attribute: [kibana_server, private_address] } + start: kibana/start.sh + app_collectd: + type: tosca.nodes.SoftwareComponent.Collectd + requirements: + - host: app_server + - log_endpoint: + node: logstash + capability: log_endpoint + relationship: + type: tosca.relationships.ConnectsTo + interfaces: + Configure: + pre_configure_target: + implementation: logstash/configure_collectd.py + interfaces: + Standard: + create: collectd/create.sh + configure: + implementation: collectd/config.py + inputs: + logstash_ip: { get_attribute: [logstash_server, private_address] } + start: collectd/start.sh + app_rsyslog: + type: tosca.nodes.SoftwareComponent.Rsyslog + requirements: + - host: app_server + - log_endpoint: + node: logstash + capability: log_endpoint + relationship: + type: tosca.relationships.ConnectsTo + interfaces: + Configure: + pre_configure_target: + implementation: logstash/configure_rsyslog.py + interfaces: + Standard: + create: rsyslog/create.sh + configure: + implementation: rsyslog/config.sh + inputs: + logstash_ip: { get_attribute: [logstash_server, private_address] } + start: rsyslog/start.sh + app_server: + type: tosca.nodes.Compute + capabilities: + host: + properties: *host_capabilities + os: + properties: *os_capabilities + mongo_server: + type: tosca.nodes.Compute + capabilities: + host: + properties: *host_capabilities + os: + properties: *os_capabilities + elasticsearch_server: + type: tosca.nodes.Compute + capabilities: + host: + properties: *host_capabilities + os: + properties: *os_capabilities + logstash_server: + type: tosca.nodes.Compute + capabilities: + host: + properties: *host_capabilities + os: + properties: *os_capabilities + kibana_server: + type: tosca.nodes.Compute + capabilities: + host: + properties: *host_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 ] } + 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/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_helloworld.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_helloworld.yaml new file mode 100644 index 0000000..5b913ff --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_helloworld.yaml @@ -0,0 +1,23 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: Template for deploying a single server with predefined properties. + +topology_template: + node_templates: + my_server: + type: tosca.nodes.Compute + capabilities: + # Host container properties + host: + properties: + num_cpus: 2 + disk_size: 10 GB + mem_size: 512 MB + # Guest Operating System properties + os: + properties: + # host Operating System image properties + architecture: x86_64 + type: Linux + distribution: RHEL + version: 6.5 diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_helloworld_invalid.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_helloworld_invalid.yaml new file mode 100644 index 0000000..ea60733 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_helloworld_invalid.yaml @@ -0,0 +1,23 @@ +tosca_definitions: tosca_simple_yaml_1_0 + +description: Template with invalid version and topology_template section. + +topology_template: + node_temp: + my_server: + type: tosca.nodes.Compute + capabilities: + # Host container properties + host: + properties: + num_cpus: 2 + disk_size: 10 GB + mem_size: 512 MB + # Guest Operating System properties + os: + properties: + # host Operating System image properties + architecture: x86_64 + type: Linux + distribution: RHEL + version: 6.5 diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_nodejs_mongodb_two_instances.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_nodejs_mongodb_two_instances.yaml new file mode 100644 index 0000000..f611071 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_nodejs_mongodb_two_instances.yaml @@ -0,0 +1,96 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with nodejs and mongodb. + +imports: + - custom_types/paypalpizzastore_nodejs_app.yaml + +dsl_definitions: + 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: + 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: http://github.com/paypal/rest-api-sample-app-nodejs.git + + node_templates: + paypal_pizzastore: + type: tosca.nodes.WebApplication.PayPalPizzaStore + properties: + github_url: { get_input: github_url } + requirements: + - host: nodejs + - database_connection: mongo_db + interfaces: + Standard: + configure: + implementation: nodejs/config.sh + inputs: + github_url: http://github.com/paypal/rest-api-sample-app-nodejs.git + mongodb_ip: { get_attribute: [mongo_server, private_address] } + start: nodejs/start.sh + nodejs: + type: tosca.nodes.WebServer + requirements: + - host: app_server + interfaces: + Standard: + create: nodejs/create.sh + mongo_db: + type: tosca.nodes.Database + requirements: + - host: mongo_dbms + interfaces: + Standard: + create: mongodb/create_database.sh + mongo_dbms: + type: tosca.nodes.DBMS + requirements: + - host: mongo_server + interfaces: + 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 + capabilities: + host: + properties: *host_capabilities + os: + properties: *os_capabilities + app_server: + type: tosca.nodes.Compute + capabilities: + host: + properties: *host_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/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_single_instance_wordpress.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_single_instance_wordpress.yaml new file mode 100644 index 0000000..f657034 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_single_instance_wordpress.yaml @@ -0,0 +1,120 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with wordpress, web server and mysql on the same server. + +imports: + - custom_types/wordpress.yaml + +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + default: 1 + db_name: + type: string + description: The name of the database. + default: wordpress + db_user: + type: string + description: The user name of the DB user. + default: wp_user + db_pwd: + type: string + description: The WordPress database admin account password. + default: wp_pass + db_root_pwd: + type: string + description: Root password for MySQL. + db_port: + type: PortDef + description: Port for the MySQL database. + default: 3306 + + node_templates: + wordpress: + type: tosca.nodes.WebApplication.WordPress + requirements: + - host: webserver + - database_endpoint: mysql_database + interfaces: + Standard: + create: wordpress/wordpress_install.sh + configure: + implementation: wordpress/wordpress_configure.sh + inputs: + wp_db_name: wordpress + wp_db_user: wp_user + wp_db_password: wp_pass + + mysql_database: + type: tosca.nodes.Database + properties: + name: { get_input: db_name } + user: { get_input: db_user } + password: { get_input: db_pwd } + capabilities: + database_endpoint: + properties: + port: { get_input: db_port } + requirements: + - host: + node: mysql_dbms + interfaces: + Standard: + configure: + implementation: mysql/mysql_database_configure.sh + inputs: + db_name: wordpress + db_user: wp_user + db_password: wp_pass + db_root_password: passw0rd + mysql_dbms: + type: tosca.nodes.DBMS + properties: + root_password: { get_input: db_root_pwd } + port: { get_input: db_port } + requirements: + - host: server + interfaces: + Standard: + create: + implementation: mysql/mysql_dbms_install.sh + inputs: + db_root_password: passw0rd + start: mysql/mysql_dbms_start.sh + configure: + implementation: mysql/mysql_dbms_configure.sh + inputs: + db_port: 3366 + + webserver: + type: tosca.nodes.WebServer + requirements: + - host: server + interfaces: + Standard: + create: webserver/webserver_install.sh + start: webserver/webserver_start.sh + 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: Ubuntu + version: 14.04 + + outputs: + website_url: + description: URL for Wordpress wiki. + value: { get_attribute: [server, private_address] } diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_single_instance_wordpress_with_local_abspath_import.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_single_instance_wordpress_with_local_abspath_import.yaml new file mode 100644 index 0000000..061f5ae --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_single_instance_wordpress_with_local_abspath_import.yaml @@ -0,0 +1,125 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with wordpress, web server and mysql on the same server. + This template was added to test an 'invalid' scenario where the input template + to heat-translator is provided as a URL and that template is referencing an + import using an absolute path. The translation of this template would work + only if it is tried locally (not via a URL link but via a file system + reference) and the referenced import exists in the path below. + +imports: + - /tmp/wordpress.yaml + +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + default: 1 + db_name: + type: string + description: The name of the database. + default: wordpress + db_user: + type: string + description: The user name of the DB user. + default: wp_user + db_pwd: + type: string + description: The WordPress database admin account password. + default: wp_pass + db_root_pwd: + type: string + description: Root password for MySQL. + db_port: + type: PortDef + description: Port for the MySQL database. + default: 3306 + + node_templates: + wordpress: + type: tosca.nodes.WebApplication.WordPress + requirements: + - host: webserver + - database_endpoint: mysql_database + interfaces: + Standard: + create: wordpress/wordpress_install.sh + configure: + implementation: wordpress/wordpress_configure.sh + inputs: + wp_db_name: wordpress + wp_db_user: wp_user + wp_db_password: wp_pass + + mysql_database: + type: tosca.nodes.Database + properties: + name: { get_input: db_name } + user: { get_input: db_user } + password: { get_input: db_pwd } + capabilities: + database_endpoint: + properties: + port: { get_input: db_port } + requirements: + - host: + node: mysql_dbms + interfaces: + Standard: + configure: + implementation: mysql/mysql_database_configure.sh + inputs: + db_name: wordpress + db_user: wp_user + db_password: wp_pass + db_root_password: passw0rd + mysql_dbms: + type: tosca.nodes.DBMS + properties: + root_password: { get_input: db_root_pwd } + port: { get_input: db_port } + requirements: + - host: server + interfaces: + Standard: + create: + implementation: mysql/mysql_dbms_install.sh + inputs: + db_root_password: passw0rd + start: mysql/mysql_dbms_start.sh + configure: + implementation: mysql/mysql_dbms_configure.sh + inputs: + db_port: 3366 + + webserver: + type: tosca.nodes.WebServer + requirements: + - host: server + interfaces: + Standard: + create: webserver/webserver_install.sh + start: webserver/webserver_start.sh + 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: Ubuntu + version: 14.04 + + outputs: + website_url: + description: URL for Wordpress wiki. + value: { get_attribute: [server, private_address] } diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_single_instance_wordpress_with_url_import.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_single_instance_wordpress_with_url_import.yaml new file mode 100644 index 0000000..e5f1580 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_single_instance_wordpress_with_url_import.yaml @@ -0,0 +1,120 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with wordpress, web server and mysql on the same server. + +imports: + - https://raw.githubusercontent.com/openstack/heat-translator/master/translator/tests/data/custom_types/wordpress.yaml + +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + default: 1 + db_name: + type: string + description: The name of the database. + default: wordpress + db_user: + type: string + description: The user name of the DB user. + default: wp_user + db_pwd: + type: string + description: The WordPress database admin account password. + default: wp_pass + db_root_pwd: + type: string + description: Root password for MySQL. + db_port: + type: PortDef + description: Port for the MySQL database. + default: 3306 + + node_templates: + wordpress: + type: tosca.nodes.WebApplication.WordPress + requirements: + - host: webserver + - database_endpoint: mysql_database + interfaces: + Standard: + create: wordpress/wordpress_install.sh + configure: + implementation: wordpress/wordpress_configure.sh + inputs: + wp_db_name: wordpress + wp_db_user: wp_user + wp_db_password: wp_pass + + mysql_database: + type: tosca.nodes.Database + properties: + name: { get_input: db_name } + user: { get_input: db_user } + password: { get_input: db_pwd } + capabilities: + database_endpoint: + properties: + port: { get_input: db_port } + requirements: + - host: + node: mysql_dbms + interfaces: + Standard: + configure: + implementation: mysql/mysql_database_configure.sh + inputs: + db_name: wordpress + db_user: wp_user + db_password: wp_pass + db_root_password: passw0rd + mysql_dbms: + type: tosca.nodes.DBMS + properties: + root_password: { get_input: db_root_pwd } + port: { get_input: db_port } + requirements: + - host: server + interfaces: + Standard: + create: + implementation: mysql/mysql_dbms_install.sh + inputs: + db_root_password: passw0rd + start: mysql/mysql_dbms_start.sh + configure: + implementation: mysql/mysql_dbms_configure.sh + inputs: + db_port: 3366 + + webserver: + type: tosca.nodes.WebServer + requirements: + - host: server + interfaces: + Standard: + create: webserver/webserver_install.sh + start: webserver/webserver_start.sh + 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: Ubuntu + version: 14.04 + + outputs: + website_url: + description: URL for Wordpress wiki. + value: { get_attribute: [server, private_address] } diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_single_server.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_single_server.yaml new file mode 100644 index 0000000..c4cce9d --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_single_server.yaml @@ -0,0 +1,32 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile that just defines a single compute instance and selects a (guest) host Operating System from the Compute node's properties. Note, this example does not include default values on inputs properties. + +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + + node_templates: + my_server: + type: Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4 MB + os: + properties: + architecture: x86_64 + type: Linux + distribution: ubuntu + version: 12.04 + outputs: + private_ip: + description: The private IP address of the deployed server instance. + value: { get_attribute: [my_server, private_address] } \ No newline at end of file diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_single_server_with_defaults.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_single_server_with_defaults.yaml new file mode 100644 index 0000000..68933e2 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_single_server_with_defaults.yaml @@ -0,0 +1,35 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile that just defines a single compute instance and + selects a (guest) host Operating System from the Compute node's properties. + Note, this example includes default values on inputs properties. + +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + default: 4 + + node_templates: + my_server: + type: Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4 MB + os: + properties: + architecture: x86_64 + type: Linux + distribution: ubuntu + version: 12.04 + outputs: + private_ip: + description: The private IP address of the deployed server instance. + value: { get_attribute: [my_server, private_address] } \ No newline at end of file diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_software_component.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_software_component.yaml new file mode 100644 index 0000000..88186a5 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_software_component.yaml @@ -0,0 +1,40 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with a software component. + +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + default: 1 + + node_templates: + my_software: + type: tosca.nodes.SoftwareComponent + properties: + component_version: 1.0 + requirements: + - host: server + interfaces: + Standard: + create: software_install.sh + start: software_start.sh + + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 1024 MB + os: + properties: + architecture: x86_64 + type: Linux + distribution: Ubuntu + version: 14.04 diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_web_application.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_web_application.yaml new file mode 100644 index 0000000..d5ab038 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/tosca_web_application.yaml @@ -0,0 +1,56 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with a web application. + +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + default: 1 + context_root: + type: string + description: Context root for installing the application. + default: app + + node_templates: + web_app: + type: tosca.nodes.WebApplication + properties: + context_root: { get_input: context_root } + requirements: + - host: web_server + interfaces: + Standard: + create: + implementation: web_app_install.sh + inputs: + context_root: { get_input: context_root } + start: web_app_start.sh + + web_server: + type: tosca.nodes.WebServer + requirements: + - host: server + interfaces: + Standard: + create: web_server_install.sh + start: web_server_start.sh + + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 1024 MB + os: + properties: + architecture: x86_64 + type: Linux + distribution: Ubuntu + version: 14.04 diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/test_conf.py b/tosca2heat/heat-translator-0.3.0/translator/tests/test_conf.py new file mode 100644 index 0000000..6506c27 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/test_conf.py @@ -0,0 +1,57 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import mock +import os + +from translator.conf.config import ConfigProvider as translatorConfig +from translator.tests.base import TestCase + + +def reload_config(func): + '''Decorator to reload config. + + Set to default values defined in translator.conf file + + ''' + + def reload(*args): + func(*args) + path = os.path.dirname(os.path.abspath(__file__)) + '/../conf/' + conf_file = os.path.join(path, 'translator.conf') + translatorConfig._load_config(conf_file) + + return reload + + +class ConfTest(TestCase): + + @reload_config + @mock.patch('six.moves.configparser.ConfigParser') + def test_load_config(self, mock_config_parser): + translatorConfig._translator_config.read = mock.MagicMock() + translatorConfig._load_config('fake_file.conf') + self.assertTrue(translatorConfig._translator_config.read.called) + + def test_get_value(self): + ret_value = mock.MagicMock(return_value='hot') + translatorConfig._translator_config.get = ret_value + value = translatorConfig.get_value('DEFAULT', 'language') + self.assertTrue(translatorConfig._translator_config.get.called) + self.assertEqual(value, 'hot') + + def test_get_all_values(self): + ret_value = mock.MagicMock(return_value=['hot']) + translatorConfig._translator_config.items = ret_value + values = translatorConfig.get_all_values() + self.assertTrue(translatorConfig._translator_config.items.called) + self.assertEqual(values[0], 'hot') diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/test_shell.py b/tosca2heat/heat-translator-0.3.0/translator/tests/test_shell.py new file mode 100644 index 0000000..abe8f5e --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/test_shell.py @@ -0,0 +1,116 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import os +import shutil +import tempfile + +from toscaparser.common import exception +from toscaparser.utils.gettextutils import _ +import translator.shell as shell +from translator.tests.base import TestCase + + +class ShellTest(TestCase): + tosca_helloworld = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/tosca_helloworld.yaml") + template_file = '--template-file=' + tosca_helloworld + template_type = '--template-type=tosca' + template_validation = "--validate-only=true" + failure_msg = _('The program raised an exception unexpectedly.') + + def test_missing_arg(self): + error = self.assertRaises(ValueError, shell.main, '') + err_msg = _('The program requires minimum two arguments. ' + 'Please refer to the usage documentation.') + self.assertEqual(err_msg, str(error)) + + def test_invalid_file_arg(self): + error = self.assertRaises(ValueError, shell.main, 'translate me') + err_msg = _('The program expects --template-file as first ' + 'argument. Please refer to the usage documentation.') + self.assertEqual(err_msg, str(error)) + + def test_invalid_type_arg(self): + error = self.assertRaises(ValueError, + shell.main, ('--template-file=', 'xyz')) + err_msg = _('The program expects --template-type as second argument. ' + 'Please refer to the usage documentation.') + self.assertEqual(err_msg, str(error)) + + def test_invalid_file_value(self): + error = self.assertRaises(ValueError, + shell.main, ('--template-file=template.txt', + self.template_type)) + err_msg = _('The path template.txt is not a valid file or URL.') + self.assertEqual(err_msg, str(error)) + + def test_invalid_type_value(self): + error = self.assertRaises(ValueError, shell.main, + (self.template_file, '--template-type=xyz')) + err_msg = _('xyz is not a valid template type.') + self.assertEqual(err_msg, str(error)) + + def test_invalid_parameters(self): + error = self.assertRaises(ValueError, shell.main, + (self.template_file, self.template_type, + '--parameters=key')) + err_msg = _("'key' is not a well-formed parameter.") + self.assertEqual(err_msg, str(error)) + + def test_valid_template(self): + try: + shell.main([self.template_file, self.template_type]) + except Exception: + self.fail(self.failure_msg) + + def test_valid_template_with_parameters(self): + tosca_single_instance_wordpress = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/tosca_single_instance_wordpress.yaml") + parameters = '--parameters="cpus=2;db_name=wpdb;db_user=test;'\ + 'db_port=2000;db_root_pwd=fun2test;db_pwd=fun2test"' + template = '--template-file=' + tosca_single_instance_wordpress + try: + shell.main([template, self.template_type, parameters]) + except Exception: + self.fail(self.failure_msg) + + def test_validate_only(self): + try: + shell.main([self.template_file, self.template_type, + self.template_validation]) + except Exception: + self.fail(self.failure_msg) + + template = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/tosca_helloworld_invalid.yaml") + invalid_template = '--template-file=' + template + self.assertRaises(exception.ValidationError, shell.main, + [invalid_template, self.template_type, + self.template_validation]) + + def test_output_file(self): + temp_dir = tempfile.mkdtemp() + temp_file = "/test_translation_output.txt" + output_file = "--output-file=" + temp_dir + temp_file + try: + shell.main([self.template_file, self.template_type, output_file]) + except Exception: + self.fail(self.failure_msg) + finally: + if temp_dir: + shutil.rmtree(temp_dir) + self.assertTrue(temp_dir is None or + not os.path.exists(temp_dir)) diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/test_template.py b/tosca2heat/heat-translator-0.3.0/translator/tests/test_template.py new file mode 100755 index 0000000..7d4f441 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/test_template.py @@ -0,0 +1,63 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import os +from toscaparser.tosca_template import ToscaTemplate +from translator.tests.base import TestCase + + +class ToscaMongoNodejsTest(TestCase): + parsed_params = {'storage_snapshot_id': 'test_id', + 'storage_location': '/test', 'cpus': '1', + 'storage_size': '1'} + + '''TOSCA template with nodejs, app and mongodb on 2 servers.''' + tosca_tpl = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "../tests/data/tosca_nodejs_mongodb_two_instances.yaml") + tosca = ToscaTemplate(tosca_tpl, parsed_params) + + def test_relationship_def(self): + expected_relationship = ['tosca.relationships.HostedOn'] + expected_capabilities_names = ['node'] + for tpl in self.tosca.nodetemplates: + if tpl.name == 'nodejs': + def_keys = tpl.type_definition.relationship.keys() + self.assertEqual( + expected_relationship, + sorted([x.type for x in def_keys])) + self.assertEqual( + expected_capabilities_names, + sorted([x.capability_name for x in def_keys])) + + def test_relationships(self): + expected_relationship = ['tosca.relationships.HostedOn'] + expected_relatednodes = ['app_server'] + for tpl in self.tosca.nodetemplates: + rels = tpl.relationships + if rels: + if tpl.name == 'nodejs': + self.assertEqual( + expected_relationship, + sorted([x.type for x in tpl.relationships.keys()])) + self.assertEqual( + expected_relatednodes, + sorted([y.name for y in tpl.relationships.values()])) + + def test_related_nodes(self): + expected_nodejs = ['app_server'] + actual_nodejs = [] + for tpl in self.tosca.nodetemplates: + if tpl.name == 'nodejs': + for node in tpl.related_nodes: + actual_nodejs.append(node.name) + self.assertEqual(sorted(actual_nodejs), expected_nodejs) diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/test_tosca_hot_translation.py b/tosca2heat/heat-translator-0.3.0/translator/tests/test_tosca_hot_translation.py new file mode 100644 index 0000000..534f8ed --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/test_tosca_hot_translation.py @@ -0,0 +1,503 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import json +import os + +from toscaparser.common.exception import ExceptionCollector +from toscaparser.common.exception import URLException +from toscaparser.common.exception import ValidationError +from toscaparser.utils.gettextutils import _ +from translator.common.utils import TranslationUtils +from translator.tests.base import TestCase + + +class ToscaHotTranslationTest(TestCase): + + def test_hot_translate_single_server(self): + tosca_file = '../tests/data/tosca_single_server.yaml' + hot_file = '../tests/data/hot_output/hot_single_server.yaml' + params = {'cpus': 1} + diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file, + hot_file, + params) + self.assertEqual({}, diff, ' : ' + + json.dumps(diff, indent=4, separators=(', ', ': '))) + + def test_hot_translate_single_server_with_defaults(self): + tosca_file = \ + '../tests/data/tosca_single_server_with_defaults.yaml' + hot_file_with_input = '../tests/data/hot_output/' \ + 'hot_single_server_with_defaults_with_input.yaml' + hot_file_without_input = '../tests/data/hot_output/' \ + 'hot_single_server_with_defaults_without_input.yaml' + + params1 = {'cpus': '1'} + diff1 = TranslationUtils.compare_tosca_translation_with_hot( + tosca_file, hot_file_with_input, params1) + self.assertEqual({}, diff1, ' : ' + + json.dumps(diff1, indent=4, separators=(', ', ': '))) + + params2 = {} + diff2 = TranslationUtils.compare_tosca_translation_with_hot( + tosca_file, hot_file_without_input, params2) + self.assertEqual({}, diff2, ' : ' + + json.dumps(diff2, indent=4, separators=(', ', ': '))) + + def test_hot_translate_wordpress_single_instance(self): + tosca_file = '../tests/data/tosca_single_instance_wordpress.yaml' + hot_file = '../tests/data/hot_output/' \ + 'hot_single_instance_wordpress.yaml' + params = {'db_name': 'wordpress', + 'db_user': 'wp_user', + 'db_pwd': 'wp_pass', + 'db_root_pwd': 'passw0rd', + 'db_port': 3366, + 'cpus': 8} + diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file, + hot_file, + params) + self.assertEqual({}, diff, ' : ' + + json.dumps(diff, indent=4, separators=(', ', ': '))) + + def test_hot_translate_helloworld(self): + tosca_file = '../tests/data/tosca_helloworld.yaml' + hot_file = '../tests/data/hot_output/hot_hello_world.yaml' + diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file, + hot_file, + {}) + self.assertEqual({}, diff, ' : ' + + json.dumps(diff, indent=4, separators=(', ', ': '))) + + def test_hot_translate_host_assignment(self): + tosca_file = '../tests/data/test_host_assignment.yaml' + hot_file = '../tests/data/hot_output/hot_host_assignment.yaml' + diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file, + hot_file, + {}) + self.assertEqual({}, diff, ' : ' + + json.dumps(diff, indent=4, separators=(', ', ': '))) + + def test_hot_translate_elk(self): + tosca_file = '../tests/data/tosca_elk.yaml' + hot_file = '../tests/data/hot_output/hot_elk.yaml' + params = {'github_url': + 'http://github.com/paypal/rest-api-sample-app-nodejs.git', + 'my_cpus': 4} + diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file, + hot_file, + params) + self.assertEqual({}, diff, ' : ' + + json.dumps(diff, indent=4, separators=(', ', ': '))) + + def test_hot_translate_nodejs_mongodb_two_instances(self): + tosca_file = '../tests/data/tosca_nodejs_mongodb_two_instances.yaml' + hot_file = '../tests/data/hot_output/' \ + 'hot_nodejs_mongodb_two_instances.yaml' + params = {'github_url': + 'http://github.com/paypal/rest-api-sample-app-nodejs.git', + 'my_cpus': 4} + diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file, + hot_file, + params) + self.assertEqual({}, diff, ' : ' + + json.dumps(diff, indent=4, separators=(', ', ': '))) + + def test_hot_translate_blockstorage_with_attachment(self): + tosca_file = '../tests/data/storage/' \ + 'tosca_blockstorage_with_attachment.yaml' + hot_file = '../tests/data/hot_output/storage/' \ + 'hot_blockstorage_with_attachment.yaml' + params = {'cpus': 1, + 'storage_location': '/dev/vdc', + 'storage_size': '2000 MB', + 'storage_snapshot_id': 'ssid'} + diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file, + hot_file, + params) + self.assertEqual({}, diff, ' : ' + + json.dumps(diff, indent=4, separators=(', ', ': '))) + + def test_hot_translate_blockstorage_with_custom_relationship_type(self): + tosca_file = '../tests/data/storage/' \ + 'tosca_blockstorage_with_custom_relationship_type.yaml' + hot_file = '../tests/data/hot_output/storage/' \ + 'hot_blockstorage_with_custom_relationship_type.yaml' + params = {'cpus': 1, + 'storage_location': '/dev/vdc', + 'storage_size': '1 GB', + 'storage_snapshot_id': 'ssid'} + diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file, + hot_file, + params) + self.assertEqual({}, diff, ' : ' + + json.dumps(diff, indent=4, separators=(', ', ': '))) + + def test_hot_translate_blockstorage_with_relationship_template(self): + tosca_file = '../tests/data/storage/' \ + 'tosca_blockstorage_with_relationship_template.yaml' + hot_file = '../tests/data/hot_output/storage/' \ + 'hot_blockstorage_with_relationship_template.yaml' + params = {'cpus': 1, + 'storage_location': '/dev/vdc', + 'storage_size': '1 GB'} + diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file, + hot_file, + params) + self.assertEqual({}, diff, ' : ' + + json.dumps(diff, indent=4, separators=(', ', ': '))) + + def test_hot_translate_blockstorage_with_attachment_notation1(self): + tosca_file = '../tests/data/storage/' \ + 'tosca_blockstorage_with_attachment_notation1.yaml' + hot_file1 = '../tests/data/hot_output/storage/' \ + 'hot_blockstorage_with_attachment_notation1_alt1.yaml' + hot_file2 = '../tests/data/hot_output/storage/' \ + 'hot_blockstorage_with_attachment_notation1_alt2.yaml' + params = {'cpus': 1, + 'storage_location': 'some_folder', + 'storage_size': '1 GB', + 'storage_snapshot_id': 'ssid'} + diff1 = TranslationUtils.compare_tosca_translation_with_hot(tosca_file, + hot_file1, + params) + try: + self.assertEqual({}, diff1, ' : ' + + json.dumps(diff1, indent=4, + separators=(', ', ': '))) + except Exception: + diff2 = TranslationUtils.compare_tosca_translation_with_hot( + tosca_file, hot_file2, params) + self.assertEqual({}, diff2, ' : ' + + json.dumps(diff2, indent=4, + separators=(', ', ': '))) + + def test_hot_translate_blockstorage_with_attachment_notation2(self): + tosca_file = '../tests/data/storage/' \ + 'tosca_blockstorage_with_attachment_notation2.yaml' + hot_file1 = '../tests/data/hot_output/storage/' \ + 'hot_blockstorage_with_attachment_notation2_alt1.yaml' + hot_file2 = '../tests/data/hot_output/storage/' \ + 'hot_blockstorage_with_attachment_notation2_alt2.yaml' + params = {'cpus': 1, + 'storage_location': '/dev/vdc', + 'storage_size': '1 GB', + 'storage_snapshot_id': 'ssid'} + diff1 = TranslationUtils.compare_tosca_translation_with_hot(tosca_file, + hot_file1, + params) + try: + self.assertEqual({}, diff1, ' : ' + + json.dumps(diff1, indent=4, + separators=(', ', ': '))) + except Exception: + diff2 = TranslationUtils.compare_tosca_translation_with_hot( + tosca_file, hot_file2, params) + self.assertEqual({}, diff2, ' : ' + + json.dumps(diff2, indent=4, + separators=(', ', ': '))) + + def test_hot_translate_multiple_blockstorage_with_attachment(self): + tosca_file = '../tests/data/storage/' \ + 'tosca_multiple_blockstorage_with_attachment.yaml' + hot_file1 = '../tests/data/hot_output/storage/' \ + 'hot_multiple_blockstorage_with_attachment_alt1.yaml' + hot_file2 = '../tests/data/hot_output/storage/' \ + 'hot_multiple_blockstorage_with_attachment_alt2.yaml' + params = {'cpus': 1, + 'storage_location': '/dev/vdc', + 'storage_size': '1 GB', + 'storage_snapshot_id': 'ssid'} + diff1 = TranslationUtils.compare_tosca_translation_with_hot(tosca_file, + hot_file1, + params) + try: + self.assertEqual({}, diff1, ' : ' + + json.dumps(diff1, indent=4, + separators=(', ', ': '))) + except Exception: + diff2 = TranslationUtils.compare_tosca_translation_with_hot( + tosca_file, hot_file2, params) + self.assertEqual({}, diff2, ' : ' + + json.dumps(diff2, indent=4, + separators=(', ', ': '))) + + def test_hot_translate_single_object_store(self): + tosca_file = '../tests/data/storage/tosca_single_object_store.yaml' + hot_file = '../tests/data/hot_output/hot_single_object_store.yaml' + params = {'objectstore_name': 'myobjstore'} + diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file, + hot_file, + params) + self.assertEqual({}, diff, ' : ' + + json.dumps(diff, indent=4, separators=(', ', ': '))) + + def test_hot_translate_one_server_one_network(self): + tosca_file = '../tests/data/network/tosca_one_server_one_network.yaml' + hot_file = '../tests/data/hot_output/network/' \ + 'hot_one_server_one_network.yaml' + params = {'network_name': 'private_net'} + diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file, + hot_file, + params) + self.assertEqual({}, diff, ' : ' + + json.dumps(diff, indent=4, separators=(', ', ': '))) + + def test_hot_translate_server_on_existing_network(self): + tosca_file = '../tests/data/network/' \ + 'tosca_server_on_existing_network.yaml' + hot_file = '../tests/data/hot_output/network/' \ + 'hot_server_on_existing_network.yaml' + params = {'network_name': 'private_net'} + diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file, + hot_file, + params) + self.assertEqual({}, diff, ' : ' + + json.dumps(diff, indent=4, separators=(', ', ': '))) + + def test_hot_translate_two_servers_one_network(self): + tosca_file = '../tests/data/network/tosca_two_servers_one_network.yaml' + hot_file = '../tests/data/hot_output/network/' \ + 'hot_two_servers_one_network.yaml' + params = {'network_name': 'my_private_net', + 'network_cidr': '10.0.0.0/24', + 'network_start_ip': '10.0.0.100', + 'network_end_ip': '10.0.0.150'} + diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file, + hot_file, + params) + self.assertEqual({}, diff, ' : ' + + json.dumps(diff, indent=4, separators=(', ', ': '))) + + def test_hot_translate_one_server_three_networks(self): + tosca_file = '../tests/data/network/' \ + 'tosca_one_server_three_networks.yaml' + hot_file = '../tests/data/hot_output/network/' \ + 'hot_one_server_three_networks.yaml' + params = {} + diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file, + hot_file, + params) + self.assertEqual({}, diff, ' : ' + + json.dumps(diff, indent=4, separators=(', ', ': '))) + + def test_hot_translate_software_component(self): + tosca_file = '../tests/data/tosca_software_component.yaml' + hot_file = '../tests/data/hot_output/hot_software_component.yaml' + params = {'cpus': '1', + 'download_url': 'http://www.software.com/download'} + diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file, + hot_file, + params) + self.assertEqual({}, diff, ' : ' + + json.dumps(diff, indent=4, separators=(', ', ': '))) + + def test_hot_translate_web_application(self): + tosca_file = '../tests/data/tosca_web_application.yaml' + hot_file = '../tests/data/hot_output/hot_web_application.yaml' + params = {'cpus': '2', 'context_root': 'my_web_app'} + diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file, + hot_file, + params) + self.assertEqual({}, diff, ' : ' + + json.dumps(diff, indent=4, separators=(', ', ': '))) + + def test_hot_translate_template_with_url_import(self): + tosca_file = '../tests/data/' \ + 'tosca_single_instance_wordpress_with_url_import.yaml' + hot_file = '../tests/data/hot_output/' \ + 'hot_single_instance_wordpress.yaml' + params = {'db_name': 'wordpress', + 'db_user': 'wp_user', + 'db_pwd': 'wp_pass', + 'db_root_pwd': 'passw0rd', + 'db_port': 3366, + 'cpus': 8} + diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file, + hot_file, + params) + self.assertEqual({}, diff, ' : ' + + json.dumps(diff, indent=4, separators=(', ', ': '))) + + def test_hot_translate_template_by_url_with_local_import(self): + tosca_file = 'https://raw.githubusercontent.com/openstack/' \ + 'heat-translator/master/translator/tests/data/' \ + 'tosca_single_instance_wordpress.yaml' + hot_file = '../tests/data/hot_output/' \ + 'hot_single_instance_wordpress.yaml' + params = {'db_name': 'wordpress', + 'db_user': 'wp_user', + 'db_pwd': 'wp_pass', + 'db_root_pwd': 'passw0rd', + 'db_port': 3366, + 'cpus': 8} + diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file, + hot_file, + params) + self.assertEqual({}, diff, ' : ' + + json.dumps(diff, indent=4, separators=(', ', ': '))) + + def test_hot_translate_template_by_url_with_local_abspath_import(self): + tosca_file = 'https://raw.githubusercontent.com/openstack/' \ + 'heat-translator/master/translator/tests/data/' \ + 'tosca_single_instance_wordpress_with_local_abspath' \ + '_import.yaml' + hot_file = '../tests/data/hot_output/' \ + 'hot_single_instance_wordpress.yaml' + params = {'db_name': 'wordpress', + 'db_user': 'wp_user', + 'db_pwd': 'wp_pass', + 'db_root_pwd': 'passw0rd', + 'db_port': 3366, + 'cpus': 8} + + self.assertRaises( + ValidationError, + TranslationUtils.compare_tosca_translation_with_hot, + tosca_file, hot_file, params) + expected_msg = _('Absolute file name "/tmp/wordpress.yaml" cannot be ' + 'used in a URL-based input template "https://raw.' + 'githubusercontent.com/openstack/heat-translator/' + 'master/translator/tests/data/tosca_single_instance_' + 'wordpress_with_local_abspath_import.yaml".') + ExceptionCollector.assertExceptionMessage(ImportError, expected_msg) + + def test_hot_translate_template_by_url_with_url_import(self): + tosca_url = 'https://raw.githubusercontent.com/openstack/' \ + 'heat-translator/master/translator/tests/data/' \ + 'tosca_single_instance_wordpress_with_url_import.yaml' + hot_file = '../tests/data/hot_output/' \ + 'hot_single_instance_wordpress.yaml' + params = {'db_name': 'wordpress', + 'db_user': 'wp_user', + 'db_pwd': 'wp_pass', + 'db_root_pwd': 'passw0rd', + 'db_port': 3366, + 'cpus': 8} + diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_url, + hot_file, + params) + self.assertEqual({}, diff, ' : ' + + json.dumps(diff, indent=4, separators=(', ', ': '))) + + def test_translate_hello_world_csar(self): + tosca_file = '../tests/data/csar_hello_world.zip' + hot_file = '../tests/data/hot_output/hot_hello_world.yaml' + diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file, + hot_file, + {}) + self.assertEqual({}, diff, ' : ' + + json.dumps(diff, indent=4, separators=(', ', ': '))) + + def test_translate_single_instance_wordpress_csar(self): + tosca_file = '../tests/data/csar_single_instance_wordpress.zip' + hot_file = '../tests/data/hot_output/' \ + 'hot_single_instance_wordpress_from_csar.yaml' + params = {'db_name': 'wordpress', + 'db_user': 'wp_user', + 'db_pwd': 'wp_pass', + 'db_root_pwd': 'passw0rd', + 'db_port': 3366, + 'cpus': 8} + diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file, + hot_file, + params) + self.assertEqual({}, diff, ' : ' + + json.dumps(diff, indent=4, separators=(', ', ': '))) + + def test_translate_elk_csar_from_url(self): + tosca_file = 'https://github.com/openstack/heat-translator/raw/' \ + 'master/translator/tests/data/csar_elk.zip' + hot_file = '../tests/data/hot_output/hot_elk_from_csar.yaml' + params = {'github_url': + 'http://github.com/paypal/rest-api-sample-app-nodejs.git', + 'my_cpus': 4} + diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file, + hot_file, + params) + self.assertEqual({}, diff, ' : ' + + json.dumps(diff, indent=4, separators=(', ', ': '))) + + def test_translate_csar_not_zip(self): + tosca_file = '../tests/data/csar_not_zip.zip' + hot_file = '' + params = {} + + self.assertRaises( + ValidationError, + TranslationUtils.compare_tosca_translation_with_hot, + tosca_file, hot_file, params) + path = os.path.normpath(os.path.join( + os.path.dirname(os.path.realpath(__file__)), tosca_file)) + expected_msg = _('"%s" is not a valid zip file.') % path + ExceptionCollector.assertExceptionMessage(ValidationError, + expected_msg) + + def test_translate_csar_metadata_not_yaml(self): + tosca_file = '../tests/data/csar_metadata_not_yaml.zip' + hot_file = '' + params = {} + + self.assertRaises( + ValidationError, + TranslationUtils.compare_tosca_translation_with_hot, + tosca_file, hot_file, params) + path = os.path.normpath(os.path.join( + os.path.dirname(os.path.realpath(__file__)), tosca_file)) + expected_msg = _('The file "TOSCA-Metadata/TOSCA.meta" in the CSAR ' + '"%s" does not contain valid YAML content.') % path + ExceptionCollector.assertExceptionMessage(ValidationError, + expected_msg) + + def test_translate_csar_wrong_metadata_file(self): + tosca_file = '../tests/data/csar_wrong_metadata_file.zip' + hot_file = '' + params = {} + + self.assertRaises( + ValidationError, + TranslationUtils.compare_tosca_translation_with_hot, + tosca_file, hot_file, params) + path = os.path.normpath(os.path.join( + os.path.dirname(os.path.realpath(__file__)), tosca_file)) + expected_msg = _('"%s" is not a valid CSAR as it does not contain the ' + 'required file "TOSCA.meta" in the folder ' + '"TOSCA-Metadata".') % path + ExceptionCollector.assertExceptionMessage(ValidationError, + expected_msg) + + def test_translate_csar_wordpress_invalid_import_path(self): + tosca_file = '../tests/data/csar_wordpress_invalid_import_path.zip' + hot_file = '' + params = {} + + self.assertRaises( + ValidationError, + TranslationUtils.compare_tosca_translation_with_hot, + tosca_file, hot_file, params) + expected_msg = _('Import "Definitions/wordpress.yaml" is not valid.') + ExceptionCollector.assertExceptionMessage(ImportError, expected_msg) + + def test_translate_csar_wordpress_invalid_script_url(self): + tosca_file = '../tests/data/csar_wordpress_invalid_script_url.zip' + hot_file = '' + params = {} + + self.assertRaises( + ValidationError, + TranslationUtils.compare_tosca_translation_with_hot, + tosca_file, hot_file, params) + expected_msg = _('The resource at ' + '"https://raw.githubusercontent.com/openstack/' + 'heat-translator/master/translator/tests/data/' + 'custom_types/wordpress1.yaml" cannot be accessed.') + ExceptionCollector.assertExceptionMessage(URLException, expected_msg) diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/test_utils.py b/tosca2heat/heat-translator-0.3.0/translator/tests/test_utils.py new file mode 100644 index 0000000..59c8637 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/test_utils.py @@ -0,0 +1,239 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import os +from toscaparser.tests.base import TestCase +import translator.common.utils + + +class CommonUtilsTest(TestCase): + + MemoryUnit = translator.common.utils.MemoryUnit + cmpUtils = translator.common.utils.CompareUtils + yamlUtils = translator.common.utils.YamlUtils + UrlUtils = translator.common.utils.UrlUtils + + def test_convert_unit_size_to_num(self): + size = '1 TB' + num_to_convert = 'GB' + expected_output = 1000 + output = self.MemoryUnit.convert_unit_size_to_num(size, num_to_convert) + self.assertEqual(output, expected_output) + + size = '40 GB' + num_to_convert = 'MB' + expected_output = 40000 + output = self.MemoryUnit.convert_unit_size_to_num(size, num_to_convert) + self.assertEqual(output, expected_output) + + size = '20 B' + num_to_convert = None + expected_output = 20 + output = self.MemoryUnit.convert_unit_size_to_num(size, num_to_convert) + self.assertEqual(output, expected_output) + + def test_validate_unit(self): + unit = 'AB' + exp_msg = ('Provided unit "{0}" is not valid. The valid units are ' + '{1}').format(unit, self.MemoryUnit.UNIT_SIZE_DICT.keys()) + try: + self.MemoryUnit.validate_unit(unit) + except Exception as err: + self.assertTrue( + isinstance(err, ValueError)) + self.assertEqual(exp_msg, err.__str__()) + + def test_unit_size_conversion_to_GNU_standard(self): + unit = 'gB' + standard_unit = 'GB' + converted_unit = self.MemoryUnit.validate_unit(unit) + self.assertEqual(converted_unit, standard_unit) + + unit = 'KB' + standard_unit = 'kB' + converted_unit = self.MemoryUnit.validate_unit(unit) + self.assertEqual(converted_unit, standard_unit) + + unit = 'kb' + standard_unit = 'kB' + converted_unit = self.MemoryUnit.validate_unit(unit) + self.assertEqual(converted_unit, standard_unit) + + unit = 'kB' + standard_unit = 'kB' + converted_unit = self.MemoryUnit.validate_unit(unit) + self.assertEqual(converted_unit, standard_unit) + + unit = 'MIB' + standard_unit = 'MiB' + converted_unit = self.MemoryUnit.validate_unit(unit) + self.assertEqual(converted_unit, standard_unit) + + def test_str_to_num_value_error(self): + str_to_convert = '55063.000000' + expected_output = 55063.0 + output = translator.common.utils.str_to_num(str_to_convert) + self.assertEqual(output, expected_output) + + def test_compare_dicts_unequal(self): + dict1 = {'allowed_values': [1, 2, 4, 8], + 'server3': {'depends_on': ['server1', 'server2']}} + dict2 = {'allowed_values': [1, 2, 4, 8], + 'server3': {'depends_on': ['server2', 'server1']}} + self.assertFalse(self.cmpUtils.compare_dicts(dict1, dict2)) + + def test_dicts_equivalent_empty_dicts(self): + self.assertTrue(self.cmpUtils.compare_dicts(None, None)) + self.assertFalse(self.cmpUtils.compare_dicts(None, {})) + self.assertFalse(self.cmpUtils.compare_dicts(None, {'x': '2'})) + + def test_compareutils_reorder(self): + dic = {'output': {'website_url': {'value': {'get_attr': + ['server', 'networks', + 'private', 0]}}}, + 'allowed_values': [2, 8, 1, 4], + 'server3': {'depends_on': ['server2', 'server1']}} + reordered_dic = {'output': {'website_url': {'value': {'get_attr': + ['server', 'networks', + 'private', 0]}}}, + 'allowed_values': [1, 2, 4, 8], + 'server3': {'depends_on': ['server1', 'server2']}} + self.assertEqual(reordered_dic, self.cmpUtils.reorder(dic)) + + def test_compareutils_diff_dicts_both_null(self): + expected = None + provided = None + self.assertEqual({}, + self.cmpUtils.diff_dicts(expected, provided)) + + def test_compareutils_diff_dicts_one_null(self): + expected = {'keyname': 'userkey'} + provided = None + self.assertEqual( + {self.cmpUtils.MISMATCH_VALUE1_LABEL: {'keyname': 'userkey'}, + self.cmpUtils.MISMATCH_VALUE2_LABEL: None}, + self.cmpUtils.diff_dicts(expected, provided)) + + def test_compareutils_diff_dicts_missing_key(self): + expected = {'server3': {'depends_on': ['server1', 'server2'], + 'keyname': 'userkey'}} + provided = {'server3': {'depends_on': ['server2', 'server1']}} + self.assertEqual( + {'server3': {'keyname': + {self.cmpUtils.MISMATCH_VALUE1_LABEL: 'userkey', + self.cmpUtils.MISMATCH_VALUE2_LABEL: None}}}, + self.cmpUtils.diff_dicts(expected, provided)) + + def test_compareutils_diff_dicts_missing_key_other_dict(self): + expected = {'server3': {'depends_on': ['server1', 'server2']}} + provided = {'server3': {'depends_on': ['server2', 'server1'], + 'keyname': 'userkey'}} + self.assertEqual( + {'server3': {'keyname': + {self.cmpUtils.MISMATCH_VALUE1_LABEL: None, + self.cmpUtils.MISMATCH_VALUE2_LABEL: 'userkey'}}}, + self.cmpUtils.diff_dicts(expected, provided)) + + def test_compareutils_diff_dicts_value_diff(self): + expected = \ + {'output': + {'website_url': + {'value': + {'get_attr': ['server', 'networks', 'private', 0]}}}, + 'server3': {'depends_on': ['server2', 'server1']}} + provided = \ + {'output': + {'website_url': + {'value': + {'get_attr': ['server', 'networks', 'public', 0]}}}, + 'server3': {'depends_on': ['server2', 'server1']}} + self.assertEqual( + {'output': + {'website_url': + {'value': + {'get_attr': + {self.cmpUtils.MISMATCH_VALUE1_LABEL: + ['server', 'networks', 'private', 0], + self.cmpUtils.MISMATCH_VALUE2_LABEL: + ['server', 'networks', 'public', 0]}}}}}, + self.cmpUtils.diff_dicts(expected, provided)) + + def test_yamlutils_get_dict_missing_file(self): + self.assertEqual(None, self.yamlUtils.get_dict('./no_file.yaml')) + + def test_yamlutils_get_dict(self): + yaml_file = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + '../tests/data/custom_types/rsyslog.yaml') + dict = \ + {'tosca_definitions_version': 'tosca_simple_yaml_1_0', + 'description': + 'RSYSLOG is the Rocket-fast SYStem for LOG processing.\n', + 'node_types': + {'tosca.nodes.SoftwareComponent.Rsyslog': + {'derived_from': 'tosca.nodes.SoftwareComponent', + 'requirements': + [{'log_endpoint': + {'capability': 'tosca.capabilities.Endpoint', + 'node': 'tosca.nodes.SoftwareComponent.Logstash', + 'relationship': 'tosca.relationships.ConnectsTo'}}]}}} + self.assertEqual(dict, self.yamlUtils.get_dict(yaml_file)) + + def test_yamlutils_compare_yamls(self): + yaml_file1 = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + '../tests/data/custom_types/kibana.yaml') + yaml_file2 = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + '../tests/data/custom_types/collectd.yaml') + self.assertEqual(True, + self.yamlUtils.compare_yamls(yaml_file1, yaml_file1)) + self.assertEqual(False, + self.yamlUtils.compare_yamls(yaml_file1, yaml_file2)) + + def test_yamlutils_compare_yaml_dict(self): + yaml_file1 = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + '../tests/data/custom_types/rsyslog.yaml') + yaml_file2 = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + '../tests/data/custom_types/collectd.yaml') + dict = \ + {'tosca_definitions_version': 'tosca_simple_yaml_1_0', + 'description': + 'RSYSLOG is the Rocket-fast SYStem for LOG processing.\n', + 'node_types': + {'tosca.nodes.SoftwareComponent.Rsyslog': + {'derived_from': 'tosca.nodes.SoftwareComponent', + 'requirements': + [{'log_endpoint': + {'capability': 'tosca.capabilities.Endpoint', + 'node': 'tosca.nodes.SoftwareComponent.Logstash', + 'relationship': 'tosca.relationships.ConnectsTo'}}]}}} + self.assertEqual({}, self.cmpUtils.diff_dicts( + self.yamlUtils.get_dict(yaml_file1), dict)) + self.assertEqual(False, + self.yamlUtils.compare_yaml_dict(yaml_file2, dict)) + + def test_assert_value_is_num(self): + value = 1 + output = translator.common.utils.str_to_num(value) + self.assertEqual(value, output) + + def test_urlutils_validate_url(self): + self.assertTrue(self.UrlUtils.validate_url("http://www.github.com/")) + self.assertTrue( + self.UrlUtils.validate_url("https://github.com:81/a/2/a.b")) + self.assertTrue(self.UrlUtils.validate_url("ftp://github.com")) + self.assertFalse(self.UrlUtils.validate_url("github.com")) + self.assertFalse(self.UrlUtils.validate_url("123")) + self.assertFalse(self.UrlUtils.validate_url("a/b/c")) diff --git a/tosca2heat/tosca-parser-0.3.0/.coveragerc b/tosca2heat/tosca-parser-0.3.0/.coveragerc new file mode 100644 index 0000000..3309d46 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/.coveragerc @@ -0,0 +1,7 @@ +[run] +branch = True +source = toscaparser +omit = toscaparser/openstack/* + +[report] +ignore_errors = True diff --git a/tosca2heat/tosca-parser-0.3.0/.mailmap b/tosca2heat/tosca-parser-0.3.0/.mailmap new file mode 100644 index 0000000..cc92f17 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/.mailmap @@ -0,0 +1,3 @@ +# Format is: +# +# \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/.testr.conf b/tosca2heat/tosca-parser-0.3.0/.testr.conf new file mode 100644 index 0000000..fb62267 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/.testr.conf @@ -0,0 +1,7 @@ +[DEFAULT] +test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ + OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ + OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \ + ${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION +test_id_option=--load-list $IDFILE +test_list_option=--list \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/AUTHORS b/tosca2heat/tosca-parser-0.3.0/AUTHORS new file mode 100644 index 0000000..1f9b09b --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/AUTHORS @@ -0,0 +1,41 @@ +Andrew F. Ly +Anjali +Atsushi SAKAI +Ben Martin +Bill Huber +Brad Topol +Christian Berendt +Dharmesh Bhakta +Dimitri Mazmanov +FeihuJiang +Haiyang DING +Idan Moyal +Jeff Feng +Jeremy Stanley +Kanagaraj Manickam +Longgeek +Madhurya +Meena +Michael Brewer +Michael Sambol +Monty Taylor +Oleksii Chuprykov +Rohan Shah +Sahdev Zala +Serg Melikyan +Sergey Lukjanov +Simeon Monov +Steve Martinelli +Ton Ngo +Vahid Hashemian +Victor HU +Yaoguo Jiang +Zach Sais +Zachary Sais +ddaskal +huruifeng +jiangyaoguo +narengan +spzala +srinivas_tadepalli +tonanhngo diff --git a/tosca2heat/tosca-parser-0.3.0/CONTRIBUTING.rst b/tosca2heat/tosca-parser-0.3.0/CONTRIBUTING.rst new file mode 100644 index 0000000..7366825 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/CONTRIBUTING.rst @@ -0,0 +1,16 @@ +If you would like to contribute to the development of OpenStack, +you must follow the steps in this page: + + http://docs.openstack.org/infra/manual/developers.html + +Once those steps have been completed, changes to OpenStack +should be submitted for review via the Gerrit tool, following +the workflow documented at: + + http://docs.openstack.org/infra/manual/developers.html#development-workflow + +Pull requests submitted through GitHub will be ignored. + +Bugs should be filed on Launchpad, not GitHub: + + https://bugs.launchpad.net/tosca-parser \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/ChangeLog b/tosca2heat/tosca-parser-0.3.0/ChangeLog new file mode 100644 index 0000000..67c4ba6 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/ChangeLog @@ -0,0 +1,276 @@ +CHANGES +======= + +0.3.0 +----- + +* Add checks in shell for optional keynames in the template +* Add full stack trace for parser errors +* Update documentation +* Fix issues with CSAR error handling +* Fix an incorrect template +* Fix a broken test +* Add expected path for built in template +* Update definition for public endpoint +* Update PortSpec definition per latest spec +* Fix more unhandled errors for full validation +* Update requirements +* Fix missing import with new test +* Fix an error message format +* Update error message to a uniform format +* Fix an issue with handling invalid section names +* Create an initial test coverage for shell entry point +* Modify test case for broader coverage +* Full validation of TOSCA templates +* Create shell entry point +* Update trove classifier +* Support .zip and .csar extension for CSAR files +* Update the endpoint admin capability definition +* Fix and test the validation of template file +* Fix a bug where the temp folder is not always removed +* Fix error message for invalid CSAR URLs +* Remove one line subject at top of file since its not necessary and update formatting for consistency +* Support nested type definitions using imports + +0.2.0 +----- + +* Fix backward compatibility issue +* Add validation of external resources for CSAR archives +* Update CSAR url to its github url +* Create CLI test utility +* Add CSAR processing support +* Allow special keywords in TOSCA template +* Add documentation for parser architecture +* Add CSAR decompression support +* Fix translation issue with interface inputs and functions +* TOSCA imports implementation single-line and multi-line grammar +* Support extracting the main template from a CSAR archive +* Restructured node template testcases in file test_toscatplvalidation.py +* Change ignore-errors to ignore_errors +* Update links for URL referenced templates +* Added PolicyType definitions for TOSCA +* Remove unused yaml files +* Change the entity type module name for consistency +* Extract CSAR description metadata from the main template +* Handle URLs for input templates and imports +* Add CSAR validation and metadata extraction +* Added occurrences of requirements validation +* Fix property inheritance for node templates + +0.1.0 +----- + +* Change i18n references +* Update TOX +* Update setup config file +* Fix coverage file with new repo +* Create README +* Add init file for toscaparser +* Update documentation +* Redefine respository structure +* Remove translator specific code +* Update gitreview file +* MemoryUnit Incorrectly normalizes to uppercase +* Implement SoftwareComponent and WebApplication normative types +* Validation of TOSCA version +* scalar-unit data type support as template input parameters +* Corrected checking required properties of OS capabilities in UT +* Validation for TOSCA second to below levels in template +* Fix two typos on heat-translator documentation +* Modified to get closest flavor based on minimal/no inputs +* Set property to be required by default +* Update TOSCA artifacts type +* Separate implementation of custom types and base types +* supporting short versions of requirements +* Add full support for PortDef data type +* Update network examples to the spec (1) +* Update TOSCA wordpress custom definition +* Update the 4th and 5th block storage examples (1) +* Add missing storage examples from the spec +* Update the 6th block storage example from the spec (1) +* Remove the circular dependency in network examples +* Update the first block storage example to the spec (1) +* Update object store definition and example +* Sync single server example with latest spec +* Sync network examples with the spec +* Remove py26 env +* Fix translation of block storage +* Updated from global requirements +* Add a unit test for nodejs-mongodb template translation +* Update TOSCA version per spec +* Prepare ELK TOSCA Template for Translation into HOT (6) +* Add app in the nodejs mongodb template +* Update TOSCA credential datatype +* Update TOSCA relationship inheritance +* Update TOSCA translator installation doc +* Update TOSCA relationship valid targets +* Document usage of translator with OSC +* Added directory structure in README.rst +* Add a unit test for ELK translation +* Annotate TOSCA scripts +* Prepare ELK TOSCA Template for Translation into HOT (5) +* Updated from global requirements +* Implement tosca.scalar-unit +* Update TOSCA base type definition file with version +* Prepare ELK TOSCA Template for Translation into HOT (4) +* Added translation to the tosca network module +* Added translation in dataentity module +* Fix typos in ELK CSAR readme file +* Updated from global requirements +* Adding unit test coverage for the validate method +* Implement artifact type definition +* Add support for parameters to translate template +* Added the missing testcases for Tosca translator +* Add handler for ConnectsTo relationship +* Prepare ELK TOSCA Template for Translation into HOT (3) +* Update TOSCA ELK scripts +* Adding an empty template test for simple_parse() +* Add unit testcases for toscalib_elements_constraints.py +* Fixed spelling mistake +* Fixing an error message which was not translated +* Add the ability to set output file +* Create an OSC plugin for heat-translator +* Resolve interfaces by symbolic name not by type +* TOSCA: Database and DBMS node properties update +* TOSCA: fix indentation in elk CSAR +* TOSCA: create csar for monitoring use case +* Installer scripts should not run simultaneously on the same server +* Prepare ELK TOSCA Template for Translation into HOT (2) +* TOSCA: Update memory size per spec changes +* Adding test coverage for HotParameter +* Fix host server assignment for resources with multi-node dependency +* Heat-Translator: Update README with new IRC Channel +* Added a unit test to cover diff_dicts in utils.py +* Fix installation package name +* Prepare ELK TOSCA Template for Translation into HOT +* TOSCA: interfaces for relationship templates +* TOSCA: fix Python34 UnicodeDecodeError +* Pick up new plugins for ELK +* Heat translator plugins for new TOSCA custom types +* TOSCA: keep the license formatting consistent +* TOSCA: Create a test CLI program +* Fix typos in tosca_elk.yaml file +* TOSCA: use the artifacts directory for scripts +* TOSCA: Correct duplicate Block Storage description +* Implement tosca.capabilities.Container +* TOSCA: minor updates in TOSCA def file per spec +* TOSCA: rename sample template file +* Create a unit test for wordpress specification in TOSCA +* Update the TOSCA monitoring use case +* Update TOSCA requirements for template and type +* Apply topology_template to tosca_template +* Inital Implementation of topology template +* Add test templates for topology template +* Update code base to be hacking compatible +* Update requirements and test-requirements +* Update README.rst to point to correct urls +* Update heat-translator's documentation theme +* Added unit test to verify num vals in str_to_num +* Implementation of tosca.node.ObjectStorage +* Implementation of CompareUtils class +* Added a unit test for convert_unit_size_to_num +* Added unit test to cover ValueError in str_to_num +* Update definition of tosca.nodes.WebServer +* TOSCA: organize test templates +* Fixes few nits in the network features code +* Create dictionary returning methods for certain class properties +* The output template is close to HOT template +* Rename TOSCA AttachTo relationship +* Fix coverage so that it works for this repo +* TOSCA: Handle memory units +* TOSCA: Create new utils module with memory units +* Add TOSCA networking features +* TOSCA: Update README source code link +* Follow the hosting chain to find the host server +* Add scripts for logstash, elasticsearch, kibana +* Add scripts to set up monitoring +* Update set of scripts for mongodb and nodejs +* tosca data type validation for float and timestamp +* TOSCA: Handle custom capability type definition +* Return input default value on get_input evaluation +* Replace ip_address attribute with public_address and private_address +* checking input parameter not None before accessing +* TOSCA: Add missing artifacts references +* Change name-value pairs to name-object pairs in the dictoinary +* validating reference properties in translate_input.py +* Add support for properties_def as a dictionary +* added _validate_capabilities_properties function & UT +* Adding tosca.capabilities.Scalable in TOSCA_definitions.yaml +* Apply TOSCA OS capability to compute node +* TOSCA: consider nodejs as web server only +* TOSCA: remove misleading key Entry-Definitions +* Use TOSCA properties from capabilities definition +* Remove Stackforge from README +* New custom type, unit test and template for use case +* Add TOSCA networking definiton +* Update TOSCA interfaces naming +* Separate TOSCA capabilities definition from assignment +* Remove unused TOSCA type variables +* TOSCA: Do not import individual exception classes +* Add missing TOSCA type keywords +* Update TOSCA compute requirement +* Validate TOSCA template version +* Update TOSCA version +* Add scalar unit type +* Handle TOSCA relationship with 'type' keyword +* Handle custom datatypes in current template +* Change definition for tosca.capabilities.Endpoint +* Remove Tosca.capabilities.feature per specs changes +* add blockstorage attachment notation +* Remove redundant TOSCA nodejs requirement +* Change TOSCA interfaces keyword 'input' to 'inputs' +* Add TOSCA service template for monitoring +* Minor tweaks +* Main translation code to handle parameters +* Add new support for get_attribute +* Add support for datatypes +* Rename TOSCA node property relationship to relationships +* Add a debug env for tox +* Sort TOSCA relation output for a match to expected test result +* Create relationship between TOSCA nodes per updated specs +* Fix .gitreview after rename/transfer +* Fix errors in templates and base types +* Workflow documentation is now in infra-manual +* get_attribute HOST keyword +* Handle get_attribute in Tosca outputs +* Add support for list and map types +* Check for tosca keyword in the TOSCA type +* Create a TOSCA CSAR for Wordpress template +* Represent memory unit in string +* Remove extraneous vim editor configuration comments +* Provide implementation to parse monitoring template in TOSCA library +* Allow Tosca templates with no inputs/outputs +* Extended intrinsic functions support +* Remove README.md as duplicate for .rst one +* Work toward Python 3.4 support and testing +* Add missing TOSCA template keynames +* Update README and other doc files +* Clean up heat-translator documentation +* Revert use of olsosphinx library +* add docs job to tox.ini +* Check tosca node requirements +* Add Schema parent class for Property, Input, Output +* Implement TOSCA Block Storage +* Allow use of TOSCA types by short name in the TOSCA template +* Add type attributes +* Enhance the validation of tosca +* Enhanced tosca validation +* Added a module for intrinsic function +* Support importing TOSCA custom node types +* Update the Babel module version +* TOSCA generator top level code +* TOSCA generator translation for individual TOSCA type +* TOSCA generator template syntax +* Remove tosca node template inheritance from node type +* Add missing parameter for the tosca property +* TOSCA parser +* TOSCA definition types for TOSCA library +* Add .gitreview file and apply cookiecutter template +* Delete testattrs.pyc +* Delete test4.pyc +* Delete test3.pyc +* Delete test2.pyc +* Delete squaretest.pyc +* First code drop on data modeling +* Initial commit diff --git a/tosca2heat/tosca-parser-0.3.0/HACKING.rst b/tosca2heat/tosca-parser-0.3.0/HACKING.rst new file mode 100644 index 0000000..60505f1 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/HACKING.rst @@ -0,0 +1,4 @@ +tosca-parser Style Commandments +=============================================== + +Read the OpenStack Style Commandments http://docs.openstack.org/developer/hacking/ \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/LICENSE b/tosca2heat/tosca-parser-0.3.0/LICENSE new file mode 100644 index 0000000..67db858 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/LICENSE @@ -0,0 +1,175 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. diff --git a/tosca2heat/tosca-parser-0.3.0/MANIFEST.in b/tosca2heat/tosca-parser-0.3.0/MANIFEST.in new file mode 100644 index 0000000..90f8a7a --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/MANIFEST.in @@ -0,0 +1,6 @@ +include AUTHORS +include ChangeLog +exclude .gitignore +exclude .gitreview + +global-exclude *.pyc \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/PKG-INFO b/tosca2heat/tosca-parser-0.3.0/PKG-INFO new file mode 100644 index 0000000..fdb8a18 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/PKG-INFO @@ -0,0 +1,63 @@ +Metadata-Version: 1.1 +Name: tosca-parser +Version: 0.3.0 +Summary: Parser for TOSCA Simple Profile in YAML. +Home-page: http://www.openstack.org/ +Author: OpenStack +Author-email: openstack-dev@lists.openstack.org +License: UNKNOWN +Description: =============== + TOSCA Parser + =============== + + Overview + -------- + + The TOSCA Parser is an OpenStack project and licensed under Apache 2. It is + developed to parse TOSCA Simple Profile in YAML. It reads the TOSCA templates + and creates an in-memory graph of TOSCA nodes and their relationship. + + Architecture + ------------ + + The TOSCA Parser takes TOSCA YAML template as an input, with optional input of + dictionary of needed parameters with their values, and produces in-memory + objects of different TOSCA elements with their relationship to each other. It + also creates a graph of TOSCA node templates and their relationship. The support + for parsing template within TOSCA CSAR is under development. + + The ToscaTemplate class located in the toscaparser/tosca_template.py is an entry + class of the parser and various functionality of parser can be used by initiating + this class. In order to see an example usage, refer to the heat-translator + class TranslateTemplate located in the translator/osc/v1/translate.py module. + + The toscaparser/elements sub-directory contains various modules to handle + various TOSCA type elements like node type, relationship type etc. The + entity_type.py module is a parent of all type elements. The toscaparser + directory contains various python module to handle service template including + topology template, node templates, relationship templates etc. The + entity_template.py is a parent of all template elements. + + + How To Use + ---------- + Please refer to `doc/source/usage.rst `_ + + Project Info + ------------ + + * License: Apache License, Version 2.0 + * Source: http://git.openstack.org/cgit/openstack/tosca-parser/ + + +Platform: UNKNOWN +Classifier: Environment :: OpenStack +Classifier: Intended Audience :: Information Technology +Classifier: Intended Audience :: System Administrators +Classifier: License :: OSI Approved :: Apache Software License +Classifier: Operating System :: POSIX :: Linux +Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 2 +Classifier: Programming Language :: Python :: 2.7 +Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3.4 diff --git a/tosca2heat/tosca-parser-0.3.0/README.rst b/tosca2heat/tosca-parser-0.3.0/README.rst new file mode 100644 index 0000000..51161ec --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/README.rst @@ -0,0 +1,43 @@ +=============== +TOSCA Parser +=============== + +Overview +-------- + +The TOSCA Parser is an OpenStack project and licensed under Apache 2. It is +developed to parse TOSCA Simple Profile in YAML. It reads the TOSCA templates +and creates an in-memory graph of TOSCA nodes and their relationship. + +Architecture +------------ + +The TOSCA Parser takes TOSCA YAML template as an input, with optional input of +dictionary of needed parameters with their values, and produces in-memory +objects of different TOSCA elements with their relationship to each other. It +also creates a graph of TOSCA node templates and their relationship. The support +for parsing template within TOSCA CSAR is under development. + +The ToscaTemplate class located in the toscaparser/tosca_template.py is an entry +class of the parser and various functionality of parser can be used by initiating +this class. In order to see an example usage, refer to the heat-translator +class TranslateTemplate located in the translator/osc/v1/translate.py module. + +The toscaparser/elements sub-directory contains various modules to handle +various TOSCA type elements like node type, relationship type etc. The +entity_type.py module is a parent of all type elements. The toscaparser +directory contains various python module to handle service template including +topology template, node templates, relationship templates etc. The +entity_template.py is a parent of all template elements. + + +How To Use +---------- +Please refer to `doc/source/usage.rst `_ + +Project Info +------------ + +* License: Apache License, Version 2.0 +* Source: http://git.openstack.org/cgit/openstack/tosca-parser/ + diff --git a/tosca2heat/tosca-parser-0.3.0/babel.cfg b/tosca2heat/tosca-parser-0.3.0/babel.cfg new file mode 100644 index 0000000..efceab8 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/babel.cfg @@ -0,0 +1 @@ +[python: **.py] diff --git a/tosca2heat/tosca-parser-0.3.0/doc/source/conf.py b/tosca2heat/tosca-parser-0.3.0/doc/source/conf.py new file mode 100755 index 0000000..e461246 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/doc/source/conf.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import sys + +sys.path.insert(0, os.path.abspath('../..')) +# -- General configuration ---------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = [ + 'sphinx.ext.autodoc', + #'sphinx.ext.intersphinx', + 'oslosphinx' +] + +# autodoc generation is a bit aggressive and a nuisance when doing heavy +# text edit cycles. +# execute "export SPHINX_DEBUG=1" in your terminal to disable + +# The suffix of source filenames. +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'tosca-parser' +copyright = u'2013, OpenStack Foundation' + +# If true, '()' will be appended to :func: etc. cross-reference text. +add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +add_module_names = True + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# -- Options for HTML output -------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. Major themes that come with +# Sphinx are currently 'default' and 'sphinxdoc'. +# html_theme_path = ["."] +# html_theme = 'default' +# html_static_path = ['static'] + +# Output file base name for HTML help builder. +htmlhelp_basename = '%sdoc' % project + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass +# [howto/manual]). +latex_documents = [ + ('index', + '%s.tex' % project, + u'%s Documentation' % project, + u'OpenStack Foundation', 'manual'), +] + +# Example configuration for intersphinx: refer to the Python standard library. +#intersphinx_mapping = {'http://docs.python.org/': None} diff --git a/tosca2heat/tosca-parser-0.3.0/doc/source/contributing.rst b/tosca2heat/tosca-parser-0.3.0/doc/source/contributing.rst new file mode 100644 index 0000000..8cb3146 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/doc/source/contributing.rst @@ -0,0 +1 @@ +.. include:: ../../CONTRIBUTING.rst \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/doc/source/index.rst b/tosca2heat/tosca-parser-0.3.0/doc/source/index.rst new file mode 100644 index 0000000..31c22fe --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/doc/source/index.rst @@ -0,0 +1,27 @@ +.. tosca-parser documentation master file, created by + sphinx-quickstart on Tue Jul 9 22:26:36 2013. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to tosca-parser's documentation! +=========================================== + +The TOSCA Parser is developed to parse TOSCA Simple Profile in YAML. It reads +the TOSCA templates and creates an in-memory graph of TOSCA nodes and their +relationship. + +Contents: + +.. toctree:: + :maxdepth: 2 + + installation + usage + contributing + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/tosca2heat/tosca-parser-0.3.0/doc/source/installation.rst b/tosca2heat/tosca-parser-0.3.0/doc/source/installation.rst new file mode 100644 index 0000000..f3805a5 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/doc/source/installation.rst @@ -0,0 +1,9 @@ +============ +Installation +============ + +You can clone the project and use it as below:: + + git clone https://github.com/openstack/tosca-parser + +Tosca-Parser can be installed via PyPI package as well. Refer to https://pypi.python.org/pypi/tosca-parser for available packages. \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/doc/source/usage.rst b/tosca2heat/tosca-parser-0.3.0/doc/source/usage.rst new file mode 100644 index 0000000..2b822a8 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/doc/source/usage.rst @@ -0,0 +1,16 @@ +===== +Usage +===== + +The TOSCA Parser can be used as a library by any client program, for example, +OpenStack heat-translator uses it to translate TOSCA to Heat Orchestration +Template (HOT). + +For an easy reference on how TOSCA Parser can be used programmatically or to +test that the a TOSCA template passes validation, refer to the tosca_parser.py +test program which is located at the root level of the project. Alternatively, +you can install 0.3.0 or higher PyPI release of TOSCA-Parser as available at the +https://pypi.python.org/pypi/tosca-parser and test use the parser via CLI +entry point as:: + tosca-parser --template-file=toscaparser/tests/data/tosca_helloworld.yaml +The value to the --template-file is required to be a relative or an absolute path. diff --git a/tosca2heat/tosca-parser-0.3.0/openstack-common.conf b/tosca2heat/tosca-parser-0.3.0/openstack-common.conf new file mode 100644 index 0000000..178c8c4 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/openstack-common.conf @@ -0,0 +1,6 @@ +[DEFAULT] + +# The list of modules to copy from oslo-incubator.git + +# The base module to hold the copy of openstack.common +base=toscaparser \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/requirements.txt b/tosca2heat/tosca-parser-0.3.0/requirements.txt new file mode 100644 index 0000000..7dc14c3 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/requirements.txt @@ -0,0 +1,9 @@ +# The order of packages is significant, because pip processes them in the order +# of appearance. Changing the order has an impact on the overall integration +# process, which may cause wedges in the gate later. +pbr>=1.6 +Babel>=1.3 +cliff>=1.14.0 # Apache-2.0 +PyYAML>=3.1.0 +python-dateutil>=2.4.2 +six>=1.9.0 diff --git a/tosca2heat/tosca-parser-0.3.0/setup.cfg b/tosca2heat/tosca-parser-0.3.0/setup.cfg new file mode 100644 index 0000000..74cd2a3 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/setup.cfg @@ -0,0 +1,55 @@ +[metadata] +name = tosca-parser +summary = Parser for TOSCA Simple Profile in YAML. +description-file = + README.rst +author = OpenStack +author-email = openstack-dev@lists.openstack.org +home-page = http://www.openstack.org/ +classifier = + Environment :: OpenStack + Intended Audience :: Information Technology + Intended Audience :: System Administrators + License :: OSI Approved :: Apache Software License + Operating System :: POSIX :: Linux + Programming Language :: Python + Programming Language :: Python :: 2 + Programming Language :: Python :: 2.7 + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.4 + +[files] +packages = + toscaparser + +[entry_points] +console_scripts = + tosca-parser = toscaparser.shell:main + +[build_sphinx] +source-dir = doc/source +build-dir = doc/build +all_files = 1 + +[upload_sphinx] +upload-dir = doc/build/html + +[compile_catalog] +directory = toscaparser/locale +domain = toscaparser + +[update_catalog] +domain = toscaparser +output_dir = toscaparser/locale +input_file = toscaparser/locale/toscaparser.pot + +[extract_messages] +keywords = _ gettext ngettext l_ lazy_gettext +mapping_file = babel.cfg +output_file = toscaparser/locale/toscaparser.pot + +[egg_info] +tag_date = 0 +tag_svn_revision = 0 +tag_build = + diff --git a/tosca2heat/tosca-parser-0.3.0/setup.py b/tosca2heat/tosca-parser-0.3.0/setup.py new file mode 100644 index 0000000..d8080d0 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/setup.py @@ -0,0 +1,29 @@ +# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT +import setuptools + +# In python < 2.7.4, a lazy loading of package `pbr` will break +# setuptools if some other modules registered functions in `atexit`. +# solution from: http://bugs.python.org/issue15881#msg170215 +try: + import multiprocessing # noqa +except ImportError: + pass + +setuptools.setup( + setup_requires=['pbr>=1.3'], + pbr=True) diff --git a/tosca2heat/tosca-parser-0.3.0/test-requirements.txt b/tosca2heat/tosca-parser-0.3.0/test-requirements.txt new file mode 100644 index 0000000..08dc3e7 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/test-requirements.txt @@ -0,0 +1,14 @@ +# The order of packages is significant, because pip processes them in the order +# of appearance. Changing the order has an impact on the overall integration +# process, which may cause wedges in the gate later. +hacking<0.11,>=0.10.0 +coverage>=3.6 +discover +fixtures>=1.3.1 +oslotest>=1.7.0 # Apache-2.0 +oslosphinx>=2.5.0 # Apache-2.0 +python-subunit>=0.0.18 +sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 +testrepository>=0.0.18 +testscenarios>=0.4 +testtools>=1.4.0 diff --git a/tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/PKG-INFO b/tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/PKG-INFO new file mode 100644 index 0000000..fdb8a18 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/PKG-INFO @@ -0,0 +1,63 @@ +Metadata-Version: 1.1 +Name: tosca-parser +Version: 0.3.0 +Summary: Parser for TOSCA Simple Profile in YAML. +Home-page: http://www.openstack.org/ +Author: OpenStack +Author-email: openstack-dev@lists.openstack.org +License: UNKNOWN +Description: =============== + TOSCA Parser + =============== + + Overview + -------- + + The TOSCA Parser is an OpenStack project and licensed under Apache 2. It is + developed to parse TOSCA Simple Profile in YAML. It reads the TOSCA templates + and creates an in-memory graph of TOSCA nodes and their relationship. + + Architecture + ------------ + + The TOSCA Parser takes TOSCA YAML template as an input, with optional input of + dictionary of needed parameters with their values, and produces in-memory + objects of different TOSCA elements with their relationship to each other. It + also creates a graph of TOSCA node templates and their relationship. The support + for parsing template within TOSCA CSAR is under development. + + The ToscaTemplate class located in the toscaparser/tosca_template.py is an entry + class of the parser and various functionality of parser can be used by initiating + this class. In order to see an example usage, refer to the heat-translator + class TranslateTemplate located in the translator/osc/v1/translate.py module. + + The toscaparser/elements sub-directory contains various modules to handle + various TOSCA type elements like node type, relationship type etc. The + entity_type.py module is a parent of all type elements. The toscaparser + directory contains various python module to handle service template including + topology template, node templates, relationship templates etc. The + entity_template.py is a parent of all template elements. + + + How To Use + ---------- + Please refer to `doc/source/usage.rst `_ + + Project Info + ------------ + + * License: Apache License, Version 2.0 + * Source: http://git.openstack.org/cgit/openstack/tosca-parser/ + + +Platform: UNKNOWN +Classifier: Environment :: OpenStack +Classifier: Intended Audience :: Information Technology +Classifier: Intended Audience :: System Administrators +Classifier: License :: OSI Approved :: Apache Software License +Classifier: Operating System :: POSIX :: Linux +Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 2 +Classifier: Programming Language :: Python :: 2.7 +Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3.4 diff --git a/tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/SOURCES.txt b/tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/SOURCES.txt new file mode 100644 index 0000000..785f1f9 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/SOURCES.txt @@ -0,0 +1,230 @@ +.coveragerc +.mailmap +.testr.conf +AUTHORS +CONTRIBUTING.rst +ChangeLog +HACKING.rst +LICENSE +MANIFEST.in +README.rst +babel.cfg +openstack-common.conf +requirements.txt +setup.cfg +setup.py +test-requirements.txt +tosca_parser.py +tox.ini +doc/source/conf.py +doc/source/contributing.rst +doc/source/index.rst +doc/source/installation.rst +doc/source/usage.rst +tosca_parser.egg-info/PKG-INFO +tosca_parser.egg-info/SOURCES.txt +tosca_parser.egg-info/dependency_links.txt +tosca_parser.egg-info/entry_points.txt +tosca_parser.egg-info/not-zip-safe +tosca_parser.egg-info/pbr.json +tosca_parser.egg-info/requires.txt +tosca_parser.egg-info/top_level.txt +toscaparser/__init__.py +toscaparser/capabilities.py +toscaparser/dataentity.py +toscaparser/entity_template.py +toscaparser/functions.py +toscaparser/groups.py +toscaparser/imports.py +toscaparser/nodetemplate.py +toscaparser/parameters.py +toscaparser/properties.py +toscaparser/relationship_template.py +toscaparser/shell.py +toscaparser/topology_template.py +toscaparser/tosca_template.py +toscaparser/tpl_relationship_graph.py +toscaparser/common/__init__.py +toscaparser/common/exception.py +toscaparser/elements/TOSCA_definition_1_0.yaml +toscaparser/elements/__init__.py +toscaparser/elements/artifacttype.py +toscaparser/elements/attribute_definition.py +toscaparser/elements/capabilitytype.py +toscaparser/elements/constraints.py +toscaparser/elements/datatype.py +toscaparser/elements/entity_type.py +toscaparser/elements/interfaces.py +toscaparser/elements/nodetype.py +toscaparser/elements/policytype.py +toscaparser/elements/property_definition.py +toscaparser/elements/relationshiptype.py +toscaparser/elements/scalarunit.py +toscaparser/elements/statefulentitytype.py +toscaparser/prereq/__init__.py +toscaparser/prereq/csar.py +toscaparser/tests/__init__.py +toscaparser/tests/base.py +toscaparser/tests/test_constraints.py +toscaparser/tests/test_datatypes.py +toscaparser/tests/test_exception.py +toscaparser/tests/test_functions.py +toscaparser/tests/test_prereq.py +toscaparser/tests/test_properties.py +toscaparser/tests/test_scalarunit.py +toscaparser/tests/test_shell.py +toscaparser/tests/test_topology_template.py +toscaparser/tests/test_toscadef.py +toscaparser/tests/test_toscatpl.py +toscaparser/tests/test_toscatplvalidation.py +toscaparser/tests/test_utils.py +toscaparser/tests/test_validate_tosca_version.py +toscaparser/tests/artifacts/collectd/config.py +toscaparser/tests/artifacts/collectd/create.sh +toscaparser/tests/artifacts/collectd/start.sh +toscaparser/tests/artifacts/elasticsearch/create.sh +toscaparser/tests/artifacts/elasticsearch/start.sh +toscaparser/tests/artifacts/kibana/config.sh +toscaparser/tests/artifacts/kibana/create.sh +toscaparser/tests/artifacts/kibana/start.sh +toscaparser/tests/artifacts/logstash/configure_collectd.py +toscaparser/tests/artifacts/logstash/configure_elasticsearch.py +toscaparser/tests/artifacts/logstash/configure_rsyslog.py +toscaparser/tests/artifacts/logstash/create.sh +toscaparser/tests/artifacts/logstash/start.sh +toscaparser/tests/artifacts/mongodb/config.sh +toscaparser/tests/artifacts/mongodb/create.sh +toscaparser/tests/artifacts/mongodb/create_database.sh +toscaparser/tests/artifacts/mongodb/start.sh +toscaparser/tests/artifacts/mysql/mysql_database_configure.sh +toscaparser/tests/artifacts/mysql/mysql_dbms_configure.sh +toscaparser/tests/artifacts/mysql/mysql_dbms_install.sh +toscaparser/tests/artifacts/mysql/mysql_dbms_start.sh +toscaparser/tests/artifacts/nodejs/config.sh +toscaparser/tests/artifacts/nodejs/create.sh +toscaparser/tests/artifacts/nodejs/start.sh +toscaparser/tests/artifacts/rsyslog/config.sh +toscaparser/tests/artifacts/rsyslog/create.sh +toscaparser/tests/artifacts/rsyslog/start.sh +toscaparser/tests/artifacts/webserver/webserver_install.sh +toscaparser/tests/artifacts/webserver/webserver_start.sh +toscaparser/tests/artifacts/wordpress/wordpress_configure.sh +toscaparser/tests/artifacts/wordpress/wordpress_install.sh +toscaparser/tests/data/test_instance_nested_imports.yaml +toscaparser/tests/data/test_invalid_section_names.yaml +toscaparser/tests/data/test_invalid_template_version.yaml +toscaparser/tests/data/test_multiple_validation_errors.yaml +toscaparser/tests/data/test_no_inputs_in_template.yaml +toscaparser/tests/data/test_no_outputs_in_template.yaml +toscaparser/tests/data/test_requirements.yaml +toscaparser/tests/data/test_tosca_normative_type_by_shortname.yaml +toscaparser/tests/data/test_tosca_top_level_error1.yaml +toscaparser/tests/data/test_tosca_top_level_error2.yaml +toscaparser/tests/data/tosca_elk.yaml +toscaparser/tests/data/tosca_helloworld.yaml +toscaparser/tests/data/tosca_single_instance_wordpress.yaml +toscaparser/tests/data/tosca_single_instance_wordpress_with_local_abspath_import.yaml +toscaparser/tests/data/tosca_single_instance_wordpress_with_url_import.yaml +toscaparser/tests/data/CSAR/csar_elk.csar +toscaparser/tests/data/CSAR/csar_elk.zip +toscaparser/tests/data/CSAR/csar_hello_world.zip +toscaparser/tests/data/CSAR/csar_invalid_entry_def.zip +toscaparser/tests/data/CSAR/csar_metadata_not_yaml.zip +toscaparser/tests/data/CSAR/csar_missing_metadata.zip +toscaparser/tests/data/CSAR/csar_no_metadata_file.zip +toscaparser/tests/data/CSAR/csar_not_zip.zip +toscaparser/tests/data/CSAR/csar_wordpress.zip +toscaparser/tests/data/CSAR/csar_wordpress_invalid_import_path.zip +toscaparser/tests/data/CSAR/csar_wordpress_invalid_import_url.zip +toscaparser/tests/data/CSAR/csar_wordpress_invalid_script_path.zip +toscaparser/tests/data/CSAR/csar_wordpress_invalid_script_url.zip +toscaparser/tests/data/CSAR/csar_wordpress_with_url_import_and_script.zip +toscaparser/tests/data/CSAR/csar_wrong_metadata_file.zip +toscaparser/tests/data/CSAR/tosca_elk/README.txt +toscaparser/tests/data/CSAR/tosca_elk/Definitions/collectd.yaml +toscaparser/tests/data/CSAR/tosca_elk/Definitions/elasticsearch.yaml +toscaparser/tests/data/CSAR/tosca_elk/Definitions/kibana.yaml +toscaparser/tests/data/CSAR/tosca_elk/Definitions/logstash.yaml +toscaparser/tests/data/CSAR/tosca_elk/Definitions/paypalpizzastore_nodejs_app.yaml +toscaparser/tests/data/CSAR/tosca_elk/Definitions/rsyslog.yaml +toscaparser/tests/data/CSAR/tosca_elk/Definitions/tosca_elk.yaml +toscaparser/tests/data/CSAR/tosca_elk/Python/collectd/config.py +toscaparser/tests/data/CSAR/tosca_elk/Python/logstash/configure_collectd.py +toscaparser/tests/data/CSAR/tosca_elk/Python/logstash/configure_elasticsearch.py +toscaparser/tests/data/CSAR/tosca_elk/Python/logstash/configure_rsyslog.py +toscaparser/tests/data/CSAR/tosca_elk/Scripts/collectd/create.sh +toscaparser/tests/data/CSAR/tosca_elk/Scripts/collectd/start.sh +toscaparser/tests/data/CSAR/tosca_elk/Scripts/elasticsearch/create.sh +toscaparser/tests/data/CSAR/tosca_elk/Scripts/elasticsearch/start.sh +toscaparser/tests/data/CSAR/tosca_elk/Scripts/kibana/config.sh +toscaparser/tests/data/CSAR/tosca_elk/Scripts/kibana/create.sh +toscaparser/tests/data/CSAR/tosca_elk/Scripts/kibana/start.sh +toscaparser/tests/data/CSAR/tosca_elk/Scripts/logstash/create.sh +toscaparser/tests/data/CSAR/tosca_elk/Scripts/logstash/start.sh +toscaparser/tests/data/CSAR/tosca_elk/Scripts/mongodb/config.sh +toscaparser/tests/data/CSAR/tosca_elk/Scripts/mongodb/create.sh +toscaparser/tests/data/CSAR/tosca_elk/Scripts/mongodb/create_database.sh +toscaparser/tests/data/CSAR/tosca_elk/Scripts/mongodb/start.sh +toscaparser/tests/data/CSAR/tosca_elk/Scripts/nodejs/config.sh +toscaparser/tests/data/CSAR/tosca_elk/Scripts/nodejs/create.sh +toscaparser/tests/data/CSAR/tosca_elk/Scripts/nodejs/start.sh +toscaparser/tests/data/CSAR/tosca_elk/Scripts/rsyslog/config.sh +toscaparser/tests/data/CSAR/tosca_elk/Scripts/rsyslog/create.sh +toscaparser/tests/data/CSAR/tosca_elk/Scripts/rsyslog/start.sh +toscaparser/tests/data/CSAR/tosca_elk/TOSCA-Metadata/TOSCA.meta +toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/README.txt +toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Definitions/tosca_single_instance_wordpress.yaml +toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Definitions/wordpress.yaml +toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/configure.sh +toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/install.sh +toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/start.sh +toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDatabase/configure.sh +toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WebServer/install.sh +toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WebServer/start.sh +toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WordPress/configure.sh +toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WordPress/install.sh +toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/TOSCA-Metadata/TOSCA.meta +toscaparser/tests/data/custom_types/collectd.yaml +toscaparser/tests/data/custom_types/elasticsearch.yaml +toscaparser/tests/data/custom_types/kibana.yaml +toscaparser/tests/data/custom_types/logstash.yaml +toscaparser/tests/data/custom_types/nested_rsyslog.yaml +toscaparser/tests/data/custom_types/nested_test_wordpress.yaml +toscaparser/tests/data/custom_types/paypalpizzastore_nodejs_app.yaml +toscaparser/tests/data/custom_types/rsyslog.yaml +toscaparser/tests/data/custom_types/wordpress.yaml +toscaparser/tests/data/datatypes/custom_datatype_def.yaml +toscaparser/tests/data/datatypes/test_custom_datatypes_in_current_template.yaml +toscaparser/tests/data/datatypes/test_custom_datatypes_nested_datatype_error.yaml +toscaparser/tests/data/datatypes/test_custom_datatypes_positive.yaml +toscaparser/tests/data/datatypes/test_custom_datatypes_value_error.yaml +toscaparser/tests/data/functions/test_get_attribute_host_keyword.yaml +toscaparser/tests/data/functions/test_get_attribute_host_not_found.yaml +toscaparser/tests/data/functions/test_get_attribute_illegal_host_in_outputs.yaml +toscaparser/tests/data/functions/test_get_attribute_unknown_attribute_name.yaml +toscaparser/tests/data/functions/test_get_attribute_unknown_node_template_name.yaml +toscaparser/tests/data/functions/test_invalid_function_signature.yaml +toscaparser/tests/data/functions/test_unknown_capability_property.yaml +toscaparser/tests/data/functions/test_unknown_input_in_interface.yaml +toscaparser/tests/data/functions/test_unknown_input_in_property.yaml +toscaparser/tests/data/topology_template/definitions.yaml +toscaparser/tests/data/topology_template/subsystem.yaml +toscaparser/tests/data/topology_template/system.yaml +toscaparser/tests/spec_samples/v1.0/tosca_nodejs_mongodb_two_instances.yaml +toscaparser/tests/spec_samples/v1.0/tosca_single_server.yaml +toscaparser/tests/spec_samples/v1.0/network/tosca_one_server_one_network.yaml +toscaparser/tests/spec_samples/v1.0/network/tosca_one_server_three_networks.yaml +toscaparser/tests/spec_samples/v1.0/network/tosca_server_on_existing_network.yaml +toscaparser/tests/spec_samples/v1.0/network/tosca_two_servers_one_network.yaml +toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_attachment.yaml +toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_attachment_notation1.yaml +toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_attachment_notation2.yaml +toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_custom_relationship_type.yaml +toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_relationship_template.yaml +toscaparser/tests/spec_samples/v1.0/storage/tosca_multiple_blockstorage_with_attachment.yaml +toscaparser/tests/spec_samples/v1.0/storage/tosca_single_object_store.yaml +toscaparser/utils/__init__.py +toscaparser/utils/gettextutils.py +toscaparser/utils/urlutils.py +toscaparser/utils/validateutils.py +toscaparser/utils/yamlparser.py \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/dependency_links.txt b/tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/entry_points.txt b/tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/entry_points.txt new file mode 100644 index 0000000..3738471 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/entry_points.txt @@ -0,0 +1,3 @@ +[console_scripts] +tosca-parser = toscaparser.shell:main + diff --git a/tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/not-zip-safe b/tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/not-zip-safe new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/not-zip-safe @@ -0,0 +1 @@ + diff --git a/tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/pbr.json b/tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/pbr.json new file mode 100644 index 0000000..f630d90 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/pbr.json @@ -0,0 +1 @@ +{"is_release": true, "git_version": "4fbd9cd"} \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/requires.txt b/tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/requires.txt new file mode 100644 index 0000000..0752db5 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/requires.txt @@ -0,0 +1,6 @@ +pbr>=1.6 +Babel>=1.3 +cliff>=1.14.0 +PyYAML>=3.1.0 +python-dateutil>=2.4.2 +six>=1.9.0 diff --git a/tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/top_level.txt b/tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/top_level.txt new file mode 100644 index 0000000..12d8e9b --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/tosca_parser.egg-info/top_level.txt @@ -0,0 +1 @@ +toscaparser diff --git a/tosca2heat/tosca-parser-0.3.0/tosca_parser.py b/tosca2heat/tosca-parser-0.3.0/tosca_parser.py new file mode 100644 index 0000000..0d2de75 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/tosca_parser.py @@ -0,0 +1,32 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +from toscaparser import shell as parser_shell + +""" +Test utility to show how TOSCA Parser can be used programmatically + +It can be used as, +#python tosca_parser.py --template-file= +#python tosca_parser.py --template-file= +#python tosca_parser.py --template-file= + +e.g. +#python tosca_parser.py +--template-file=toscaparser/tests/data/tosca_helloworld.yaml +#python tosca_parser.py +--template-file=toscaparser/tests/data/CSAR/csar_hello_world.zip +""" + +if __name__ == '__main__': + parser_shell.main() diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/__init__.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/__init__.py new file mode 100644 index 0000000..d6fa60c --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/__init__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import pbr.version + + +__version__ = pbr.version.VersionInfo( + 'tosca-parser').version_string() diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/capabilities.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/capabilities.py new file mode 100644 index 0000000..c23ef72 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/capabilities.py @@ -0,0 +1,45 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from toscaparser.properties import Property + + +class Capability(object): + '''TOSCA built-in capabilities type.''' + + def __init__(self, name, properties, definition): + self.name = name + self._properties = properties + self.definition = definition + + def get_properties_objects(self): + '''Return a list of property objects.''' + properties = [] + props = self._properties + if props: + for name, value in props.items(): + props_def = self.definition.get_properties_def() + if props_def and name in props_def: + properties.append(Property(name, value, + props_def[name].schema)) + return properties + + def get_properties(self): + '''Return a dictionary of property name-object pairs.''' + return {prop.name: prop + for prop in self.get_properties_objects()} + + def get_property_value(self, name): + '''Return the value of a given property name.''' + props = self.get_properties() + if props and name in props: + return props[name].value diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/common/__init__.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/common/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/common/exception.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/common/exception.py new file mode 100644 index 0000000..f41b65c --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/common/exception.py @@ -0,0 +1,180 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +''' +TOSCA exception classes +''' +import logging +import sys +import traceback + +from toscaparser.utils.gettextutils import _ + + +log = logging.getLogger(__name__) + + +class TOSCAException(Exception): + '''Base exception class for TOSCA + + To correctly use this class, inherit from it and define + a 'msg_fmt' property. + + ''' + + _FATAL_EXCEPTION_FORMAT_ERRORS = False + + message = _('An unknown exception occurred.') + + def __init__(self, **kwargs): + try: + self.message = self.msg_fmt % kwargs + except KeyError: + exc_info = sys.exc_info() + log.exception(_('Exception in string format operation: %s') + % exc_info[1]) + + if TOSCAException._FATAL_EXCEPTION_FORMAT_ERRORS: + raise exc_info[0] + + def __str__(self): + return self.message + + @staticmethod + def set_fatal_format_exception(flag): + if isinstance(flag, bool): + TOSCAException._FATAL_EXCEPTION_FORMAT_ERRORS = flag + + +class MissingRequiredFieldError(TOSCAException): + msg_fmt = _('%(what)s is missing required field "%(required)s".') + + +class UnknownFieldError(TOSCAException): + msg_fmt = _('%(what)s contains unknown field "%(field)s". Refer to the ' + 'definition to verify valid values.') + + +class TypeMismatchError(TOSCAException): + msg_fmt = _('%(what)s must be of type "%(type)s".') + + +class InvalidNodeTypeError(TOSCAException): + msg_fmt = _('Node type "%(what)s" is not a valid type.') + + +class InvalidTypeError(TOSCAException): + msg_fmt = _('Type "%(what)s" is not a valid type.') + + +class InvalidSchemaError(TOSCAException): + msg_fmt = _('%(message)s') + + +class ValidationError(TOSCAException): + msg_fmt = _('%(message)s') + + +class UnknownInputError(TOSCAException): + msg_fmt = _('Unknown input "%(input_name)s".') + + +class InvalidPropertyValueError(TOSCAException): + msg_fmt = _('Value of property "%(what)s" is invalid.') + + +class InvalidTemplateVersion(TOSCAException): + msg_fmt = _('The template version "%(what)s" is invalid. ' + 'Valid versions are "%(valid_versions)s".') + + +class InvalidTOSCAVersionPropertyException(TOSCAException): + msg_fmt = _('Value of TOSCA version property "%(what)s" is invalid.') + + +class URLException(TOSCAException): + msg_fmt = _('%(what)s') + + +class ExceptionCollector(object): + + exceptions = [] + collecting = False + + @staticmethod + def clear(): + del ExceptionCollector.exceptions[:] + + @staticmethod + def start(): + ExceptionCollector.clear() + ExceptionCollector.collecting = True + + @staticmethod + def stop(): + ExceptionCollector.collecting = False + + @staticmethod + def contains(exception): + for ex in ExceptionCollector.exceptions: + if str(ex) == str(exception): + return True + return False + + @staticmethod + def appendException(exception): + if ExceptionCollector.collecting: + if not ExceptionCollector.contains(exception): + exception.trace = traceback.extract_stack()[:-1] + ExceptionCollector.exceptions.append(exception) + else: + raise exception + + @staticmethod + def exceptionsCaught(): + return len(ExceptionCollector.exceptions) > 0 + + @staticmethod + def getTraceString(traceList): + traceString = '' + for entry in traceList: + f, l, m, c = entry[0], entry[1], entry[2], entry[3] + traceString += (_('\t\tFile %(file)s, line %(line)s, in ' + '%(method)s\n\t\t\t%(call)s\n') + % {'file': f, 'line': l, 'method': m, 'call': c}) + return traceString + + @staticmethod + def getExceptionReportEntry(exception, full=True): + entry = exception.__class__.__name__ + ': ' + str(exception) + if full: + entry += '\n' + ExceptionCollector.getTraceString(exception.trace) + return entry + + @staticmethod + def getExceptions(): + return ExceptionCollector.exceptions + + @staticmethod + def getExceptionsReport(full=True): + report = [] + for exception in ExceptionCollector.exceptions: + report.append( + ExceptionCollector.getExceptionReportEntry(exception, full)) + return report + + @staticmethod + def assertExceptionMessage(exception, message): + err_msg = exception.__name__ + ': ' + message + report = ExceptionCollector.getExceptionsReport(False) + assert err_msg in report, (_('Could not find "%(msg)s" in "%(rep)s".') + % {'rep': report.__str__(), 'msg': err_msg}) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/dataentity.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/dataentity.py new file mode 100644 index 0000000..4b37e03 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/dataentity.py @@ -0,0 +1,163 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from toscaparser.common.exception import ExceptionCollector +from toscaparser.common.exception import MissingRequiredFieldError +from toscaparser.common.exception import TypeMismatchError +from toscaparser.common.exception import UnknownFieldError +from toscaparser.elements.constraints import Schema +from toscaparser.elements.datatype import DataType +from toscaparser.elements.scalarunit import ScalarUnit_Frequency +from toscaparser.elements.scalarunit import ScalarUnit_Size +from toscaparser.elements.scalarunit import ScalarUnit_Time + +from toscaparser.utils.gettextutils import _ +from toscaparser.utils import validateutils + + +class DataEntity(object): + '''A complex data value entity.''' + + def __init__(self, datatypename, value_dict, custom_def=None): + self.custom_def = custom_def + self.datatype = DataType(datatypename, custom_def) + self.schema = self.datatype.get_all_properties() + self.value = value_dict + + def validate(self): + '''Validate the value by the definition of the datatype.''' + + # A datatype can not have both 'type' and 'properties' definitions. + # If the datatype has 'type' definition + if self.datatype.value_type: + self.value = DataEntity.validate_datatype(self.datatype.value_type, + self.value, + None, + self.custom_def) + schema = Schema(None, self.datatype.defs) + for constraint in schema.constraints: + constraint.validate(self.value) + # If the datatype has 'properties' definition + else: + if not isinstance(self.value, dict): + ExceptionCollector.appendException( + TypeMismatchError(what=self.value, + type=self.datatype.type)) + allowed_props = [] + required_props = [] + default_props = {} + if self.schema: + allowed_props = self.schema.keys() + for name, prop_def in self.schema.items(): + if prop_def.required: + required_props.append(name) + if prop_def.default: + default_props[name] = prop_def.default + + # check allowed field + for value_key in list(self.value.keys()): + if value_key not in allowed_props: + ExceptionCollector.appendException( + UnknownFieldError(what=(_('Data value of type "%s"') + % self.datatype.type), + field=value_key)) + + # check default field + for def_key, def_value in list(default_props.items()): + if def_key not in list(self.value.keys()): + self.value[def_key] = def_value + + # check missing field + missingprop = [] + for req_key in required_props: + if req_key not in list(self.value.keys()): + missingprop.append(req_key) + if missingprop: + ExceptionCollector.appendException( + MissingRequiredFieldError( + what=(_('Data value of type "%s"') + % self.datatype.type), required=missingprop)) + + # check every field + for name, value in list(self.value.items()): + prop_schema = Schema(name, self._find_schema(name)) + # check if field value meets type defined + DataEntity.validate_datatype(prop_schema.type, value, + prop_schema.entry_schema, + self.custom_def) + # check if field value meets constraints defined + if prop_schema.constraints: + for constraint in prop_schema.constraints: + constraint.validate(value) + + return self.value + + def _find_schema(self, name): + if self.schema and name in self.schema.keys(): + return self.schema[name].schema + + @staticmethod + def validate_datatype(type, value, entry_schema=None, custom_def=None): + '''Validate value with given type. + + If type is list or map, validate its entry by entry_schema(if defined) + If type is a user-defined complex datatype, custom_def is required. + ''' + if type == Schema.STRING: + return validateutils.validate_string(value) + elif type == Schema.INTEGER: + return validateutils.validate_integer(value) + elif type == Schema.FLOAT: + return validateutils.validate_float(value) + elif type == Schema.NUMBER: + return validateutils.validate_number(value) + elif type == Schema.BOOLEAN: + return validateutils.validate_boolean(value) + elif type == Schema.TIMESTAMP: + validateutils.validate_timestamp(value) + return value + elif type == Schema.LIST: + validateutils.validate_list(value) + if entry_schema: + DataEntity.validate_entry(value, entry_schema, custom_def) + return value + elif type == Schema.SCALAR_UNIT_SIZE: + return ScalarUnit_Size(value).validate_scalar_unit() + elif type == Schema.SCALAR_UNIT_FREQUENCY: + return ScalarUnit_Frequency(value).validate_scalar_unit() + elif type == Schema.SCALAR_UNIT_TIME: + return ScalarUnit_Time(value).validate_scalar_unit() + elif type == Schema.VERSION: + return validateutils.TOSCAVersionProperty(value).get_version() + elif type == Schema.MAP: + validateutils.validate_map(value) + if entry_schema: + DataEntity.validate_entry(value, entry_schema, custom_def) + return value + else: + data = DataEntity(type, value, custom_def) + return data.validate() + + @staticmethod + def validate_entry(value, entry_schema, custom_def=None): + '''Validate entries for map and list.''' + schema = Schema(None, entry_schema) + valuelist = value + if isinstance(value, dict): + valuelist = list(value.values()) + for v in valuelist: + DataEntity.validate_datatype(schema.type, v, schema.entry_schema, + custom_def) + if schema.constraints: + for constraint in schema.constraints: + constraint.validate(v) + return value diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/TOSCA_definition_1_0.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/TOSCA_definition_1_0.yaml new file mode 100644 index 0000000..2f50ff0 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/TOSCA_definition_1_0.yaml @@ -0,0 +1,778 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +########################################################################## +# The content of this file reflects TOSCA Simple Profile in YAML version +# 1.0.0. It describes the definition for TOSCA types including Node Type, +# Relationship Type, Capability Type and Interfaces. +########################################################################## +tosca_definitions_version: tosca_simple_yaml_1_0 + +########################################################################## +# Node Type. +# A Node Type is a reusable entity that defines the type of one or more +# Node Templates. +########################################################################## +tosca.nodes.Root: + description: > + The TOSCA root node all other TOSCA base node types derive from. + attributes: + tosca_id: + type: string + tosca_name: + type: string + state: + type: string + capabilities: + feature: + type: tosca.capabilities.Node + requirements: + - dependency: + capability: tosca.capabilities.Node + node: tosca.nodes.Root + relationship: tosca.relationships.DependsOn + occurrences: [ 0, UNBOUNDED ] + interfaces: + Standard: + type: tosca.interfaces.node.lifecycle.Standard + +tosca.nodes.Compute: + derived_from: tosca.nodes.Root + attributes: + private_address: + type: string + public_address: + type: string + capabilities: + host: + type: tosca.capabilities.Container + binding: + type: tosca.capabilities.network.Bindable + os: + type: tosca.capabilities.OperatingSystem + scalable: + type: tosca.capabilities.Scalable + requirements: + - local_storage: + capability: tosca.capabilities.Attachment + node: tosca.nodes.BlockStorage + relationship: tosca.relationships.AttachesTo + occurrences: [0, UNBOUNDED] + +tosca.nodes.SoftwareComponent: + derived_from: tosca.nodes.Root + properties: + # domain-specific software component version + component_version: + type: version + required: false + description: > + Software component version. + admin_credential: + type: tosca.datatypes.Credential + required: false + requirements: + - host: + capability: tosca.capabilities.Container + node: tosca.nodes.Compute + relationship: tosca.relationships.HostedOn + +tosca.nodes.DBMS: + derived_from: tosca.nodes.SoftwareComponent + properties: + port: + required: no + type: integer + description: > + The port the DBMS service will listen to for data and requests. + root_password: + required: no + type: string + description: > + The root password for the DBMS service. + capabilities: + host: + type: tosca.capabilities.Container + valid_source_types: [tosca.nodes.Database] + +tosca.nodes.Database: + derived_from: tosca.nodes.Root + properties: + user: + required: no + type: string + description: > + User account name for DB administration + name: + required: no + type: string + description: > + The name of the database. + password: + required: no + type: string + description: > + The password for the DB user account + requirements: + - host: + capability: tosca.capabilities.Container + node: tosca.nodes.DBMS + relationship: tosca.relationships.HostedOn + capabilities: + database_endpoint: + type: tosca.capabilities.Endpoint.Database + +tosca.nodes.WebServer: + derived_from: tosca.nodes.SoftwareComponent + capabilities: + data_endpoint: + type: tosca.capabilities.Endpoint + admin_endpoint: + type: tosca.capabilities.Endpoint.Admin + host: + type: tosca.capabilities.Container + valid_source_types: [tosca.nodes.WebApplication] + +tosca.nodes.WebApplication: + derived_from: tosca.nodes.Root + properties: + context_root: + type: string + required: false + requirements: + - host: + capability: tosca.capabilities.Container + node: tosca.nodes.WebServer + relationship: tosca.relationships.HostedOn + capabilities: + app_endpoint: + type: tosca.capabilities.Endpoint + +tosca.nodes.BlockStorage: + derived_from: tosca.nodes.Root + properties: + size: + type: scalar-unit.size + constraints: + - greater_or_equal: 1 MB + volume_id: + type: string + required: false + snapshot_id: + type: string + required: false + attributes: + volume_id: + type: string + capabilities: + attachment: + type: tosca.capabilities.Attachment + +tosca.nodes.network.Network: + derived_from: tosca.nodes.Root + description: > + The TOSCA Network node represents a simple, logical network service. + properties: + ip_version: + type: integer + required: no + default: 4 + constraints: + - valid_values: [ 4, 6 ] + description: > + The IP version of the requested network. Valid values are 4 for ipv4 + or 6 for ipv6. + cidr: + type: string + required: no + description: > + The cidr block of the requested network. + start_ip: + type: string + required: no + description: > + The IP address to be used as the start of a pool of addresses within + the full IP range derived from the cidr block. + end_ip: + type: string + required: no + description: > + The IP address to be used as the end of a pool of addresses within + the full IP range derived from the cidr block. + gateway_ip: + type: string + required: no + description: > + The gateway IP address. + network_name: + type: string + required: no + description: > + An identifier that represents an existing Network instance in the + underlying cloud infrastructure or can be used as the name of the + newly created network. If network_name is provided and no other + properties are provided (with exception of network_id), then an + existing network instance will be used. If network_name is provided + alongside with more properties then a new network with this name will + be created. + network_id: + type: string + required: no + description: > + An identifier that represents an existing Network instance in the + underlying cloud infrastructure. This property is mutually exclusive + with all other properties except network_name. This can be used alone + or together with network_name to identify an existing network. + segmentation_id: + type: string + required: no + description: > + A segmentation identifier in the underlying cloud infrastructure. + E.g. VLAN ID, GRE tunnel ID, etc.. + dhcp_enabled: + type: boolean + required: no + default: true + description: > + Indicates should DHCP service be enabled on the network or not. + capabilities: + link: + type: tosca.capabilities.network.Linkable + +tosca.nodes.network.Port: + derived_from: tosca.nodes.Root + description: > + The TOSCA Port node represents a logical entity that associates between + Compute and Network normative types. The Port node type effectively + represents a single virtual NIC on the Compute node instance. + properties: + ip_address: + type: string + required: no + description: > + Allow the user to set a static IP. + order: + type: integer + required: no + default: 0 + constraints: + - greater_or_equal: 0 + description: > + The order of the NIC on the compute instance (e.g. eth2). + is_default: + type: boolean + required: no + default: false + description: > + If is_default=true this port will be used for the default gateway + route. Only one port that is associated to single compute node can + set as is_default=true. + ip_range_start: + type: string + required: no + description: > + Defines the starting IP of a range to be allocated for the compute + instances that are associated with this Port. + ip_range_end: + type: string + required: no + description: > + Defines the ending IP of a range to be allocated for the compute + instances that are associated with this Port. + attributes: + ip_address: + type: string + requirements: + - binding: + description: > + Binding requirement expresses the relationship between Port and + Compute nodes. Effectevely it indicates that the Port will be + attached to specific Compute node instance + capability: tosca.capabilities.network.Bindable + relationship: tosca.relationships.network.BindsTo + - link: + description: > + Link requirement expresses the relationship between Port and Network + nodes. It indicates which network this port will connect to. + capability: tosca.capabilities.network.Linkable + relationship: tosca.relationships.network.LinksTo + +tosca.nodes.ObjectStorage: + derived_from: tosca.nodes.Root + description: > + The TOSCA ObjectStorage node represents storage that provides the ability + to store data as objects (or BLOBs of data) without consideration for the + underlying filesystem or devices + properties: + name: + type: string + required: yes + description: > + The logical name of the object store (or container). + size: + type: scalar-unit.size + required: no + constraints: + - greater_or_equal: 0 GB + description: > + The requested initial storage size. + maxsize: + type: scalar-unit.size + required: no + constraints: + - greater_or_equal: 0 GB + description: > + The requested maximum storage size. + capabilities: + storage_endpoint: + type: tosca.capabilities.Endpoint + +########################################################################## +# Relationship Type. +# A Relationship Type is a reusable entity that defines the type of one +# or more relationships between Node Types or Node Templates. +########################################################################## +tosca.relationships.Root: + description: > + The TOSCA root Relationship Type all other TOSCA base Relationship Types + derive from. + attributes: + tosca_id: + type: string + tosca_name: + type: string + interfaces: + Configure: + type: tosca.interfaces.relationship.Configure + +tosca.relationships.DependsOn: + derived_from: tosca.relationships.Root + +tosca.relationships.HostedOn: + derived_from: tosca.relationships.Root + valid_target_types: [ tosca.capabilities.Container ] + +tosca.relationships.ConnectsTo: + derived_from: tosca.relationships.Root + valid_target_types: [ tosca.capabilities.Endpoint ] + credential: + type: tosca.datatypes.Credential + required: false + +tosca.relationships.AttachesTo: + derived_from: tosca.relationships.Root + valid_target_types: [ tosca.capabilities.Attachment ] + properties: + location: + required: true + type: string + constraints: + - min_length: 1 + device: + required: false + type: string + +tosca.relationships.network.LinksTo: + derived_from: tosca.relationships.DependsOn + valid_target_types: [ tosca.capabilities.network.Linkable ] + +tosca.relationships.network.BindsTo: + derived_from: tosca.relationships.DependsOn + valid_target_types: [ tosca.capabilities.network.Bindable ] + +########################################################################## +# Capability Type. +# A Capability Type is a reusable entity that describes a kind of +# capability that a Node Type can declare to expose. +########################################################################## +tosca.capabilities.Root: + description: > + The TOSCA root Capability Type all other TOSCA base Capability Types + derive from. + +tosca.capabilities.Node: + derived_from: tosca.capabilities.Root + +tosca.capabilities.Container: + derived_from: tosca.capabilities.Root + properties: + num_cpus: + required: no + type: integer + constraints: + - greater_or_equal: 1 + cpu_frequency: + required: no + type: scalar-unit.frequency + constraints: + - greater_or_equal: 0.1 GHz + 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 + properties: + protocol: + type: string + default: tcp + port: + type: tosca.datatypes.network.PortDef + required: false + secure: + type: boolean + default: false + url_path: + type: string + required: false + port_name: + type: string + required: false + network_name: + type: string + required: false + initiator: + type: string + default: source + constraints: + - valid_values: [source, target, peer] + ports: + type: map + required: false + constraints: + - min_length: 1 + entry_schema: + type: tosca.datatypes.network.PortSpec + attributes: + ip_address: + type: string + +tosca.capabilities.Endpoint.Admin: + derived_from: tosca.capabilities.Endpoint + properties: + secure: + type: boolean + default: true + constraints: + - equal: true + +tosca.capabilities.Endpoint.Public: + derived_from: tosca.capabilities.Endpoint + properties: + # Change the default network_name to use the first public network found + network_name: + type: string + default: PUBLIC + constraints: + - equal: PUBLIC + floating: + description: > + Indicates that the public address should be allocated from a pool of + floating IPs that are associated with the network. + type: boolean + default: false + status: experimental + dns_name: + description: The optional name to register with DNS + type: string + required: false + status: experimental + +tosca.capabilities.Scalable: + derived_from: tosca.capabilities.Root + properties: + min_instances: + type: integer + required: yes + default: 1 + description: > + This property is used to indicate the minimum number of instances + that should be created for the associated TOSCA Node Template by + a TOSCA orchestrator. + max_instances: + type: integer + required: yes + default: 1 + description: > + This property is used to indicate the maximum number of instances + that should be created for the associated TOSCA Node Template by + a TOSCA orchestrator. + default_instances: + type: integer + required: no + description: > + An optional property that indicates the requested default number + of instances that should be the starting number of instances a + TOSCA orchestrator should attempt to allocate. + The value for this property MUST be in the range between the values + set for min_instances and max_instances properties. + +tosca.capabilities.Endpoint.Database: + derived_from: tosca.capabilities.Endpoint + +tosca.capabilities.Attachment: + derived_from: tosca.capabilities.Root + +tosca.capabilities.network.Linkable: + derived_from: tosca.capabilities.Root + description: > + A node type that includes the Linkable capability indicates that it can + be pointed by tosca.relationships.network.LinksTo relationship type, which + represents an association relationship between Port and Network node types. + +tosca.capabilities.network.Bindable: + derived_from: tosca.capabilities.Root + description: > + A node type that includes the Bindable capability indicates that it can + be pointed by tosca.relationships.network.BindsTo relationship type, which + represents a network association relationship between Port and Compute node + types. + +tosca.capabilities.OperatingSystem: + derived_from: tosca.capabilities.Root + properties: + architecture: + required: false + type: string + description: > + The host Operating System (OS) architecture. + type: + required: false + type: string + description: > + The host Operating System (OS) type. + distribution: + required: false + type: string + description: > + The host Operating System (OS) distribution. Examples of valid values + for an “type” of “Linux” would include: + debian, fedora, rhel and ubuntu. + version: + required: false + type: version + description: > + The host Operating System version. + +########################################################################## + # Interfaces Type. + # The Interfaces element describes a list of one or more interface + # definitions for a modelable entity (e.g., a Node or Relationship Type) + # as defined within the TOSCA Simple Profile specification. +########################################################################## +tosca.interfaces.node.lifecycle.Standard: + create: + description: Standard lifecycle create operation. + configure: + description: Standard lifecycle configure operation. + start: + description: Standard lifecycle start operation. + stop: + description: Standard lifecycle stop operation. + delete: + description: Standard lifecycle delete operation. + +tosca.interfaces.relationship.Configure: + pre_configure_source: + description: Operation to pre-configure the source endpoint. + pre_configure_target: + description: Operation to pre-configure the target endpoint. + post_configure_source: + description: Operation to post-configure the source endpoint. + post_configure_target: + description: Operation to post-configure the target endpoint. + add_target: + description: Operation to add a target node. + remove_target: + description: Operation to remove a target node. + add_source: > + description: Operation to notify the target node of a source node which + is now available via a relationship. + description: + target_changed: > + description: Operation to notify source some property or attribute of the + target changed + +########################################################################## + # Data Type. + # A Datatype is a complex data type declaration which contains other + # complex or simple data types. +########################################################################## +tosca.datatypes.Root: + description: > + The TOSCA root Data Type all other TOSCA base Data Types derive from + +tosca.datatypes.network.NetworkInfo: + derived_from: tosca.datatypes.Root + properties: + network_name: + type: string + network_id: + type: string + addresses: + type: list + entry_schema: + type: string + +tosca.datatypes.network.PortInfo: + derived_from: tosca.datatypes.Root + properties: + port_name: + type: string + port_id: + type: string + network_id: + type: string + mac_address: + type: string + addresses: + type: list + entry_schema: + type: string + +tosca.datatypes.network.PortDef: + derived_from: tosca.datatypes.Root + type: integer + constraints: + - in_range: [ 1, 65535 ] + +tosca.datatypes.network.PortSpec: + derived_from: tosca.datatypes.Root + properties: + protocol: + type: string + required: true + default: tcp + constraints: + - valid_values: [ udp, tcp, igmp ] + target: + type: PortDef + target_range: + type: range + constraints: + - in_range: [ 1, 65535 ] + source: + type: PortDef + source_range: + type: range + constraints: + - in_range: [ 1, 65535 ] + +tosca.datatypes.Credential: + derived_from: tosca.datatypes.Root + properties: + protocol: + type: string + token_type: + type: string + token: + type: string + keys: + type: map + entry_schema: + type: string + user: + type: string + required: false + +########################################################################## + # Artifact Type. + # An Artifact Type is a reusable entity that defines the type of one or more + # files which Node Types or Node Templates can have dependent relationships + # and used during operations such as during installation or deployment. +########################################################################## +tosca.artifacts.Root: + description: > + The TOSCA Artifact Type all other TOSCA Artifact Types derive from + properties: + version: version + +tosca.artifacts.File: + derived_from: tosca.artifacts.Root + +tosca.artifacts.Deployment: + derived_from: tosca.artifacts.Root + description: TOSCA base type for deployment artifacts + +tosca.artifacts.Deployment.Image: + derived_from: tosca.artifacts.Deployment + +tosca.artifacts.Deployment.Image.VM: + derived_from: tosca.artifacts.Deployment.Image + +tosca.artifacts.Implementation: + derived_from: tosca.artifacts.Root + description: TOSCA base type for implementation artifacts + +tosca.artifacts.Implementation.Bash: + derived_from: tosca.artifacts.Implementation + description: Script artifact for the Unix Bash shell + mime_type: application/x-sh + file_ext: [ sh ] + +tosca.artifacts.Implementation.Python: + derived_from: tosca.artifacts.Implementation + description: Artifact for the interpreted Python language + mime_type: application/x-python + file_ext: [ py ] + +tosca.artifacts.Deployment.Image.Container.Docker: + derived_from: tosca.artifacts.Deployment.Image + description: Docker container image + +tosca.artifacts.Deployment.Image.VM.ISO: + derived_from: tosca.artifacts.Deployment.Image + description: Virtual Machine (VM) image in ISO disk format + mime_type: application/octet-stream + file_ext: [ iso ] + +tosca.artifacts.Deployment.Image.VM.QCOW2: + derived_from: tosca.artifacts.Deployment.Image + description: Virtual Machine (VM) image in QCOW v2 standard disk format + mime_type: application/octet-stream + file_ext: [ qcow2 ] + +########################################################################## + # Policy Type. + # TOSCA Policy Types represent logical grouping of TOSCA nodes that have + # an implied relationship and need to be orchestrated or managed together + # to achieve some result. +########################################################################## +tosca.policies.Root: + description: The TOSCA Policy Type all other TOSCA Policy Types derive from. + +tosca.policies.Placement: + derived_from: tosca.policies.Root + description: The TOSCA Policy Type definition that is used to govern + placement of TOSCA nodes or groups of nodes. + +tosca.policies.Scaling: + derived_from: tosca.policies.Root + description: The TOSCA Policy Type definition that is used to govern + scaling of TOSCA nodes or groups of nodes. + +tosca.policies.Update: + derived_from: tosca.policies.Root + description: The TOSCA Policy Type definition that is used to govern + update of TOSCA nodes or groups of nodes. + +tosca.policies.Performance: + derived_from: tosca.policies.Root + description: The TOSCA Policy Type definition that is used to declare + performance requirements for TOSCA nodes or groups of nodes. diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/__init__.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/artifacttype.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/artifacttype.py new file mode 100644 index 0000000..3bfd7d0 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/artifacttype.py @@ -0,0 +1,45 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from toscaparser.elements.statefulentitytype import StatefulEntityType + + +class ArtifactTypeDef(StatefulEntityType): + '''TOSCA built-in artifacts type.''' + + def __init__(self, atype, custom_def=None): + super(ArtifactTypeDef, self).__init__(atype, self.ARTIFACT_PREFIX, + custom_def) + self.type = atype + self.properties = None + if self.PROPERTIES in self.defs: + self.properties = self.defs[self.PROPERTIES] + self.parent_artifacts = self._get_parent_artifacts() + + def _get_parent_artifacts(self): + artifacts = {} + parent_artif = self.parent_type + if parent_artif: + while parent_artif != 'tosca.artifacts.Root': + artifacts[parent_artif] = self.TOSCA_DEF[parent_artif] + parent_artif = artifacts[parent_artif]['derived_from'] + return artifacts + + @property + def parent_type(self): + '''Return an artifact this artifact is derived from.''' + return self.derived_from(self.defs) + + def get_artifact(self, name): + '''Return the definition of an artifact field by name.''' + if name in self.defs: + return self.defs[name] diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/attribute_definition.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/attribute_definition.py new file mode 100644 index 0000000..35ba27f --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/attribute_definition.py @@ -0,0 +1,20 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +class AttributeDef(object): + '''TOSCA built-in Attribute type.''' + + def __init__(self, name, value=None, schema=None): + self.name = name + self.value = value + self.schema = schema diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/capabilitytype.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/capabilitytype.py new file mode 100644 index 0000000..f9c8476 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/capabilitytype.py @@ -0,0 +1,72 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from toscaparser.elements.property_definition import PropertyDef +from toscaparser.elements.statefulentitytype import StatefulEntityType + + +class CapabilityTypeDef(StatefulEntityType): + '''TOSCA built-in capabilities type.''' + + def __init__(self, name, ctype, ntype, custom_def=None): + self.name = name + super(CapabilityTypeDef, self).__init__(ctype, self.CAPABILITY_PREFIX, + custom_def) + self.nodetype = ntype + self.properties = None + if self.PROPERTIES in self.defs: + self.properties = self.defs[self.PROPERTIES] + self.parent_capabilities = self._get_parent_capabilities() + + def get_properties_def_objects(self): + '''Return a list of property definition objects.''' + properties = [] + parent_properties = {} + if self.parent_capabilities: + for type, value in self.parent_capabilities.items(): + parent_properties[type] = value.get('properties') + if self.properties: + for prop, schema in self.properties.items(): + properties.append(PropertyDef(prop, None, schema)) + if parent_properties: + for parent, props in parent_properties.items(): + for prop, schema in props.items(): + # add parent property if not overridden by children type + if not self.properties or \ + prop not in self.properties.items(): + properties.append(PropertyDef(prop, None, schema)) + return properties + + def get_properties_def(self): + '''Return a dictionary of property definition name-object pairs.''' + return {prop.name: prop + for prop in self.get_properties_def_objects()} + + def get_property_def_value(self, name): + '''Return the definition of a given property name.''' + props_def = self.get_properties_def() + if props_def and name in props_def: + return props_def[name].value + + def _get_parent_capabilities(self): + capabilities = {} + parent_cap = self.parent_type + if parent_cap: + while parent_cap != 'tosca.capabilities.Root': + capabilities[parent_cap] = self.TOSCA_DEF[parent_cap] + parent_cap = capabilities[parent_cap]['derived_from'] + return capabilities + + @property + def parent_type(self): + '''Return a capability this capability is derived from.''' + return self.derived_from(self.defs) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/constraints.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/constraints.py new file mode 100644 index 0000000..e462095 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/constraints.py @@ -0,0 +1,597 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import collections +import datetime +import re + +import toscaparser +from toscaparser.common.exception import ExceptionCollector +from toscaparser.common.exception import InvalidSchemaError +from toscaparser.common.exception import ValidationError +from toscaparser.elements import scalarunit +from toscaparser.utils.gettextutils import _ + + +class Schema(collections.Mapping): + + KEYS = ( + TYPE, REQUIRED, DESCRIPTION, + DEFAULT, CONSTRAINTS, ENTRYSCHEMA + ) = ( + 'type', 'required', 'description', + 'default', 'constraints', 'entry_schema' + ) + + PROPERTY_TYPES = ( + INTEGER, STRING, BOOLEAN, FLOAT, + NUMBER, TIMESTAMP, LIST, MAP, + SCALAR_UNIT_SIZE, SCALAR_UNIT_FREQUENCY, SCALAR_UNIT_TIME, + PORTDEF, VERSION + ) = ( + 'integer', 'string', 'boolean', 'float', + 'number', 'timestamp', 'list', 'map', + 'scalar-unit.size', 'scalar-unit.frequency', 'scalar-unit.time', + 'PortDef', 'version' + ) + + SCALAR_UNIT_SIZE_DEFAULT = 'B' + SCALAR_UNIT_SIZE_DICT = {'B': 1, 'KB': 1000, 'KIB': 1024, 'MB': 1000000, + 'MIB': 1048576, 'GB': 1000000000, + 'GIB': 1073741824, 'TB': 1000000000000, + 'TIB': 1099511627776} + + def __init__(self, name, schema_dict): + self.name = name + if not isinstance(schema_dict, collections.Mapping): + msg = (_('Schema definition of "%(pname)s" must be a dict.') + % dict(pname=name)) + ExceptionCollector.appendException(InvalidSchemaError(message=msg)) + + try: + schema_dict['type'] + except KeyError: + msg = (_('Schema definition of "%(pname)s" must have a "type" ' + 'attribute.') % dict(pname=name)) + ExceptionCollector.appendException(InvalidSchemaError(message=msg)) + + self.schema = schema_dict + self._len = None + self.constraints_list = [] + + @property + def type(self): + return self.schema[self.TYPE] + + @property + def required(self): + return self.schema.get(self.REQUIRED, True) + + @property + def description(self): + return self.schema.get(self.DESCRIPTION, '') + + @property + def default(self): + return self.schema.get(self.DEFAULT) + + @property + def constraints(self): + if not self.constraints_list: + constraint_schemata = self.schema.get(self.CONSTRAINTS) + if constraint_schemata: + self.constraints_list = [Constraint(self.name, + self.type, + cschema) + for cschema in constraint_schemata] + return self.constraints_list + + @property + def entry_schema(self): + return self.schema.get(self.ENTRYSCHEMA) + + def __getitem__(self, key): + return self.schema[key] + + def __iter__(self): + for k in self.KEYS: + try: + self.schema[k] + except KeyError: + pass + else: + yield k + + def __len__(self): + if self._len is None: + self._len = len(list(iter(self))) + return self._len + + +class Constraint(object): + '''Parent class for constraints for a Property or Input.''' + + CONSTRAINTS = (EQUAL, GREATER_THAN, + GREATER_OR_EQUAL, LESS_THAN, LESS_OR_EQUAL, IN_RANGE, + VALID_VALUES, LENGTH, MIN_LENGTH, MAX_LENGTH, PATTERN) = \ + ('equal', 'greater_than', 'greater_or_equal', 'less_than', + 'less_or_equal', 'in_range', 'valid_values', 'length', + 'min_length', 'max_length', 'pattern') + + def __new__(cls, property_name, property_type, constraint): + if cls is not Constraint: + return super(Constraint, cls).__new__(cls) + + if(not isinstance(constraint, collections.Mapping) or + len(constraint) != 1): + ExceptionCollector.appendException( + InvalidSchemaError(message=_('Invalid constraint schema.'))) + + for type in constraint.keys(): + ConstraintClass = get_constraint_class(type) + if not ConstraintClass: + msg = _('Invalid property "%s".') % type + ExceptionCollector.appendException( + InvalidSchemaError(message=msg)) + + return ConstraintClass(property_name, property_type, constraint) + + def __init__(self, property_name, property_type, constraint): + self.property_name = property_name + self.property_type = property_type + self.constraint_value = constraint[self.constraint_key] + self.constraint_value_msg = self.constraint_value + if self.property_type in scalarunit.ScalarUnit.SCALAR_UNIT_TYPES: + self.constraint_value = self._get_scalarunit_constraint_value() + # check if constraint is valid for property type + if property_type not in self.valid_prop_types: + msg = _('Property "%(ctype)s" is not valid for data type ' + '"%(dtype)s".') % dict( + ctype=self.constraint_key, + dtype=property_type) + ExceptionCollector.appendException(InvalidSchemaError(message=msg)) + + def _get_scalarunit_constraint_value(self): + if self.property_type in scalarunit.ScalarUnit.SCALAR_UNIT_TYPES: + ScalarUnit_Class = (scalarunit. + get_scalarunit_class(self.property_type)) + if isinstance(self.constraint_value, list): + return [ScalarUnit_Class(v).get_num_from_scalar_unit() + for v in self.constraint_value] + else: + return (ScalarUnit_Class(self.constraint_value). + get_num_from_scalar_unit()) + + def _err_msg(self, value): + return _('Property "%s" could not be validated.') % self.property_name + + def validate(self, value): + self.value_msg = value + if self.property_type in scalarunit.ScalarUnit.SCALAR_UNIT_TYPES: + value = scalarunit.get_scalarunit_value(self.property_type, value) + if not self._is_valid(value): + err_msg = self._err_msg(value) + ExceptionCollector.appendException( + ValidationError(message=err_msg)) + + +class Equal(Constraint): + """Constraint class for "equal" + + Constrains a property or parameter to a value equal to ('=') + the value declared. + """ + + constraint_key = Constraint.EQUAL + + valid_prop_types = Schema.PROPERTY_TYPES + + def _is_valid(self, value): + if value == self.constraint_value: + return True + + return False + + def _err_msg(self, value): + return (_('The value "%(pvalue)s" of property "%(pname)s" is not ' + 'equal to "%(cvalue)s".') % + dict(pname=self.property_name, + pvalue=self.value_msg, + cvalue=self.constraint_value_msg)) + + +class GreaterThan(Constraint): + """Constraint class for "greater_than" + + Constrains a property or parameter to a value greater than ('>') + the value declared. + """ + + constraint_key = Constraint.GREATER_THAN + + valid_types = (int, float, datetime.date, + datetime.time, datetime.datetime) + + valid_prop_types = (Schema.INTEGER, Schema.FLOAT, Schema.TIMESTAMP, + Schema.SCALAR_UNIT_SIZE, Schema.SCALAR_UNIT_FREQUENCY, + Schema.SCALAR_UNIT_TIME) + + def __init__(self, property_name, property_type, constraint): + super(GreaterThan, self).__init__(property_name, property_type, + constraint) + if not isinstance(constraint[self.GREATER_THAN], self.valid_types): + ExceptionCollector.appendException( + InvalidSchemaError(message=_('The property "greater_than" ' + 'expects comparable values.'))) + + def _is_valid(self, value): + if value > self.constraint_value: + return True + + return False + + def _err_msg(self, value): + return (_('The value "%(pvalue)s" of property "%(pname)s" must be ' + 'greater than "%(cvalue)s".') % + dict(pname=self.property_name, + pvalue=self.value_msg, + cvalue=self.constraint_value_msg)) + + +class GreaterOrEqual(Constraint): + """Constraint class for "greater_or_equal" + + Constrains a property or parameter to a value greater than or equal + to ('>=') the value declared. + """ + + constraint_key = Constraint.GREATER_OR_EQUAL + + valid_types = (int, float, datetime.date, + datetime.time, datetime.datetime) + + valid_prop_types = (Schema.INTEGER, Schema.FLOAT, Schema.TIMESTAMP, + Schema.SCALAR_UNIT_SIZE, Schema.SCALAR_UNIT_FREQUENCY, + Schema.SCALAR_UNIT_TIME) + + def __init__(self, property_name, property_type, constraint): + super(GreaterOrEqual, self).__init__(property_name, property_type, + constraint) + if not isinstance(self.constraint_value, self.valid_types): + ExceptionCollector.appendException( + InvalidSchemaError(message=_('The property ' + '"greater_or_equal" expects ' + 'comparable values.'))) + + def _is_valid(self, value): + if toscaparser.functions.is_function(value) or \ + value >= self.constraint_value: + return True + return False + + def _err_msg(self, value): + return (_('The value "%(pvalue)s" of property "%(pname)s" must be ' + 'greater than or equal to "%(cvalue)s".') % + dict(pname=self.property_name, + pvalue=self.value_msg, + cvalue=self.constraint_value_msg)) + + +class LessThan(Constraint): + """Constraint class for "less_than" + + Constrains a property or parameter to a value less than ('<') + the value declared. + """ + + constraint_key = Constraint.LESS_THAN + + valid_types = (int, float, datetime.date, + datetime.time, datetime.datetime) + + valid_prop_types = (Schema.INTEGER, Schema.FLOAT, Schema.TIMESTAMP, + Schema.SCALAR_UNIT_SIZE, Schema.SCALAR_UNIT_FREQUENCY, + Schema.SCALAR_UNIT_TIME) + + def __init__(self, property_name, property_type, constraint): + super(LessThan, self).__init__(property_name, property_type, + constraint) + if not isinstance(self.constraint_value, self.valid_types): + ExceptionCollector.appendException( + InvalidSchemaError(message=_('The property "less_than" ' + 'expects comparable values.'))) + + def _is_valid(self, value): + if value < self.constraint_value: + return True + + return False + + def _err_msg(self, value): + return (_('The value "%(pvalue)s" of property "%(pname)s" must be ' + 'less than "%(cvalue)s".') % + dict(pname=self.property_name, + pvalue=self.value_msg, + cvalue=self.constraint_value_msg)) + + +class LessOrEqual(Constraint): + """Constraint class for "less_or_equal" + + Constrains a property or parameter to a value less than or equal + to ('<=') the value declared. + """ + + constraint_key = Constraint.LESS_OR_EQUAL + + valid_types = (int, float, datetime.date, + datetime.time, datetime.datetime) + + valid_prop_types = (Schema.INTEGER, Schema.FLOAT, Schema.TIMESTAMP, + Schema.SCALAR_UNIT_SIZE, Schema.SCALAR_UNIT_FREQUENCY, + Schema.SCALAR_UNIT_TIME) + + def __init__(self, property_name, property_type, constraint): + super(LessOrEqual, self).__init__(property_name, property_type, + constraint) + if not isinstance(self.constraint_value, self.valid_types): + ExceptionCollector.appendException( + InvalidSchemaError(message=_('The property "less_or_equal" ' + 'expects comparable values.'))) + + def _is_valid(self, value): + if value <= self.constraint_value: + return True + + return False + + def _err_msg(self, value): + return (_('The value "%(pvalue)s" of property "%(pname)s" must be ' + 'less than or equal to "%(cvalue)s".') % + dict(pname=self.property_name, + pvalue=self.value_msg, + cvalue=self.constraint_value_msg)) + + +class InRange(Constraint): + """Constraint class for "in_range" + + Constrains a property or parameter to a value in range of (inclusive) + the two values declared. + """ + + constraint_key = Constraint.IN_RANGE + + valid_types = (int, float, datetime.date, + datetime.time, datetime.datetime) + + valid_prop_types = (Schema.INTEGER, Schema.FLOAT, Schema.TIMESTAMP, + Schema.SCALAR_UNIT_SIZE, Schema.SCALAR_UNIT_FREQUENCY, + Schema.SCALAR_UNIT_TIME) + + def __init__(self, property_name, property_type, constraint): + super(InRange, self).__init__(property_name, property_type, constraint) + if(not isinstance(self.constraint_value, collections.Sequence) or + (len(constraint[self.IN_RANGE]) != 2)): + ExceptionCollector.appendException( + InvalidSchemaError(message=_('The property "in_range" ' + 'expects a list.'))) + + for value in self.constraint_value: + if not isinstance(value, self.valid_types): + ExceptionCollector.appendException( + InvalidSchemaError(_('The property "in_range" expects ' + 'comparable values.'))) + + self.min = self.constraint_value[0] + self.max = self.constraint_value[1] + + def _is_valid(self, value): + if value < self.min: + return False + if value > self.max: + return False + + return True + + def _err_msg(self, value): + return (_('The value "%(pvalue)s" of property "%(pname)s" is out of ' + 'range "(min:%(vmin)s, max:%(vmax)s)".') % + dict(pname=self.property_name, + pvalue=self.value_msg, + vmin=self.constraint_value_msg[0], + vmax=self.constraint_value_msg[1])) + + +class ValidValues(Constraint): + """Constraint class for "valid_values" + + Constrains a property or parameter to a value that is in the list of + declared values. + """ + constraint_key = Constraint.VALID_VALUES + + valid_prop_types = Schema.PROPERTY_TYPES + + def __init__(self, property_name, property_type, constraint): + super(ValidValues, self).__init__(property_name, property_type, + constraint) + if not isinstance(self.constraint_value, collections.Sequence): + ExceptionCollector.appendException( + InvalidSchemaError(message=_('The property "valid_values" ' + 'expects a list.'))) + + def _is_valid(self, value): + if isinstance(value, list): + return all(v in self.constraint_value for v in value) + return value in self.constraint_value + + def _err_msg(self, value): + allowed = '[%s]' % ', '.join(str(a) for a in self.constraint_value) + return (_('The value "%(pvalue)s" of property "%(pname)s" is not ' + 'valid. Expected a value from "%(cvalue)s".') % + dict(pname=self.property_name, + pvalue=value, + cvalue=allowed)) + + +class Length(Constraint): + """Constraint class for "length" + + Constrains the property or parameter to a value of a given length. + """ + + constraint_key = Constraint.LENGTH + + valid_types = (int, ) + + valid_prop_types = (Schema.STRING, ) + + def __init__(self, property_name, property_type, constraint): + super(Length, self).__init__(property_name, property_type, constraint) + if not isinstance(self.constraint_value, self.valid_types): + ExceptionCollector.appendException( + InvalidSchemaError(message=_('The property "length" expects ' + 'an integer.'))) + + def _is_valid(self, value): + if isinstance(value, str) and len(value) == self.constraint_value: + return True + + return False + + def _err_msg(self, value): + return (_('Length of value "%(pvalue)s" of property "%(pname)s" ' + 'must be equal to "%(cvalue)s".') % + dict(pname=self.property_name, + pvalue=value, + cvalue=self.constraint_value)) + + +class MinLength(Constraint): + """Constraint class for "min_length" + + Constrains the property or parameter to a value to a minimum length. + """ + + constraint_key = Constraint.MIN_LENGTH + + valid_types = (int, ) + + valid_prop_types = (Schema.STRING, ) + + def __init__(self, property_name, property_type, constraint): + super(MinLength, self).__init__(property_name, property_type, + constraint) + if not isinstance(self.constraint_value, self.valid_types): + ExceptionCollector.appendException( + InvalidSchemaError(message=_('The property "min_length" ' + 'expects an integer.'))) + + def _is_valid(self, value): + if isinstance(value, str) and len(value) >= self.constraint_value: + return True + + return False + + def _err_msg(self, value): + return (_('Length of value "%(pvalue)s" of property "%(pname)s" ' + 'must be at least "%(cvalue)s".') % + dict(pname=self.property_name, + pvalue=value, + cvalue=self.constraint_value)) + + +class MaxLength(Constraint): + """Constraint class for "max_length" + + Constrains the property or parameter to a value to a maximum length. + """ + + constraint_key = Constraint.MAX_LENGTH + + valid_types = (int, ) + + valid_prop_types = (Schema.STRING, ) + + def __init__(self, property_name, property_type, constraint): + super(MaxLength, self).__init__(property_name, property_type, + constraint) + if not isinstance(self.constraint_value, self.valid_types): + ExceptionCollector.appendException( + InvalidSchemaError(message=_('The property "max_length" ' + 'expects an integer.'))) + + def _is_valid(self, value): + if isinstance(value, str) and len(value) <= self.constraint_value: + return True + + return False + + def _err_msg(self, value): + return (_('Length of value "%(pvalue)s" of property "%(pname)s" ' + 'must be no greater than "%(cvalue)s".') % + dict(pname=self.property_name, + pvalue=value, + cvalue=self.constraint_value)) + + +class Pattern(Constraint): + """Constraint class for "pattern" + + Constrains the property or parameter to a value that is allowed by + the provided regular expression. + """ + + constraint_key = Constraint.PATTERN + + valid_types = (str, ) + + valid_prop_types = (Schema.STRING, ) + + def __init__(self, property_name, property_type, constraint): + super(Pattern, self).__init__(property_name, property_type, constraint) + if not isinstance(self.constraint_value, self.valid_types): + ExceptionCollector.appendException( + InvalidSchemaError(message=_('The property "pattern" ' + 'expects a string.'))) + self.match = re.compile(self.constraint_value).match + + def _is_valid(self, value): + match = self.match(value) + return match is not None and match.end() == len(value) + + def _err_msg(self, value): + return (_('The value "%(pvalue)s" of property "%(pname)s" does not ' + 'match pattern "%(cvalue)s".') % + dict(pname=self.property_name, + pvalue=value, + cvalue=self.constraint_value)) + + +constraint_mapping = { + Constraint.EQUAL: Equal, + Constraint.GREATER_THAN: GreaterThan, + Constraint.GREATER_OR_EQUAL: GreaterOrEqual, + Constraint.LESS_THAN: LessThan, + Constraint.LESS_OR_EQUAL: LessOrEqual, + Constraint.IN_RANGE: InRange, + Constraint.VALID_VALUES: ValidValues, + Constraint.LENGTH: Length, + Constraint.MIN_LENGTH: MinLength, + Constraint.MAX_LENGTH: MaxLength, + Constraint.PATTERN: Pattern + } + + +def get_constraint_class(type): + return constraint_mapping.get(type) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/datatype.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/datatype.py new file mode 100644 index 0000000..7e05a69 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/datatype.py @@ -0,0 +1,56 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +from toscaparser.elements.statefulentitytype import StatefulEntityType + + +class DataType(StatefulEntityType): + '''TOSCA built-in and user defined complex data type.''' + + def __init__(self, datatypename, custom_def=None): + super(DataType, self).__init__(datatypename, self.DATATYPE_PREFIX, + custom_def) + self.custom_def = custom_def + + @property + def parent_type(self): + '''Return a datatype this datatype is derived from.''' + ptype = self.derived_from(self.defs) + if ptype: + return DataType(ptype, self.custom_def) + return None + + @property + def value_type(self): + '''Return 'type' section in the datatype schema.''' + return self.entity_value(self.defs, 'type') + + def get_all_properties_objects(self): + '''Return all properties objects defined in type and parent type.''' + props_def = self.get_properties_def_objects() + ptype = self.parent_type + while ptype: + props_def.extend(ptype.get_properties_def_objects()) + ptype = ptype.parent_type + return props_def + + def get_all_properties(self): + '''Return a dictionary of all property definition name-object pairs.''' + return {prop.name: prop + for prop in self.get_all_properties_objects()} + + def get_all_property_value(self, name): + '''Return the value of a given property name.''' + props_def = self.get_all_properties() + if props_def and name in props_def.key(): + return props_def[name].value diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/entity_type.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/entity_type.py new file mode 100644 index 0000000..54aaa7e --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/entity_type.py @@ -0,0 +1,115 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import logging +import os +import toscaparser.utils.yamlparser + +log = logging.getLogger('tosca') + + +class EntityType(object): + '''Base class for TOSCA elements.''' + + SECTIONS = (DERIVED_FROM, PROPERTIES, ATTRIBUTES, REQUIREMENTS, + INTERFACES, CAPABILITIES, TYPE, ARTIFACTS) = \ + ('derived_from', 'properties', 'attributes', 'requirements', + 'interfaces', 'capabilities', 'type', 'artifacts') + + '''TOSCA definition file.''' + TOSCA_DEF_FILE = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "TOSCA_definition_1_0.yaml") + + loader = toscaparser.utils.yamlparser.load_yaml + + TOSCA_DEF = loader(TOSCA_DEF_FILE) + + RELATIONSHIP_TYPE = (DEPENDSON, HOSTEDON, CONNECTSTO, ATTACHESTO, + LINKSTO, BINDSTO) = \ + ('tosca.relationships.DependsOn', + 'tosca.relationships.HostedOn', + 'tosca.relationships.ConnectsTo', + 'tosca.relationships.AttachesTo', + 'tosca.relationships.network.LinksTo', + 'tosca.relationships.network.BindsTo') + + NODE_PREFIX = 'tosca.nodes.' + RELATIONSHIP_PREFIX = 'tosca.relationships.' + CAPABILITY_PREFIX = 'tosca.capabilities.' + INTERFACE_PREFIX = 'tosca.interfaces.' + ARTIFACT_PREFIX = 'tosca.artifacts.' + POLICY_PREFIX = 'tosca.policies.' + # currently the data types are defined only for network + # but may have changes in the future. + DATATYPE_PREFIX = 'tosca.datatypes.network.' + TOSCA = 'tosca' + + def derived_from(self, defs): + '''Return a type this type is derived from.''' + return self.entity_value(defs, 'derived_from') + + def is_derived_from(self, type_str): + '''Check if object inherits from the given type. + + Returns true if this object is derived from 'type_str'. + False otherwise. + ''' + if not self.type: + return False + elif self.type == type_str: + return True + elif self.parent_type: + return self.parent_type.is_derived_from(type_str) + else: + return False + + def entity_value(self, defs, key): + if key in defs: + return defs[key] + + def get_value(self, ndtype, defs=None, parent=None): + value = None + if defs is None: + if not hasattr(self, 'defs'): + return + defs = self.defs + if ndtype in defs: + value = defs[ndtype] + if parent and not value: + p = self.parent_type + while value is None: + # check parent node + if not p: + break + if p and p.type == 'tosca.nodes.Root': + break + value = p.get_value(ndtype) + p = p.parent_type + return value + + def get_definition(self, ndtype): + value = None + defs = self.defs + if ndtype in defs: + value = defs[ndtype] + p = self.parent_type + if p: + inherited = p.get_definition(ndtype) + if inherited: + inherited = dict(inherited) + if not value: + value = inherited + else: + inherited.update(value) + value.update(inherited) + return value diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/interfaces.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/interfaces.py new file mode 100644 index 0000000..88fb8ab --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/interfaces.py @@ -0,0 +1,76 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from toscaparser.common.exception import ExceptionCollector +from toscaparser.common.exception import UnknownFieldError +from toscaparser.elements.statefulentitytype import StatefulEntityType + +SECTIONS = (LIFECYCLE, CONFIGURE, LIFECYCLE_SHORTNAME, + CONFIGURE_SHORTNAME) = \ + ('tosca.interfaces.node.lifecycle.Standard', + 'tosca.interfaces.relationship.Configure', + 'Standard', 'Configure') + +INTERFACEVALUE = (IMPLEMENTATION, INPUTS) = ('implementation', 'inputs') + + +class InterfacesDef(StatefulEntityType): + '''TOSCA built-in interfaces type.''' + + def __init__(self, node_type, interfacetype, + node_template=None, name=None, value=None): + self.ntype = node_type + self.node_template = node_template + self.type = interfacetype + self.name = name + self.value = value + self.implementation = None + self.inputs = None + self.defs = {} + if interfacetype == LIFECYCLE_SHORTNAME: + interfacetype = LIFECYCLE + if interfacetype == CONFIGURE_SHORTNAME: + interfacetype = CONFIGURE + if node_type: + self.defs = self.TOSCA_DEF[interfacetype] + if value: + if isinstance(self.value, dict): + for i, j in self.value.items(): + if i == IMPLEMENTATION: + self.implementation = j + elif i == INPUTS: + self.inputs = j + else: + what = ('"interfaces" of template "%s"' % + self.node_template.name) + ExceptionCollector.appendException( + UnknownFieldError(what=what, field=i)) + else: + self.implementation = value + + @property + def lifecycle_ops(self): + if self.defs: + if self.type == LIFECYCLE: + return self._ops() + + @property + def configure_ops(self): + if self.defs: + if self.type == CONFIGURE: + return self._ops() + + def _ops(self): + ops = [] + for name in list(self.defs.keys()): + ops.append(name) + return ops diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/nodetype.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/nodetype.py new file mode 100644 index 0000000..8ddc5a2 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/nodetype.py @@ -0,0 +1,202 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from toscaparser.elements.capabilitytype import CapabilityTypeDef +import toscaparser.elements.interfaces as ifaces +from toscaparser.elements.interfaces import InterfacesDef +from toscaparser.elements.relationshiptype import RelationshipType +from toscaparser.elements.statefulentitytype import StatefulEntityType + + +class NodeType(StatefulEntityType): + '''TOSCA built-in node type.''' + + def __init__(self, ntype, custom_def=None): + super(NodeType, self).__init__(ntype, self.NODE_PREFIX, custom_def) + self.custom_def = custom_def + + @property + def parent_type(self): + '''Return a node this node is derived from.''' + if not hasattr(self, 'defs'): + return + pnode = self.derived_from(self.defs) + if pnode: + return NodeType(pnode, self.custom_def) + + @property + def relationship(self): + '''Return a dictionary of relationships to other node types. + + This method returns a dictionary of named relationships that nodes + of the current node type (self) can have to other nodes (of specific + types) in a TOSCA template. + + ''' + relationship = {} + requires = self.get_all_requirements() + if requires: + # NOTE(sdmonov): Check if requires is a dict. + # If it is a dict convert it to a list of dicts. + # This is needed because currently the code below supports only + # lists as requirements definition. The following check will + # make sure if a map (dict) was provided it will be converted to + # a list before proceeding to the parsing. + if isinstance(requires, dict): + requires = [{key: value} for key, value in requires.items()] + + keyword = None + node_type = None + for require in requires: + for key, req in require.items(): + if 'relationship' in req: + relation = req.get('relationship') + if 'type' in relation: + relation = relation.get('type') + node_type = req.get('node') + value = req + if node_type: + keyword = 'node' + else: + # If value is a dict and has a type key + # we need to lookup the node type using + # the capability type + value = req + if isinstance(value, dict): + captype = value['capability'] + value = (self. + _get_node_type_by_cap(key, captype)) + relation = self._get_relation(key, value) + keyword = key + node_type = value + rtype = RelationshipType(relation, keyword, req) + relatednode = NodeType(node_type, self.custom_def) + relationship[rtype] = relatednode + return relationship + + def _get_node_type_by_cap(self, key, cap): + '''Find the node type that has the provided capability + + This method will lookup all node types if they have the + provided capability. + ''' + + # Filter the node types + node_types = [node_type for node_type in self.TOSCA_DEF.keys() + if node_type.startswith(self.NODE_PREFIX) and + node_type != 'tosca.nodes.Root'] + + for node_type in node_types: + node_def = self.TOSCA_DEF[node_type] + if isinstance(node_def, dict) and 'capabilities' in node_def: + node_caps = node_def['capabilities'] + for value in node_caps.values(): + if isinstance(value, dict) and \ + 'type' in value and value['type'] == cap: + return node_type + + def _get_relation(self, key, ndtype): + relation = None + ntype = NodeType(ndtype) + caps = ntype.get_capabilities() + if caps and key in caps.keys(): + c = caps[key] + for r in self.RELATIONSHIP_TYPE: + rtypedef = ntype.TOSCA_DEF[r] + for properties in rtypedef.values(): + if c.type in properties: + relation = r + break + if relation: + break + else: + for properties in rtypedef.values(): + if c.parent_type in properties: + relation = r + break + return relation + + def get_capabilities_objects(self): + '''Return a list of capability objects.''' + typecapabilities = [] + caps = self.get_value(self.CAPABILITIES) + if caps is None: + caps = self.get_value(self.CAPABILITIES, None, True) + if caps: + for name, value in caps.items(): + ctype = value.get('type') + cap = CapabilityTypeDef(name, ctype, self.type, + self.custom_def) + typecapabilities.append(cap) + return typecapabilities + + def get_capabilities(self): + '''Return a dictionary of capability name-objects pairs.''' + return {cap.name: cap + for cap in self.get_capabilities_objects()} + + @property + def requirements(self): + return self.get_value(self.REQUIREMENTS) + + def get_all_requirements(self): + requires = self.requirements + parent_node = self.parent_type + if requires is None: + requires = self.get_value(self.REQUIREMENTS, None, True) + parent_node = parent_node.parent_type + if parent_node: + while parent_node.type != 'tosca.nodes.Root': + req = parent_node.get_value(self.REQUIREMENTS, None, True) + for r in req: + if r not in requires: + requires.append(r) + parent_node = parent_node.parent_type + return requires + + @property + def interfaces(self): + return self.get_value(self.INTERFACES) + + @property + def lifecycle_inputs(self): + '''Return inputs to life cycle operations if found.''' + inputs = [] + interfaces = self.interfaces + if interfaces: + for name, value in interfaces.items(): + if name == ifaces.LIFECYCLE: + for x, y in value.items(): + if x == 'inputs': + for i in y.iterkeys(): + inputs.append(i) + return inputs + + @property + def lifecycle_operations(self): + '''Return available life cycle operations if found.''' + ops = None + interfaces = self.interfaces + if interfaces: + i = InterfacesDef(self.type, ifaces.LIFECYCLE) + ops = i.lifecycle_ops + return ops + + def get_capability(self, name): + caps = self.get_capabilities() + if caps and name in caps.keys(): + return caps[name].value + + def get_capability_type(self, name): + captype = self.get_capability(name) + if captype and name in captype.keys(): + return captype[name].value diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/policytype.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/policytype.py new file mode 100644 index 0000000..aa53c2d --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/policytype.py @@ -0,0 +1,45 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from toscaparser.elements.statefulentitytype import StatefulEntityType + + +class PolicyType(StatefulEntityType): + '''TOSCA built-in policies type.''' + + def __init__(self, ptype, custom_def=None): + super(PolicyType, self).__init__(ptype, self.POLICY_PREFIX, + custom_def) + self.type = ptype + self.properties = None + if self.PROPERTIES in self.defs: + self.properties = self.defs[self.PROPERTIES] + self.parent_policies = self._get_parent_policies() + + def _get_parent_policies(self): + policies = {} + parent_policy = self.parent_type + if parent_policy: + while parent_policy != 'tosca.policies.Root': + policies[parent_policy] = self.TOSCA_DEF[parent_policy] + parent_policy = policies[parent_policy]['derived_from'] + return policies + + @property + def parent_type(self): + '''Return a policy this policy is derived from.''' + return self.derived_from(self.defs) + + def get_policy(self, name): + '''Return the definition of a policy field by name.''' + if name in self.defs: + return self.defs[name] diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/property_definition.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/property_definition.py new file mode 100644 index 0000000..4ffcade --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/property_definition.py @@ -0,0 +1,48 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from toscaparser.common.exception import ExceptionCollector +from toscaparser.common.exception import InvalidSchemaError +from toscaparser.utils.gettextutils import _ + + +class PropertyDef(object): + '''TOSCA built-in Property type.''' + + def __init__(self, name, value=None, schema=None): + self.name = name + self.value = value + self.schema = schema + + try: + self.schema['type'] + except KeyError: + msg = (_('Schema definition of "%(pname)s" must have a "type" ' + 'attribute.') % dict(pname=self.name)) + ExceptionCollector.appendException( + InvalidSchemaError(message=msg)) + + @property + def required(self): + if self.schema: + for prop_key, prop_value in self.schema.items(): + if prop_key == 'required' and prop_value: + return True + return False + + @property + def default(self): + if self.schema: + for prop_key, prop_value in self.schema.items(): + if prop_key == 'default': + return prop_value + return None diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/relationshiptype.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/relationshiptype.py new file mode 100644 index 0000000..9462d38 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/relationshiptype.py @@ -0,0 +1,33 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from toscaparser.elements.statefulentitytype import StatefulEntityType + + +class RelationshipType(StatefulEntityType): + '''TOSCA built-in relationship type.''' + def __init__(self, type, capability_name=None, custom_def=None): + super(RelationshipType, self).__init__(type, self.RELATIONSHIP_PREFIX, + custom_def) + self.capability_name = capability_name + self.custom_def = custom_def + + @property + def parent_type(self): + '''Return a relationship this reletionship is derived from.''' + prel = self.derived_from(self.defs) + if prel: + return RelationshipType(prel) + + @property + def valid_target_types(self): + return self.entity_value(self.defs, 'valid_target_types') diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/scalarunit.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/scalarunit.py new file mode 100644 index 0000000..d7f72e6 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/scalarunit.py @@ -0,0 +1,129 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import logging +import re + +from toscaparser.common.exception import ExceptionCollector +from toscaparser.utils.gettextutils import _ +from toscaparser.utils import validateutils + +log = logging.getLogger('tosca') + + +class ScalarUnit(object): + '''Parent class for scalar-unit type.''' + + SCALAR_UNIT_TYPES = ( + SCALAR_UNIT_SIZE, SCALAR_UNIT_FREQUENCY, SCALAR_UNIT_TIME + ) = ( + 'scalar-unit.size', 'scalar-unit.frequency', 'scalar-unit.time' + ) + + def __init__(self, value): + self.value = value + + def _check_unit_in_scalar_standard_units(self, input_unit): + """Check whether the input unit is following specified standard + + If unit is not following specified standard, convert it to standard + unit after displaying a warning message. + """ + if input_unit in self.SCALAR_UNIT_DICT.keys(): + return input_unit + else: + for key in self.SCALAR_UNIT_DICT.keys(): + if key.upper() == input_unit.upper(): + log.warning(_('The unit "%(unit)s" does not follow ' + 'scalar unit standards; using "%(key)s" ' + 'instead.') % {'unit': input_unit, + 'key': key}) + return key + msg = (_('The unit "%(unit)s" is not valid. Valid units are ' + '"%(valid_units)s".') % + {'unit': input_unit, + 'valid_units': sorted(self.SCALAR_UNIT_DICT.keys())}) + ExceptionCollector.appendException(ValueError(msg)) + + def validate_scalar_unit(self): + regex = re.compile('([0-9.]+)\s*(\w+)') + try: + result = regex.match(str(self.value)).groups() + validateutils.str_to_num(result[0]) + scalar_unit = self._check_unit_in_scalar_standard_units(result[1]) + self.value = ' '.join([result[0], scalar_unit]) + return self.value + + except Exception: + ExceptionCollector.appendException( + ValueError(_('"%s" is not a valid scalar-unit.') + % self.value)) + + def get_num_from_scalar_unit(self, unit=None): + if unit: + unit = self._check_unit_in_scalar_standard_units(unit) + else: + unit = self.SCALAR_UNIT_DEFAULT + self.validate_scalar_unit() + + regex = re.compile('([0-9.]+)\s*(\w+)') + result = regex.match(str(self.value)).groups() + converted = (float(validateutils.str_to_num(result[0])) + * self.SCALAR_UNIT_DICT[result[1]] + / self.SCALAR_UNIT_DICT[unit]) + if converted - int(converted) < 0.0000000000001: + converted = int(converted) + return converted + + +class ScalarUnit_Size(ScalarUnit): + + SCALAR_UNIT_DEFAULT = 'B' + SCALAR_UNIT_DICT = {'B': 1, 'kB': 1000, 'KiB': 1024, 'MB': 1000000, + 'MiB': 1048576, 'GB': 1000000000, + 'GiB': 1073741824, 'TB': 1000000000000, + 'TiB': 1099511627776} + + +class ScalarUnit_Time(ScalarUnit): + + SCALAR_UNIT_DEFAULT = 'ms' + SCALAR_UNIT_DICT = {'d': 86400, 'h': 3600, 'm': 60, 's': 1, + 'ms': 0.001, 'us': 0.000001, 'ns': 0.000000001} + + +class ScalarUnit_Frequency(ScalarUnit): + + SCALAR_UNIT_DEFAULT = 'GHz' + SCALAR_UNIT_DICT = {'Hz': 1, 'kHz': 1000, + 'MHz': 1000000, 'GHz': 1000000000} + + +scalarunit_mapping = { + ScalarUnit.SCALAR_UNIT_FREQUENCY: ScalarUnit_Frequency, + ScalarUnit.SCALAR_UNIT_SIZE: ScalarUnit_Size, + ScalarUnit.SCALAR_UNIT_TIME: ScalarUnit_Time, + } + + +def get_scalarunit_class(type): + return scalarunit_mapping.get(type) + + +def get_scalarunit_value(type, value, unit=None): + if type in ScalarUnit.SCALAR_UNIT_TYPES: + ScalarUnit_Class = get_scalarunit_class(type) + return (ScalarUnit_Class(value). + get_num_from_scalar_unit(unit)) + else: + ExceptionCollector.appendException( + TypeError(_('"%s" is not a valid scalar-unit type.') % type)) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/statefulentitytype.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/statefulentitytype.py new file mode 100644 index 0000000..9c8f4e2 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/elements/statefulentitytype.py @@ -0,0 +1,83 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from toscaparser.common.exception import ExceptionCollector +from toscaparser.common.exception import InvalidTypeError +from toscaparser.elements.attribute_definition import AttributeDef +from toscaparser.elements.entity_type import EntityType +from toscaparser.elements.property_definition import PropertyDef + + +class StatefulEntityType(EntityType): + '''Class representing TOSCA states.''' + + interfaces_node_lifecycle_operations = ['create', + 'configure', 'start', + 'stop', 'delete'] + + interfaces_relationship_confiure_operations = ['post_configure_source', + 'post_configure_target', + 'add_target', + 'remove_target'] + + def __init__(self, entitytype, prefix, custom_def=None): + entire_entitytype = entitytype + if not entitytype.startswith(self.TOSCA): + entire_entitytype = prefix + entitytype + if entire_entitytype in list(self.TOSCA_DEF.keys()): + self.defs = self.TOSCA_DEF[entire_entitytype] + entitytype = entire_entitytype + elif custom_def and entitytype in list(custom_def.keys()): + self.defs = custom_def[entitytype] + else: + ExceptionCollector.appendException( + InvalidTypeError(what=entitytype)) + self.type = entitytype + + def get_properties_def_objects(self): + '''Return a list of property definition objects.''' + properties = [] + props = self.get_definition(self.PROPERTIES) + if props: + for prop, schema in props.items(): + properties.append(PropertyDef(prop, None, schema)) + return properties + + def get_properties_def(self): + '''Return a dictionary of property definition name-object pairs.''' + return {prop.name: prop + for prop in self.get_properties_def_objects()} + + def get_property_def_value(self, name): + '''Return the property definition associated with a given name.''' + props_def = self.get_properties_def() + if props_def and name in props_def.keys(): + return props_def[name].value + + def get_attributes_def_objects(self): + '''Return a list of attribute definition objects.''' + attrs = self.get_value(self.ATTRIBUTES) + if attrs: + return [AttributeDef(attr, None, schema) + for attr, schema in attrs.items()] + return [] + + def get_attributes_def(self): + '''Return a dictionary of attribute definition name-object pairs.''' + return {attr.name: attr + for attr in self.get_attributes_def_objects()} + + def get_attribute_def_value(self, name): + '''Return the attribute definition associated with a given name.''' + attrs_def = self.get_attributes_def() + if attrs_def and name in attrs_def.keys(): + return attrs_def[name].value diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/entity_template.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/entity_template.py new file mode 100644 index 0000000..6f62ec5 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/entity_template.py @@ -0,0 +1,287 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from toscaparser.capabilities import Capability +from toscaparser.common.exception import ExceptionCollector +from toscaparser.common.exception import MissingRequiredFieldError +from toscaparser.common.exception import UnknownFieldError +from toscaparser.common.exception import ValidationError +from toscaparser.elements.interfaces import InterfacesDef +from toscaparser.elements.nodetype import NodeType +from toscaparser.elements.relationshiptype import RelationshipType +from toscaparser.properties import Property + + +class EntityTemplate(object): + '''Base class for TOSCA templates.''' + + SECTIONS = (DERIVED_FROM, PROPERTIES, REQUIREMENTS, + INTERFACES, CAPABILITIES, TYPE, DESCRIPTION, DIRECTIVES, + ATTRIBUTES, ARTIFACTS, NODE_FILTER, COPY) = \ + ('derived_from', 'properties', 'requirements', 'interfaces', + 'capabilities', 'type', 'description', 'directives', + 'attributes', 'artifacts', 'node_filter', 'copy') + REQUIREMENTS_SECTION = (NODE, CAPABILITY, RELATIONSHIP, OCCURRENCES) = \ + ('node', 'capability', 'relationship', + 'occurrences') + # Special key names + SPECIAL_SECTIONS = (METADATA) = ('metadata') + + def __init__(self, name, template, entity_name, custom_def=None): + self.name = name + self.entity_tpl = template + self.custom_def = custom_def + self._validate_field(self.entity_tpl) + if entity_name == 'node_type': + type = self.entity_tpl.get('type') + self.type_definition = NodeType(type, custom_def) \ + if type is not None else None + if entity_name == 'relationship_type': + relationship = template.get('relationship') + type = None + if relationship and isinstance(relationship, dict): + type = relationship.get('type') + elif isinstance(relationship, str): + type = self.entity_tpl['relationship'] + else: + type = self.entity_tpl['type'] + self.type_definition = RelationshipType(type, + None, custom_def) + self._properties = None + self._interfaces = None + self._requirements = None + self._capabilities = None + + @property + def type(self): + if self.type_definition: + return self.type_definition.type + + @property + def requirements(self): + if self._requirements is None: + self._requirements = self.type_definition.get_value( + self.REQUIREMENTS, + self.entity_tpl) or [] + return self._requirements + + def get_properties_objects(self): + '''Return properties objects for this template.''' + if self._properties is None: + self._properties = self._create_properties() + return self._properties + + def get_properties(self): + '''Return a dictionary of property name-object pairs.''' + return {prop.name: prop + for prop in self.get_properties_objects()} + + def get_property_value(self, name): + '''Return the value of a given property name.''' + props = self.get_properties() + if props and name in props.keys(): + return props[name].value + + @property + def interfaces(self): + if self._interfaces is None: + self._interfaces = self._create_interfaces() + return self._interfaces + + def get_capabilities_objects(self): + '''Return capabilities objects for this template.''' + if not self._capabilities: + self._capabilities = self._create_capabilities() + return self._capabilities + + def get_capabilities(self): + '''Return a dictionary of capability name-object pairs.''' + return {cap.name: cap + for cap in self.get_capabilities_objects()} + + def is_derived_from(self, type_str): + '''Check if object inherits from the given type. + + Returns true if this object is derived from 'type_str'. + False otherwise. + ''' + if not self.type: + return False + elif self.type == type_str: + return True + elif self.parent_type: + return self.parent_type.is_derived_from(type_str) + else: + return False + + def _create_capabilities(self): + capability = [] + caps = self.type_definition.get_value(self.CAPABILITIES, + self.entity_tpl) + if caps: + for name, props in caps.items(): + capabilities = self.type_definition.get_capabilities() + if name in capabilities.keys(): + c = capabilities[name] + cap = Capability(name, props['properties'], c) + capability.append(cap) + return capability + + def _validate_properties(self, template, entitytype): + properties = entitytype.get_value(self.PROPERTIES, template) + self._common_validate_properties(entitytype, properties) + + def _validate_capabilities(self): + type_capabilities = self.type_definition.get_capabilities() + allowed_caps = \ + type_capabilities.keys() if type_capabilities else [] + capabilities = self.type_definition.get_value(self.CAPABILITIES, + self.entity_tpl) + if capabilities: + self._common_validate_field(capabilities, allowed_caps, + 'capabilities') + self._validate_capabilities_properties(capabilities) + + def _validate_capabilities_properties(self, capabilities): + for cap, props in capabilities.items(): + capabilitydef = self.get_capability(cap).definition + self._common_validate_properties(capabilitydef, + props[self.PROPERTIES]) + + # validating capability properties values + for prop in self.get_capability(cap).get_properties_objects(): + prop.validate() + + # TODO(srinivas_tadepalli): temporary work around to validate + # default_instances until standardized in specification + if cap == "scalable" and prop.name == "default_instances": + prop_dict = props[self.PROPERTIES] + min_instances = prop_dict.get("min_instances") + max_instances = prop_dict.get("max_instances") + default_instances = prop_dict.get("default_instances") + if not (min_instances <= default_instances + <= max_instances): + err_msg = ('"properties" of template "%s": ' + '"default_instances" value is not between ' + '"min_instances" and "max_instances".' % + self.name) + ExceptionCollector.appendException( + ValidationError(message=err_msg)) + + def _common_validate_properties(self, entitytype, properties): + allowed_props = [] + required_props = [] + for p in entitytype.get_properties_def_objects(): + allowed_props.append(p.name) + if p.required: + required_props.append(p.name) + if properties: + self._common_validate_field(properties, allowed_props, + 'properties') + # make sure it's not missing any property required by a tosca type + missingprop = [] + for r in required_props: + if r not in properties.keys(): + missingprop.append(r) + if missingprop: + ExceptionCollector.appendException( + MissingRequiredFieldError( + what='"properties" of template "%s"' % self.name, + required=missingprop)) + else: + if required_props: + ExceptionCollector.appendException( + MissingRequiredFieldError( + what='"properties" of template "%s"' % self.name, + required=missingprop)) + + def _validate_field(self, template): + if not isinstance(template, dict): + ExceptionCollector.appendException( + MissingRequiredFieldError( + what='Template "%s"' % self.name, required=self.TYPE)) + try: + relationship = template.get('relationship') + if relationship and not isinstance(relationship, str): + relationship[self.TYPE] + elif isinstance(relationship, str): + template['relationship'] + else: + template[self.TYPE] + except KeyError: + ExceptionCollector.appendException( + MissingRequiredFieldError( + what='Template "%s"' % self.name, required=self.TYPE)) + + def _common_validate_field(self, schema, allowedlist, section): + for name in schema: + if name not in allowedlist: + ExceptionCollector.appendException( + UnknownFieldError( + what=('"%(section)s" of template "%(nodename)s"' + % {'section': section, 'nodename': self.name}), + field=name)) + + def _create_properties(self): + props = [] + properties = self.type_definition.get_value(self.PROPERTIES, + self.entity_tpl) or {} + for name, value in properties.items(): + props_def = self.type_definition.get_properties_def() + if props_def and name in props_def: + prop = Property(name, value, + props_def[name].schema, self.custom_def) + props.append(prop) + for p in self.type_definition.get_properties_def_objects(): + if p.default is not None and p.name not in properties.keys(): + prop = Property(p.name, p.default, p.schema, self.custom_def) + props.append(prop) + return props + + def _create_interfaces(self): + interfaces = [] + type_interfaces = None + if isinstance(self.type_definition, RelationshipType): + if isinstance(self.entity_tpl, dict): + for rel_def, value in self.entity_tpl.items(): + if rel_def != 'type': + rel_def = self.entity_tpl.get(rel_def) + rel = None + if isinstance(rel_def, dict): + rel = rel_def.get('relationship') + if rel: + if self.INTERFACES in rel: + type_interfaces = rel[self.INTERFACES] + break + else: + type_interfaces = self.type_definition.get_value(self.INTERFACES, + self.entity_tpl) + if type_interfaces: + for interface_type, value in type_interfaces.items(): + for op, op_def in value.items(): + iface = InterfacesDef(self.type_definition, + interfacetype=interface_type, + node_template=self, + name=op, + value=op_def) + interfaces.append(iface) + return interfaces + + def get_capability(self, name): + """Provide named capability + + :param name: name of capability + :return: capability object if found, None otherwise + """ + caps = self.get_capabilities() + if caps and name in caps.keys(): + return caps[name] diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/functions.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/functions.py new file mode 100644 index 0000000..37cdd04 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/functions.py @@ -0,0 +1,416 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +import abc +import six + +from toscaparser.common.exception import ExceptionCollector +from toscaparser.common.exception import UnknownInputError +from toscaparser.dataentity import DataEntity +from toscaparser.utils.gettextutils import _ + + +GET_PROPERTY = 'get_property' +GET_ATTRIBUTE = 'get_attribute' +GET_INPUT = 'get_input' + +SELF = 'SELF' +HOST = 'HOST' + +HOSTED_ON = 'tosca.relationships.HostedOn' + + +@six.add_metaclass(abc.ABCMeta) +class Function(object): + """An abstract type for representing a Tosca template function.""" + + def __init__(self, tosca_tpl, context, name, args): + self.tosca_tpl = tosca_tpl + self.context = context + self.name = name + self.args = args + self.validate() + + @abc.abstractmethod + def result(self): + """Invokes the function and returns its result + + Some methods invocation may only be relevant on runtime (for example, + getting runtime properties) and therefore its the responsibility of + the orchestrator/translator to take care of such functions invocation. + + :return: Function invocation result. + """ + return {self.name: self.args} + + @abc.abstractmethod + def validate(self): + """Validates function arguments.""" + pass + + +class GetInput(Function): + """Get a property value declared within the input of the service template. + + Arguments: + + * Input name. + + Example: + + * get_input: port + """ + + def validate(self): + if len(self.args) != 1: + ExceptionCollector.appendException( + ValueError(_( + 'Expected one argument for function "get_input" but ' + 'received "%s".') % self.args)) + inputs = [input.name for input in self.tosca_tpl.inputs] + if self.args[0] not in inputs: + ExceptionCollector.appendException( + UnknownInputError(input_name=self.args[0])) + + def result(self): + if self.tosca_tpl.parsed_params and \ + self.input_name in self.tosca_tpl.parsed_params: + return DataEntity.validate_datatype( + self.tosca_tpl.tpl['inputs'][self.input_name]['type'], + self.tosca_tpl.parsed_params[self.input_name]) + + input = [input_def for input_def in self.tosca_tpl.inputs + if self.input_name == input_def.name][0] + return input.default + + @property + def input_name(self): + return self.args[0] + + +class GetAttribute(Function): + """Get an attribute value of an entity defined in the service template + + Node template attributes values are set in runtime and therefore its the + responsibility of the Tosca engine to implement the evaluation of + get_attribute functions. + + Arguments: + + * Node template name | HOST. + * Attribute name. + + If the HOST keyword is passed as the node template name argument the + function will search each node template along the HostedOn relationship + chain until a node which contains the attribute is found. + + Examples: + + * { get_attribute: [ server, private_address ] } + * { get_attribute: [ HOST, private_address ] } + """ + + def validate(self): + if len(self.args) != 2: + ExceptionCollector.appendException( + ValueError(_('Illegal arguments for function "{0}". Expected ' + 'arguments: "node-template-name", ' + '"attribute-name"').format(GET_ATTRIBUTE))) + self._find_node_template_containing_attribute() + + def result(self): + return self.args + + def get_referenced_node_template(self): + """Gets the NodeTemplate instance the get_attribute function refers to. + + If HOST keyword was used as the node template argument, the node + template which contains the attribute along the HostedOn relationship + chain will be returned. + """ + return self._find_node_template_containing_attribute() + + def _find_node_template_containing_attribute(self): + if self.node_template_name == HOST: + # Currently this is the only way to tell whether the function + # is used within the outputs section of the TOSCA template. + if isinstance(self.context, list): + ExceptionCollector.appendException( + ValueError(_( + '"get_attribute: [ HOST, ... ]" is not allowed in ' + '"outputs" section of the TOSCA template.'))) + return + node_tpl = self._find_host_containing_attribute() + if not node_tpl: + ExceptionCollector.appendException( + ValueError(_( + '"get_attribute: [ HOST, ... ]" was used in node ' + 'template "{0}" but "{1}" was not found in ' + 'the relationship chain.').format(self.context.name, + HOSTED_ON))) + else: + node_tpl = self._find_node_template(self.args[0]) + if node_tpl and \ + not self._attribute_exists_in_type(node_tpl.type_definition): + ExceptionCollector.appendException( + KeyError(_('Attribute "%(att)s" was not found in node ' + 'template "%(ntpl)s".') % + {'att': self.attribute_name, + 'ntpl': node_tpl.name})) + return node_tpl + + def _attribute_exists_in_type(self, type_definition): + attrs_def = type_definition.get_attributes_def() + found = [attrs_def[self.attribute_name]] \ + if self.attribute_name in attrs_def else [] + return len(found) == 1 + + def _find_host_containing_attribute(self, node_template_name=SELF): + node_template = self._find_node_template(node_template_name) + if node_template: + from toscaparser.elements.entity_type import EntityType + hosted_on_rel = EntityType.TOSCA_DEF[HOSTED_ON] + for r in node_template.requirements: + for requirement, target_name in r.items(): + target_node = self._find_node_template(target_name) + target_type = target_node.type_definition + for capability in target_type.get_capabilities_objects(): + if capability.type in \ + hosted_on_rel['valid_target_types']: + if self._attribute_exists_in_type(target_type): + return target_node + return self._find_host_containing_attribute( + target_name) + + def _find_node_template(self, node_template_name): + name = self.context.name \ + if node_template_name == SELF and \ + not isinstance(self.context, list) \ + else node_template_name + for node_template in self.tosca_tpl.nodetemplates: + if node_template.name == name: + return node_template + ExceptionCollector.appendException( + KeyError(_( + 'Node template "{0}" was not found.' + ).format(node_template_name))) + + @property + def node_template_name(self): + return self.args[0] + + @property + def attribute_name(self): + return self.args[1] + + +class GetProperty(Function): + """Get a property value of an entity defined in the same service template. + + Arguments: + + * Node template name. + * Requirement or capability name (optional). + * Property name. + + If requirement or capability name is specified, the behavior is as follows: + The req or cap name is first looked up in the specified node template's + requirements. + If found, it would search for a matching capability + of an other node template and get its property as specified in function + arguments. + Otherwise, the req or cap name would be looked up in the specified + node template's capabilities and if found, it would return the property of + the capability as specified in function arguments. + + Examples: + + * { get_property: [ mysql_server, port ] } + * { get_property: [ SELF, db_port ] } + * { get_property: [ SELF, database_endpoint, port ] } + """ + + def validate(self): + if len(self.args) < 2 or len(self.args) > 3: + ExceptionCollector.appendException( + ValueError(_( + 'Expected arguments: "node-template-name", "req-or-cap" ' + '(optional), "property name".'))) + return + if len(self.args) == 2: + found_prop = self._find_property(self.args[1]) + if not found_prop: + return + prop = found_prop.value + if not isinstance(prop, Function): + get_function(self.tosca_tpl, self.context, prop) + elif len(self.args) == 3: + get_function(self.tosca_tpl, + self.context, + self._find_req_or_cap_property(self.args[1], + self.args[2])) + else: + ExceptionCollector.appendException( + NotImplementedError(_( + 'Nested properties are not supported.'))) + + def _find_req_or_cap_property(self, req_or_cap, property_name): + node_tpl = self._find_node_template(self.args[0]) + # Find property in node template's requirements + for r in node_tpl.requirements: + for req, node_name in r.items(): + if req == req_or_cap: + node_template = self._find_node_template(node_name) + return self._get_capability_property( + node_template, + req, + property_name) + # If requirement was not found, look in node template's capabilities + return self._get_capability_property(node_tpl, + req_or_cap, + property_name) + + def _get_capability_property(self, + node_template, + capability_name, + property_name): + """Gets a node template capability property.""" + caps = node_template.get_capabilities() + if caps and capability_name in caps.keys(): + cap = caps[capability_name] + property = None + props = cap.get_properties() + if props and property_name in props.keys(): + property = props[property_name].value + if not property: + ExceptionCollector.appendException( + KeyError(_('Property "%(prop)s" was not found in ' + 'capability "%(cap)s" of node template ' + '"%(ntpl1)s" referenced from node template ' + '"%(ntpl2)s".') % {'prop': property_name, + 'cap': capability_name, + 'ntpl1': node_template.name, + 'ntpl2': self.context.name})) + return property + msg = _('Requirement/Capability "{0}" referenced from node template ' + '"{1}" was not found in node template "{2}".').format( + capability_name, + self.context.name, + node_template.name) + ExceptionCollector.appendException(KeyError(msg)) + + def _find_property(self, property_name): + node_tpl = self._find_node_template(self.args[0]) + if not node_tpl: + return + props = node_tpl.get_properties() + found = [props[property_name]] if property_name in props else [] + if len(found) == 0: + ExceptionCollector.appendException( + KeyError(_('Property "%(prop)s" was not found in node ' + 'template "%(ntpl)s".') % + {'prop': property_name, + 'ntpl': node_tpl.name})) + return None + return found[0] + + def _find_node_template(self, node_template_name): + if node_template_name == SELF: + return self.context + if not hasattr(self.tosca_tpl, 'nodetemplates'): + return + for node_template in self.tosca_tpl.nodetemplates: + if node_template.name == node_template_name: + return node_template + ExceptionCollector.appendException( + KeyError(_( + 'Node template "{0}" was not found.' + ).format(node_template_name))) + + def result(self): + if len(self.args) == 3: + property_value = self._find_req_or_cap_property(self.args[1], + self.args[2]) + else: + property_value = self._find_property(self.args[1]).value + if isinstance(property_value, Function): + return property_value.result() + return get_function(self.tosca_tpl, + self.context, + property_value) + + @property + def node_template_name(self): + return self.args[0] + + @property + def property_name(self): + if len(self.args) > 2: + return self.args[2] + return self.args[1] + + @property + def req_or_cap(self): + if len(self.args) > 2: + return self.args[1] + return None + + +function_mappings = { + GET_PROPERTY: GetProperty, + GET_INPUT: GetInput, + GET_ATTRIBUTE: GetAttribute +} + + +def is_function(function): + """Returns True if the provided function is a Tosca intrinsic function. + + Examples: + + * "{ get_property: { SELF, port } }" + * "{ get_input: db_name }" + * Function instance + + :param function: Function as string or a Function instance. + :return: True if function is a Tosca intrinsic function, otherwise False. + """ + if isinstance(function, dict) and len(function) == 1: + func_name = list(function.keys())[0] + return func_name in function_mappings + return isinstance(function, Function) + + +def get_function(tosca_tpl, node_template, raw_function): + """Gets a Function instance representing the provided template function. + + If the format provided raw_function format is not relevant for template + functions or if the function name doesn't exist in function mapping the + method returns the provided raw_function. + + :param tosca_tpl: The tosca template. + :param node_template: The node template the function is specified for. + :param raw_function: The raw function as dict. + :return: Template function as Function instance or the raw_function if + parsing was unsuccessful. + """ + if is_function(raw_function): + func_name = list(raw_function.keys())[0] + if func_name in function_mappings: + func = function_mappings[func_name] + func_args = list(raw_function.values())[0] + if not isinstance(func_args, list): + func_args = [func_args] + return func(tosca_tpl, node_template, func_name, func_args) + return raw_function diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/groups.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/groups.py new file mode 100644 index 0000000..40ebcf5 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/groups.py @@ -0,0 +1,27 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +class NodeGroup(object): + + def __init__(self, name, group_templates, member_nodes): + self.name = name + self.tpl = group_templates + self.members = member_nodes + + @property + def member_names(self): + return self.tpl.get('members') + + @property + def policies(self): + return self.tpl.get('policies') diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/imports.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/imports.py new file mode 100644 index 0000000..e42e640 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/imports.py @@ -0,0 +1,208 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import logging +import os + +from toscaparser.common.exception import ExceptionCollector +from toscaparser.common.exception import MissingRequiredFieldError +from toscaparser.common.exception import UnknownFieldError +from toscaparser.common.exception import ValidationError +from toscaparser.utils.gettextutils import _ +import toscaparser.utils.urlutils +import toscaparser.utils.yamlparser + +YAML_LOADER = toscaparser.utils.yamlparser.load_yaml +log = logging.getLogger("tosca") + + +class ImportsLoader(object): + + IMPORTS_SECTION = (FILE, REPOSITORY, NAMESPACE_URI, NAMESPACE_PREFIX) = \ + ('file', 'repository', 'namespace_uri', + 'namespace_prefix') + + def __init__(self, importslist, path, type_definition_list=None): + self.importslist = importslist + self.custom_defs = {} + if not path: + msg = _('Input tosca template is not provided.') + log.warning(msg) + ExceptionCollector.appendException(ValidationError(message=msg)) + self.path = path + self.type_definition_list = [] + if type_definition_list: + if isinstance(type_definition_list, list): + self.type_definition_list = type_definition_list + else: + self.type_definition_list.append(type_definition_list) + self._validate_and_load_imports() + + def get_custom_defs(self): + return self.custom_defs + + def _validate_and_load_imports(self): + imports_names = set() + + if not self.importslist: + msg = _('"imports" keyname is defined without including ' + 'templates.') + log.error(msg) + ExceptionCollector.appendException(ValidationError(message=msg)) + return + + for import_def in self.importslist: + if isinstance(import_def, dict): + for import_name, import_uri in import_def.items(): + if import_name in imports_names: + msg = (_('Duplicate import name "%s" was found.') % + import_name) + log.error(msg) + ExceptionCollector.appendException( + ValidationError(message=msg)) + imports_names.add(import_name) + + custom_type = self._load_import_template(import_name, + import_uri) + self._update_custom_def(custom_type) + else: # old style of imports + custom_type = self._load_import_template(None, + import_def) + if custom_type: + self._update_custom_def(custom_type) + + def _update_custom_def(self, custom_type): + outer_custom_types = {} + for type_def in self.type_definition_list: + outer_custom_types = custom_type.get(type_def) + if outer_custom_types: + if type_def == "imports": + self.custom_defs.update({'imports': outer_custom_types}) + else: + self.custom_defs.update(outer_custom_types) + + def _validate_import_keys(self, import_name, import_uri_def): + if self.FILE not in import_uri_def.keys(): + log.warning(_('Missing keyname "file" in import "%(name)s".') + % {'name': import_name}) + ExceptionCollector.appendException( + MissingRequiredFieldError( + what='Import of template "%s"' % import_name, + required=self.FILE)) + for key in import_uri_def.keys(): + if key not in self.IMPORTS_SECTION: + log.warning(_('Unknown keyname "%(key)s" error in ' + 'imported definition "%(def)s".') + % {'key': key, 'def': import_name}) + ExceptionCollector.appendException( + UnknownFieldError( + what='Import of template "%s"' % import_name, + field=key)) + + def _load_import_template(self, import_name, import_uri_def): + """Handle custom types defined in imported template files + + This method loads the custom type definitions referenced in "imports" + section of the TOSCA YAML template by determining whether each import + is specified via a file reference (by relative or absolute path) or a + URL reference. + + Possibilities: + +----------+--------+------------------------------+ + | template | import | comment | + +----------+--------+------------------------------+ + | file | file | OK | + | file | URL | OK | + | URL | file | file must be a relative path | + | URL | URL | OK | + +----------+--------+------------------------------+ + """ + + short_import_notation = False + if isinstance(import_uri_def, dict): + self._validate_import_keys(import_name, import_uri_def) + file_name = import_uri_def.get(self.FILE) + repository = import_uri_def.get(self.REPOSITORY) + namespace_uri = import_uri_def.get(self.NAMESPACE_URI) + # TODO(anyone) : will be extended this namespace_prefix in + # the next patch after design discussion with PTL. + # namespace_prefix = import_uri_def.get(self.NAMESPACE_PREFIX) + else: + file_name = import_uri_def + namespace_uri = None + short_import_notation = True + + if not file_name: + msg = (_('A template file name is not provided with import ' + 'definition "%(import_name)s".') + % {'import_name': import_name}) + log.error(msg) + ExceptionCollector.appendException(ValidationError(message=msg)) + return + + if toscaparser.utils.urlutils.UrlUtils.validate_url(file_name): + return YAML_LOADER(file_name, False) + elif not namespace_uri: + import_template = None + a_file = True + main_a_file = os.path.isfile(self.path) + if main_a_file: + if os.path.isfile(file_name): + import_template = file_name + else: + full_path = os.path.join( + os.path.dirname(os.path.abspath(self.path)), + file_name) + if os.path.isfile(full_path): + import_template = full_path + else: # main_a_url + if os.path.isabs(file_name): + msg = (_('Absolute file name "%(name)s" cannot be used ' + 'in a URL-based input template "%(template)s".') + % {'name': file_name, 'template': self.path}) + log.error(msg) + ExceptionCollector.appendException(ImportError(msg)) + return + import_template = toscaparser.utils.urlutils.UrlUtils.\ + join_url(self.path, file_name) + a_file = False + if not import_template: + log.error(_('Import "%(name)s" is not valid.') % + {'name': import_uri_def}) + ExceptionCollector.appendException( + ImportError(_('Import "%s" is not valid.') % + import_uri_def)) + return + return YAML_LOADER(import_template, a_file) + + if short_import_notation: + log.error(_('Import "%(name)s" is not valid.') % import_uri_def) + ExceptionCollector.appendException( + ImportError(_('Import "%s" is not valid.') % import_uri_def)) + + # Remove leading, ending spaces and strip the last character if "/" + namespace_uri = ((namespace_uri).strip()).rstrip("//") + + if toscaparser.utils.urlutils.UrlUtils.validate_url(namespace_uri): + full_url = None + if repository: + repository = ((repository).strip()).rstrip("//") + full_url = namespace_uri + "/" + repository + "/" + file_name + else: + full_url = namespace_uri + "/" + file_name + return YAML_LOADER(full_url, False) + else: + msg = (_('namespace_uri "%(n_uri)s" is not valid in import ' + 'definition "%(tpl)s".') + % {'n_uri': namespace_uri, 'tpl': import_name}) + log.error(msg) + ExceptionCollector.appendException(ImportError(msg)) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/nodetemplate.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/nodetemplate.py new file mode 100644 index 0000000..b3fbf5c --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/nodetemplate.py @@ -0,0 +1,260 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +import logging + +from toscaparser.common.exception import ExceptionCollector +from toscaparser.common.exception import InvalidPropertyValueError +from toscaparser.common.exception import MissingRequiredFieldError +from toscaparser.common.exception import TypeMismatchError +from toscaparser.common.exception import UnknownFieldError +from toscaparser.dataentity import DataEntity +from toscaparser.elements.interfaces import CONFIGURE +from toscaparser.elements.interfaces import CONFIGURE_SHORTNAME +from toscaparser.elements.interfaces import InterfacesDef +from toscaparser.elements.interfaces import LIFECYCLE +from toscaparser.elements.interfaces import LIFECYCLE_SHORTNAME +from toscaparser.elements.relationshiptype import RelationshipType +from toscaparser.entity_template import EntityTemplate +from toscaparser.relationship_template import RelationshipTemplate +from toscaparser.utils.gettextutils import _ + +log = logging.getLogger('tosca') + + +class NodeTemplate(EntityTemplate): + '''Node template from a Tosca profile.''' + def __init__(self, name, node_templates, custom_def=None, + available_rel_tpls=None, available_rel_types=None): + super(NodeTemplate, self).__init__(name, node_templates[name], + 'node_type', + custom_def) + self.templates = node_templates + self._validate_fields(node_templates[name]) + self.custom_def = custom_def + self.related = {} + self.relationship_tpl = [] + self.available_rel_tpls = available_rel_tpls + self.available_rel_types = available_rel_types + self._relationships = {} + + @property + def relationships(self): + if not self._relationships: + requires = self.requirements + if requires: + for r in requires: + for r1, value in r.items(): + explicit = self._get_explicit_relationship(r, value) + if explicit: + for key, value in explicit.items(): + self._relationships[key] = value + return self._relationships + + def _get_explicit_relationship(self, req, value): + """Handle explicit relationship + + For example, + - req: + node: DBMS + relationship: tosca.relationships.HostedOn + """ + explicit_relation = {} + node = value.get('node') if isinstance(value, dict) else value + + if node: + # TODO(spzala) implement look up once Glance meta data is available + # to find a matching TOSCA node using the TOSCA types + msg = _('Lookup by TOSCA types is not supported. ' + 'Requirement for "%s" can not be full-filled.') % self.name + if (node in list(self.type_definition.TOSCA_DEF.keys()) + or node in self.custom_def): + ExceptionCollector.appendException(NotImplementedError(msg)) + return + + if node not in self.templates: + ExceptionCollector.appendException( + KeyError(_('Node template "%s" was not found.') % node)) + return + + related_tpl = NodeTemplate(node, self.templates, self.custom_def) + relationship = value.get('relationship') \ + if isinstance(value, dict) else None + # check if it's type has relationship defined + if not relationship: + parent_reqs = self.type_definition.get_all_requirements() + for key in req.keys(): + for req_dict in parent_reqs: + if key in req_dict.keys(): + relationship = (req_dict.get(key). + get('relationship')) + break + if relationship: + found_relationship_tpl = False + # apply available relationship templates if found + for tpl in self.available_rel_tpls: + if tpl.name == relationship: + rtype = RelationshipType(tpl.type, None, + self.custom_def) + explicit_relation[rtype] = related_tpl + self.relationship_tpl.append(tpl) + found_relationship_tpl = True + # create relationship template object. + rel_prfx = self.type_definition.RELATIONSHIP_PREFIX + if not found_relationship_tpl: + if isinstance(relationship, dict): + relationship = relationship.get('type') + if relationship: + if self.available_rel_types and \ + relationship in self.available_rel_types.keys(): + pass + elif not relationship.startswith(rel_prfx): + relationship = rel_prfx + relationship + else: + ExceptionCollector.appendException( + MissingRequiredFieldError( + what=_('"relationship" used in template ' + '"%s"') % related_tpl.name, + required=self.TYPE)) + for rtype in self.type_definition.relationship.keys(): + if rtype.type == relationship: + explicit_relation[rtype] = related_tpl + related_tpl._add_relationship_template(req, + rtype.type) + elif self.available_rel_types: + if relationship in self.available_rel_types.keys(): + rel_type_def = self.available_rel_types.\ + get(relationship) + if 'derived_from' in rel_type_def: + super_type = \ + rel_type_def.get('derived_from') + if not super_type.startswith(rel_prfx): + super_type = rel_prfx + super_type + if rtype.type == super_type: + explicit_relation[rtype] = related_tpl + related_tpl.\ + _add_relationship_template( + req, rtype.type) + return explicit_relation + + def _add_relationship_template(self, requirement, rtype): + req = requirement.copy() + req['type'] = rtype + tpl = RelationshipTemplate(req, rtype, None) + self.relationship_tpl.append(tpl) + + def get_relationship_template(self): + return self.relationship_tpl + + def _add_next(self, nodetpl, relationship): + self.related[nodetpl] = relationship + + @property + def related_nodes(self): + if not self.related: + for relation, node in self.type_definition.relationship.items(): + for tpl in self.templates: + if tpl == node.type: + self.related[NodeTemplate(tpl)] = relation + return self.related.keys() + + def validate(self, tosca_tpl=None): + self._validate_capabilities() + self._validate_requirements() + self._validate_properties(self.entity_tpl, self.type_definition) + self._validate_interfaces() + for prop in self.get_properties_objects(): + prop.validate() + + def _validate_requirements(self): + type_requires = self.type_definition.get_all_requirements() + allowed_reqs = ["template"] + if type_requires: + for treq in type_requires: + for key, value in treq.items(): + allowed_reqs.append(key) + if isinstance(value, dict): + for key in value: + allowed_reqs.append(key) + + requires = self.type_definition.get_value(self.REQUIREMENTS, + self.entity_tpl) + if requires: + if not isinstance(requires, list): + ExceptionCollector.appendException( + TypeMismatchError( + what='"requirements" of template "%s"' % self.name, + type='list')) + for req in requires: + for r1, value in req.items(): + if isinstance(value, dict): + self._validate_requirements_keys(value) + self._validate_requirements_properties(value) + allowed_reqs.append(r1) + self._common_validate_field(req, allowed_reqs, 'requirements') + + def _validate_requirements_properties(self, requirements): + # TODO(anyone): Only occurrences property of the requirements is + # validated here. Validation of other requirement properties are being + # validated in different files. Better to keep all the requirements + # properties validation here. + for key, value in requirements.items(): + if key == 'occurrences': + self._validate_occurrences(value) + break + + def _validate_occurrences(self, occurrences): + DataEntity.validate_datatype('list', occurrences) + for value in occurrences: + DataEntity.validate_datatype('integer', value) + if len(occurrences) != 2 or not (0 <= occurrences[0] <= occurrences[1]) \ + or occurrences[1] == 0: + ExceptionCollector.appendException( + InvalidPropertyValueError(what=(occurrences))) + + def _validate_requirements_keys(self, requirement): + for key in requirement.keys(): + if key not in self.REQUIREMENTS_SECTION: + ExceptionCollector.appendException( + UnknownFieldError( + what='"requirements" of template "%s"' % self.name, + field=key)) + + def _validate_interfaces(self): + ifaces = self.type_definition.get_value(self.INTERFACES, + self.entity_tpl) + if ifaces: + for i in ifaces: + for name, value in ifaces.items(): + if name in (LIFECYCLE, LIFECYCLE_SHORTNAME): + self._common_validate_field( + value, InterfacesDef. + interfaces_node_lifecycle_operations, + 'interfaces') + elif name in (CONFIGURE, CONFIGURE_SHORTNAME): + self._common_validate_field( + value, InterfacesDef. + interfaces_relationship_confiure_operations, + 'interfaces') + else: + ExceptionCollector.appendException( + UnknownFieldError( + what='"interfaces" of template "%s"' % + self.name, field=name)) + + def _validate_fields(self, nodetemplate): + for name in nodetemplate.keys(): + if name not in self.SECTIONS and name not in self.SPECIAL_SECTIONS: + ExceptionCollector.appendException( + UnknownFieldError(what='Node template "%s"' % self.name, + field=name)) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/parameters.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/parameters.py new file mode 100644 index 0000000..983aee3 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/parameters.py @@ -0,0 +1,114 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +import logging + +from toscaparser.common.exception import ExceptionCollector +from toscaparser.common.exception import MissingRequiredFieldError +from toscaparser.common.exception import UnknownFieldError +from toscaparser.dataentity import DataEntity +from toscaparser.elements.constraints import Schema +from toscaparser.elements.entity_type import EntityType +from toscaparser.utils.gettextutils import _ + + +log = logging.getLogger('tosca') + + +class Input(object): + + INPUTFIELD = (TYPE, DESCRIPTION, DEFAULT, CONSTRAINTS) = \ + ('type', 'description', 'default', 'constraints') + + def __init__(self, name, schema_dict): + self.name = name + self.schema = Schema(name, schema_dict) + + @property + def type(self): + return self.schema.type + + @property + def description(self): + return self.schema.description + + @property + def default(self): + return self.schema.default + + @property + def constraints(self): + return self.schema.constraints + + def validate(self, value=None): + self._validate_field() + self.validate_type(self.type) + if value: + self._validate_value(value) + + def _validate_field(self): + for name in self.schema.schema: + if name not in self.INPUTFIELD: + ExceptionCollector.appendException( + UnknownFieldError(what='Input "%s"' % self.name, + field=name)) + + def validate_type(self, input_type): + if input_type not in Schema.PROPERTY_TYPES: + ExceptionCollector.appendException( + ValueError(_('Invalid type "%s".') % type)) + + def _validate_value(self, value): + tosca = EntityType.TOSCA_DEF + datatype = None + if self.type in tosca: + datatype = tosca[self.type] + elif EntityType.DATATYPE_PREFIX + self.type in tosca: + datatype = tosca[EntityType.DATATYPE_PREFIX + self.type] + + DataEntity.validate_datatype(self.type, value, None, datatype) + + +class Output(object): + + OUTPUTFIELD = (DESCRIPTION, VALUE) = ('description', 'value') + + def __init__(self, name, attrs): + self.name = name + self.attrs = attrs + + @property + def description(self): + return self.attrs.get(self.DESCRIPTION) + + @property + def value(self): + return self.attrs.get(self.VALUE) + + def validate(self): + self._validate_field() + + def _validate_field(self): + if not isinstance(self.attrs, dict): + ExceptionCollector.appendException( + MissingRequiredFieldError(what='Output "%s"' % self.name, + required=self.VALUE)) + if self.value is None: + ExceptionCollector.appendException( + MissingRequiredFieldError(what='Output "%s"' % self.name, + required=self.VALUE)) + for name in self.attrs: + if name not in self.OUTPUTFIELD: + ExceptionCollector.appendException( + UnknownFieldError(what='Output "%s"' % self.name, + field=name)) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/prereq/__init__.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/prereq/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/prereq/csar.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/prereq/csar.py new file mode 100644 index 0000000..1cba5c4 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/prereq/csar.py @@ -0,0 +1,286 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import os.path +import requests +import shutil +import six +import tempfile +import yaml +import zipfile + +from toscaparser.common.exception import ExceptionCollector +from toscaparser.common.exception import URLException +from toscaparser.common.exception import ValidationError +from toscaparser.imports import ImportsLoader +from toscaparser.utils.gettextutils import _ +from toscaparser.utils.urlutils import UrlUtils + +try: # Python 2.x + from BytesIO import BytesIO +except ImportError: # Python 3.x + from io import BytesIO + + +class CSAR(object): + + def __init__(self, csar_file, a_file=True): + self.path = csar_file + self.a_file = a_file + self.is_validated = False + self.error_caught = False + self.csar = None + self.temp_dir = None + + def validate(self): + """Validate the provided CSAR file.""" + + self.is_validated = True + + # validate that the file or URL exists + missing_err_msg = (_('"%s" does not exist.') % self.path) + if self.a_file: + if not os.path.isfile(self.path): + ExceptionCollector.appendException( + ValidationError(message=missing_err_msg)) + return False + else: + self.csar = self.path + else: # a URL + if not UrlUtils.validate_url(self.path): + ExceptionCollector.appendException( + ValidationError(message=missing_err_msg)) + return False + else: + response = requests.get(self.path) + self.csar = BytesIO(response.content) + + # validate that it is a valid zip file + if not zipfile.is_zipfile(self.csar): + err_msg = (_('"%s" is not a valid zip file.') % self.path) + ExceptionCollector.appendException( + ValidationError(message=err_msg)) + return False + + # validate that it contains the metadata file in the correct location + self.zfile = zipfile.ZipFile(self.csar, 'r') + filelist = self.zfile.namelist() + if 'TOSCA-Metadata/TOSCA.meta' not in filelist: + err_msg = (_('"%s" is not a valid CSAR as it does not contain the ' + 'required file "TOSCA.meta" in the folder ' + '"TOSCA-Metadata".') % self.path) + ExceptionCollector.appendException( + ValidationError(message=err_msg)) + return False + + # validate that 'Entry-Definitions' property exists in TOSCA.meta + data = self.zfile.read('TOSCA-Metadata/TOSCA.meta') + invalid_yaml_err_msg = (_('The file "TOSCA-Metadata/TOSCA.meta" in ' + 'the CSAR "%s" does not contain valid YAML ' + 'content.') % self.path) + try: + meta = yaml.load(data) + if type(meta) is dict: + self.metadata = meta + else: + ExceptionCollector.appendException( + ValidationError(message=invalid_yaml_err_msg)) + return False + except yaml.YAMLError: + ExceptionCollector.appendException( + ValidationError(message=invalid_yaml_err_msg)) + return False + + if 'Entry-Definitions' not in self.metadata: + err_msg = (_('The CSAR "%s" is missing the required metadata ' + '"Entry-Definitions" in ' + '"TOSCA-Metadata/TOSCA.meta".') + % self.path) + ExceptionCollector.appendException( + ValidationError(message=err_msg)) + return False + + # validate that 'Entry-Definitions' metadata value points to an + # existing file in the CSAR + entry = self.metadata.get('Entry-Definitions') + if entry and entry not in filelist: + err_msg = (_('The "Entry-Definitions" file defined in the ' + 'CSAR "%s" does not exist.') % self.path) + ExceptionCollector.appendException( + ValidationError(message=err_msg)) + return False + + # validate that external references in the main template actually + # exist and are accessible + self._validate_external_references() + return not self.error_caught + + def get_metadata(self): + """Return the metadata dictionary.""" + + # validate the csar if not already validated + if not self.is_validated: + self.validate() + + # return a copy to avoid changes overwrite the original + return dict(self.metadata) if self.metadata else None + + def _get_metadata(self, key): + if not self.is_validated: + self.validate() + return self.metadata.get(key) + + def get_author(self): + return self._get_metadata('Created-By') + + def get_version(self): + return self._get_metadata('CSAR-Version') + + def get_main_template(self): + entry_def = self._get_metadata('Entry-Definitions') + if entry_def in self.zfile.namelist(): + return entry_def + + def get_main_template_yaml(self): + main_template = self.get_main_template() + if main_template: + data = self.zfile.read(main_template) + invalid_tosca_yaml_err_msg = ( + _('The file "%(template)s" in the CSAR "%(csar)s" does not ' + 'contain valid TOSCA YAML content.') % + {'template': main_template, 'csar': self.path}) + try: + tosca_yaml = yaml.load(data) + if type(tosca_yaml) is not dict: + ExceptionCollector.appendException( + ValidationError(message=invalid_tosca_yaml_err_msg)) + return tosca_yaml + except Exception: + ExceptionCollector.appendException( + ValidationError(message=invalid_tosca_yaml_err_msg)) + + def get_description(self): + desc = self._get_metadata('Description') + if desc is not None: + return desc + + self.metadata['Description'] = \ + self.get_main_template_yaml().get('description') + return self.metadata['Description'] + + def decompress(self): + if not self.is_validated: + self.validate() + self.temp_dir = tempfile.NamedTemporaryFile().name + with zipfile.ZipFile(self.csar, "r") as zf: + zf.extractall(self.temp_dir) + + def _validate_external_references(self): + """Extracts files referenced in the main template + + These references are currently supported: + * imports + * interface implementations + * artifacts + """ + try: + self.decompress() + main_tpl_file = self.get_main_template() + if not main_tpl_file: + return + main_tpl = self.get_main_template_yaml() + + if 'imports' in main_tpl: + ImportsLoader(main_tpl['imports'], + os.path.join(self.temp_dir, main_tpl_file)) + + if 'topology_template' in main_tpl: + topology_template = main_tpl['topology_template'] + + if 'node_templates' in topology_template: + node_templates = topology_template['node_templates'] + + for node_template_key in node_templates: + node_template = node_templates[node_template_key] + if 'artifacts' in node_template: + artifacts = node_template['artifacts'] + for artifact_key in artifacts: + artifact = artifacts[artifact_key] + if isinstance(artifact, six.string_types): + self._validate_external_reference( + main_tpl_file, + artifact) + elif isinstance(artifact, dict): + if 'file' in artifact: + self._validate_external_reference( + main_tpl_file, + artifact['file']) + else: + ExceptionCollector.appendException( + ValueError(_('Unexpected artifact ' + 'definition for "%s".') + % artifact_key)) + self.error_caught = True + if 'interfaces' in node_template: + interfaces = node_template['interfaces'] + for interface_key in interfaces: + interface = interfaces[interface_key] + for opertation_key in interface: + operation = interface[opertation_key] + if isinstance(operation, six.string_types): + self._validate_external_reference( + main_tpl_file, + operation, + False) + elif isinstance(operation, dict): + if 'implementation' in operation: + self._validate_external_reference( + main_tpl_file, + operation['implementation']) + finally: + if self.temp_dir: + shutil.rmtree(self.temp_dir) + + def _validate_external_reference(self, tpl_file, resource_file, + raise_exc=True): + """Verify that the external resource exists + + If resource_file is a URL verify that the URL is valid. + If resource_file is a relative path verify that the path is valid + considering base folder (self.temp_dir) and tpl_file. + Note that in a CSAR resource_file cannot be an absolute path. + """ + if UrlUtils.validate_url(resource_file): + msg = (_('The resource at "%s" cannot be accessed.') % + resource_file) + try: + if UrlUtils.url_accessible(resource_file): + return + else: + ExceptionCollector.appendException( + URLException(what=msg)) + self.error_caught = True + except Exception: + ExceptionCollector.appendException( + URLException(what=msg)) + self.error_caught = True + + if os.path.isfile(os.path.join(self.temp_dir, + os.path.dirname(tpl_file), + resource_file)): + return + + if raise_exc: + ExceptionCollector.appendException( + ValueError(_('The resource "%s" does not exist.') + % resource_file)) + self.error_caught = True diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/properties.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/properties.py new file mode 100644 index 0000000..23c1db2 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/properties.py @@ -0,0 +1,76 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from toscaparser.dataentity import DataEntity +from toscaparser.elements.constraints import Schema +from toscaparser.functions import is_function + + +class Property(object): + '''TOSCA built-in Property type.''' + + PROPERTY_KEYS = ( + TYPE, REQUIRED, DESCRIPTION, DEFAULT, CONSTRAINTS + ) = ( + 'type', 'required', 'description', 'default', 'constraints' + ) + + ENTRY_SCHEMA_KEYS = ( + ENTRYTYPE, ENTRYPROPERTIES + ) = ( + 'type', 'properties' + ) + + def __init__(self, property_name, value, schema_dict, custom_def=None): + self.name = property_name + self.value = value + self.custom_def = custom_def + self.schema = Schema(property_name, schema_dict) + + @property + def type(self): + return self.schema.type + + @property + def required(self): + return self.schema.required + + @property + def description(self): + return self.schema.description + + @property + def default(self): + return self.schema.default + + @property + def constraints(self): + return self.schema.constraints + + @property + def entry_schema(self): + return self.schema.entry_schema + + def validate(self): + '''Validate if not a reference property.''' + if not is_function(self.value): + if self.type == Schema.STRING: + self.value = str(self.value) + self.value = DataEntity.validate_datatype(self.type, self.value, + self.entry_schema, + self.custom_def) + self._validate_constraints() + + def _validate_constraints(self): + if self.constraints: + for constraint in self.constraints: + constraint.validate(self.value) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/relationship_template.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/relationship_template.py new file mode 100644 index 0000000..d405b9c --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/relationship_template.py @@ -0,0 +1,68 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +import logging + +from toscaparser.entity_template import EntityTemplate +from toscaparser.properties import Property + +SECTIONS = (DERIVED_FROM, PROPERTIES, REQUIREMENTS, + INTERFACES, CAPABILITIES, TYPE) = \ + ('derived_from', 'properties', 'requirements', 'interfaces', + 'capabilities', 'type') + +log = logging.getLogger('tosca') + + +class RelationshipTemplate(EntityTemplate): + '''Relationship template.''' + def __init__(self, relationship_template, name, custom_def=None): + super(RelationshipTemplate, self).__init__(name, + relationship_template, + 'relationship_type', + custom_def) + self.name = name.lower() + + def get_properties_objects(self): + '''Return properties objects for this template.''' + if self._properties is None: + self._properties = self._create_relationship_properties() + return self._properties + + def _create_relationship_properties(self): + props = [] + properties = {} + relationship = self.entity_tpl.get('relationship') + if relationship: + properties = self.type_definition.get_value(self.PROPERTIES, + relationship) or {} + if not properties: + properties = self.entity_tpl.get(self.PROPERTIES) or {} + + if properties: + for name, value in properties.items(): + props_def = self.type_definition.get_properties_def() + if props_def and name in props_def: + if name in properties.keys(): + value = properties.get(name) + prop = Property(name, value, + props_def[name].schema, self.custom_def) + props.append(prop) + for p in self.type_definition.get_properties_def_objects(): + if p.default is not None and p.name not in properties.keys(): + prop = Property(p.name, p.default, p.schema, self.custom_def) + props.append(prop) + return props + + def validate(self): + self._validate_properties(self.entity_tpl, self.type_definition) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/shell.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/shell.py new file mode 100644 index 0000000..848726f --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/shell.py @@ -0,0 +1,106 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +import os +import sys + +from toscaparser.tosca_template import ToscaTemplate +from toscaparser.utils.gettextutils import _ +import toscaparser.utils.urlutils + +""" +CLI entry point to show how TOSCA Parser can be used programmatically + +This is a basic command line utility showing the entry point in the +TOSCA Parser and how to iterate over parsed template. It can be extended +or modified to fit an individual need. + +It can be used as, +#tosca-parser --template-file= +#tosca-parser --template-file= +#tosca-parser --template-file= + +e.g. +#tosca-parser + --template-file=toscaparser/tests/data/tosca_helloworld.yaml +#tosca-parser + --template-file=toscaparser/tests/data/CSAR/csar_hello_world.zip +""" + + +class ParserShell(object): + + def _validate(self, args): + if len(args) < 1: + msg = _('The program requires a template or a CSAR file as an ' + 'argument. Please refer to the usage documentation.') + raise ValueError(msg) + if "--template-file=" not in args[0]: + msg = _('The program expects "--template-file" as the first ' + 'argument. Please refer to the usage documentation.') + raise ValueError(msg) + + def main(self, args): + self._validate(args) + path = args[0].split('--template-file=')[1] + if os.path.isfile(path): + self.parse(path) + elif toscaparser.utils.urlutils.UrlUtils.validate_url(path): + self.parse(path, False) + else: + raise ValueError(_('"%(path)s" is not a valid file.') + % {'path': path}) + + def parse(self, path, a_file=True): + output = None + tosca = ToscaTemplate(path, None, a_file) + + version = tosca.version + if tosca.version: + print ("\nversion: " + version) + + if hasattr(tosca, 'description'): + description = tosca.description + if description: + print ("\ndescription: " + description) + + if hasattr(tosca, 'inputs'): + inputs = tosca.inputs + if inputs: + print ("\ninputs:") + for input in inputs: + print ("\t" + input.name) + + if hasattr(tosca, 'nodetemplates'): + nodetemplates = tosca.nodetemplates + if nodetemplates: + print ("\nnodetemplates:") + for node in nodetemplates: + print ("\t" + node.name) + + if hasattr(tosca, 'outputs'): + outputs = tosca.outputs + if outputs: + print ("\noutputs:") + for output in outputs: + print ("\t" + output.name) + + +def main(args=None): + if args is None: + args = sys.argv[1:] + ParserShell().main(args) + + +if __name__ == '__main__': + main() diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/__init__.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/collectd/config.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/collectd/config.py new file mode 100755 index 0000000..686bbd1 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/collectd/config.py @@ -0,0 +1,25 @@ +#!/usr/bin/python + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# This script configures collectd to send metric data to the +# logstash server port 25826 +# The environment variable logstash_ip is expected to be set up +import os +with open("/etc/collectd/collectd.conf.d/tosca_elk.conf", "w") as fh: + fh.write(""" + LoadPlugin network + + Server "%s" "25826" + + """ % (os.environ['logstash_ip'])) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/collectd/create.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/collectd/create.sh new file mode 100755 index 0000000..a483b88 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/collectd/create.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# This script install collectd for monitoring data + +apt-get update +apt-get install -y collectd diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/collectd/start.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/collectd/start.sh new file mode 100755 index 0000000..7e8e033 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/collectd/start.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# This script starts collectd as a service in init.d +service collectd stop +service collectd start diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/elasticsearch/create.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/elasticsearch/create.sh new file mode 100755 index 0000000..c34126c --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/elasticsearch/create.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# This script installs java and elasticsearch + +apt-get update +apt-get install -y openjdk-7-jre-headless + +wget -qO - https://packages.elasticsearch.org/GPG-KEY-elasticsearch | apt-key add - +echo "deb http://packages.elasticsearch.org/elasticsearch/1.5/debian stable main" | tee -a /etc/apt/sources.list + +apt-get update +apt-get install -y elasticsearch + +# set up to run as service +update-rc.d elasticsearch defaults 95 10 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/elasticsearch/start.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/elasticsearch/start.sh new file mode 100755 index 0000000..bbc0347 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/elasticsearch/start.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# This script starts elasticsearch as a service in init.d +service elasticsearch stop +service elasticsearch start diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/kibana/config.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/kibana/config.sh new file mode 100755 index 0000000..f28215a --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/kibana/config.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# This script configures kibana to connect to the elasticsearch server +# to access data and to export the app url on port 5601: +# The environment variable elasticsearch_ip and kibana_ip are expected +# to be set up. +sed -i 's/localhost/'$elasticsearch_ip'/' /opt/kibana/config/kibana.yml +sed -i 's/0.0.0.0/'$kibana_ip'/' /opt/kibana/config/kibana.yml diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/kibana/create.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/kibana/create.sh new file mode 100755 index 0000000..41914b1 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/kibana/create.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# This script installs kibana and sets it up to run as a service in init.d +cd /opt +wget https://download.elastic.co/kibana/kibana/kibana-4.1.0-linux-x64.tar.gz +tar xzvf kibana-4.1.0-linux-x64.tar.gz +mv kibana-4.1.0-linux-x64 kibana + +# set up to run as service +cd /etc/init.d +wget https://gist.githubusercontent.com/thisismitch/8b15ac909aed214ad04a/raw/bce61d85643c2dcdfbc2728c55a41dab444dca20/kibana4 +chmod +x kibana4 +update-rc.d kibana4 defaults 96 9 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/kibana/start.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/kibana/start.sh new file mode 100755 index 0000000..5149bb3 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/kibana/start.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# This script starts kibana as a service in init.d +service kibana4 stop +service kibana4 start diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/logstash/configure_collectd.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/logstash/configure_collectd.py new file mode 100755 index 0000000..18fdacf --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/logstash/configure_collectd.py @@ -0,0 +1,28 @@ +#!/usr/bin/python + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# This script configures the logstash input using the udp protocol on +# port 25826. This is intended to receive data from collectd from +# any source +with open("/etc/logstash/conf.d/collectd.conf", "w") as fh: + fh.write(""" + input { + udp { + port => 25826 # 25826 is the default for collectd + buffer_size => 1452 # 1452 is the default for collectd + codec => collectd { } + tags => ["metrics"] + type => "collectd" + } + }""") diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/logstash/configure_elasticsearch.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/logstash/configure_elasticsearch.py new file mode 100755 index 0000000..2e5389c --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/logstash/configure_elasticsearch.py @@ -0,0 +1,26 @@ +#!/usr/bin/python + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# This script configures the logstash output to forward to elasticsearch +# The environment variable elasticsearch_ip is expected to be set up +import os +with open("/etc/logstash/conf.d/elasticsearch.conf", 'w') as fh: + fh.write(""" + output { + elasticsearch { + action => index + host => "%s" + protocol => "http" + } + }""" % (os.environ['elasticsearch_ip'])) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/logstash/configure_rsyslog.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/logstash/configure_rsyslog.py new file mode 100755 index 0000000..fc610c2 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/logstash/configure_rsyslog.py @@ -0,0 +1,25 @@ +#!/usr/bin/python + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# This script configures the logstash input using the RELP protocol on +# port 2514 This is intended to receive logs from rsyslog from +# any source +with open("/etc/logstash/conf.d/rsyslog.conf", "w") as fh: + fh.write(""" + input { + relp { + port => 2514 + tags => ["logs"] + } + }""") diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/logstash/create.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/logstash/create.sh new file mode 100755 index 0000000..77cc8fd --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/logstash/create.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# This script installs java, logstash and the contrib package for logstash +# install java as prereq + +apt-get update +apt-get install -y openjdk-7-jre-headless +mkdir /etc/logstash + +# install by apt-get from repo +wget -O - http://packages.elasticsearch.org/GPG-KEY-elasticsearch | apt-key add - +echo "deb http://packages.elasticsearch.org/logstash/1.4/debian stable main" | tee -a /etc/apt/sources.list + +apt-get update +apt-get install -y logstash + +# install contrib to get the relp plugin +/opt/logstash/bin/plugin install contrib + +# set up to run as service +update-rc.d logstash defaults 95 10 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/logstash/start.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/logstash/start.sh new file mode 100755 index 0000000..a73cf61 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/logstash/start.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# Run logstash as service in init.d +service logstash stop +service logstash start diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mongodb/config.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mongodb/config.sh new file mode 100644 index 0000000..78f484e --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mongodb/config.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# Edit the file /etc/mongod.conf, update with real IP of Mongo server +# This script configures the mongodb server to export its service on +# the server IP +# bind_ip = 127.0.0.1 -> bind_ip = +# The environment variable mongodb_ip is expected to be set up +sed -i "s/= 127.0.0.1/= $mongodb_ip,127.0.0.1/" /etc/mongod.conf diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mongodb/create.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mongodb/create.sh new file mode 100644 index 0000000..d84c275 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mongodb/create.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# This script installs mongodb + +apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 +echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.0.list + +apt-get update +apt-get install -y mongodb-org + +#Wait for mongodb initialization +while [[ ! -d "/var/lib/mongodb/_tmp" ]]; do + echo "Waiting for mongodb initialization ..." + sleep 5 +done diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mongodb/create_database.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mongodb/create_database.sh new file mode 100644 index 0000000..16f1358 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mongodb/create_database.sh @@ -0,0 +1,5 @@ +#!/bin/bash +echo "conn = new Mongo();" > setup.js +echo "db = conn.getDB('paypal_pizza');" >> setup.js +echo "db.about.insert({'name': 'PayPal Pizza Store'});" >> setup.js +mongo setup.js diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mongodb/start.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mongodb/start.sh new file mode 100644 index 0000000..ac200a5 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mongodb/start.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# This script starts mongodb +service mongod stop +rm /var/lib/mongodb/mongod.lock +service mongod start diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mysql/mysql_database_configure.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mysql/mysql_database_configure.sh new file mode 100755 index 0000000..092136a --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mysql/mysql_database_configure.sh @@ -0,0 +1,8 @@ +#!/bin/sh +cat << EOF | mysql -u root --password=$db_root_password +CREATE DATABASE $db_name; +GRANT ALL PRIVILEGES ON $db_name.* TO "$db_user"@"localhost" +IDENTIFIED BY "$db_password"; +FLUSH PRIVILEGES; +EXIT +EOF \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mysql/mysql_dbms_configure.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mysql/mysql_dbms_configure.sh new file mode 100755 index 0000000..d4ef6b4 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mysql/mysql_dbms_configure.sh @@ -0,0 +1,5 @@ +#!/bin/sh +sed --regexp-extended "s/(port\s*=\s*)[0-9]*/\1$db_port/g" /tmp/my.cnf +mv -f /tmp/my.cnf /etc/mysql/my.cnf +/etc/init.d/mysql stop +/etc/init.d/mysql start \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mysql/mysql_dbms_install.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mysql/mysql_dbms_install.sh new file mode 100755 index 0000000..38628b9 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mysql/mysql_dbms_install.sh @@ -0,0 +1,9 @@ +#!/bin/bash +#This script installs mysql server + +apt-get update + +debconf-set-selections <<< "mysql-server mysql-server/root_password password $db_root_password" +debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $db_root_password" + +apt-get -y install --fix-missing mysql-server \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mysql/mysql_dbms_start.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mysql/mysql_dbms_start.sh new file mode 100755 index 0000000..3378670 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/mysql/mysql_dbms_start.sh @@ -0,0 +1,2 @@ +#!/bin/sh +/etc/init.d/mysql start \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/nodejs/config.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/nodejs/config.sh new file mode 100644 index 0000000..1e149a2 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/nodejs/config.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# This script installs an app for nodejs: the app intended is the paypal app +# and it is configured to connect to the mongodb server +# The environment variables github_url and mongodb_ip are expected to be set up +export app_dir=/opt/app +git clone $github_url /opt/app +if [ -f /opt/app/package.json ]; then + cd /opt/app/ && npm install + sed -i "s/localhost/$mongodb_ip/" config.json +fi + +cat > /etc/init/nodeapp.conf <> /var/log/nodeapp.log 2>&1 & +end script +EOS diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/nodejs/create.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/nodejs/create.sh new file mode 100644 index 0000000..04fd6c6 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/nodejs/create.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# This script installs nodejs and the prereq + +add-apt-repository ppa:chris-lea/node.js + +apt-get update +apt-get install -y nodejs build-essential diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/nodejs/start.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/nodejs/start.sh new file mode 100644 index 0000000..6939cb7 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/nodejs/start.sh @@ -0,0 +1,3 @@ +#!/bin/bash +# This script starts the nodejs application +start nodeapp diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/rsyslog/config.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/rsyslog/config.sh new file mode 100644 index 0000000..630767d --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/rsyslog/config.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# This script configures the output for rsyslogd to send logs to the +# logstash server port 2514 using the RELP protocol +# The environment variable logstash_ip is expected to be set up +echo "module(load=\"omrelp\") +action(type=\"omrelp\" target=\"$logstash_ip\" port=\"2514\")" > /etc/rsyslog.d/tosca_elk.conf + +# Remove the /dev/xconsole configuration as xconsole +# is not available by default +l=`awk '/=warn.*\|.*\/dev\/xconsole/{print NR - 1}' /etc/rsyslog.d/50-default.conf` +if [ ! -z $l ]; then + l=`expr $l + 1` + line=`cat /etc/rsyslog.d/50-default.conf | head -n $l | tail -1` + if [[ ! $line == \#* ]]; then + l0=`expr $l - 3` + sed -i -r -e "${l0},${l}s/^.{0}/&#/" /etc/rsyslog.d/50-default.conf + fi +fi + +# Enable nodejs logs for rsyslog +if ! grep -q nodeapp "/etc/rsyslog.conf"; then + sed -i 's/\$PrivDropToGroup\ syslog/\$PrivDropToGroup adm/' /etc/rsyslog.conf + echo "\$ModLoad imfile.so +\$InputFileName /var/log/nodeapp.log +\$InputFileTag paypal_pizza: +\$InputFileStateFile stat-nodeapp +\$InputRunFileMonitor +\$InputFilePollInterval 1" >> /etc/rsyslog.conf +fi diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/rsyslog/create.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/rsyslog/create.sh new file mode 100755 index 0000000..affdd6e --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/rsyslog/create.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# This script installs rsyslog and the library for RELP + +apt-get update +apt-get install -y rsyslog rsyslog-relp diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/rsyslog/start.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/rsyslog/start.sh new file mode 100755 index 0000000..3de82d1 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/rsyslog/start.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# This script starts rsyslogd as a service in init.d +service rsyslog stop +service rsyslog start diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/webserver/webserver_install.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/webserver/webserver_install.sh new file mode 100755 index 0000000..4ca9b4e --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/webserver/webserver_install.sh @@ -0,0 +1,5 @@ +#!/bin/sh +#This script installs apache web server + +apt-get update +apt-get install -y apache2 \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/webserver/webserver_start.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/webserver/webserver_start.sh new file mode 100755 index 0000000..e962ca5 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/webserver/webserver_start.sh @@ -0,0 +1,2 @@ +#!/bin/sh +service apache2 start \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/wordpress/wordpress_configure.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/wordpress/wordpress_configure.sh new file mode 100755 index 0000000..5598b4f --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/wordpress/wordpress_configure.sh @@ -0,0 +1,4 @@ +#!/bin/sh +ln -s /usr/share/wordpress /var/www/html/wordpress +gzip -d /usr/share/doc/wordpress/examples/setup-mysql.gz +echo $wp_db_password | bash /usr/share/doc/wordpress/examples/setup-mysql -e $wp_db_name -u $wp_db_user localhost \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/wordpress/wordpress_install.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/wordpress/wordpress_install.sh new file mode 100755 index 0000000..1320443 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/artifacts/wordpress/wordpress_install.sh @@ -0,0 +1,5 @@ +#!/bin/sh +#This script installs wordpress + +apt-get update +apt-get install -y wordpress \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/base.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/base.py new file mode 100644 index 0000000..f6ff8d1 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/base.py @@ -0,0 +1,67 @@ +# -*- coding: utf-8 -*- + +# Copyright 2010-2011 OpenStack Foundation +# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import os + +import fixtures +import testscenarios +import testtools + +from toscaparser.tosca_template import ToscaTemplate + +_TRUE_VALUES = ('True', 'true', '1', 'yes') + + +class TestCase(testscenarios.TestWithScenarios, testtools.TestCase): + + """Test case base class for all unit tests.""" + + def setUp(self): + """Run before each test method to initialize test environment.""" + + super(TestCase, self).setUp() + test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0) + try: + test_timeout = int(test_timeout) + except ValueError: + # If timeout value is invalid do not set a timeout. + test_timeout = 0 + if test_timeout > 0: + self.useFixture(fixtures.Timeout(test_timeout, gentle=True)) + + self.useFixture(fixtures.NestedTempfile()) + self.useFixture(fixtures.TempHomeDir()) + + if os.environ.get('OS_STDOUT_CAPTURE') in _TRUE_VALUES: + stdout = self.useFixture(fixtures.StringStream('stdout')).stream + self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout)) + if os.environ.get('OS_STDERR_CAPTURE') in _TRUE_VALUES: + stderr = self.useFixture(fixtures.StringStream('stderr')).stream + self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr)) + + self.log_fixture = self.useFixture(fixtures.FakeLogger()) + + def _load_template(self, filename): + """Load a Tosca template from tests data folder. + + :param filename: Tosca template file name to load. + :return: ToscaTemplate + """ + return ToscaTemplate(os.path.join( + os.path.dirname(os.path.abspath(__file__)), + 'data', + filename)) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_elk.csar b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_elk.csar new file mode 100644 index 0000000000000000000000000000000000000000..5fae801a7538fea7208bedc504f300bcda30efff GIT binary patch literal 17488 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 R01TjCGf?3F5`+N&{6B74f*Ak+ literal 0 HcmV?d00001 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_elk.zip b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_elk.zip new file mode 100644 index 0000000000000000000000000000000000000000..5fae801a7538fea7208bedc504f300bcda30efff GIT binary patch literal 17488 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 R01TjCGf?3F5`+N&{6B74f*Ak+ literal 0 HcmV?d00001 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_hello_world.zip b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_hello_world.zip new file mode 100644 index 0000000000000000000000000000000000000000..43ffbbc83003a5b4fa1e04284d080610c9051877 GIT binary patch literal 936 zcmWIWW@Zs#U|`^2XiJlK*F7Nc&47`Cp_GY%L6kv;p(MXJIWayXH76&(JijO>MXxe3 zHzzcNlYu#B!;{cU$Df3jR&X;gvb=@U(4maJG_BymW7dTLBgyp zZ{=FAG`L=N*|__n?cbPN8^e-!s(j4<|1Zgv$vT_sPOz)f!lciQonJSw?DX)lo0cK< z+S}N4vX1tI*hL!C=ah$B%sTL+~Rhv`U0$Q2YGv+BX>@%DjU(Px~E$RHs?W}X`+2pei#+94hlAU_R?AJ=h z9nHQ8jN)1wy(Y7nT%WTz?N1nw5u0P{n!SY^pQ)Z{d)V}2N%8NXZ7*4_tzP)-;`d86 zR?W|^He|&vPTHHHto>HtzSK3wJBzrLd+Hxt*;sot-uctFhV41GQzu(bS}@s4^YPEb zM6vISTk@VouX^=aV_p9=m)*O5i?5%({H@2nf2&;W&hKLk00uu7F!&i5a!cgh!3-$D z4-Ebg|6pfFUEkD_#FWI6M163;&pq)ZbTbg61w6Zt;D_>8VHErhfNTw?RIZFd3#m|`|F@NH$ z$&=&f#ZQ^MD17FO*@syf0=yZSMXxe3 zHzzcNlYu#B!;?@DF0J5ZU}Sm8%)kI9N+%u6J7mDq_P&?6Pt9MccnIw>E|)?^OAi|Nmc-E0c9L*PUQjr-ezM8#}*lVA<*6V>c~B>b1AA z>0}-439*Ybrq3x4xyp6OPDR6D+QNme7{nsB3pE<9l&_g2qo}s$%R#4p#Uvr8bDMpf zcv3A)+^ROGvIVpWU7WNxLs|Q+zWcecIB(DuIH7~(`P)d@_OrPojY@WbCAIm;|E22Wjsz|hEIz0ynJ;$ zeJ_@-+7k4koaY-)7zd-|0)axeIR!Fi$^9ICdT!9QR znt?%p;jd#o&<2bk2O5ecY>?fH8Q{q7J%MQ`a`59ao|O&cQDz|I2O7{0%#REV09pz@ A`2YX_ literal 0 HcmV?d00001 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_metadata_not_yaml.zip b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_metadata_not_yaml.zip new file mode 100644 index 0000000000000000000000000000000000000000..3e6120bbac84a9986d2662488cd2feed3afe1bc8 GIT binary patch literal 936 zcmWIWW@Zs#U|`^2XiJlK*F7Nc&47`Cp_GY%L6kv;p(MXJIWayXH76&(JijO>MXxe3 zHzzcNlYu#B!;{d&ZBIf=E4UdLSza>`cnbIL=mavic$(J+{{aN#Qkv54(LjfN}bYbMDks_pr5(5YWBNyzEk zW*;Y>R0|Wgs?Div0j*5y8S|7G_8HENFK3;gmUMpRcGfxeZ1UL$Jl}Z2I2a`t2s}FTbXIs!$jaA~W=)$pJ(B54z?#JYlj7&hk(fVm z*5t|Y^WvvWUKBoa#_Yqa3<2JZOmfV)5}^b*Jb-DEVM`;3i6cp}LXsq!7a&IC3SfxQ z3=9Gce;wJ|4U?aQt1g4?LL66ILRyL4FnSqcWXh1VCFETIy0GTT` AZvX%Q literal 0 HcmV?d00001 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_missing_metadata.zip b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_missing_metadata.zip new file mode 100644 index 0000000000000000000000000000000000000000..5ec7a99940dd618889839878116180f55fc12eeb GIT binary patch literal 933 zcmWIWW@Zs#U|`^2XiJlK*F7Nc&47`Cp_GY%L6kv;p(MXJIWayXH76&(JijO>MXxe3 zHzzcNlYu#B!;?@DF0J5ZU}Sm8%)kI9N+%u6J7mDq_P&?6Pt9MccnIw>E|)?^OAi|Nmc-E0c9L*PUQjr-ezM8#}*lVA<*6V>c~B>b1AA z>0}-439*Ybrq3x4xyp6OPDR6D+QNme7{nsB3pE<9l&_g2qo}s$%R#4p#Uvr8bDMpf zcv3A)+^ROGvIVpWU7WNxLs|Q+zg58> zg&PSn7A-EhKk}EAUHR&(>v^U0^cl~qyxzK6=gyqp9At3C_(2h08IO~g;gcdgFJB!` z-;1TIwgi1B=lRAH#=$7LK;Y4tr?bL?LRP+>G;7+->5)v=0w%@JnIkcO;;hM&OHB8NLJ<5}529%TkXexLyjz>LVi003V^IF0}S literal 0 HcmV?d00001 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_no_metadata_file.zip b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_no_metadata_file.zip new file mode 100644 index 0000000000000000000000000000000000000000..b0df9b9eec2df1537f38d237687bf749f06f27f7 GIT binary patch literal 496 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 literal 0 HcmV?d00001 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_wordpress_invalid_import_path.zip b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_wordpress_invalid_import_path.zip new file mode 100644 index 0000000000000000000000000000000000000000..d6442594363def4ad1dca76b884680e8c375fa15 GIT binary patch literal 5971 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 PZs2zT_+-FA{O|t&l?c`g literal 0 HcmV?d00001 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_wordpress_invalid_import_url.zip b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_wordpress_invalid_import_url.zip new file mode 100644 index 0000000000000000000000000000000000000000..c7a260f584159f562e88404fc1c0cc32bd8d8b0d GIT binary patch literal 6043 zcmbVQc|4SB{~kMI-u;9)FG9%Z1v(;vt-}b zWGN|I6haXd@q32zo|!3m^&6l2@ys7{J=gcTulu_^MtWrAY#;dUFGse#LH4+O+)>leFv$UT^!SkrgTu?t@XIbP!Z&%BD*(HQ_G_hegX3G(^+rH z<@1`3Kd(bL-v`|dy>@b50gd(bJW8e&0@KGU6t5OMAmddZf7 zMJj4OrudZ8EMt%Pj|Dp*R!&$sEd<46xKkTlZ#NNG=W+`+?tIlO>u#;eC^#sU#e1}a zomufc8@FW7a9luu&8Vb{Ui+{^^CBFnXmws}btOJzu{@1j%4;Mk<6s3V2{JoeIw`&> z#_<^xmM_dcUBGN?mR{toqG8o2t?`7kn}6(*!~M5Mr&5Qy7=*72s`X*wb0d?B?((t+ z!TML=AL0{dnT*$b$**nvbQ(m- z(zDB#Vl8Cz?fX|Cn-M3a_d{OTmQA@(J$@dEk@vco)pD1X0Ht}O#~xYd$sY&lY-FFG zT@^|*GqE{)z51(F-4V^#(VCkV9fsafW4&63BonI+RhE3xdKsd3$FktThCwl>zqFy% zIz;gUgS^{|fvE77NlcB~Y_k5&@y=q1zZ7o}z5cOxzKQGe;70D) z`)sXqGiv#lW+U{JUzIT;xT$;Dw)kQwqTL4Ut>8hLEjMa-+I#uF(##>Xq82k0{+?Db z0t^TS3<#LcS4n&O=AR2AU_diN)3a()P&fwW48y==wq2N9OtYH{aX>px#sL{DimKcM zfZBk?{WH)uuCxb$yB8$1Qw>}%%M?C-$smsQ(13^E35jxS2#se)Z!}AG0+vSC^FIUO zwl!2+GgOE`-)8VE7sAX^l9!dcV&DMG_KKB?HH=ohDb=s5HSG^k(eI=Xuclx(q+4tm zr0_E7Nz{oa$^Id6!lMXYVIPWQ@1QIel$y)v*iqU$*+S-Tt+j*&XA}$yRz?#-3~J*( zb3Pk4+7Dgu>c6g z1sr{zA5i}ALOFY*;ApgT0L;UEuQZT|RWoRmrPEwf)|6JI7+KJ&<)g{8((;@P$r_|7 zRm^yOPo(&`W+=8*;@jmno28l`YN_TU+Qf>!u|`VYZ?+N_zkyU$X*l(T>WaNNFWJRA ztZt?iUfJErgWB$l;`Gne7R>lF!Z_8WQqUyf23$chKJJ@K?B|xyLUqh9EGp4|NMBW> zjpS3vgt%LaKV@Jkmcw>guSKbMU}pwQR31V726-nDnf3y8X;b}-x(BL;iZ4fZ4ky(# zIa*&!Tj?E#hgy;`2#oXGIRzb}Use?5Ki?xeVQ0%wZBymrroM4G)G+cBqf+p!!UFo$ zxf&2&LEJu&T$g{{2;@T+dJstV2L&-+XeXFG8tI8}hub4P(HNMg6Wo3mU2%K0OM0!o z?cvpbnyux{nrRB7QT%7OWG#Dv591-&lU!_af?-0UKGqi^4!R?<1Zos#PDQZZE}qNG z8{r&r=HI%+cX_6>q}^Gv?W+j{79KAWF!gebA6?+t@n?~Qe-RuW*BPJCc4$VVKfS1X zdVqYaf4ymdLe9?!S;F=uP*Vh+S)$&i@PK&ud;{omacpR68$WtHv7f^9lT05 z>s=hXkl_-dtBbd$-W|N9KaK&}rSTO1NDbnKn>sfk5B6>o)K2C`e; z82K>K09}+N<#8Jw2Y)&yqGer^Zh*j=C<&N%D{Fedl|9F$Vut@@`0L%hhn(i-e@6G6 zh%?j;R9#*y>8+YlEY43XM9(%~dsJsIV^$Bh6VG&ijX^&1C@u{vv@42c#BdHPD)a|D zRj+b0xI|*iCS!A2f4(}}_9?rj^I#qG;oFYp7x<{h@5)(=aSTpj%%1VTW~N_9Exj<) z89J~;Yr)Iicgmo6)Pz60&hS9U)4D|;_8~Uy>~fdkyk|%Mh>o90c%EY8TF8HQt|0Zp zVaId5FcX{A=}|83@-xvD@+jt2txCbq*M_mL7i1rMI3SVty2kiY8JK<7DFTZ-`bctD zVH8xU=QjeEFRJKzgEFV5&IFCo_$T+191{k2r359bNj9>PPCgaTNFW2*y_ROEm7mq> zfy#GX$M&gi9*|A0YGLNkZ*Y3g!|hG4$o2Zm)rP|;%*xdf+OD!aSL%vHjIA;(e?uA z(Ca*|)%vaF@z$4G-MMRhLrRv(6qK7$&GSm9(>8KnuDY`5`+J$prK83CEvl;vXn>TRS%%*hpgOkn%h`x6*yWooRip$;|u4S^ezjB{fF z>T)E+0^_mvC-5V~N(P`E8Cho6?zlM1ICXqDFSDXlG)t%TVC<$cwT33A2&G=B?mUgtGB#r*>*WRlaUh|;M*)I@kfIF6kf78fRQxGM& zASL&oLp2FYQcsfqUTunag`zKrb6Wb|?Y7zXrn1fFTSd`m{bw{UlXlHyy->;n+wWxf z3W(dI{?OUyfk2RDz~Up=BYcofUY;&Ugf9yIKlTalBMAejaqobXF4XXmSTFREm`;}- zNu(J2+y%BN&csHx3ol3uU5bMr!}D)lj!x6nHBo}7tJvz)X{nSPvQjB4Dwm~#%pRV} z5+8nldx}F!+yhf`4v~#&jREvfJJn&|Hay$ z@$fsc`^gsTkV46q2zf)8@PW=V|J1I`2; z#hOAmvwLW)nL@;XS$pg$L8H%0H#N;mB@rvrwlc1_!Y0fisT2izqY)C5tpkbeMIEB% zyiTcJM^o&&=1f#8-?YL58L;+jdJbyigHbVF0b%P^5~XJvJZ`onq!8pRu@ZZ?LyiiK_EC8_&SVF(V+pkv8 zm@aULDqHy4GFw@Wxx<;Ols5uOg4NDG%ub9}aY!{#&?Q$6(qWV8X=zbFocViM4{;}% z%?&g}5l!Z=zAjrvna_Oj5miBc-m&S&>!@n6Wp~FHx3L}}`a)mykHuzDC-mi%q9A`2 zKuB3hS7}sG!GaH%v{jr+$hpbxPPpdY^K{Li9eDnd?xr`ta2r|78ULBsmAjb?G>w9z z-v>^U8`{LLedRRLBO&D@!&fKbR}x&?@&b7jR2+=EC450avGaoBr%4Bg_p1qW2M+{d z0)1Bt2Bx2%=1l+;H*f9=`m1S^kYxMMpoFvMUhq4df1dIPITr#m2l31YAmZkTJqY8n zHSxqpNOmoP`~k2!I_MEHc;KzMs~Py53s)R|ZrFfAS* zUncjf3~{4G$lGF9-2Ezp*PggbA$)=&-EPc@Q|tcJA#NK8pTPjU9r&;Mcy;hi#QyMq zt$rv0KE9OhSAF7cfsl94uDHLiK5^M6e1a||Bw2F>TnR9T2)5;Gj`O+7v#N^ g$GeBP924@#{t|nCF;GzAc(Ve3E5KbG6Yksp0eTSvH2?qr literal 0 HcmV?d00001 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_wordpress_invalid_script_path.zip b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_wordpress_invalid_script_path.zip new file mode 100644 index 0000000000000000000000000000000000000000..5e4f9e0a0d64eefd73777caf4e63be3e1ebb2ee2 GIT binary patch literal 5969 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 literal 0 HcmV?d00001 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_wrong_metadata_file.zip b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/csar_wrong_metadata_file.zip new file mode 100644 index 0000000000000000000000000000000000000000..85d660a037693b3447038e5bc94732679f3ac8d2 GIT binary patch literal 873 zcmWIWW@Zs#U|`^2XiJlK*F7Nc&47`Cp_GY%L6kv;p(MXJIWayXH76&(JijO>MXxe3 zHzzcNlYu#B!;?@DF0J5ZU}Sm8%)kI9N+%u6J7mDq_P&?6Pt9MccnIw>E|)?^OAi|Nmc-E0c9L*PUQjr-ezM8#}*lVA<*6V>c~B>b1AA z>0}-439*Ybrq3x4xyp6OPDR6D+QNme7{nsB3pE<9l&_g2qo}s$%R#4p#Uvr8bDMpf zcv3A)+^ROGvIVpWU7WNxLs|Q+zBs36+(E=V}5F^l_yG{p{~u_UHJU~~0A=7No6 z1RCdnX{2jjNl~S)OKMtXUS>&VeqOPa0@n1v72wUtB*%;^6-j_S1WZ&6TN*)3tY(CU zutL%lhPOaQ;|d{&(F_a%41XQ#fi_@-7tl~pc;PV=GqjN1djiu? + collectd is a daemon which gathers statistics about the system it is running on. + +node_types: + tosca.nodes.SoftwareComponent.Collectd: + derived_from: tosca.nodes.SoftwareComponent + requirements: + - log_endpoint: + capability: tosca.capabilities.Endpoint + node: tosca.nodes.SoftwareComponent.Logstash + relationship: tosca.relationships.ConnectsTo \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/elasticsearch.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/elasticsearch.yaml new file mode 100644 index 0000000..4a1770f --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/elasticsearch.yaml @@ -0,0 +1,11 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + Elasticsearch is an open-source search engine built on top of Apache Lucene, a full-text search-engine library. + +node_types: + tosca.nodes.SoftwareComponent.Elasticsearch: + derived_from: tosca.nodes.SoftwareComponent + capabilities: + search_endpoint: + type: tosca.capabilities.Endpoint diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/kibana.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/kibana.yaml new file mode 100644 index 0000000..3a4351c --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/kibana.yaml @@ -0,0 +1,16 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + Kibana is an open source analytics and visualization platform designed to work with Elasticsearch. + You use Kibana to search, view, and interact with data stored in Elasticsearch. + +node_types: + tosca.nodes.SoftwareComponent.Kibana: + derived_from: tosca.nodes.SoftwareComponent + requirements: + - search_endpoint: + capability: tosca.capabilities.Endpoint + node: tosca.nodes.SoftwareComponent.Elasticsearch + relationship: tosca.relationships.ConnectsTo + + diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/logstash.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/logstash.yaml new file mode 100644 index 0000000..8495954 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/logstash.yaml @@ -0,0 +1,25 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + Logstash is a tool for receiving, processing and outputting logs. All kinds of logs. System logs, webserver logs, + error logs, application logs, and just about anything you can throw at it. + +node_types: + tosca.nodes.SoftwareComponent.Logstash: + derived_from: tosca.nodes.SoftwareComponent + requirements: + - search_endpoint: + capability: tosca.capabilities.Endpoint + node: tosca.nodes.SoftwareComponent.Elasticsearch + relationship: + type: tosca.relationships.ConnectsTo + interfaces: + Configure: + pre_configure_source: + inputs: + elasticsearch_ip: + type: string + capabilities: + log_endpoint: + type: tosca.capabilities.Endpoint + diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/paypalpizzastore_nodejs_app.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/paypalpizzastore_nodejs_app.yaml new file mode 100644 index 0000000..d62c4c1 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/paypalpizzastore_nodejs_app.yaml @@ -0,0 +1,29 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + Pizza store app that allows you to explore the features provided by PayPal's REST APIs. + More detail can be found at https://github.com/paypal/rest-api-sample-app-nodejs/ + +node_types: + tosca.nodes.WebApplication.PayPalPizzaStore: + derived_from: tosca.nodes.WebApplication + properties: + github_url: + required: no + type: string + description: location of the application on the github. + default: https://github.com/sample.git + requirements: + #WebApplication inherits Computer, so host implied. + - database_connection: + capability: tosca.capabilities.Endpoint.Database + node: tosca.nodes.Database + relationship: tosca.relationships.ConnectsTo + interfaces: + Standard: + configure: + inputs: + github_url: + type: string + mongodb_ip: + type: string diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/rsyslog.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/rsyslog.yaml new file mode 100644 index 0000000..4614ee7 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/rsyslog.yaml @@ -0,0 +1,13 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + RSYSLOG is the Rocket-fast SYStem for LOG processing. + +node_types: + tosca.nodes.SoftwareComponent.Rsyslog: + derived_from: tosca.nodes.SoftwareComponent + requirements: + - log_endpoint: + capability: tosca.capabilities.Endpoint + node: tosca.nodes.SoftwareComponent.Logstash + relationship: tosca.relationships.ConnectsTo diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/tosca_elk.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/tosca_elk.yaml new file mode 100644 index 0000000..932f131 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Definitions/tosca_elk.yaml @@ -0,0 +1,217 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + This TOSCA simple profile deploys nodejs, mongodb, elasticsearch, logstash and kibana each on a separate server + with monitoring enabled for nodejs server where a sample nodejs application is running. The rsyslog and collectd are + installed on a nodejs server. + +imports: + - paypalpizzastore_nodejs_app.yaml + - elasticsearch.yaml + - logstash.yaml + - kibana.yaml + - collectd.yaml + - rsyslog.yaml + +dsl_definitions: + host_capabilities: &host_capabilities + # container properties (flavor) + disk_size: 10 GB + num_cpus: { get_input: my_cpus } + mem_size: 4096 MB + os_capabilities: &os_capabilities + architecture: x86_64 + type: Linux + distribution: Ubuntu + version: 14.04 + +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: http://github.com/paypal/rest-api-sample-app-nodejs.git + + node_templates: + paypal_pizzastore: + type: tosca.nodes.WebApplication.PayPalPizzaStore + properties: + github_url: { get_input: github_url } + requirements: + - host: nodejs + - database_connection: mongo_db + interfaces: + Standard: + configure: + implementation: ../Scripts/nodejs/config.sh + inputs: + github_url: { get_property: [ SELF, github_url ] } + mongodb_ip: { get_attribute: [mongo_server, private_address] } + start: ../Scripts/nodejs/start.sh + nodejs: + type: tosca.nodes.WebServer + requirements: + - host: + node: app_server + interfaces: + Standard: + create: ../Scripts/nodejs/create.sh + mongo_db: + type: tosca.nodes.Database + requirements: + - host: mongo_dbms + interfaces: + Standard: + create: ../Scripts/mongodb/create_database.sh + mongo_dbms: + type: tosca.nodes.DBMS + requirements: + - host: mongo_server + interfaces: + Standard: + create: ../Scripts/mongodb/create.sh + configure: + implementation: ../Scripts/mongodb/config.sh + inputs: + mongodb_ip: { get_attribute: [mongo_server, private_address] } + start: ../Scripts/mongodb/start.sh + elasticsearch: + type: tosca.nodes.SoftwareComponent.Elasticsearch + requirements: + - host: elasticsearch_server + interfaces: + Standard: + create: ../Scripts/elasticsearch/create.sh + start: ../Scripts/elasticsearch/start.sh + logstash: + type: tosca.nodes.SoftwareComponent.Logstash + requirements: + - host: logstash_server + - search_endpoint: + node: elasticsearch + capability: search_endpoint + relationship: + type: tosca.relationships.ConnectsTo + interfaces: + Configure: + pre_configure_source: + implementation: ../Python/logstash/configure_elasticsearch.py + inputs: + elasticsearch_ip: { get_attribute: [elasticsearch_server, private_address] } + interfaces: + Standard: + create: ../Scripts/logstash/create.sh + start: ../Scripts/logstash/start.sh + kibana: + type: tosca.nodes.SoftwareComponent.Kibana + requirements: + - host: kibana_server + - search_endpoint: elasticsearch + interfaces: + Standard: + create: ../Scripts/kibana/create.sh + configure: + implementation: ../Scripts/kibana/config.sh + inputs: + elasticsearch_ip: { get_attribute: [elasticsearch_server, private_address] } + kibana_ip: { get_attribute: [kibana_server, private_address] } + start: ../Scripts/kibana/start.sh + app_collectd: + type: tosca.nodes.SoftwareComponent.Collectd + requirements: + - host: app_server + - log_endpoint: + node: logstash + capability: log_endpoint + relationship: + type: tosca.relationships.ConnectsTo + interfaces: + Configure: + pre_configure_target: + implementation: ../Python/logstash/configure_collectd.py + interfaces: + Standard: + create: ../Scripts/collectd/create.sh + configure: + implementation: ../Python/collectd/config.py + inputs: + logstash_ip: { get_attribute: [logstash_server, private_address] } + start: ../Scripts/collectd/start.sh + app_rsyslog: + type: tosca.nodes.SoftwareComponent.Rsyslog + requirements: + - host: app_server + - log_endpoint: + node: logstash + capability: log_endpoint + relationship: + type: tosca.relationships.ConnectsTo + interfaces: + Configure: + pre_configure_target: + implementation: ../Python/logstash/configure_rsyslog.py + interfaces: + Standard: + create: ../Scripts/rsyslog/create.sh + configure: + implementation: ../Scripts/rsyslog/config.sh + inputs: + logstash_ip: { get_attribute: [logstash_server, private_address] } + start: ../Scripts/rsyslog/start.sh + app_server: + type: tosca.nodes.Compute + capabilities: + host: + properties: *host_capabilities + os: + properties: *os_capabilities + mongo_server: + type: tosca.nodes.Compute + capabilities: + host: + properties: *host_capabilities + os: + properties: *os_capabilities + elasticsearch_server: + type: tosca.nodes.Compute + capabilities: + host: + properties: *host_capabilities + os: + properties: *os_capabilities + logstash_server: + type: tosca.nodes.Compute + capabilities: + host: + properties: *host_capabilities + os: + properties: *os_capabilities + kibana_server: + type: tosca.nodes.Compute + capabilities: + host: + properties: *host_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 ] } + 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/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Python/collectd/config.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Python/collectd/config.py new file mode 100755 index 0000000..686bbd1 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Python/collectd/config.py @@ -0,0 +1,25 @@ +#!/usr/bin/python + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# This script configures collectd to send metric data to the +# logstash server port 25826 +# The environment variable logstash_ip is expected to be set up +import os +with open("/etc/collectd/collectd.conf.d/tosca_elk.conf", "w") as fh: + fh.write(""" + LoadPlugin network + + Server "%s" "25826" + + """ % (os.environ['logstash_ip'])) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Python/logstash/configure_collectd.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Python/logstash/configure_collectd.py new file mode 100755 index 0000000..18fdacf --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Python/logstash/configure_collectd.py @@ -0,0 +1,28 @@ +#!/usr/bin/python + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# This script configures the logstash input using the udp protocol on +# port 25826. This is intended to receive data from collectd from +# any source +with open("/etc/logstash/conf.d/collectd.conf", "w") as fh: + fh.write(""" + input { + udp { + port => 25826 # 25826 is the default for collectd + buffer_size => 1452 # 1452 is the default for collectd + codec => collectd { } + tags => ["metrics"] + type => "collectd" + } + }""") diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Python/logstash/configure_elasticsearch.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Python/logstash/configure_elasticsearch.py new file mode 100755 index 0000000..2e5389c --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Python/logstash/configure_elasticsearch.py @@ -0,0 +1,26 @@ +#!/usr/bin/python + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# This script configures the logstash output to forward to elasticsearch +# The environment variable elasticsearch_ip is expected to be set up +import os +with open("/etc/logstash/conf.d/elasticsearch.conf", 'w') as fh: + fh.write(""" + output { + elasticsearch { + action => index + host => "%s" + protocol => "http" + } + }""" % (os.environ['elasticsearch_ip'])) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Python/logstash/configure_rsyslog.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Python/logstash/configure_rsyslog.py new file mode 100755 index 0000000..fc610c2 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Python/logstash/configure_rsyslog.py @@ -0,0 +1,25 @@ +#!/usr/bin/python + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# This script configures the logstash input using the RELP protocol on +# port 2514 This is intended to receive logs from rsyslog from +# any source +with open("/etc/logstash/conf.d/rsyslog.conf", "w") as fh: + fh.write(""" + input { + relp { + port => 2514 + tags => ["logs"] + } + }""") diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/README.txt b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/README.txt new file mode 100644 index 0000000..382c9b0 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/README.txt @@ -0,0 +1,5 @@ +README: + +This TOSCA simple profile deploys nodejs, mongodb, elasticsearch, logstash and kibana each on a separate server with monitoring enabled for nodejs server where a sample nodejs application is running. The syslog and collectd are installed on a nodejs server. + +Entry information for processing through an orchestrator is contained in file TOSCA-Metadata/TOSCA.meta. This file provides high-level information such as CSAR version or creator of the CSAR. Furthermore, it provides pointers to the entry template under 'Entry-Definitions' key. The entry template itself may contain pointers to one or more files that are used to define TOSCA base type, unless provided by orchestrator as built-in TOSCA basetypes, and other non-normative types. These are typically provided under 'imports' section in the entry template file. Those type definitions will be read and processed by orchestrator or TOSCA parser to create an internal graph showing dependencies and relationships between various TOSCA types. The entry template may have references to various artifacts required for deployment and will be processed accordingly. diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/collectd/create.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/collectd/create.sh new file mode 100755 index 0000000..a483b88 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/collectd/create.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# This script install collectd for monitoring data + +apt-get update +apt-get install -y collectd diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/collectd/start.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/collectd/start.sh new file mode 100755 index 0000000..7e8e033 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/collectd/start.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# This script starts collectd as a service in init.d +service collectd stop +service collectd start diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/elasticsearch/create.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/elasticsearch/create.sh new file mode 100755 index 0000000..c34126c --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/elasticsearch/create.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# This script installs java and elasticsearch + +apt-get update +apt-get install -y openjdk-7-jre-headless + +wget -qO - https://packages.elasticsearch.org/GPG-KEY-elasticsearch | apt-key add - +echo "deb http://packages.elasticsearch.org/elasticsearch/1.5/debian stable main" | tee -a /etc/apt/sources.list + +apt-get update +apt-get install -y elasticsearch + +# set up to run as service +update-rc.d elasticsearch defaults 95 10 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/elasticsearch/start.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/elasticsearch/start.sh new file mode 100755 index 0000000..bbc0347 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/elasticsearch/start.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# This script starts elasticsearch as a service in init.d +service elasticsearch stop +service elasticsearch start diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/kibana/config.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/kibana/config.sh new file mode 100755 index 0000000..f28215a --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/kibana/config.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# This script configures kibana to connect to the elasticsearch server +# to access data and to export the app url on port 5601: +# The environment variable elasticsearch_ip and kibana_ip are expected +# to be set up. +sed -i 's/localhost/'$elasticsearch_ip'/' /opt/kibana/config/kibana.yml +sed -i 's/0.0.0.0/'$kibana_ip'/' /opt/kibana/config/kibana.yml diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/kibana/create.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/kibana/create.sh new file mode 100755 index 0000000..41914b1 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/kibana/create.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# This script installs kibana and sets it up to run as a service in init.d +cd /opt +wget https://download.elastic.co/kibana/kibana/kibana-4.1.0-linux-x64.tar.gz +tar xzvf kibana-4.1.0-linux-x64.tar.gz +mv kibana-4.1.0-linux-x64 kibana + +# set up to run as service +cd /etc/init.d +wget https://gist.githubusercontent.com/thisismitch/8b15ac909aed214ad04a/raw/bce61d85643c2dcdfbc2728c55a41dab444dca20/kibana4 +chmod +x kibana4 +update-rc.d kibana4 defaults 96 9 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/kibana/start.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/kibana/start.sh new file mode 100755 index 0000000..5149bb3 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/kibana/start.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# This script starts kibana as a service in init.d +service kibana4 stop +service kibana4 start diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/logstash/create.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/logstash/create.sh new file mode 100755 index 0000000..77cc8fd --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/logstash/create.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# This script installs java, logstash and the contrib package for logstash +# install java as prereq + +apt-get update +apt-get install -y openjdk-7-jre-headless +mkdir /etc/logstash + +# install by apt-get from repo +wget -O - http://packages.elasticsearch.org/GPG-KEY-elasticsearch | apt-key add - +echo "deb http://packages.elasticsearch.org/logstash/1.4/debian stable main" | tee -a /etc/apt/sources.list + +apt-get update +apt-get install -y logstash + +# install contrib to get the relp plugin +/opt/logstash/bin/plugin install contrib + +# set up to run as service +update-rc.d logstash defaults 95 10 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/logstash/start.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/logstash/start.sh new file mode 100755 index 0000000..a73cf61 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/logstash/start.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# Run logstash as service in init.d +service logstash stop +service logstash start diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/mongodb/config.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/mongodb/config.sh new file mode 100644 index 0000000..78f484e --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/mongodb/config.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# Edit the file /etc/mongod.conf, update with real IP of Mongo server +# This script configures the mongodb server to export its service on +# the server IP +# bind_ip = 127.0.0.1 -> bind_ip = +# The environment variable mongodb_ip is expected to be set up +sed -i "s/= 127.0.0.1/= $mongodb_ip,127.0.0.1/" /etc/mongod.conf diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/mongodb/create.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/mongodb/create.sh new file mode 100644 index 0000000..d84c275 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/mongodb/create.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# This script installs mongodb + +apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 +echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.0.list + +apt-get update +apt-get install -y mongodb-org + +#Wait for mongodb initialization +while [[ ! -d "/var/lib/mongodb/_tmp" ]]; do + echo "Waiting for mongodb initialization ..." + sleep 5 +done diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/mongodb/create_database.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/mongodb/create_database.sh new file mode 100644 index 0000000..16f1358 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/mongodb/create_database.sh @@ -0,0 +1,5 @@ +#!/bin/bash +echo "conn = new Mongo();" > setup.js +echo "db = conn.getDB('paypal_pizza');" >> setup.js +echo "db.about.insert({'name': 'PayPal Pizza Store'});" >> setup.js +mongo setup.js diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/mongodb/start.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/mongodb/start.sh new file mode 100644 index 0000000..ac200a5 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/mongodb/start.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# This script starts mongodb +service mongod stop +rm /var/lib/mongodb/mongod.lock +service mongod start diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/nodejs/config.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/nodejs/config.sh new file mode 100644 index 0000000..1e149a2 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/nodejs/config.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# This script installs an app for nodejs: the app intended is the paypal app +# and it is configured to connect to the mongodb server +# The environment variables github_url and mongodb_ip are expected to be set up +export app_dir=/opt/app +git clone $github_url /opt/app +if [ -f /opt/app/package.json ]; then + cd /opt/app/ && npm install + sed -i "s/localhost/$mongodb_ip/" config.json +fi + +cat > /etc/init/nodeapp.conf <> /var/log/nodeapp.log 2>&1 & +end script +EOS diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/nodejs/create.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/nodejs/create.sh new file mode 100644 index 0000000..04fd6c6 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/nodejs/create.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# This script installs nodejs and the prereq + +add-apt-repository ppa:chris-lea/node.js + +apt-get update +apt-get install -y nodejs build-essential diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/nodejs/start.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/nodejs/start.sh new file mode 100644 index 0000000..6939cb7 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/nodejs/start.sh @@ -0,0 +1,3 @@ +#!/bin/bash +# This script starts the nodejs application +start nodeapp diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/rsyslog/config.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/rsyslog/config.sh new file mode 100644 index 0000000..630767d --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/rsyslog/config.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# This script configures the output for rsyslogd to send logs to the +# logstash server port 2514 using the RELP protocol +# The environment variable logstash_ip is expected to be set up +echo "module(load=\"omrelp\") +action(type=\"omrelp\" target=\"$logstash_ip\" port=\"2514\")" > /etc/rsyslog.d/tosca_elk.conf + +# Remove the /dev/xconsole configuration as xconsole +# is not available by default +l=`awk '/=warn.*\|.*\/dev\/xconsole/{print NR - 1}' /etc/rsyslog.d/50-default.conf` +if [ ! -z $l ]; then + l=`expr $l + 1` + line=`cat /etc/rsyslog.d/50-default.conf | head -n $l | tail -1` + if [[ ! $line == \#* ]]; then + l0=`expr $l - 3` + sed -i -r -e "${l0},${l}s/^.{0}/&#/" /etc/rsyslog.d/50-default.conf + fi +fi + +# Enable nodejs logs for rsyslog +if ! grep -q nodeapp "/etc/rsyslog.conf"; then + sed -i 's/\$PrivDropToGroup\ syslog/\$PrivDropToGroup adm/' /etc/rsyslog.conf + echo "\$ModLoad imfile.so +\$InputFileName /var/log/nodeapp.log +\$InputFileTag paypal_pizza: +\$InputFileStateFile stat-nodeapp +\$InputRunFileMonitor +\$InputFilePollInterval 1" >> /etc/rsyslog.conf +fi diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/rsyslog/create.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/rsyslog/create.sh new file mode 100755 index 0000000..affdd6e --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/rsyslog/create.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# This script installs rsyslog and the library for RELP + +apt-get update +apt-get install -y rsyslog rsyslog-relp diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/rsyslog/start.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/rsyslog/start.sh new file mode 100755 index 0000000..3de82d1 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/Scripts/rsyslog/start.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# This script starts rsyslogd as a service in init.d +service rsyslog stop +service rsyslog start diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/TOSCA-Metadata/TOSCA.meta b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 0000000..feb3d4f --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_elk/TOSCA-Metadata/TOSCA.meta @@ -0,0 +1,4 @@ +TOSCA-Meta-File-Version: 1.0 +CSAR-Version: 1.1 +Created-By: OASIS TOSCA TC +Entry-Definitions: Definitions/tosca_elk.yaml \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Definitions/tosca_single_instance_wordpress.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Definitions/tosca_single_instance_wordpress.yaml new file mode 100644 index 0000000..1dd195a --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Definitions/tosca_single_instance_wordpress.yaml @@ -0,0 +1,109 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with wordpress, web server and mysql on the same server. + +imports: + - wordpress.yaml + +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: PortDef + description: Port for the MySQL database. + + node_templates: + wordpress: + type: tosca.nodes.WebApplication.WordPress + requirements: + - host: webserver + - database_endpoint: mysql_database + interfaces: + Standard: + create: ../Scripts/WordPress/install.sh + configure: + implementation: ../Scripts/WordPress/configure.sh + inputs: + wp_db_name: { get_property: [ mysql_database, name ] } + wp_db_user: { get_property: [ mysql_database, user ] } + wp_db_password: { get_property: [ mysql_database, password ] } + + mysql_database: + type: tosca.nodes.Database + properties: + name: { get_input: db_name } + user: { get_input: db_user } + password: { get_input: db_pwd } + requirements: + - host: mysql_dbms + interfaces: + Standard: + configure: + implementation: ../Scripts/MYSQLDatabase/configure.sh + inputs: + db_name: { get_property: [ SELF, name ] } + db_user: { get_property: [ SELF, user ] } + db_password: { get_property: [ SELF, password ] } + db_root_password: { get_property: [ mysql_dbms, root_password ] } + + mysql_dbms: + type: tosca.nodes.DBMS + properties: + root_password: { get_input: db_root_pwd } + port: { get_input: db_port } + requirements: + - host: server + interfaces: + Standard: + create: ../Scripts/MYSQLDBMS/install.sh + start: ../Scripts/MYSQLDBMS/start.sh + configure: + implementation: ../Scripts/MYSQLDBMS/configure.sh + inputs: + root_password: { get_property: [ mysql_dbms, root_password ] } + + webserver: + type: tosca.nodes.WebServer + requirements: + - host: server + interfaces: + Standard: + create: ../Scripts/WebServer/install.sh + start: ../Scripts/WebServer/start.sh + + 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.0 + + outputs: + website_url: + description: IP address for Wordpress wiki. + value: { get_attribute: [server, private_address] } diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Definitions/wordpress.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Definitions/wordpress.yaml new file mode 100644 index 0000000..5899ed9 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Definitions/wordpress.yaml @@ -0,0 +1,19 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +node_types: + tosca.nodes.WebApplication.WordPress: + derived_from: tosca.nodes.WebApplication + requirements: + - database_endpoint: + capability: tosca.capabilities.Endpoint.Database + node: tosca.nodes.Database + relationship: tosca.relationships.ConnectsTo + interfaces: + Standard: + inputs: + wp_db_name: + type: string + wp_db_user: + type: string + wp_db_password: + type: string diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/README.txt b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/README.txt new file mode 100644 index 0000000..e882ff6 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/README.txt @@ -0,0 +1,22 @@ +README: + +This CSAR contains all definitions that are required for deploying WordPress +and MySQL on a single compute instance. + +Entry information for processing through an orchestrator is contained in file +TOSCA-Metadata/TOSCA.meta. This file provides high-level information such as +CSAR version or creator of the CSAR. Furthermore, it provides pointers to the +various TOSCA definitions files that contain the real details. +The entry 'Entry-Definitions' points to the definitions file which holds the +service template for the workload. +'Entry-Definitions' is optional. An orchestrator can also process the contents +like this: +1) Read in and process each definitions file. +2) For each definitions file: + 2.1) Read in all * type definitions (node types, capability types, etc.) and + store them in an internal map +3) Verify and build dependencies (e.g. inheritance) between all type definitions + previously read in. Orchestrator built-in types (e.g. TOSCA base types) are + also considered in this step. +4) Process the actual service template (the file with a node_templates section). + Validate using previously obtained type information. diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/configure.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/configure.sh new file mode 100644 index 0000000..d4ef6b4 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/configure.sh @@ -0,0 +1,5 @@ +#!/bin/sh +sed --regexp-extended "s/(port\s*=\s*)[0-9]*/\1$db_port/g" /tmp/my.cnf +mv -f /tmp/my.cnf /etc/mysql/my.cnf +/etc/init.d/mysql stop +/etc/init.d/mysql start \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/install.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/install.sh new file mode 100644 index 0000000..38628b9 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/install.sh @@ -0,0 +1,9 @@ +#!/bin/bash +#This script installs mysql server + +apt-get update + +debconf-set-selections <<< "mysql-server mysql-server/root_password password $db_root_password" +debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $db_root_password" + +apt-get -y install --fix-missing mysql-server \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/start.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/start.sh new file mode 100644 index 0000000..3378670 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/start.sh @@ -0,0 +1,2 @@ +#!/bin/sh +/etc/init.d/mysql start \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDatabase/configure.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDatabase/configure.sh new file mode 100644 index 0000000..092136a --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDatabase/configure.sh @@ -0,0 +1,8 @@ +#!/bin/sh +cat << EOF | mysql -u root --password=$db_root_password +CREATE DATABASE $db_name; +GRANT ALL PRIVILEGES ON $db_name.* TO "$db_user"@"localhost" +IDENTIFIED BY "$db_password"; +FLUSH PRIVILEGES; +EXIT +EOF \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WebServer/install.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WebServer/install.sh new file mode 100644 index 0000000..4ca9b4e --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WebServer/install.sh @@ -0,0 +1,5 @@ +#!/bin/sh +#This script installs apache web server + +apt-get update +apt-get install -y apache2 \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WebServer/start.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WebServer/start.sh new file mode 100644 index 0000000..e962ca5 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WebServer/start.sh @@ -0,0 +1,2 @@ +#!/bin/sh +service apache2 start \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WordPress/configure.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WordPress/configure.sh new file mode 100644 index 0000000..5598b4f --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WordPress/configure.sh @@ -0,0 +1,4 @@ +#!/bin/sh +ln -s /usr/share/wordpress /var/www/html/wordpress +gzip -d /usr/share/doc/wordpress/examples/setup-mysql.gz +echo $wp_db_password | bash /usr/share/doc/wordpress/examples/setup-mysql -e $wp_db_name -u $wp_db_user localhost \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WordPress/install.sh b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WordPress/install.sh new file mode 100644 index 0000000..1320443 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WordPress/install.sh @@ -0,0 +1,5 @@ +#!/bin/sh +#This script installs wordpress + +apt-get update +apt-get install -y wordpress \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/TOSCA-Metadata/TOSCA.meta b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 0000000..5208113 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/CSAR/tosca_single_instance_wordpress/TOSCA-Metadata/TOSCA.meta @@ -0,0 +1,5 @@ +TOSCA-Meta-File-Version: 1.0 +CSAR-Version: 1.1 +Created-By: OASIS TOSCA TC +Entry-Definitions: Definitions/tosca_single_instance_wordpress.yaml +Content-Type: application/vnd.oasis.tosca.definitions.yaml diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/collectd.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/collectd.yaml new file mode 100644 index 0000000..1ac0935 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/collectd.yaml @@ -0,0 +1,13 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + collectd is a daemon which gathers statistics about the system it is running on. + +node_types: + tosca.nodes.SoftwareComponent.Collectd: + derived_from: tosca.nodes.SoftwareComponent + requirements: + - log_endpoint: + capability: tosca.capabilities.Endpoint + node: tosca.nodes.SoftwareComponent.Logstash + relationship: tosca.relationships.ConnectsTo \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/elasticsearch.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/elasticsearch.yaml new file mode 100644 index 0000000..b140a32 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/elasticsearch.yaml @@ -0,0 +1,12 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + Elasticsearch is an open-source search engine built on top of Apache Lucene, + a full-text search-engine library. + +node_types: + tosca.nodes.SoftwareComponent.Elasticsearch: + derived_from: tosca.nodes.SoftwareComponent + capabilities: + search_endpoint: + type: tosca.capabilities.Endpoint diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/kibana.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/kibana.yaml new file mode 100644 index 0000000..5701e69 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/kibana.yaml @@ -0,0 +1,14 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + Kibana is an open source analytics and visualization platform designed to work with Elasticsearch. + You use Kibana to search, view, and interact with data stored in Elasticsearch. + +node_types: + tosca.nodes.SoftwareComponent.Kibana: + derived_from: tosca.nodes.SoftwareComponent + requirements: + - search_endpoint: + capability: tosca.capabilities.Endpoint + node: tosca.nodes.SoftwareComponent.Elasticsearch + relationship: tosca.relationships.ConnectsTo diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/logstash.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/logstash.yaml new file mode 100644 index 0000000..cf60521 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/logstash.yaml @@ -0,0 +1,25 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + Logstash is a tool for receiving, processing and outputting logs. All kinds + of logs. System logs, webserver logs, error logs, application logs, and just + about anything you can throw at it. + +node_types: + tosca.nodes.SoftwareComponent.Logstash: + derived_from: tosca.nodes.SoftwareComponent + requirements: + - search_endpoint: + capability: tosca.capabilities.Endpoint + node: tosca.nodes.SoftwareComponent.Elasticsearch + relationship: + type: tosca.relationships.ConnectsTo + interfaces: + Configure: + pre_configure_source: + inputs: + elasticsearch_ip: + type: string + capabilities: + log_endpoint: + type: tosca.capabilities.Endpoint diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/nested_rsyslog.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/nested_rsyslog.yaml new file mode 100644 index 0000000..622acab --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/nested_rsyslog.yaml @@ -0,0 +1,17 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + RSYSLOG is the Rocket-fast SYStem for LOG processing. + +imports: + - test_import: + file: custom_types/logstash.yaml + +node_types: + tosca.nodes.SoftwareComponent.Rsyslog: + derived_from: tosca.nodes.SoftwareComponent + requirements: + - log_endpoint: + capability: tosca.capabilities.Endpoint + node: tosca.nodes.SoftwareComponent.Logstash + relationship: tosca.relationships.ConnectsTo diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/nested_test_wordpress.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/nested_test_wordpress.yaml new file mode 100644 index 0000000..294bcc9 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/nested_test_wordpress.yaml @@ -0,0 +1,23 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 +imports: + - rsyslog: custom_types/nested_rsyslog.yaml +node_types: + tosca.nodes.SoftwareComponent.Rsyslog.TestRsyslogType: + derived_from: tosca.nodes.SoftwareComponent.Rsyslog + + tosca.nodes.WebApplication.WordPress: + derived_from: tosca.nodes.WebApplication + requirements: + - database_endpoint: + capability: tosca.capabilities.Endpoint.Database + node: tosca.nodes.Database + relationship: tosca.relationships.ConnectsTo + interfaces: + Standard: + inputs: + wp_db_name: + type: string + wp_db_user: + type: string + wp_db_password: + type: string diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/paypalpizzastore_nodejs_app.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/paypalpizzastore_nodejs_app.yaml new file mode 100644 index 0000000..d62c4c1 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/paypalpizzastore_nodejs_app.yaml @@ -0,0 +1,29 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + Pizza store app that allows you to explore the features provided by PayPal's REST APIs. + More detail can be found at https://github.com/paypal/rest-api-sample-app-nodejs/ + +node_types: + tosca.nodes.WebApplication.PayPalPizzaStore: + derived_from: tosca.nodes.WebApplication + properties: + github_url: + required: no + type: string + description: location of the application on the github. + default: https://github.com/sample.git + requirements: + #WebApplication inherits Computer, so host implied. + - database_connection: + capability: tosca.capabilities.Endpoint.Database + node: tosca.nodes.Database + relationship: tosca.relationships.ConnectsTo + interfaces: + Standard: + configure: + inputs: + github_url: + type: string + mongodb_ip: + type: string diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/rsyslog.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/rsyslog.yaml new file mode 100644 index 0000000..4614ee7 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/rsyslog.yaml @@ -0,0 +1,13 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + RSYSLOG is the Rocket-fast SYStem for LOG processing. + +node_types: + tosca.nodes.SoftwareComponent.Rsyslog: + derived_from: tosca.nodes.SoftwareComponent + requirements: + - log_endpoint: + capability: tosca.capabilities.Endpoint + node: tosca.nodes.SoftwareComponent.Logstash + relationship: tosca.relationships.ConnectsTo diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/wordpress.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/wordpress.yaml new file mode 100644 index 0000000..5899ed9 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/custom_types/wordpress.yaml @@ -0,0 +1,19 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +node_types: + tosca.nodes.WebApplication.WordPress: + derived_from: tosca.nodes.WebApplication + requirements: + - database_endpoint: + capability: tosca.capabilities.Endpoint.Database + node: tosca.nodes.Database + relationship: tosca.relationships.ConnectsTo + interfaces: + Standard: + inputs: + wp_db_name: + type: string + wp_db_user: + type: string + wp_db_password: + type: string diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/datatypes/custom_datatype_def.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/datatypes/custom_datatype_def.yaml new file mode 100644 index 0000000..4b7da71 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/datatypes/custom_datatype_def.yaml @@ -0,0 +1,48 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + Custom type and node definition used to test custom datatypes. + +node_types: + tosca.nodes.my.SomeNode: + derived_from: tosca.nodes.Root + properties: + people: + type: tosca.my.datatypes.People + +datatype_definitions: + tosca.my.datatypes.PeopleBase: + properties: + name: + type: string + required: true + constraints: + - min_length: 2 + gender: + type: string + default: unknown + + tosca.my.datatypes.People: + derived_from: tosca.my.datatypes.PeopleBase + properties: + addresses: + type: map + entry_schema: + type: string + contacts: + type: list + entry_schema: + type: tosca.my.datatypes.ContactInfo + + tosca.my.datatypes.ContactInfo: + description: simple contact information + properties: + contact_name: + type: string + required: true + constraints: + - min_length: 2 + contact_email: + type: string + contact_phone: + type: string diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/datatypes/test_custom_datatypes_in_current_template.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/datatypes/test_custom_datatypes_in_current_template.yaml new file mode 100644 index 0000000..aefe862 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/datatypes/test_custom_datatypes_in_current_template.yaml @@ -0,0 +1,65 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA templates used to test custom datatypes. + +node_types: + tosca.nodes.my.SomeNode: + derived_from: tosca.nodes.Root + properties: + people: + type: tosca.my.datatypes.People + +datatype_definitions: + tosca.my.datatypes.PeopleBase: + properties: + name: + type: string + required: true + constraints: + - min_length: 2 + gender: + type: string + default: unknown + + tosca.my.datatypes.People: + derived_from: tosca.my.datatypes.PeopleBase + properties: + addresses: + type: map + entry_schema: + type: string + contacts: + type: list + entry_schema: + type: tosca.my.datatypes.ContactInfo + + tosca.my.datatypes.ContactInfo: + description: simple contact information + properties: + contact_name: + type: string + required: true + constraints: + - min_length: 2 + contact_email: + type: string + contact_phone: + type: string + +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/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/datatypes/test_custom_datatypes_nested_datatype_error.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/datatypes/test_custom_datatypes_nested_datatype_error.yaml new file mode 100644 index 0000000..b28f499 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/datatypes/test_custom_datatypes_nested_datatype_error.yaml @@ -0,0 +1,25 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA templates used to test custom datatypes. + +imports: + - custom_datatype_def.yaml + +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/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/datatypes/test_custom_datatypes_positive.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/datatypes/test_custom_datatypes_positive.yaml new file mode 100644 index 0000000..f1762f4 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/datatypes/test_custom_datatypes_positive.yaml @@ -0,0 +1,24 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA templates used to test custom datatypes. + +imports: + - custom_datatype_def.yaml + +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/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/datatypes/test_custom_datatypes_value_error.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/datatypes/test_custom_datatypes_value_error.yaml new file mode 100644 index 0000000..31cf681 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/datatypes/test_custom_datatypes_value_error.yaml @@ -0,0 +1,18 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA templates used to test custom datatypes. + +imports: + - custom_datatype_def.yaml + +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/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_get_attribute_host_keyword.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_get_attribute_host_keyword.yaml new file mode 100644 index 0000000..90ffbe2 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_get_attribute_host_keyword.yaml @@ -0,0 +1,33 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA template for testing get_attribute with HOST keyword. + +topology_template: + node_templates: + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + num_cpus: 2 + dbms: + type: tosca.nodes.DBMS + requirements: + - host: server + interfaces: + Standard: + configure: + implementation: configure.sh + inputs: + ip_address: { get_attribute: [ HOST, private_address ] } + database: + type: tosca.nodes.Database + requirements: + - host: dbms + interfaces: + Standard: + configure: + implementation: configure.sh + inputs: + ip_address: { get_attribute: [ HOST, private_address ] } diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_get_attribute_host_not_found.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_get_attribute_host_not_found.yaml new file mode 100644 index 0000000..69679ff --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_get_attribute_host_not_found.yaml @@ -0,0 +1,20 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA template for testing get_attribute with HOST keyword. + +topology_template: + node_templates: + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + num_cpus: 2 + interfaces: + Standard: + configure: + implementation: configure.sh + inputs: + ip_address: { get_attribute: [ HOST, private_address ] } + diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_get_attribute_illegal_host_in_outputs.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_get_attribute_illegal_host_in_outputs.yaml new file mode 100644 index 0000000..6c7d9bb --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_get_attribute_illegal_host_in_outputs.yaml @@ -0,0 +1,17 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA template for testing get_attribute with HOST keyword. + +topology_template: + node_templates: + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + num_cpus: 2 + + outputs: + ip_address: + value: { get_attribute: [ HOST, private_address ] } diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_get_attribute_unknown_attribute_name.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_get_attribute_unknown_attribute_name.yaml new file mode 100644 index 0000000..0570c7c --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_get_attribute_unknown_attribute_name.yaml @@ -0,0 +1,28 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + Tosca template for testing unknown attribute name in get_attribute + function. + +topology_template: + inputs: + image_id: + type: string + + node_templates: + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + num_cpus: 2 + interfaces: + Standard: + configure: + implementation: start_server.sh + inputs: + image_id: { get_input: image_id } + + outputs: + ip_address: + value: { get_attribute: [ server, unknown_attribute ] } diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_get_attribute_unknown_node_template_name.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_get_attribute_unknown_node_template_name.yaml new file mode 100644 index 0000000..923305c --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_get_attribute_unknown_node_template_name.yaml @@ -0,0 +1,28 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + Tosca template for testing unknown node template name in get_attribute + function. + +topology_template: + inputs: + image_id: + type: string + + node_templates: + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + num_cpus: 2 + interfaces: + Standard: + configure: + implementation: start_server.sh + inputs: + image_id: { get_input: image_id } + + outputs: + ip_address: + value: { get_attribute: [ unknown_node_template, private_address ] } diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_invalid_function_signature.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_invalid_function_signature.yaml new file mode 100644 index 0000000..dde8427 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_invalid_function_signature.yaml @@ -0,0 +1,34 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile template to test invalid get_input function. + +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 + capabilities: + host: + properties: + # compute properties (flavor) + disk_size: 10 GB + num_cpus: { get_input: [cpus, cpus] } + mem_size: 4096 MB + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18.0 + + outputs: + server_address: + description: IP address of server instance. + value: { get_attribute: [server, private_address] } diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_unknown_capability_property.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_unknown_capability_property.yaml new file mode 100644 index 0000000..4a92530 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_unknown_capability_property.yaml @@ -0,0 +1,36 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + Tosca template for testing an unknown capability property. + +topology_template: + node_templates: + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + num_cpus: 2 + dbms: + type: tosca.nodes.DBMS + properties: + root_password: 1234 + port: 3672 + database: + type: tosca.nodes.Database + properties: + name: my_db + user: abcd + password: 1234 + capabilities: + database_endpoint: + properties: + port: { get_property: [ dbms, port ] } + requirements: + - host: dbms + interfaces: + Standard: + configure: + implementation: database_configure.sh + inputs: + db_port: { get_property: [ SELF, database_endpoint, unknown ] } diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_unknown_input_in_interface.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_unknown_input_in_interface.yaml new file mode 100644 index 0000000..cbfb391 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_unknown_input_in_interface.yaml @@ -0,0 +1,20 @@ + +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + Tosca template for testing an unknown input. + +topology_template: + node_templates: + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + num_cpus: 2 + interfaces: + Standard: + configure: + implementation: start_server.sh + inputs: + image_id: { get_input: image_id } diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_unknown_input_in_property.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_unknown_input_in_property.yaml new file mode 100644 index 0000000..9ba7ee5 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/functions/test_unknown_input_in_property.yaml @@ -0,0 +1,13 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + Tosca template for testing an unknown input. + +topology_template: + node_templates: + obj_store_server: + type: tosca.nodes.ObjectStorage + properties: + name: { get_input: objectstore_name } + size: 1024 MB + maxsize: 1 GB diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_instance_nested_imports.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_instance_nested_imports.yaml new file mode 100644 index 0000000..6b6542c --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_instance_nested_imports.yaml @@ -0,0 +1,22 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with wordpress, web server and mysql on the same server. + +imports: + - wordpress: custom_types/nested_test_wordpress.yaml + +topology_template: + + node_templates: + wordpress: + type: tosca.nodes.WebApplication.WordPress + + testrsyslogtype: + type: tosca.nodes.SoftwareComponent.Rsyslog.TestRsyslogType + + rsyslog: + type: tosca.nodes.SoftwareComponent.Rsyslog + + logstash: + type: tosca.nodes.SoftwareComponent.Logstash diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_invalid_section_names.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_invalid_section_names.yaml new file mode 100644 index 0000000..6241585 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_invalid_section_names.yaml @@ -0,0 +1,25 @@ +tosca_definitions_versions: tosca_simple_yaml_1_0 + +descriptions: > + TOSCA profile with invalid top-level section names. + +import: + - imported.yaml + +topology_templates: + + node_templates: + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: 1 + mem_size: 4096 MB + os: + properties: + architecture: x86_64 + type: Linux + distribution: Ubuntu + version: 14.04 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_invalid_template_version.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_invalid_template_version.yaml new file mode 100644 index 0000000..86dce79 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_invalid_template_version.yaml @@ -0,0 +1,14 @@ +tosca_definitions_version: tosca_xyz + +description: > + Test template with an invalid template version. + +topology_template: + node_templates: + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + num_cpus: 2 + diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_multiple_validation_errors.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_multiple_validation_errors.yaml new file mode 100644 index 0000000..ccae4eb --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_multiple_validation_errors.yaml @@ -0,0 +1,125 @@ +tosca_definitions_version: tosca_simple_yaml_1 + +description: > + TOSCA simple profile with wordpress, web server and mysql on the same server. + +imports: + - custom_types/not_there.yaml + +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + default: 1 + db_name: + type: string + description: The name of the database. + default: wordpress + db_user: + type: string + description: The user name of the DB user. + default: wp_user + db_pwd: + type: string + description: The WordPress database admin account password. + default: wp_pass + db_root_pwd: + type: string + description: Root password for MySQL. + db_port: + type: PortDef + description: Port for the MySQL database. + default: 3306 + + node_templates: + wordpress: + type: tosca.nodes.WebApplication.WordPress + requirement: + - host: webserver + - database_endpoint: mysql_database + interfaces: + Standard: + create: wordpress/wordpress_install.sh + configure: + implementation: wordpress/wordpress_configure.sh + inputs: + wp_db_name: { get_property: [ mysql_database, name ] } + wp_db_user: { get_property: [ mysql_database, user ] } + wp_db_password: { get_property: [ mysql_database, password ] } + + mysql_database: + type: tosca.nodes.Database + properties: + name: { get_input: db_name } + user: { get_input: db_user } + password: { get_input: db_pwd } + capabilities: + database_endpoint: + properties: + port: { get_input: db_port } + requirements: + - host: mysql_dbms + interfaces: + Standard: + configure: + implementation: mysql/mysql_database_configure.sh + inputs: + db_name: { get_property: [ SELF, name ] } + db_user: { get_property: [ SELF, user ] } + db_password: { get_property: [ SELF, passwords ] } + db_root_password: { get_property: [ mysql_dbms, root_password ] } + + mysql_dbms: + type1: tosca.nodes.DBMS + properties: + root_password: { get_input: db_root_pwd } + port: { get_input: db_port } + requirements: + - host: server + interfaces: + Standard: + create: + implementation: mysql/mysql_dbms_install.sh + inputs: + db_root_password: { get_property: [ mysql_dbms, root_password ] } + start: mysql/mysql_dbms_start.sh + configure: + implementation: mysql/mysql_dbms_configure.sh + inputs: + db_port: { get_property: [ mysql_dbms, port ] } + + webserver: + type: tosca.nodes.WebServer + requirements: + - host: server1 + - database_endpoint: + node: webserver + relationship: + type1: tosca.relationships.ConnectsTo + interfaces: + Standard: + create: webserver/webserver_install.sh + start: webserver/webserver_start.sh + + 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: Ubuntu + version: 14.04 + + outputs: + website_url: + description: URL for Wordpress wiki. + value: { get_attribute: [server, private_address] } diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_no_inputs_in_template.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_no_inputs_in_template.yaml new file mode 100644 index 0000000..0b9da4c --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_no_inputs_in_template.yaml @@ -0,0 +1,17 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + Tosca template for testing a template with no inputs. + +metadata: test + +topology_template: + node_templates: + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + num_cpus: 2 + + outputs: diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_no_outputs_in_template.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_no_outputs_in_template.yaml new file mode 100644 index 0000000..51d42ff --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_no_outputs_in_template.yaml @@ -0,0 +1,15 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + Tosca template for testing a template with no outputs. + +topology_template: + inputs: + + node_templates: + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + num_cpus: 2 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_requirements.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_requirements.yaml new file mode 100644 index 0000000..269c46d --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_requirements.yaml @@ -0,0 +1,67 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + Test Requirements. + +imports: + - custom_types/wordpress.yaml + +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: + node: my_dbms + relationship: tosca.relationships.HostedOn + 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 + capabilities: + host: + properties: + num_cpus: 2 + disk_size: 10 GB + mem_size: 4 MB + os: + properties: + # host Operating System image properties + architecture: x86_64 + type: linux + distribution: rhel + version: 6.5 + requirements: + - req1: + node: my_storage + relationship: storage_attachment + my_storage: + type: tosca.nodes.BlockStorage + properties: + size: 1 GiB + snapshot_id: id + + relationship_templates: + storage_attachment: + type: tosca.relationships.AttachesTo + properties: + location: /temp diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_tosca_normative_type_by_shortname.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_tosca_normative_type_by_shortname.yaml new file mode 100644 index 0000000..8a702fb --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_tosca_normative_type_by_shortname.yaml @@ -0,0 +1,33 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with short type name for Compute. + +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 + 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.0 + + outputs: + server_address: + description: IP address of server instance. + value: { get_attribute: [server, private_address] } diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_tosca_top_level_error1.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_tosca_top_level_error1.yaml new file mode 100644 index 0000000..591ee97 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_tosca_top_level_error1.yaml @@ -0,0 +1,31 @@ +description: > + TOSCA simple profile missing version section. + +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 + 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.0 + + outputs: + server_address: + description: IP address of server instance. + value: { get_property: [server, private_address] } diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_tosca_top_level_error2.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_tosca_top_level_error2.yaml new file mode 100644 index 0000000..683e623 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/test_tosca_top_level_error2.yaml @@ -0,0 +1,33 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with invalid top-level key: 'node_template'. + +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 + 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.0 + + outputs: + server_address: + description: IP address of server instance. + value: { get_property: [server, private_address] } diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/topology_template/definitions.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/topology_template/definitions.yaml new file mode 100644 index 0000000..083ee75 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/topology_template/definitions.yaml @@ -0,0 +1,54 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +node_types: + example.TransactionSubsystem: + properties: + mq_server_ip: + type: string + receiver_port: + type: integer + attributes: + receiver_ip: + type: string + receiver_port: + type: integer + capabilities: + message_receiver: + type: example.capabilities.Receiver + requirements: + - database_endpoint: + capability: tosca.capabilities.Endpoint.Database + node: tosca.nodes.Database + relationship: tosca.relationships.ConnectsTo + + example.QueuingSubsystem: + derived_from: tosca.nodes.SoftwareComponent + requirements: + - receiver1: + node: example.TransactionSubsystem + relationship: tosca.relationships.ConnectsTo + - receiver2: + node: example.TransactionSubsystem + relationship: tosca.relationships.ConnectsTo + + example.DatabaseSubsystem: + derived_from: tosca.nodes.Database + + example.SomeApp: + derived_from: tosca.nodes.SoftwareComponent + properties: + admin_user: + type: string + pool_size: + type: integer + capabilities: + message_receiver: + type: example.capabilities.Receiver + +capability_types: + example.capabilities.Receiver: + derived_from: tosca.capabilities.Endpoint + properties: + server_ip: + type: string + diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/topology_template/subsystem.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/topology_template/subsystem.yaml new file mode 100644 index 0000000..ddbc94e --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/topology_template/subsystem.yaml @@ -0,0 +1,85 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + Service template with topology_template, act as a nested system inside another system. + +imports: + - definitions.yaml + +topology_template: + description: Template of a database including its hosting stack. + + inputs: + mq_server_ip: + type: string + description: IP address of the message queuing server to receive messages from. + receiver_port: + type: string + description: Port to be used for receiving messages. + my_cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + + substitution_mappings: + node_type: example.TransactionSubsystem + capabilities: + message_receiver: [ app, message_receiver ] + requirements: + database_endpoint: [ app, database ] + + node_templates: + app: + type: example.SomeApp + properties: + admin_user: foo + pool_size: 10 + capabilities: + message_receiver: + properties: + server_ip: { get_input: mq_server_ip } + requirements: + - host: + node: websrv + + websrv: + type: tosca.nodes.WebServer + capabilities: + data_endpoint: + properties: + port_name: { get_input: receiver_port } + requirements: + - host: + node: server + + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: my_cpus } + mem_size: 4096 MB + os: + properties: + architecture: x86_64 + type: Linux + distribution: Ubuntu + version: 14.04 + + outputs: + receiver_ip: + description: private IP address of the message receiver application + value: { get_attribute: [ server, private_address ] } +# It seems current _process_intrisic_function can not handle more than 2 arguments, save it for later +# receiver_port: +# description: Port of the message receiver endpoint +# value: { get_attribute: [ app, data_endpoint, port_name ] } + + groups: + webserver_group: + members: [ websrv, server ] + policies: + - policy_name: none + diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/topology_template/system.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/topology_template/system.yaml new file mode 100644 index 0000000..99aee0d --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/topology_template/system.yaml @@ -0,0 +1,51 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +imports: + - definitions.yaml + +topology_template: + description: Template of online transaction processing service. + + node_templates: + mq: + type: example.QueuingSubsystem + # properties: + # to be updated when substitution_mapping is implemented + # capabilities: + # message_queue_endpoint: + # to be updated when substitution_mapping is implemented + requirements: + - receiver1: trans1 + - receiver2: trans2 + + trans1: + type: example.TransactionSubsystem + properties: + # to be updated when substitution_mapping is implemented + # mq_server_ip: { get_attribute: [ mq, server_ip ] } + receiver_port: 8080 + # capabilities: + # message_receiver: + # to be updated when substitution_mapping is implemented + requirements: + - database_endpoint: dbsys + + trans2: + type: example.TransactionSubsystem + properties: + # to be updated when substitution_mapping is implemented + # mq_server_ip: { get_attribute: [ mq, server_ip ] } + receiver_port: 8080 + # capabilities: + # message_receiver: + # to be updated when substitution_mapping is implemented + requirements: + - database_endpoint: dbsys + + dbsys: + type: example.DatabaseSubsystem + # properties: + # to be updated when substitution_mapping is implemented + # capabilities: + # database_endpoint: + # to be updated when substitution_mapping is implemented \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/tosca_elk.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/tosca_elk.yaml new file mode 100644 index 0000000..6fc1756 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/tosca_elk.yaml @@ -0,0 +1,217 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + This TOSCA simple profile deploys nodejs, mongodb, elasticsearch, logstash + and kibana each on a separate server with monitoring enabled for nodejs + server where a sample nodejs application is running. The rsyslog and collectd + are installed on a nodejs server. + +imports: + - custom_types/paypalpizzastore_nodejs_app.yaml + - custom_types/elasticsearch.yaml + - custom_types/logstash.yaml + - custom_types/kibana.yaml + - custom_types/collectd.yaml + - custom_types/rsyslog.yaml + +dsl_definitions: + host_capabilities: &host_capabilities + disk_size: 10 GB + num_cpus: { get_input: my_cpus } + mem_size: 4096 MB + os_capabilities: &os_capabilities + architecture: x86_64 + type: Linux + distribution: Ubuntu + version: 14.04 + +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: http://github.com/paypal/rest-api-sample-app-nodejs.git + + node_templates: + paypal_pizzastore: + type: tosca.nodes.WebApplication.PayPalPizzaStore + properties: + github_url: { get_input: github_url } + requirements: + - host: nodejs + - database_connection: mongo_db + interfaces: + Standard: + 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 + nodejs: + type: tosca.nodes.WebServer + requirements: + - host: app_server + interfaces: + Standard: + create: nodejs/create.sh + mongo_db: + type: tosca.nodes.Database + requirements: + - host: mongo_dbms + interfaces: + Standard: + create: mongodb/create_database.sh + mongo_dbms: + type: tosca.nodes.DBMS + requirements: + - host: mongo_server + interfaces: + Standard: + create: mongodb/create.sh + configure: + implementation: mongodb/config.sh + inputs: + mongodb_ip: { get_attribute: [mongo_server, private_address] } + start: mongodb/start.sh + elasticsearch: + type: tosca.nodes.SoftwareComponent.Elasticsearch + requirements: + - host: elasticsearch_server + interfaces: + Standard: + create: elasticsearch/create.sh + start: elasticsearch/start.sh + logstash: + type: tosca.nodes.SoftwareComponent.Logstash + requirements: + - host: logstash_server + - search_endpoint: + node: elasticsearch + capability: search_endpoint + relationship: + type: tosca.relationships.ConnectsTo + interfaces: + Configure: + pre_configure_source: + implementation: logstash/configure_elasticsearch.py + inputs: + elasticsearch_ip: { get_attribute: [elasticsearch_server, private_address] } + interfaces: + Standard: + create: logstash/create.sh + start: logstash/start.sh + kibana: + type: tosca.nodes.SoftwareComponent.Kibana + requirements: + - host: kibana_server + - search_endpoint: elasticsearch + interfaces: + Standard: + create: kibana/create.sh + configure: + implementation: kibana/config.sh + inputs: + elasticsearch_ip: { get_attribute: [elasticsearch_server, private_address] } + kibana_ip: { get_attribute: [kibana_server, private_address] } + start: kibana/start.sh + app_collectd: + type: tosca.nodes.SoftwareComponent.Collectd + requirements: + - host: app_server + - log_endpoint: + node: logstash + capability: log_endpoint + relationship: + type: tosca.relationships.ConnectsTo + interfaces: + Configure: + pre_configure_target: + implementation: logstash/configure_collectd.py + interfaces: + Standard: + create: collectd/create.sh + configure: + implementation: collectd/config.py + inputs: + logstash_ip: { get_attribute: [logstash_server, private_address] } + start: collectd/start.sh + app_rsyslog: + type: tosca.nodes.SoftwareComponent.Rsyslog + requirements: + - host: app_server + - log_endpoint: + node: logstash + capability: log_endpoint + relationship: + type: tosca.relationships.ConnectsTo + interfaces: + Configure: + pre_configure_target: + implementation: logstash/configure_rsyslog.py + interfaces: + Standard: + create: rsyslog/create.sh + configure: + implementation: rsyslog/config.sh + inputs: + logstash_ip: { get_attribute: [logstash_server, private_address] } + start: rsyslog/start.sh + app_server: + type: tosca.nodes.Compute + capabilities: + host: + properties: *host_capabilities + os: + properties: *os_capabilities + mongo_server: + type: tosca.nodes.Compute + capabilities: + host: + properties: *host_capabilities + os: + properties: *os_capabilities + elasticsearch_server: + type: tosca.nodes.Compute + capabilities: + host: + properties: *host_capabilities + os: + properties: *os_capabilities + logstash_server: + type: tosca.nodes.Compute + capabilities: + host: + properties: *host_capabilities + os: + properties: *os_capabilities + kibana_server: + type: tosca.nodes.Compute + capabilities: + host: + properties: *host_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 ] } + 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/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/tosca_helloworld.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/tosca_helloworld.yaml new file mode 100644 index 0000000..5b913ff --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/tosca_helloworld.yaml @@ -0,0 +1,23 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: Template for deploying a single server with predefined properties. + +topology_template: + node_templates: + my_server: + type: tosca.nodes.Compute + capabilities: + # Host container properties + host: + properties: + num_cpus: 2 + disk_size: 10 GB + mem_size: 512 MB + # Guest Operating System properties + os: + properties: + # host Operating System image properties + architecture: x86_64 + type: Linux + distribution: RHEL + version: 6.5 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/tosca_single_instance_wordpress.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/tosca_single_instance_wordpress.yaml new file mode 100644 index 0000000..9e686ab --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/tosca_single_instance_wordpress.yaml @@ -0,0 +1,121 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with wordpress, web server and mysql on the same server. + +imports: + - custom_types/wordpress.yaml + +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + default: 1 + db_name: + type: string + description: The name of the database. + default: wordpress + db_user: + type: string + description: The user name of the DB user. + default: wp_user + db_pwd: + type: string + description: The WordPress database admin account password. + default: wp_pass + db_root_pwd: + type: string + description: Root password for MySQL. + db_port: + type: PortDef + description: Port for the MySQL database. + default: 3306 + + node_templates: + wordpress: + type: tosca.nodes.WebApplication.WordPress + requirements: + - host: webserver + - database_endpoint: mysql_database + interfaces: + Standard: + create: wordpress/wordpress_install.sh + configure: + implementation: wordpress/wordpress_configure.sh + inputs: + wp_db_name: { get_property: [ mysql_database, name ] } + wp_db_user: { get_property: [ mysql_database, user ] } + wp_db_password: { get_property: [ mysql_database, password ] } + + mysql_database: + type: tosca.nodes.Database + properties: + name: { get_input: db_name } + user: { get_input: db_user } + password: { get_input: db_pwd } + capabilities: + database_endpoint: + properties: + port: { get_input: db_port } + requirements: + - host: mysql_dbms + interfaces: + Standard: + configure: + implementation: mysql/mysql_database_configure.sh + inputs: + db_name: { get_property: [ SELF, name ] } + db_user: { get_property: [ SELF, user ] } + db_password: { get_property: [ SELF, password ] } + db_root_password: { get_property: [ mysql_dbms, root_password ] } + + mysql_dbms: + type: tosca.nodes.DBMS + properties: + root_password: { get_input: db_root_pwd } + port: { get_input: db_port } + requirements: + - host: server + interfaces: + Standard: + create: + implementation: mysql/mysql_dbms_install.sh + inputs: + db_root_password: { get_property: [ mysql_dbms, root_password ] } + start: mysql/mysql_dbms_start.sh + configure: + implementation: mysql/mysql_dbms_configure.sh + inputs: + db_port: { get_property: [ mysql_dbms, port ] } + + webserver: + type: tosca.nodes.WebServer + requirements: + - host: server + interfaces: + Standard: + create: webserver/webserver_install.sh + start: webserver/webserver_start.sh + + 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: Ubuntu + version: 14.04 + + outputs: + website_url: + description: URL for Wordpress wiki. + value: { get_attribute: [server, private_address] } diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/tosca_single_instance_wordpress_with_local_abspath_import.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/tosca_single_instance_wordpress_with_local_abspath_import.yaml new file mode 100644 index 0000000..6caac11 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/tosca_single_instance_wordpress_with_local_abspath_import.yaml @@ -0,0 +1,122 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with wordpress, web server and mysql on the same server. + Parsing of this test template will fail with errors if provided imports does + not refer to a valid absolute path. + +imports: + - /tmp/tosca-parser/toscaparser/tests/data/custom_types/wordpress.yaml + +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + default: 1 + db_name: + type: string + description: The name of the database. + default: wordpress + db_user: + type: string + description: The user name of the DB user. + default: wp_user + db_pwd: + type: string + description: The WordPress database admin account password. + default: wp_pass + db_root_pwd: + type: string + description: Root password for MySQL. + db_port: + type: PortDef + description: Port for the MySQL database. + default: 3306 + + node_templates: + wordpress: + type: tosca.nodes.WebApplication.WordPress + requirements: + - host: webserver + - database_endpoint: mysql_database + interfaces: + Standard: + create: wordpress/wordpress_install.sh + configure: + implementation: wordpress/wordpress_configure.sh + inputs: + wp_db_name: wordpress + wp_db_user: wp_user + wp_db_password: wp_pass + + mysql_database: + type: tosca.nodes.Database + properties: + name: { get_input: db_name } + user: { get_input: db_user } + password: { get_input: db_pwd } + capabilities: + database_endpoint: + properties: + port: { get_input: db_port } + requirements: + - host: + node: mysql_dbms + interfaces: + Standard: + configure: + implementation: mysql/mysql_database_configure.sh + inputs: + db_name: wordpress + db_user: wp_user + db_password: wp_pass + db_root_password: passw0rd + mysql_dbms: + type: tosca.nodes.DBMS + properties: + root_password: { get_input: db_root_pwd } + port: { get_input: db_port } + requirements: + - host: server + interfaces: + Standard: + create: + implementation: mysql/mysql_dbms_install.sh + inputs: + db_root_password: passw0rd + start: mysql/mysql_dbms_start.sh + configure: + implementation: mysql/mysql_dbms_configure.sh + inputs: + db_port: 3366 + + webserver: + type: tosca.nodes.WebServer + requirements: + - host: server + interfaces: + Standard: + create: webserver/webserver_install.sh + start: webserver/webserver_start.sh + 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: Ubuntu + version: 14.04 + + outputs: + website_url: + description: URL for Wordpress wiki. + value: { get_attribute: [server, private_address] } diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/tosca_single_instance_wordpress_with_url_import.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/tosca_single_instance_wordpress_with_url_import.yaml new file mode 100644 index 0000000..e5f1580 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/data/tosca_single_instance_wordpress_with_url_import.yaml @@ -0,0 +1,120 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with wordpress, web server and mysql on the same server. + +imports: + - https://raw.githubusercontent.com/openstack/heat-translator/master/translator/tests/data/custom_types/wordpress.yaml + +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + default: 1 + db_name: + type: string + description: The name of the database. + default: wordpress + db_user: + type: string + description: The user name of the DB user. + default: wp_user + db_pwd: + type: string + description: The WordPress database admin account password. + default: wp_pass + db_root_pwd: + type: string + description: Root password for MySQL. + db_port: + type: PortDef + description: Port for the MySQL database. + default: 3306 + + node_templates: + wordpress: + type: tosca.nodes.WebApplication.WordPress + requirements: + - host: webserver + - database_endpoint: mysql_database + interfaces: + Standard: + create: wordpress/wordpress_install.sh + configure: + implementation: wordpress/wordpress_configure.sh + inputs: + wp_db_name: wordpress + wp_db_user: wp_user + wp_db_password: wp_pass + + mysql_database: + type: tosca.nodes.Database + properties: + name: { get_input: db_name } + user: { get_input: db_user } + password: { get_input: db_pwd } + capabilities: + database_endpoint: + properties: + port: { get_input: db_port } + requirements: + - host: + node: mysql_dbms + interfaces: + Standard: + configure: + implementation: mysql/mysql_database_configure.sh + inputs: + db_name: wordpress + db_user: wp_user + db_password: wp_pass + db_root_password: passw0rd + mysql_dbms: + type: tosca.nodes.DBMS + properties: + root_password: { get_input: db_root_pwd } + port: { get_input: db_port } + requirements: + - host: server + interfaces: + Standard: + create: + implementation: mysql/mysql_dbms_install.sh + inputs: + db_root_password: passw0rd + start: mysql/mysql_dbms_start.sh + configure: + implementation: mysql/mysql_dbms_configure.sh + inputs: + db_port: 3366 + + webserver: + type: tosca.nodes.WebServer + requirements: + - host: server + interfaces: + Standard: + create: webserver/webserver_install.sh + start: webserver/webserver_start.sh + 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: Ubuntu + version: 14.04 + + outputs: + website_url: + description: URL for Wordpress wiki. + value: { get_attribute: [server, private_address] } diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/network/tosca_one_server_one_network.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/network/tosca_one_server_one_network.yaml new file mode 100644 index 0000000..8e58fa9 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/network/tosca_one_server_one_network.yaml @@ -0,0 +1,43 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with 1 server bound to a new network + +topology_template: + + inputs: + network_name: + type: string + description: Network name + + node_templates: + my_server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: 1 + mem_size: 512 MB + 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 } + ip_version: 4 + cidr: '192.168.0.0/24' + 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/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/network/tosca_one_server_three_networks.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/network/tosca_one_server_three_networks.yaml new file mode 100644 index 0000000..d791b17 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/network/tosca_one_server_three_networks.yaml @@ -0,0 +1,64 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with 1 server bound to 3 networks + +topology_template: + + node_templates: + my_server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: 1 + mem_size: 512 MB + 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_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_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 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/network/tosca_server_on_existing_network.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/network/tosca_server_on_existing_network.yaml new file mode 100644 index 0000000..7fedc13 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/network/tosca_server_on_existing_network.yaml @@ -0,0 +1,39 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with 1 server bound to an existing network + +topology_template: + inputs: + network_name: + type: string + description: Network name + + node_templates: + my_server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: 1 + mem_size: 512 MB + 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: + node: my_server + - link: + node: my_network diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/network/tosca_two_servers_one_network.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/network/tosca_two_servers_one_network.yaml new file mode 100644 index 0000000..1473a8d --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/network/tosca_two_servers_one_network.yaml @@ -0,0 +1,79 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with 2 servers bound to the 1 network + +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 + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: 1 + mem_size: 512 MB + os: + properties: + architecture: x86_64 + type: Linux + distribution: CirrOS + version: 0.3.2 + + my_server2: + type: tosca.nodes.Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: 1 + mem_size: 512 MB + 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_port: + type: tosca.nodes.network.Port + requirements: + - binding: + node: my_server + - link: + node: my_network + + my_port2: + type: tosca.nodes.network.Port + requirements: + - binding: + node: my_server2 + - link: + node: my_network diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_attachment.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_attachment.yaml new file mode 100644 index 0000000..460fa4c --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_attachment.yaml @@ -0,0 +1,61 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with server and attached block storage using the normative AttachesTo Relationship Type. + +topology_template: + + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + storage_size: + type: scalar-unit.size + description: Size of the storage to be created. + default: 1 GB + storage_snapshot_id: + type: string + description: > + Optional identifier for an existing snapshot to use when creating storage. + storage_location: + type: string + description: Block storage mount point (filesystem path). + + node_templates: + my_server: + type: Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 kB + os: + properties: + architecture: x86_64 + type: linux + distribution: fedora + version: 18.0 + requirements: + - local_storage: + node: my_storage + relationship: + type: AttachesTo + properties: + location: { get_input: storage_location } + + my_storage: + type: BlockStorage + properties: + size: { get_input: storage_size } + snapshot_id: { get_input: storage_snapshot_id } + + outputs: + private_ip: + description: The 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/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_attachment_notation1.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_attachment_notation1.yaml new file mode 100644 index 0000000..df22d72 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_attachment_notation1.yaml @@ -0,0 +1,87 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with a Single Block Storage node shared by 2-Tier Application with custom AttachesTo Type and implied relationships. + +relationship_types: + MyAttachesTo: + derived_from: tosca.relationships.AttachesTo + properties: + location: + type: string + default: /default_location + +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + storage_size: + type: scalar-unit.size + default: 1 GB + description: Size of the storage to be created. + storage_snapshot_id: + type: string + description: > + Optional identifier for an existing snapshot to use when creating storage. + + node_templates: + my_web_app_tier_1: + 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.0 + requirements: + - local_storage: + node: my_storage + relationship: MyAttachesTo + + my_web_app_tier_2: + 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.0 + requirements: + - local_storage: + node: my_storage + relationship: + type: MyAttachesTo + 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 } + + outputs: + private_ip_1: + description: The private IP address of the application's first tier. + value: { get_attribute: [my_web_app_tier_1, private_address] } + private_ip_2: + description: The private IP address of the application's second tier. + value: { get_attribute: [my_web_app_tier_2, private_address] } + volume_id: + description: The volume id of the block storage instance. + value: { get_attribute: [my_storage, volume_id] } diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_attachment_notation2.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_attachment_notation2.yaml new file mode 100644 index 0000000..cb1c17a --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_attachment_notation2.yaml @@ -0,0 +1,99 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with a single Block Storage node shared by 2-Tier Application with custom AttachesTo Type and explicit Relationship Templates. + +relationship_types: + MyAttachesTo: + derived_from: tosca.relationships.AttachesTo + properties: + location: + type: string + default: /default_location + +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + storage_size: + type: scalar-unit.size + default: 1 GB + description: Size of the storage to be created. + storage_snapshot_id: + type: string + description: > + Optional identifier for an existing snapshot to use when creating storage. + storage_location: + type: string + description: > + Block storage mount point (filesystem path). + + node_templates: + + my_web_app_tier_1: + type: tosca.nodes.Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 kB + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18.0 + requirements: + - local_storage: + node: my_storage + relationship: storage_attachesto_1 + + my_web_app_tier_2: + type: tosca.nodes.Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4096 kB + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18.0 + requirements: + - local_storage: + node: my_storage + relationship: storage_attachesto_2 + + 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: MyAttachesTo + properties: + location: /my_data_location + + storage_attachesto_2: + type: MyAttachesTo + properties: + location: /some_other_data_location + outputs: + private_ip_1: + description: The private IP address of the application's first tier. + value: { get_attribute: [my_web_app_tier_1, private_address] } + private_ip_2: + description: The private IP address of the application's second tier. + value: { get_attribute: [my_web_app_tier_2, private_address] } + volume_id: + description: The volume id of the block storage instance. + value: { get_attribute: [my_storage, volume_id] } diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_custom_relationship_type.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_custom_relationship_type.yaml new file mode 100644 index 0000000..932f89e --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_custom_relationship_type.yaml @@ -0,0 +1,64 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with server and attached block storage using a custom AttachesTo Relationship Type. + +relationship_types: + MyCustomAttachesTo: + derived_from: AttachesTo + +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + storage_size: + type: scalar-unit.size + description: Size of the storage to be created. + default: 1 GB + storage_snapshot_id: + type: string + description: > + Optional identifier for an existing snapshot to use when creating storage. + storage_location: + type: string + description: Block storage mount point (filesystem path). + + node_templates: + my_server: + type: Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4 MB + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18.0 + requirements: + - local_storage: + node: my_storage + # Declare custom AttachesTo type using the 'relationship' keyword + relationship: + type: MyCustomAttachesTo + properties: + location: { get_input: storage_location } + my_storage: + type: BlockStorage + properties: + size: { get_input: storage_size } + snapshot_id: { get_input: storage_snapshot_id } + + outputs: + private_ip: + description: The 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/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_relationship_template.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_relationship_template.yaml new file mode 100644 index 0000000..c31a4da --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_blockstorage_with_relationship_template.yaml @@ -0,0 +1,59 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with server and attached block storage using a named Relationship Template for the storage attachment. + +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + storage_size: + type: scalar-unit.size + description: Size of the storage to be created. + default: 1 GB + storage_location: + type: string + description: Block storage mount point (filesystem path). + + node_templates: + my_server: + type: Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4 MB + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18.0 + requirements: + - local_storage: + node: my_storage + # Declare template to use with 'relationship' keyword + relationship: storage_attachment + + my_storage: + type: BlockStorage + properties: + size: { get_input: storage_size } + + relationship_templates: + storage_attachment: + type: AttachesTo + properties: + location: { get_input: storage_location } + + outputs: + private_ip: + description: The 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/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_multiple_blockstorage_with_attachment.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_multiple_blockstorage_with_attachment.yaml new file mode 100644 index 0000000..aa4647e --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_multiple_blockstorage_with_attachment.yaml @@ -0,0 +1,93 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with 2 servers each with different attached block storage. + +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + storage_size: + type: scalar-unit.size + default: 1 GB + description: Size of the storage to be created. + storage_snapshot_id: + type: string + description: > + Optional identifier for an existing snapshot to use when creating storage. + storage_location: + type: string + description: > + Block storage mount point (filesystem path). + + node_templates: + my_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.0 + requirements: + - local_storage: + node: my_storage + relationship: + 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 + 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.0 + requirements: + - local_storage: + node: my_storage2 + relationship: + 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: + server_ip_1: + description: The private IP address of the application's first server. + value: { get_attribute: [my_server, private_address] } + server_ip_2: + description: The private IP address of the application's second server. + value: { get_attribute: [my_server2, private_address] } + volume_id_1: + description: The volume id of the first block storage instance. + value: { get_attribute: [my_storage, volume_id] } + volume_id_2: + description: The volume id of the second block storage instance. + value: { get_attribute: [my_storage2, volume_id] } diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_single_object_store.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_single_object_store.yaml new file mode 100644 index 0000000..869af48 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/storage/tosca_single_object_store.yaml @@ -0,0 +1,17 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + Tosca template for creating an object storage service. + +topology_template: + inputs: + objectstore_name: + type: string + + node_templates: + obj_store_server: + type: tosca.nodes.ObjectStorage + properties: + name: { get_input: objectstore_name } + size: 1024 kB + maxsize: 1 GB diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/tosca_nodejs_mongodb_two_instances.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/tosca_nodejs_mongodb_two_instances.yaml new file mode 100644 index 0000000..f611071 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/tosca_nodejs_mongodb_two_instances.yaml @@ -0,0 +1,96 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with nodejs and mongodb. + +imports: + - custom_types/paypalpizzastore_nodejs_app.yaml + +dsl_definitions: + 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: + 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: http://github.com/paypal/rest-api-sample-app-nodejs.git + + node_templates: + paypal_pizzastore: + type: tosca.nodes.WebApplication.PayPalPizzaStore + properties: + github_url: { get_input: github_url } + requirements: + - host: nodejs + - database_connection: mongo_db + interfaces: + Standard: + configure: + implementation: nodejs/config.sh + inputs: + github_url: http://github.com/paypal/rest-api-sample-app-nodejs.git + mongodb_ip: { get_attribute: [mongo_server, private_address] } + start: nodejs/start.sh + nodejs: + type: tosca.nodes.WebServer + requirements: + - host: app_server + interfaces: + Standard: + create: nodejs/create.sh + mongo_db: + type: tosca.nodes.Database + requirements: + - host: mongo_dbms + interfaces: + Standard: + create: mongodb/create_database.sh + mongo_dbms: + type: tosca.nodes.DBMS + requirements: + - host: mongo_server + interfaces: + 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 + capabilities: + host: + properties: *host_capabilities + os: + properties: *os_capabilities + app_server: + type: tosca.nodes.Compute + capabilities: + host: + properties: *host_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/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/tosca_single_server.yaml b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/tosca_single_server.yaml new file mode 100644 index 0000000..c4cce9d --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/spec_samples/v1.0/tosca_single_server.yaml @@ -0,0 +1,32 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile that just defines a single compute instance and selects a (guest) host Operating System from the Compute node's properties. Note, this example does not include default values on inputs properties. + +topology_template: + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + + node_templates: + my_server: + type: Compute + capabilities: + host: + properties: + disk_size: 10 GB + num_cpus: { get_input: cpus } + mem_size: 4 MB + os: + properties: + architecture: x86_64 + type: Linux + distribution: ubuntu + version: 12.04 + outputs: + private_ip: + description: The private IP address of the deployed server instance. + value: { get_attribute: [my_server, private_address] } \ No newline at end of file diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_constraints.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_constraints.py new file mode 100644 index 0000000..78f4c71 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_constraints.py @@ -0,0 +1,357 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import datetime +import yaml + +from toscaparser.common import exception +from toscaparser.elements.constraints import Constraint +from toscaparser.elements.constraints import Schema +from toscaparser.tests.base import TestCase +from toscaparser.utils.gettextutils import _ +from toscaparser.utils import yamlparser + + +class ConstraintTest(TestCase): + + def test_schema_dict(self): + tpl_snippet = ''' + cpus: + type: integer + description: Number of CPUs for the server. + ''' + schema = yamlparser.simple_parse(tpl_snippet) + cpus_schema = Schema('cpus', schema['cpus']) + self.assertEqual(len(cpus_schema), 2) + self.assertEqual('integer', cpus_schema.type) + self.assertEqual('Number of CPUs for the server.', + cpus_schema.description) + self.assertEqual(True, cpus_schema.required) + self.assertIsNone(cpus_schema.default) + + def test_schema_not_dict(self): + tpl_snippet = ''' + cpus: + - type: integer + - description: Number of CPUs for the server. + ''' + schema = yamlparser.simple_parse(tpl_snippet) + error = self.assertRaises(exception.InvalidSchemaError, Schema, + 'cpus', schema['cpus']) + self.assertEqual(_('Schema definition of "cpus" must be a dict.'), + str(error)) + + def test_schema_miss_type(self): + tpl_snippet = ''' + cpus: + description: Number of CPUs for the server. + ''' + schema = yamlparser.simple_parse(tpl_snippet) + error = self.assertRaises(exception.InvalidSchemaError, Schema, + 'cpus', schema['cpus']) + self.assertEqual(_('Schema definition of "cpus" must have a "type" ' + 'attribute.'), str(error)) + + def test_schema_none_description(self): + tpl_snippet = ''' + cpus: + type: integer + ''' + schema = yamlparser.simple_parse(tpl_snippet) + cpus_schema = Schema('cpus', schema['cpus']) + self.assertEqual('', cpus_schema.description) + + def test_invalid_constraint_type(self): + schema = {'invalid_type': 2} + error = self.assertRaises(exception.InvalidSchemaError, Constraint, + 'prop', Schema.INTEGER, + schema) + self.assertEqual(_('Invalid property "invalid_type".'), + str(error)) + + def test_invalid_prop_type(self): + schema = {'length': 5} + error = self.assertRaises(exception.InvalidSchemaError, Constraint, + 'prop', Schema.INTEGER, + schema) + self.assertEqual(_('Property "length" is not valid for data type ' + '"integer".'), str(error)) + + def test_invalid_validvalues(self): + schema = {'valid_values': 2} + error = self.assertRaises(exception.InvalidSchemaError, Constraint, + 'prop', Schema.INTEGER, + schema) + self.assertEqual(_('The property "valid_values" expects a list.'), + str(error)) + + def test_validvalues_validate(self): + schema = {'valid_values': [2, 4, 6, 8]} + constraint = Constraint('prop', Schema.INTEGER, schema) + self.assertIsNone(constraint.validate(4)) + + def test_validvalues_validate_fail(self): + schema = {'valid_values': [2, 4, 6, 8]} + constraint = Constraint('prop', Schema.INTEGER, schema) + error = self.assertRaises(exception.ValidationError, + constraint.validate, 5) + self.assertEqual(_('The value "5" of property "prop" is not valid. ' + 'Expected a value from "[2, 4, 6, 8]".'), + str(error)) + + def test_invalid_in_range(self): + snippet = 'in_range: {2, 6}' + schema = yaml.load(snippet) + error = self.assertRaises(exception.InvalidSchemaError, Constraint, + 'prop', Schema.INTEGER, + schema) + self.assertEqual(_('The property "in_range" expects a list.'), + str(error)) + + def test_in_range_min_max(self): + schema = {'in_range': [2, 6]} + constraint = Constraint('prop', Schema.INTEGER, schema) + self.assertEqual(2, constraint.min) + self.assertEqual(6, constraint.max) + + def test_in_range_validate(self): + schema = {'in_range': [2, 6]} + constraint = Constraint('prop', Schema.INTEGER, schema) + self.assertIsNone(constraint.validate(2)) + self.assertIsNone(constraint.validate(4)) + self.assertIsNone(constraint.validate(6)) + + def test_in_range_validate_fail(self): + schema = {'in_range': [2, 6]} + constraint = Constraint('prop', Schema.INTEGER, schema) + error = self.assertRaises(exception.ValidationError, + constraint.validate, 8) + self.assertEqual(_('The value "8" of property "prop" is out of range ' + '"(min:2, max:6)".'), str(error)) + + def test_equal_validate(self): + schema = {'equal': 4} + constraint = Constraint('prop', Schema.INTEGER, schema) + self.assertIsNone(constraint.validate(4)) + + def test_equal_validate_fail(self): + schema = {'equal': 4} + constraint = Constraint('prop', Schema.INTEGER, schema) + error = self.assertRaises(exception.ValidationError, + constraint.validate, 8) + self.assertEqual('The value "8" of property "prop" is not equal to ' + '"4".', str(error)) + + def test_greater_than_validate(self): + schema = {'greater_than': 4} + constraint = Constraint('prop', Schema.INTEGER, schema) + self.assertIsNone(constraint.validate(6)) + + def test_greater_than_validate_fail(self): + schema = {'greater_than': 4} + constraint = Constraint('prop', Schema.INTEGER, schema) + error = self.assertRaises(exception.ValidationError, + constraint.validate, 3) + self.assertEqual(_('The value "3" of property "prop" must be greater ' + 'than "4".'), str(error)) + + error = self.assertRaises(exception.ValidationError, + constraint.validate, 4) + self.assertEqual(_('The value "4" of property "prop" must be greater ' + 'than "4".'), str(error)) + + def test_greater_than_invalid(self): + snippet = 'greater_than: {4}' + schema = yaml.load(snippet) + error = self.assertRaises(exception.InvalidSchemaError, Constraint, + 'prop', Schema.INTEGER, + schema) + self.assertEqual(_('The property "greater_than" expects comparable ' + 'values.'), str(error)) + + def test_greater_or_equal_validate(self): + schema = {'greater_or_equal': 3.9} + constraint = Constraint('prop', Schema.FLOAT, schema) + self.assertIsNone(constraint.validate(3.9)) + self.assertIsNone(constraint.validate(4.0)) + + def test_greater_or_equal_validate_fail(self): + schema = {'greater_or_equal': 3.9} + constraint = Constraint('prop', Schema.FLOAT, schema) + error = self.assertRaises(exception.ValidationError, + constraint.validate, 3.0) + self.assertEqual(_('The value "3.0" of property "prop" must be ' + 'greater than or equal to "3.9".'), + str(error)) + + error = self.assertRaises(exception.ValidationError, + constraint.validate, 3.8) + self.assertEqual(_('The value "3.8" of property "prop" must be ' + 'greater than or equal to "3.9".'), + str(error)) + + def test_greater_or_equal_invalid(self): + snippet = 'greater_or_equal: {3.9}' + schema = yaml.load(snippet) + error = self.assertRaises(exception.InvalidSchemaError, Constraint, + 'prop', Schema.INTEGER, + schema) + self.assertEqual(_('The property "greater_or_equal" expects ' + 'comparable values.'), str(error)) + + def test_less_than_validate(self): + schema = {'less_than': datetime.date(2014, 0o7, 25)} + constraint = Constraint('prop', Schema.TIMESTAMP, schema) + self.assertIsNone(constraint.validate(datetime.date(2014, 0o7, 20))) + self.assertIsNone(constraint.validate(datetime.date(2014, 0o7, 24))) + + def test_less_than_validate_fail(self): + schema = {'less_than': datetime.date(2014, 0o7, 25)} + constraint = Constraint('prop', Schema.TIMESTAMP, schema) + error = self.assertRaises(exception.ValidationError, + constraint.validate, + datetime.date(2014, 0o7, 25)) + self.assertEqual(_('The value "2014-07-25" of property "prop" must be ' + 'less than "2014-07-25".'), + str(error)) + + error = self.assertRaises(exception.ValidationError, + constraint.validate, + datetime.date(2014, 0o7, 27)) + self.assertEqual(_('The value "2014-07-27" of property "prop" must be ' + 'less than "2014-07-25".'), + str(error)) + + def test_less_than_invalid(self): + snippet = 'less_than: {3.9}' + schema = yaml.load(snippet) + error = self.assertRaises(exception.InvalidSchemaError, Constraint, + 'prop', Schema.INTEGER, + schema) + self.assertEqual(_('The property "less_than" expects comparable ' + 'values.'), str(error)) + + def test_less_or_equal_validate(self): + schema = {'less_or_equal': 4} + constraint = Constraint('prop', Schema.INTEGER, schema) + self.assertIsNone(constraint.validate(4)) + self.assertIsNone(constraint.validate(3)) + + def test_less_or_equal_validate_fail(self): + schema = {'less_or_equal': 4} + constraint = Constraint('prop', Schema.INTEGER, schema) + error = self.assertRaises(exception.ValidationError, + constraint.validate, 5) + self.assertEqual(_('The value "5" of property "prop" must be less ' + 'than or equal to "4".'), str(error)) + + def test_less_or_equal_invalid(self): + snippet = 'less_or_equal: {3.9}' + schema = yaml.load(snippet) + error = self.assertRaises(exception.InvalidSchemaError, Constraint, + 'prop', Schema.INTEGER, + schema) + self.assertEqual(_('The property "less_or_equal" expects comparable ' + 'values.'), str(error)) + + def test_invalid_length(self): + schema = {'length': 'four'} + error = self.assertRaises(exception.InvalidSchemaError, Constraint, + 'prop', Schema.STRING, + schema) + self.assertEqual(_('The property "length" expects an integer.'), + str(error)) + + schema = {'length': 4.5} + error = self.assertRaises(exception.InvalidSchemaError, Constraint, + 'prop', Schema.STRING, + schema) + self.assertEqual(_('The property "length" expects an integer.'), + str(error)) + + def test_length_validate(self): + schema = {'length': 4} + constraint = Constraint('prop', Schema.STRING, schema) + self.assertIsNone(constraint.validate('abcd')) + + def test_length_validate_fail(self): + schema = {'length': 4} + constraint = Constraint('prop', Schema.STRING, schema) + error = self.assertRaises(exception.ValidationError, + constraint.validate, 'abc') + self.assertEqual(_('Length of value "abc" of property "prop" must ' + 'be equal to "4".'), str(error)) + + error = self.assertRaises(exception.ValidationError, + constraint.validate, + 'abcde') + self.assertEqual(_('Length of value "abcde" of property "prop" must ' + 'be equal to "4".'), str(error)) + + def test_invalid_min_length(self): + schema = {'min_length': 'four'} + error = self.assertRaises(exception.InvalidSchemaError, Constraint, + 'prop', Schema.STRING, + schema) + self.assertEqual(_('The property "min_length" expects an integer.'), + str(error)) + + def test_min_length_validate(self): + schema = {'min_length': 4} + constraint = Constraint('prop', Schema.STRING, schema) + self.assertIsNone(constraint.validate('abcd')) + self.assertIsNone(constraint.validate('abcde')) + + def test_min_length_validate_fail(self): + schema = {'min_length': 4} + constraint = Constraint('prop', Schema.STRING, schema) + error = self.assertRaises(exception.ValidationError, + constraint.validate, 'abc') + self.assertEqual(_('Length of value "abc" of property "prop" must ' + 'be at least "4".'), str(error)) + + def test_invalid_max_length(self): + schema = {'max_length': 'four'} + error = self.assertRaises(exception.InvalidSchemaError, Constraint, + 'prop', Schema.STRING, + schema) + self.assertEqual(_('The property "max_length" expects an integer.'), + str(error)) + + def test_max_length_validate(self): + schema = {'max_length': 4} + constraint = Constraint('prop', Schema.STRING, schema) + self.assertIsNone(constraint.validate('abcd')) + self.assertIsNone(constraint.validate('abc')) + + def test_max_length_validate_fail(self): + schema = {'max_length': 4} + constraint = Constraint('prop', Schema.STRING, schema) + error = self.assertRaises(exception.ValidationError, + constraint.validate, + 'abcde') + self.assertEqual(_('Length of value "abcde" of property "prop" ' + 'must be no greater than "4".'), + str(error)) + + def test_pattern_validate(self): + schema = {'pattern': '[0-9]*'} + constraint = Constraint('prop', Schema.STRING, schema) + self.assertIsNone(constraint.validate('123')) + + def test_pattern_validate_fail(self): + schema = {'pattern': '[0-9]*'} + constraint = Constraint('prop', Schema.STRING, schema) + error = self.assertRaises(exception.ValidationError, + constraint.validate, 'abc') + self.assertEqual(_('The value "abc" of property "prop" does not ' + 'match pattern "[0-9]*".'), str(error)) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_datatypes.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_datatypes.py new file mode 100644 index 0000000..c1a6de0 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_datatypes.py @@ -0,0 +1,327 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import os + +from testtools.testcase import skip +from toscaparser.common import exception +from toscaparser.dataentity import DataEntity +from toscaparser.elements.datatype import DataType +from toscaparser.parameters import Input +from toscaparser.tests.base import TestCase +from toscaparser.tosca_template import ToscaTemplate +from toscaparser.utils.gettextutils import _ +from toscaparser.utils import yamlparser + + +class DataTypeTest(TestCase): + + custom_type_schema = ''' + tosca.my.datatypes.PeopleBase: + properties: + name: + type: string + required: true + constraints: + - min_length: 2 + gender: + type: string + default: unknown + + tosca.my.datatypes.People: + derived_from: tosca.my.datatypes.PeopleBase + properties: + addresses: + type: map + entry_schema: + type: string + contacts: + type: list + entry_schema: + type: tosca.my.datatypes.ContactInfo + + tosca.my.datatypes.ContactInfo: + description: simple contact information + properties: + contact_name: + type: string + required: true + constraints: + - min_length: 2 + contact_email: + type: string + contact_phone: + type: string + ''' + custom_type_def = yamlparser.simple_parse(custom_type_schema) + + def test_empty_template(self): + value_snippet = '' + value = yamlparser.simple_parse(value_snippet) + self.assertEqual(value, {}) + + def test_built_in_datatype(self): + value_snippet = ''' + private_network: + network_name: private + network_id: 3e54214f-5c09-1bc9-9999-44100326da1b + addresses: [ 10.111.128.10 ] + ''' + value = yamlparser.simple_parse(value_snippet) + data = DataEntity('tosca.datatypes.network.NetworkInfo', + value.get('private_network')) + self.assertIsNotNone(data.validate()) + + value_snippet = ''' + portspec_valid: + protocol: tcp + ''' + value = yamlparser.simple_parse(value_snippet) + data = DataEntity('tosca.datatypes.network.PortSpec', + value.get('portspec_valid')) + self.assertIsNotNone(data.validate()) + + value_snippet = ''' + portspec_invalid: + protocol: xyz + ''' + value = yamlparser.simple_parse(value_snippet) + data = DataEntity('tosca.datatypes.network.PortSpec', + value.get('portspec_invalid')) + err = self.assertRaises(exception.ValidationError, data.validate) + self.assertEqual(_('The value "xyz" of property "protocol" is not ' + 'valid. Expected a value from "[udp, tcp, igmp]".' + ), + err.__str__()) + + def test_built_in_datatype_with_short_name(self): + value_snippet = ''' + ethernet_port: + port_name: port1 + port_id: 2c0c7a37-691a-23a6-7709-2d10ad041467 + network_id: 3e54214f-5c09-1bc9-9999-44100326da1b + mac_address: f1:18:3b:41:92:1e + addresses: [ 172.24.9.102 ] + ''' + value = yamlparser.simple_parse(value_snippet) + data = DataEntity('PortInfo', value.get('ethernet_port')) + self.assertIsNotNone(data.validate()) + + def test_built_in_datatype_without_properties(self): + value_snippet = ''' + 2 + ''' + value = yamlparser.simple_parse(value_snippet) + datatype = DataType('PortDef') + self.assertEqual('integer', datatype.value_type) + data = DataEntity('PortDef', value) + self.assertIsNotNone(data.validate()) + + @skip('The example in TOSCA spec may have some problem.') + def test_built_in_nested_datatype(self): + value_snippet = ''' + user_port: + protocol: tcp + target: [50000] + source: [9000] + ''' + value = yamlparser.simple_parse(value_snippet) + data = DataEntity('PortSpec', value.get('user_port')) + self.assertIsNotNone(data.validate()) + + def test_built_in_nested_datatype_portdef(self): + tpl_snippet = ''' + inputs: + db_port: + type: PortDef + description: Port for the MySQL database + ''' + inputs = yamlparser.simple_parse(tpl_snippet)['inputs'] + name, attrs = list(inputs.items())[0] + input = Input(name, attrs) + self.assertIsNone(input.validate(3360)) + err = self.assertRaises(exception.ValidationError, input.validate, + 336000) + self.assertEqual(_('The value "336000" of property "None" is out of ' + 'range "(min:1, max:65535)".'), + err.__str__()) + + def test_custom_datatype(self): + value_snippet = ''' + name: Mike + gender: male + ''' + value = yamlparser.simple_parse(value_snippet) + data = DataEntity('tosca.my.datatypes.PeopleBase', value, + DataTypeTest.custom_type_def) + self.assertIsNotNone(data.validate()) + + def test_custom_datatype_with_parent(self): + value_snippet = ''' + name: Mike + gender: male + contacts: + - {contact_name: Tom, + contact_email: tom@email.com, + contact_phone: '123456789'} + - {contact_name: Jerry, + contact_email: jerry@email.com, + contact_phone: '321654987'} + ''' + value = yamlparser.simple_parse(value_snippet) + data = DataEntity('tosca.my.datatypes.People', value, + DataTypeTest.custom_type_def) + self.assertIsNotNone(data.validate()) + + # [Tom, Jerry] is not a dict, it can't be a value of datatype PeopleBase + def test_non_dict_value_for_datatype(self): + value_snippet = ''' + [Tom, Jerry] + ''' + value = yamlparser.simple_parse(value_snippet) + data = DataEntity('tosca.my.datatypes.PeopleBase', value, + DataTypeTest.custom_type_def) + error = self.assertRaises(exception.TypeMismatchError, data.validate) + self.assertEqual(_('[\'Tom\', \'Jerry\'] must be of type ' + '"tosca.my.datatypes.PeopleBase".'), + error.__str__()) + + # 'nema' is an invalid field name + def test_field_error_in_dataentity(self): + value_snippet = ''' + nema: Mike + gender: male + ''' + value = yamlparser.simple_parse(value_snippet) + data = DataEntity('tosca.my.datatypes.PeopleBase', value, + DataTypeTest.custom_type_def) + error = self.assertRaises(exception.UnknownFieldError, data.validate) + self.assertEqual(_('Data value of type ' + '"tosca.my.datatypes.PeopleBase" contains unknown ' + 'field "nema". Refer to the definition to verify ' + 'valid values.'), + error.__str__()) + + def test_default_field_in_dataentity(self): + value_snippet = ''' + name: Mike + ''' + value = yamlparser.simple_parse(value_snippet) + data = DataEntity('tosca.my.datatypes.PeopleBase', value, + DataTypeTest.custom_type_def) + data = data.validate() + self.assertEqual('unknown', data.get('gender')) + + # required field 'name' is missing + def test_missing_field_in_dataentity(self): + value_snippet = ''' + gender: male + ''' + value = yamlparser.simple_parse(value_snippet) + data = DataEntity('tosca.my.datatypes.PeopleBase', value, + DataTypeTest.custom_type_def) + error = self.assertRaises(exception.MissingRequiredFieldError, + data.validate) + self.assertEqual(_('Data value of type ' + '"tosca.my.datatypes.PeopleBase" is missing ' + 'required field "[\'name\']".'), + error.__str__()) + + # the value of name field is not a string + def test_type_error_in_dataentity(self): + value_snippet = ''' + name: 123 + gender: male + ''' + value = yamlparser.simple_parse(value_snippet) + data = DataEntity('tosca.my.datatypes.PeopleBase', value, + DataTypeTest.custom_type_def) + error = self.assertRaises(ValueError, data.validate) + self.assertEqual(_('"123" is not a string.'), error.__str__()) + + # the value of name doesn't meet the defined constraint + def test_value_error_in_dataentity(self): + value_snippet = ''' + name: M + gender: male + ''' + value = yamlparser.simple_parse(value_snippet) + data = DataEntity('tosca.my.datatypes.PeopleBase', value, + DataTypeTest.custom_type_def) + error = self.assertRaises(exception.ValidationError, data.validate) + self.assertEqual(_('Length of value "M" of property "name" must be ' + 'at least "2".'), error.__str__()) + + # value of addresses doesn't fit the entry_schema + def test_validation_in_collection_entry(self): + value_snippet = ''' + name: Mike + gender: male + addresses: {Home: 1, Office: 9 bar avenue} + ''' + value = yamlparser.simple_parse(value_snippet) + data = DataEntity('tosca.my.datatypes.People', value, + DataTypeTest.custom_type_def) + error = self.assertRaises(ValueError, data.validate) + self.assertEqual(_('"1" is not a string.'), error.__str__()) + + # contact_pone is an invalid field name in nested datatype + def test_validation_in_nested_datatype(self): + value_snippet = ''' + name: Mike + gender: male + contacts: + - {contact_name: Tom, + contact_email: tom@email.com, + contact_pone: '123456789'} + - {contact_name: Jerry, + contact_email: jerry@email.com, + contact_phone: '321654987'} + ''' + value = yamlparser.simple_parse(value_snippet) + data = DataEntity('tosca.my.datatypes.People', value, + DataTypeTest.custom_type_def) + error = self.assertRaises(exception.UnknownFieldError, data.validate) + self.assertEqual(_('Data value of type ' + '"tosca.my.datatypes.ContactInfo" contains unknown ' + 'field "contact_pone". Refer to the definition to ' + 'verify valid values.'), + error.__str__()) + + def test_datatype_in_current_template(self): + tpl_path = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/datatypes/test_custom_datatypes_in_current_template.yaml") + self.assertIsNotNone(ToscaTemplate(tpl_path)) + + def test_datatype_in_template_positive(self): + tpl_path = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/datatypes/test_custom_datatypes_positive.yaml") + self.assertIsNotNone(ToscaTemplate(tpl_path)) + + def test_datatype_in_template_invalid_value(self): + tpl_path = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/datatypes/test_custom_datatypes_value_error.yaml") + self.assertRaises(exception.ValidationError, ToscaTemplate, tpl_path) + exception.ExceptionCollector.assertExceptionMessage( + ValueError, + _('"[\'1 foo street\', \'9 bar avenue\']" is not a map.')) + + def test_datatype_in_template_nested_datatype_error(self): + tpl_path = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/datatypes/test_custom_datatypes_nested_datatype_error.yaml") + self.assertRaises(exception.ValidationError, ToscaTemplate, tpl_path) + exception.ExceptionCollector.assertExceptionMessage( + ValueError, _('"123456789" is not a string.')) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_exception.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_exception.py new file mode 100644 index 0000000..a404f4f --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_exception.py @@ -0,0 +1,42 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from toscaparser.common import exception +from toscaparser.tests.base import TestCase +from toscaparser.utils.gettextutils import _ + + +class ExceptionTest(TestCase): + + def setUp(self): + super(TestCase, self).setUp() + exception.TOSCAException.set_fatal_format_exception(False) + + def test_message(self): + ex = exception.MissingRequiredFieldError(what='Template', + required='type') + self.assertEqual(_('Template is missing required field "type".'), + ex.__str__()) + + def test_set_flag(self): + exception.TOSCAException.set_fatal_format_exception('True') + self.assertFalse( + exception.TOSCAException._FATAL_EXCEPTION_FORMAT_ERRORS) + + def test_format_error(self): + ex = exception.UnknownFieldError(what='Template') + self.assertEqual(_('An unknown exception occurred.'), ex.__str__(),) + self.assertRaises(KeyError, self._formate_exception) + + def _formate_exception(self): + exception.UnknownFieldError.set_fatal_format_exception(True) + raise exception.UnknownFieldError(what='Template') diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_functions.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_functions.py new file mode 100644 index 0000000..ccc6f8b --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_functions.py @@ -0,0 +1,204 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import os +import six +from toscaparser.common import exception +from toscaparser import functions +from toscaparser.tests.base import TestCase +from toscaparser.tosca_template import ToscaTemplate +from toscaparser.utils.gettextutils import _ + + +class IntrinsicFunctionsTest(TestCase): + + tosca_tpl = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/tosca_single_instance_wordpress.yaml") + params = {'db_name': 'my_wordpress', 'db_user': 'my_db_user'} + tosca = ToscaTemplate(tosca_tpl, parsed_params=params) + + def _get_node(self, node_name): + return [ + node for node in self.tosca.nodetemplates + if node.name == node_name][0] + + def _get_operation(self, interfaces, operation): + return [ + interface for interface in interfaces + if interface.name == operation][0] + + def _get_property(self, node_template, property_name): + return [prop.value for prop in node_template.get_properties_objects() + if prop.name == property_name][0] + + def _get_inputs_dict(self): + inputs = {} + for input in self.tosca.inputs: + inputs[input.name] = input.default + return inputs + + def _get_input(self, name): + self._get_inputs_dict()[name] + + def test_get_property(self): + wordpress = self._get_node('wordpress') + operation = self._get_operation(wordpress.interfaces, 'configure') + wp_db_password = operation.inputs['wp_db_password'] + self.assertTrue(isinstance(wp_db_password, functions.GetProperty)) + result = wp_db_password.result() + self.assertEqual('wp_pass', result) + + def test_get_property_with_input_param(self): + wordpress = self._get_node('wordpress') + operation = self._get_operation(wordpress.interfaces, 'configure') + wp_db_user = operation.inputs['wp_db_user'] + self.assertTrue(isinstance(wp_db_user, functions.GetProperty)) + result = wp_db_user.result() + self.assertEqual('my_db_user', result) + + def test_unknown_capability_property(self): + self.assertRaises(exception.ValidationError, self._load_template, + 'functions/test_unknown_capability_property.yaml') + exception.ExceptionCollector.assertExceptionMessage( + KeyError, + _('\'Property "unknown" was not found in capability ' + '"database_endpoint" of node template "database" referenced ' + 'from node template "database".\'')) + + def test_get_input_in_properties(self): + mysql_dbms = self._get_node('mysql_dbms') + expected_inputs = ['db_root_pwd', 'db_port'] + props = mysql_dbms.get_properties() + for key in props.keys(): + prop = props[key] + self.assertTrue(isinstance(prop.value, functions.GetInput)) + expected_inputs.remove(prop.value.input_name) + self.assertListEqual(expected_inputs, []) + + def test_get_input_validation(self): + self.assertRaises( + exception.ValidationError, self._load_template, + 'functions/test_unknown_input_in_property.yaml') + exception.ExceptionCollector.assertExceptionMessage( + exception.UnknownInputError, + _('Unknown input "objectstore_name".')) + + self.assertRaises( + exception.ValidationError, self._load_template, + 'functions/test_unknown_input_in_interface.yaml') + exception.ExceptionCollector.assertExceptionMessage( + exception.UnknownInputError, + _('Unknown input "image_id".')) + + self.assertRaises( + exception.ValidationError, self._load_template, + 'functions/test_invalid_function_signature.yaml') + exception.ExceptionCollector.assertExceptionMessage( + ValueError, + _('Expected one argument for function "get_input" but received ' + '"[\'cpus\', \'cpus\']".')) + + def test_get_input_default_value_result(self): + mysql_dbms = self._get_node('mysql_dbms') + dbms_port = self._get_property(mysql_dbms, 'port') + self.assertEqual(3306, dbms_port.result()) + dbms_root_password = self._get_property(mysql_dbms, + 'root_password') + self.assertIsNone(dbms_root_password.result()) + + +class GetAttributeTest(TestCase): + + def _load_template(self, filename): + return ToscaTemplate(os.path.join( + os.path.dirname(os.path.abspath(__file__)), + 'data', + filename)) + + def test_get_attribute_in_outputs(self): + tpl = self._load_template('tosca_single_instance_wordpress.yaml') + website_url_output = [ + x for x in tpl.outputs if x.name == 'website_url'][0] + self.assertIsInstance(website_url_output.value, functions.GetAttribute) + self.assertEqual('server', website_url_output.value.node_template_name) + self.assertEqual('private_address', + website_url_output.value.attribute_name) + + def test_get_attribute_invalid_args(self): + expected_msg = _('Expected arguments: "node-template-name", ' + '"attribute-name"') + err = self.assertRaises(ValueError, + functions.get_function, None, None, + {'get_attribute': []}) + self.assertIn(expected_msg, six.text_type(err)) + err = self.assertRaises(ValueError, + functions.get_function, None, None, + {'get_attribute': ['x']}) + self.assertIn(expected_msg, six.text_type(err)) + err = self.assertRaises(ValueError, + functions.get_function, None, None, + {'get_attribute': ['x', 'y', 'z']}) + self.assertIn(expected_msg, six.text_type(err)) + + def test_get_attribute_unknown_node_template_name(self): + self.assertRaises( + exception.ValidationError, self._load_template, + 'functions/test_get_attribute_unknown_node_template_name.yaml') + exception.ExceptionCollector.assertExceptionMessage( + KeyError, + _('\'Node template "unknown_node_template" was not found.\'')) + + def test_get_attribute_unknown_attribute(self): + self.assertRaises( + exception.ValidationError, self._load_template, + 'functions/test_get_attribute_unknown_attribute_name.yaml') + exception.ExceptionCollector.assertExceptionMessage( + KeyError, + _('\'Attribute "unknown_attribute" was not found in node template ' + '"server".\'')) + + def test_get_attribute_host_keyword(self): + tpl = self._load_template( + 'functions/test_get_attribute_host_keyword.yaml') + + def assert_get_attribute_host_functionality(node_template_name): + node = [x for x in tpl.nodetemplates + if x.name == node_template_name][0] + configure_op = [ + x for x in node.interfaces if x.name == 'configure'][0] + ip_addr_input = configure_op.inputs['ip_address'] + self.assertIsInstance(ip_addr_input, functions.GetAttribute) + self.assertEqual('server', + ip_addr_input.get_referenced_node_template().name) + + assert_get_attribute_host_functionality('dbms') + assert_get_attribute_host_functionality('database') + + def test_get_attribute_host_not_found(self): + self.assertRaises( + exception.ValidationError, self._load_template, + 'functions/test_get_attribute_host_not_found.yaml') + exception.ExceptionCollector.assertExceptionMessage( + ValueError, + _('"get_attribute: [ HOST, ... ]" was used in node template ' + '"server" but "tosca.relationships.HostedOn" was not found in ' + 'the relationship chain.')) + + def test_get_attribute_illegal_host_in_outputs(self): + self.assertRaises( + exception.ValidationError, self._load_template, + 'functions/test_get_attribute_illegal_host_in_outputs.yaml') + exception.ExceptionCollector.assertExceptionMessage( + ValueError, + _('"get_attribute: [ HOST, ... ]" is not allowed in "outputs" ' + 'section of the TOSCA template.')) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_prereq.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_prereq.py new file mode 100644 index 0000000..98d616f --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_prereq.py @@ -0,0 +1,230 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import os +import shutil +import zipfile + +from toscaparser.common.exception import URLException +from toscaparser.common.exception import ValidationError +from toscaparser.prereq.csar import CSAR +from toscaparser.tests.base import TestCase +import toscaparser.utils +from toscaparser.utils.gettextutils import _ + + +class CSARPrereqTest(TestCase): + + base_path = os.path.dirname(os.path.abspath(__file__)) + + def test_file_exists(self): + path = os.path.join(self.base_path, "data/CSAR/csar_not_there.zip") + csar = CSAR(path) + error = self.assertRaises(ValidationError, csar.validate) + self.assertEqual(_('"%s" does not exist.') % path, str(error)) + self.assertTrue(csar.temp_dir is None or + not os.path.exists(csar.temp_dir)) + + def test_file_is_zip(self): + path = os.path.join(self.base_path, "data/CSAR/csar_not_zip.zip") + csar = CSAR(path) + error = self.assertRaises(ValidationError, csar.validate) + self.assertEqual(_('"%s" is not a valid zip file.') % path, str(error)) + + def test_url_is_zip(self): + path = "https://github.com/openstack/tosca-parser/raw/master/" \ + "toscaparser/tests/data/CSAR/csar_not_zip.zip" + csar = CSAR(path, False) + error = self.assertRaises(ValidationError, csar.validate) + self.assertEqual(_('"%s" is not a valid zip file.') % path, str(error)) + self.assertTrue(csar.temp_dir is None or + not os.path.exists(csar.temp_dir)) + + def test_metadata_file_exists(self): + path = os.path.join(self.base_path, + "data/CSAR/csar_no_metadata_file.zip") + csar = CSAR(path) + error = self.assertRaises(ValidationError, csar.validate) + self.assertEqual(_('"%s" is not a valid CSAR as it does not contain ' + 'the required file "TOSCA.meta" in the folder ' + '"TOSCA-Metadata".') % path, str(error)) + self.assertTrue(csar.temp_dir is None or + not os.path.exists(csar.temp_dir)) + + def test_valid_metadata_file_exists(self): + path = os.path.join(self.base_path, + "data/CSAR/csar_wrong_metadata_file.zip") + csar = CSAR(path) + error = self.assertRaises(ValidationError, csar.validate) + self.assertEqual(_('"%s" is not a valid CSAR as it does not contain ' + 'the required file "TOSCA.meta" in the folder ' + '"TOSCA-Metadata".') % path, str(error)) + self.assertTrue(csar.temp_dir is None or + not os.path.exists(csar.temp_dir)) + + def test_metadata_is_yaml(self): + path = os.path.join(self.base_path, + "data/CSAR/csar_metadata_not_yaml.zip") + csar = CSAR(path) + error = self.assertRaises(ValidationError, csar.validate) + self.assertEqual(_('The file "TOSCA-Metadata/TOSCA.meta" in the CSAR ' + '"%s" does not contain valid YAML content.') % path, + str(error)) + self.assertTrue(csar.temp_dir is None or + not os.path.exists(csar.temp_dir)) + + def test_metadata_exists(self): + path = os.path.join(self.base_path, + "data/CSAR/csar_missing_metadata.zip") + csar = CSAR(path) + error = self.assertRaises(ValidationError, csar.validate) + self.assertEqual(_('The CSAR "%s" is missing the required metadata ' + '"Entry-Definitions" in ' + '"TOSCA-Metadata/TOSCA.meta".') % path, str(error)) + self.assertTrue(csar.temp_dir is None or + not os.path.exists(csar.temp_dir)) + + def test_entry_def_exists(self): + path = os.path.join(self.base_path, + "data/CSAR/csar_invalid_entry_def.zip") + csar = CSAR(path) + error = self.assertRaises(ValidationError, csar.validate) + self.assertEqual(_('The "Entry-Definitions" file defined in the CSAR ' + '"%s" does not exist.') % path, str(error)) + self.assertTrue(csar.temp_dir is None or + not os.path.exists(csar.temp_dir)) + + def test_csar_invalid_import_path(self): + path = os.path.join(self.base_path, + "data/CSAR/csar_wordpress_invalid_import_path.zip") + csar = CSAR(path) + error = self.assertRaises(ImportError, csar.validate) + self.assertEqual(_('Import "Definitions/wordpress.yaml" is not ' + 'valid.'), str(error)) + self.assertTrue(csar.temp_dir is None or + not os.path.exists(csar.temp_dir)) + + def test_csar_invalid_import_url(self): + path = os.path.join(self.base_path, + "data/CSAR/csar_wordpress_invalid_import_url.zip") + csar = CSAR(path) + error = self.assertRaises(URLException, csar.validate) + self.assertEqual(_('Failed to reach server ' + '"https://raw.githubusercontent.com/openstack/' + 'tosca-parser/master/toscaparser/tests/data/CSAR/' + 'tosca_single_instance_wordpress/Definitions/' + 'wordpress1.yaml". Reason is: Not Found.'), + str(error)) + self.assertTrue(csar.temp_dir is None or + not os.path.exists(csar.temp_dir)) + + def test_csar_invalid_script_path(self): + path = os.path.join(self.base_path, + "data/CSAR/csar_wordpress_invalid_script_path.zip") + csar = CSAR(path) + error = self.assertRaises(ValueError, csar.validate) + self.assertTrue( + str(error) == _('The resource "Scripts/WordPress/install.sh" does ' + 'not exist.') or + str(error) == _('The resource "Scripts/WordPress/configure.sh" ' + 'does not exist.')) + self.assertTrue(csar.temp_dir is None or + not os.path.exists(csar.temp_dir)) + + def test_csar_invalid_script_url(self): + path = os.path.join(self.base_path, + "data/CSAR/csar_wordpress_invalid_script_url.zip") + csar = CSAR(path) + error = self.assertRaises(URLException, csar.validate) + self.assertEqual(_('The resource at ' + '"https://raw.githubusercontent.com/openstack/' + 'tosca-parser/master/toscaparser/tests/data/CSAR/' + 'tosca_single_instance_wordpress/Scripts/WordPress/' + 'install1.sh" cannot be accessed.'), + str(error)) + self.assertTrue(csar.temp_dir is None or + not os.path.exists(csar.temp_dir)) + + def test_valid_csar(self): + path = os.path.join(self.base_path, "data/CSAR/csar_hello_world.zip") + csar = CSAR(path) + self.assertTrue(csar.validate()) + self.assertTrue(csar.temp_dir is None or + not os.path.exists(csar.temp_dir)) + + def test_valid_csar_with_url_import_and_script(self): + path = os.path.join(self.base_path, "data/CSAR/csar_wordpress_with_url" + "_import_and_script.zip") + csar = CSAR(path) + self.assertTrue(csar.validate()) + self.assertTrue(csar.temp_dir is None or + not os.path.exists(csar.temp_dir)) + + def test_metadata_invalid_csar(self): + path = os.path.join(self.base_path, + "data/CSAR/csar_metadata_not_yaml.zip") + csar = CSAR(path) + error = self.assertRaises(ValidationError, csar.get_author) + self.assertEqual(_('The file "TOSCA-Metadata/TOSCA.meta" in the CSAR ' + '"%s" does not contain valid YAML content.') % path, + str(error)) + self.assertTrue(csar.temp_dir is None or + not os.path.exists(csar.temp_dir)) + + def test_metadata_valid_csar(self): + path = os.path.join(self.base_path, "data/CSAR/csar_hello_world.zip") + csar = CSAR(path) + expected_meta = {'TOSCA-Meta-File-Version': 1.0, + 'CSAR-Version': 1.1, + 'Created-By': 'OASIS TOSCA TC', + 'Entry-Definitions': 'tosca_helloworld.yaml'} + self.assertEqual(expected_meta, csar.get_metadata(), + 'The extracted metadata of the CSAR %(csar)s does ' + 'not match the expected metadata %(meta)s' + % {'csar': path, 'meta': expected_meta.__str__()}) + self.assertEqual(1.1, csar.get_version()) + self.assertEqual('OASIS TOSCA TC', csar.get_author()) + self.assertEqual('tosca_helloworld.yaml', csar.get_main_template()) + self.assertEqual('Template for deploying a single server with ' + 'predefined properties.', csar.get_description()) + self.assertTrue(csar.temp_dir is None or + not os.path.exists(csar.temp_dir)) + + def test_csar_main_template(self): + path = os.path.join(self.base_path, "data/CSAR/csar_hello_world.zip") + csar = CSAR(path) + yaml_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), + "data/tosca_helloworld.yaml") + expected_yaml = toscaparser.utils.yamlparser.load_yaml(yaml_file) + self.assertEqual(expected_yaml, csar.get_main_template_yaml()) + self.assertTrue(csar.temp_dir is None or + not os.path.exists(csar.temp_dir)) + + def test_decompress(self): + path = os.path.join(self.base_path, "data/CSAR/csar_hello_world.zip") + csar = CSAR(path) + csar.decompress() + zf = zipfile.ZipFile(path) + for name in zf.namelist(): + tmp_path = os.path.join(csar.temp_dir, name) + self.assertTrue(os.path.isdir(tmp_path) or + os.path.isfile(tmp_path)) + shutil.rmtree(csar.temp_dir) + self.assertTrue(csar.temp_dir is None or + not os.path.exists(csar.temp_dir)) + + def test_alternate_csar_extension(self): + path = os.path.join(self.base_path, "data/CSAR/csar_elk.csar") + csar = CSAR(path) + self.assertTrue(csar.validate()) + self.assertTrue(csar.temp_dir is None or + not os.path.exists(csar.temp_dir)) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_properties.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_properties.py new file mode 100644 index 0000000..1896b1e --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_properties.py @@ -0,0 +1,236 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from toscaparser.common import exception +from toscaparser.elements.property_definition import PropertyDef +from toscaparser.properties import Property +from toscaparser.tests.base import TestCase +from toscaparser.utils.gettextutils import _ +from toscaparser.utils import yamlparser + + +class PropertyTest(TestCase): + + def test_type(self): + test_property_schema = {'type': 'string'} + propertyInstance = Property('test_property', 'Hughes', + test_property_schema) + self.assertEqual('string', propertyInstance.type) + + def test_type_invalid(self): + test_property_schema = {'type': 'Fish'} + propertyInstance = Property('test_property', 'Hughes', + test_property_schema) + error = self.assertRaises(exception.InvalidTypeError, + propertyInstance.validate) + self.assertEqual(_('Type "Fish" is not a valid type.'), str(error)) + + def test_list(self): + test_property_schema = {'type': 'list'} + propertyInstance = Property('test_property', ['a', 'b'], + test_property_schema) + self.assertIsNone(propertyInstance.validate()) + self.assertEqual(['a', 'b'], propertyInstance.value) + + def test_list_invalid(self): + test_property_schema = {'type': 'list'} + propertyInstance = Property('test_property', 'a', + test_property_schema) + error = self.assertRaises(ValueError, propertyInstance.validate) + self.assertEqual(_('"a" is not a list.'), str(error)) + + def test_list_entry_schema(self): + test_property_schema = {'type': 'list', + 'entry_schema': {'type': 'string'}} + propertyInstance = Property('test_property', ['a', 'b'], + test_property_schema) + self.assertIsNone(propertyInstance.validate()) + self.assertEqual(['a', 'b'], propertyInstance.value) + + schema_snippet = ''' + type: list + entry_schema: + type: string + constraints: + - min_length: 2 + ''' + test_property_schema = yamlparser.simple_parse(schema_snippet) + propertyInstance = Property('test_property', ['ab', 'cd'], + test_property_schema) + self.assertIsNone(propertyInstance.validate()) + self.assertEqual(['ab', 'cd'], propertyInstance.value) + + def test_list_entry_schema_invalid(self): + test_property_schema = {'type': 'list', + 'entry_schema': {'type': 'integer'}} + propertyInstance = Property('test_property', [1, 'b'], + test_property_schema) + error = self.assertRaises(ValueError, propertyInstance.validate) + self.assertEqual(_('"b" is not an integer.'), str(error)) + + def test_map(self): + test_property_schema = {'type': 'map'} + propertyInstance = Property('test_property', {'a': 'b'}, + test_property_schema) + self.assertIsNone(propertyInstance.validate()) + self.assertEqual({'a': 'b'}, propertyInstance.value) + + def test_map_invalid(self): + test_property_schema = {'type': 'map'} + propertyInstance = Property('test_property', 12, + test_property_schema) + error = self.assertRaises(ValueError, propertyInstance.validate) + self.assertEqual(_('"12" is not a map.'), str(error)) + + def test_map_entry_schema(self): + test_property_schema = {'type': 'map', + 'entry_schema': {'type': 'boolean'}} + propertyInstance = Property('test_property', + {'valid': True, 'required': True}, + test_property_schema) + self.assertIsNone(propertyInstance.validate()) + self.assertEqual({'valid': True, 'required': True}, + propertyInstance.value) + + def test_map_entry_schema_invalid(self): + test_property_schema = {'type': 'map', + 'entry_schema': {'type': 'boolean'}} + propertyInstance = Property('test_property', + {'valid': True, 'contact_name': 123}, + test_property_schema) + error = self.assertRaises(ValueError, propertyInstance.validate) + self.assertEqual(_('"123" is not a boolean.'), str(error)) + + def test_boolean(self): + test_property_schema = {'type': 'boolean'} + propertyInstance = Property('test_property', 'true', + test_property_schema) + self.assertIsNone(propertyInstance.validate()) + propertyInstance = Property('test_property', True, + test_property_schema) + self.assertIsNone(propertyInstance.validate()) + self.assertEqual(True, propertyInstance.value) + + def test_boolean_invalid(self): + test_property_schema = {'type': 'boolean'} + propertyInstance = Property('test_property', 12, + test_property_schema) + error = self.assertRaises(ValueError, propertyInstance.validate) + self.assertEqual(_('"12" is not a boolean.'), str(error)) + + def test_float(self): + test_property_schema = {'type': 'float'} + propertyInstance = Property('test_property', 0.1, + test_property_schema) + self.assertIsNone(propertyInstance.validate()) + self.assertEqual(0.1, propertyInstance.value) + + def test_float_invalid(self): + test_property_schema = {'type': 'float'} + propertyInstance = Property('test_property', 12, + test_property_schema) + error = self.assertRaises(ValueError, propertyInstance.validate) + self.assertEqual(_('"12" is not a float.'), str(error)) + + def test_timestamp(self): + test_property_schema = {'type': 'timestamp'} + # canonical timestamp + propertyInstance = Property('test_property', '2015-04-01T02:59:43.1Z', + test_property_schema) + self.assertIsNone(propertyInstance.validate()) + self.assertEqual("2015-04-01T02:59:43.1Z", propertyInstance.value) + + # iso8601 timestamp + propertyInstance = Property('test_property', + '2015-04-01t21:59:43.10-05:00', + test_property_schema) + self.assertIsNone(propertyInstance.validate()) + self.assertEqual("2015-04-01t21:59:43.10-05:00", + propertyInstance.value) + + # space separated timestamp + propertyInstance = Property('test_property', + '2015-04-01 21:59:43.10 -5', + test_property_schema) + self.assertIsNone(propertyInstance.validate()) + self.assertEqual("2015-04-01 21:59:43.10 -5", propertyInstance.value) + + # no time zone timestamp + propertyInstance = Property('test_property', '2015-04-01 21:59:43.10', + test_property_schema) + self.assertIsNone(propertyInstance.validate()) + self.assertEqual("2015-04-01 21:59:43.10", propertyInstance.value) + + # date (00:00:00Z) + propertyInstance = Property('test_property', '2015-04-01', + test_property_schema) + self.assertIsNone(propertyInstance.validate()) + self.assertEqual("2015-04-01", propertyInstance.value) + + def test_timestamp_invalid(self): + test_property_schema = {'type': 'timestamp'} + # invalid timestamp - day out of range + propertyInstance = Property('test_property', '2015-04-115T02:59:43.1Z', + test_property_schema) + error = self.assertRaises(ValueError, propertyInstance.validate) + self.assertEqual(_('day is out of range for month'), str(error)) + + def test_required(self): + test_property_schema = {'type': 'string'} + propertyInstance = Property('test_property', 'Foo', + test_property_schema) + self.assertEqual(True, propertyInstance.required) + + def test_proprety_inheritance(self): + from toscaparser.nodetemplate import NodeTemplate + + tosca_custom_def = ''' + tosca.nodes.SoftwareComponent.MySoftware: + derived_from: SoftwareComponent + properties: + install_path: + required: false + type: string + default: /opt/mysoftware + ''' + + tosca_node_template = ''' + node_templates: + mysoftware_instance: + type: tosca.nodes.SoftwareComponent.MySoftware + properties: + component_version: 3.1 + ''' + + expected_properties = ['component_version', + 'install_path'] + + nodetemplates = yamlparser.\ + simple_parse(tosca_node_template)['node_templates'] + custom_def = yamlparser.simple_parse(tosca_custom_def) + name = list(nodetemplates.keys())[0] + tpl = NodeTemplate(name, nodetemplates, custom_def) + self.assertIsNone(tpl.validate()) + self.assertEqual(expected_properties, + sorted(tpl.get_properties().keys())) + + def test_missing_property_type(self): + tpl_snippet = ''' + properties: + prop: + typo: tosca.mytesttype.Test + ''' + schema = yamlparser.simple_parse(tpl_snippet) + error = self.assertRaises(exception.InvalidSchemaError, PropertyDef, + 'prop', None, schema['properties']['prop']) + self.assertEqual(_('Schema definition of "prop" must have a "type" ' + 'attribute.'), str(error)) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_scalarunit.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_scalarunit.py new file mode 100644 index 0000000..24864a1 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_scalarunit.py @@ -0,0 +1,355 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from toscaparser.common import exception +from toscaparser.elements.scalarunit import ScalarUnit_Frequency +from toscaparser.elements.scalarunit import ScalarUnit_Size +from toscaparser.elements.scalarunit import ScalarUnit_Time +from toscaparser.nodetemplate import NodeTemplate +from toscaparser.tests.base import TestCase +from toscaparser.utils.gettextutils import _ +from toscaparser.utils import yamlparser + + +class ScalarUnitPositiveTest(TestCase): + + scenarios = [ + ( + # tpl_snippet with mem_size given as number+space+MB + 'mem_size_is_number_Space_MB', + dict(tpl_snippet=''' + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + mem_size: 1024 MB + ''', + property='mem_size', + expected='1024 MB') + ), + ( + # tpl_snippet with mem_size given as number+spaces+GB + 'mem_size_is_number_Space_GB', + dict(tpl_snippet=''' + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + mem_size: 1 GB + ''', + property='mem_size', + expected='1 GB') + ), + ( + # tpl_snippet with mem_size given as number+tiB + 'mem_size_is_number_NoSpace_GB', + dict(tpl_snippet=''' + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + mem_size: 1tiB + ''', + property='mem_size', + expected='1 TiB') + ), + ( + # tpl_snippet with mem_size given as number+Spaces+GIB + 'mem_size_is_number_Spaces_GB', + dict(tpl_snippet=''' + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + mem_size: 1 GIB + ''', + property='mem_size', + expected='1 GiB') + ), + ( + # tpl_snippet with mem_size given as number+Space+tib + 'mem_size_is_number_Spaces_GB', + dict(tpl_snippet=''' + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + mem_size: 1 tib + ''', + property='mem_size', + expected='1 TiB') + ), + ( + 'cpu_frequency_is_float_Space_GHz', + dict(tpl_snippet=''' + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + cpu_frequency: 2.5 GHz + ''', + property='cpu_frequency', + expected='2.5 GHz') + ), + ( + 'cpu_frequency_is_float_Space_MHz', + dict(tpl_snippet=''' + server: + type: tosca.nodes.Compute + capabilities: + host: + properties: + cpu_frequency: 800 MHz + ''', + property='cpu_frequency', + expected='800 MHz') + ), + ] + + def test_scenario_scalar_unit_positive(self): + tpl = self.tpl_snippet + nodetemplates = yamlparser.simple_parse(tpl) + nodetemplate = NodeTemplate('server', nodetemplates) + props = nodetemplate.get_capability('host').get_properties() + prop_name = self.property + if props and prop_name in props.keys(): + prop = props[prop_name] + self.assertIsNone(prop.validate()) + resolved = prop.value + self.assertEqual(resolved, self.expected) + + +class GetNumFromScalarUnitSizePositive(TestCase): + + scenarios = [ + ( # Note that (1 TB) / (1 GB) = 1000 + 'Input is TB, user input is GB', + dict(InputMemSize='1 TB', + UserInputUnit='gB', + expected=1000) + ), + ( # Note that (1 Tib)/ (1 GB) = 1099 + 'Input is TiB, user input is GB', + dict(InputMemSize='1 TiB', + UserInputUnit='gB', + expected=1099.511627776) + ), + ] + + def test_scenario_get_num_from_scalar_unit_size(self): + resolved = (ScalarUnit_Size(self.InputMemSize). + get_num_from_scalar_unit(self.UserInputUnit)) + self.assertEqual(resolved, self.expected) + + +class GetNumFromScalarUnitFrequencyPositive(TestCase): + + scenarios = [ + ( # Note that (1 GHz) / (1 Hz) = 1000000000 + 'Input is GHz, user input is Hz', + dict(InputMemSize='1 GHz', + UserInputUnit='Hz', + expected=1000000000) + ), + ( + 'Input is GHz, user input is Hz', + dict(InputMemSize='2.4 GHz', + UserInputUnit='Hz', + expected=2400000000) + ), + ( # Note that (1 GHz)/ (1 MHz) = 1000 + 'Input is MHz, user input is GHz', + dict(InputMemSize='800 MHz', + UserInputUnit='GHz', + expected=0.8) + ), + ( + 'Input is GHz, user input is Hz', + dict(InputMemSize='0.9 GHz', + UserInputUnit='MHz', + expected=900) + ), + ( + 'Input is GHz, user input is Hz', + dict(InputMemSize='2.7GHz', + UserInputUnit='MHz', + expected=2700) + ), + ] + + def test_scenario_get_num_from_scalar_unit_frequency(self): + resolved = (ScalarUnit_Frequency(self.InputMemSize). + get_num_from_scalar_unit(self.UserInputUnit)) + self.assertEqual(resolved, self.expected) + + +class GetNumFromScalarUnitTimePositive(TestCase): + + scenarios = [ + ( # Note that (1 s) / (1 ms) = 1000 + 'Input is 500ms, user input is s', + dict(InputMemSize='500 ms', + UserInputUnit='s', + expected=0.5) + ), + ( # Note that (1 h)/ (1 s) = 3600 + 'Input is h, user input is s', + dict(InputMemSize='1 h', + UserInputUnit='s', + expected=3600) + ), + ( # Note that (1 m)/ (1 s) = 60 + 'Input is m, user input is s', + dict(InputMemSize='0.5 m', + UserInputUnit='s', + expected=30) + ), + ( # Note that (1 d)/ (1 h) = 24 + 'Input is d, user input is h', + dict(InputMemSize='1 d', + UserInputUnit='h', + expected=24) + ), + ] + + def test_scenario_get_num_from_scalar_unit_time(self): + resolved = (ScalarUnit_Time(self.InputMemSize). + get_num_from_scalar_unit(self.UserInputUnit)) + self.assertEqual(resolved, self.expected) + + +class GetNumFromScalarUnitSizeNegative(TestCase): + + InputMemSize = '1 GB' + UserInputUnit = 'qB' + + def test_get_num_from_scalar_unit_size_negative(self): + try: + (ScalarUnit_Size(self.InputMemSize). + get_num_from_scalar_unit(self.UserInputUnit)) + except Exception as error: + self.assertTrue(isinstance(error, ValueError)) + self.assertEqual(_('The unit "qB" is not valid. Valid units are ' + '"[\'B\', \'GB\', \'GiB\', \'KiB\', \'MB\', ' + '\'MiB\', \'TB\', \'TiB\', \'kB\']".'), + error.__str__()) + + +class GetNumFromScalarUnitFrequencyNegative(TestCase): + + InputFrequency = '2.7 GHz' + UserInputUnit = 'Jz' + + def test_get_num_from_scalar_unit_frequency_negative(self): + try: + (ScalarUnit_Frequency(self.InputFrequency). + get_num_from_scalar_unit(self.UserInputUnit)) + except Exception as error: + self.assertTrue(isinstance(error, ValueError)) + self.assertEqual(_('The unit "Jz" is not valid. Valid units are ' + '"[\'GHz\', \'Hz\', \'MHz\', \'kHz\']".'), + error.__str__()) + + +class GetNumFromScalarUnitTimeNegative(TestCase): + + InputTime = '5 ms' + UserInputUnit = 'D' + + def test_get_num_from_scalar_unit_frequency_negative(self): + try: + (ScalarUnit_Time(self.InputTime). + get_num_from_scalar_unit(self.UserInputUnit)) + except Exception as error: + self.assertTrue(isinstance(error, ValueError)) + self.assertEqual(_('"Jz" is not a valid scalar-unit.'), + error.__str__()) + + +class ScalarUnitNegativeTest(TestCase): + + custom_def_snippet = ''' + tosca.my.nodes.Compute: + derived_from: tosca.nodes.Root + properties: + cpu_frequency: + required: no + type: scalar-unit.frequency + constraints: + - greater_or_equal: 0.1 GHz + disk_size: + required: no + type: scalar-unit.size + constraints: + - greater_or_equal: 1 GB + mem_size: + required: no + type: scalar-unit.size + constraints: + - in_range: [1 MiB, 1 GiB] + ''' + custom_def = yamlparser.simple_parse(custom_def_snippet) + + # disk_size doesn't provide a value, mem_size uses an invalid unit. + def test_invalid_scalar_unit(self): + tpl_snippet = ''' + server: + type: tosca.my.nodes.Compute + properties: + cpu_frequency: 50.3.6 GHZ + disk_size: MB + mem_size: 1 QB + ''' + nodetemplates = yamlparser.simple_parse(tpl_snippet) + nodetemplate = NodeTemplate('server', nodetemplates, self.custom_def) + for p in nodetemplate.get_properties_objects(): + self.assertRaises(ValueError, p.validate) + + # disk_size is less than 1 GB, mem_size is not in the required range. + # Note: in the spec, the minimum value of mem_size is 1 MiB (> 1 MB) + def test_constraint_for_scalar_unit(self): + tpl_snippet = ''' + server: + type: tosca.my.nodes.Compute + properties: + cpu_frequency: 0.05 GHz + disk_size: 500 MB + mem_size: 1 MB + ''' + nodetemplates = yamlparser.simple_parse(tpl_snippet) + nodetemplate = NodeTemplate('server', nodetemplates, self.custom_def) + props = nodetemplate.get_properties() + if 'cpu_frequency' in props.keys(): + error = self.assertRaises(exception.ValidationError, + props['cpu_frequency'].validate) + self.assertEqual(_('The value "0.05 GHz" of property ' + '"cpu_frequency" must be greater than or equal ' + 'to "0.1 GHz".'), error.__str__()) + if 'disk_size' in props.keys(): + error = self.assertRaises(exception.ValidationError, + props['disk_size'].validate) + self.assertEqual(_('The value "500 MB" of property "disk_size" ' + 'must be greater than or equal to "1 GB".'), + error.__str__()) + + if 'mem_size' in props.keys(): + error = self.assertRaises(exception.ValidationError, + props['mem_size'].validate) + self.assertEqual(_('The value "1 MB" of property "mem_size" is ' + 'out of range "(min:1 MiB, max:1 GiB)".'), + error.__str__()) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_shell.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_shell.py new file mode 100644 index 0000000..e0b5a4e --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_shell.py @@ -0,0 +1,57 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import os + +from toscaparser.common import exception +import toscaparser.shell as shell +from toscaparser.tests.base import TestCase +from toscaparser.utils.gettextutils import _ + + +class ShellTest(TestCase): + + tosca_helloworld = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/tosca_helloworld.yaml") + + errornous_template = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/test_multiple_validation_errors.yaml") + + def test_missing_arg(self): + error = self.assertRaises(ValueError, shell.main, '') + err_msg = _('The program requires a template or a CSAR file as an ' + 'argument. Please refer to the usage documentation.') + self.assertEqual(err_msg, str(error)) + + def test_invalid_arg(self): + error = self.assertRaises(ValueError, shell.main, 'parse me') + err_msg = _('The program expects "--template-file" as the first ' + 'argument. Please refer to the usage documentation.') + self.assertEqual(err_msg, str(error)) + + def test_template_not_exist(self): + error = self.assertRaises( + ValueError, shell.main, ['--template-file=template.txt']) + self.assertEqual(_('"template.txt" is not a valid file.'), str(error)) + + def test_template_invalid(self): + arg = '--template-file=' + self.errornous_template + self.assertRaises(exception.ValidationError, shell.main, [arg]) + + def test_template_valid(self): + arg = '--template-file=' + self.tosca_helloworld + try: + shell.main([arg]) + except Exception: + self.fail(_('The program raised an exception unexpectedly.')) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_topology_template.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_topology_template.py new file mode 100644 index 0000000..d12037e --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_topology_template.py @@ -0,0 +1,160 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import os + +from toscaparser.tests.base import TestCase +from toscaparser.topology_template import TopologyTemplate +from toscaparser.tosca_template import ToscaTemplate +import toscaparser.utils.yamlparser + +YAML_LOADER = toscaparser.utils.yamlparser.load_yaml + + +class TopologyTemplateTest(TestCase): + + def setUp(self): + TestCase.setUp(self) + '''TOSCA template.''' + self.tosca_tpl_path = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/topology_template/subsystem.yaml") + self.tpl = YAML_LOADER(self.tosca_tpl_path) + self.topo_tpl = self.tpl.get('topology_template') + self.imports = self.tpl.get('imports') + self.topo = TopologyTemplate(self.topo_tpl, + self._get_all_custom_def()) + + def _get_custom_def(self, type_definition): + custom_defs = {} + for definition in self.imports: + if os.path.isabs(definition): + def_file = definition + else: + tpl_dir = os.path.dirname(os.path.abspath(self.tosca_tpl_path)) + def_file = os.path.join(tpl_dir, definition) + custom_type = YAML_LOADER(def_file) + custom_defs.update(custom_type.get(type_definition)) + return custom_defs + + def _get_all_custom_def(self): + custom_defs = {} + custom_defs.update(self._get_custom_def('node_types')) + custom_defs.update(self._get_custom_def('capability_types')) + return custom_defs + + def test_description(self): + expected_desc = 'Template of a database including its hosting stack.' + self.assertEqual(expected_desc, self.topo.description) + + def test_inputs(self): + self.assertEqual( + ['mq_server_ip', 'my_cpus', 'receiver_port'], + sorted([input.name for input in self.topo.inputs])) + + input_name = "receiver_port" + expected_description = "Port to be used for receiving messages." + for input in self.topo.inputs: + if input.name == input_name: + self.assertEqual(expected_description, input.description) + + def test_node_tpls(self): + '''Test nodetemplate names.''' + self.assertEqual( + ['app', 'server', 'websrv'], + sorted([tpl.name for tpl in self.topo.nodetemplates])) + + tpl_name = "app" + expected_type = "example.SomeApp" + expected_properties = ['admin_user', 'pool_size'] + expected_capabilities = ['message_receiver'] + expected_requirements = [{'host': {'node': 'websrv'}}] + expected_relationshp = ['tosca.relationships.HostedOn'] + expected_host = ['websrv'] + for tpl in self.topo.nodetemplates: + if tpl_name == tpl.name: + '''Test node type.''' + self.assertEqual(tpl.type, expected_type) + + '''Test properties.''' + self.assertEqual( + expected_properties, + sorted(tpl.get_properties().keys())) + + '''Test capabilities.''' + self.assertEqual( + expected_capabilities, + sorted(tpl.get_capabilities().keys())) + + '''Test requirements.''' + self.assertEqual( + expected_requirements, tpl.requirements) + + '''Test relationship.''' + ''' TODO : skip tempororily. need to fix it + ''' + self.assertEqual( + expected_relationshp, + [x.type for x in tpl.relationships.keys()]) + self.assertEqual( + expected_host, + [y.name for y in tpl.relationships.values()]) + '''Test interfaces.''' + # TODO(hurf) add interface test when new template is available + + if tpl.name == 'server': + '''Test property value''' + props = tpl.get_properties() + if props and 'mem_size' in props.keys(): + self.assertEqual(props['mem_size'].value, '4096 MB') + '''Test capability''' + caps = tpl.get_capabilities() + self.assertIn('os', caps.keys()) + os_props_objs = None + os_props = None + os_type_prop = None + if caps and 'os' in caps.keys(): + capability = caps['os'] + os_props_objs = capability.get_properties_objects() + os_props = capability.get_properties() + os_type_prop = capability.get_property_value('type') + break + self.assertEqual( + ['Linux'], + [p.value for p in os_props_objs if p.name == 'type']) + self.assertEqual( + 'Linux', + os_props['type'].value if 'type' in os_props else '') + self.assertEqual('Linux', os_props['type'].value) + self.assertEqual('Linux', os_type_prop) + + def test_outputs(self): + self.assertEqual( + ['receiver_ip'], + sorted([output.name for output in self.topo.outputs])) + + def test_groups(self): + group = self.topo.groups[0] + self.assertEqual('webserver_group', group.name) + self.assertEqual(['websrv', 'server'], group.member_names) + for node in group.members: + if node.name == 'server': + '''Test property value''' + props = node.get_properties() + if props and 'mem_size' in props.keys(): + self.assertEqual(props['mem_size'].value, '4096 MB') + + def test_system_template(self): + tpl_path = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/topology_template/system.yaml") + self.assertIsNotNone(ToscaTemplate(tpl_path)) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_toscadef.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_toscadef.py new file mode 100644 index 0000000..38d08d7 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_toscadef.py @@ -0,0 +1,335 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from toscaparser.common import exception +from toscaparser.elements.artifacttype import ArtifactTypeDef +from toscaparser.elements.entity_type import EntityType +import toscaparser.elements.interfaces as ifaces +from toscaparser.elements.nodetype import NodeType +from toscaparser.elements.policytype import PolicyType +from toscaparser.tests.base import TestCase + +compute_type = NodeType('tosca.nodes.Compute') +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') +artif_root_type = ArtifactTypeDef('tosca.artifacts.Root') +artif_file_type = ArtifactTypeDef('tosca.artifacts.File') +artif_bash_type = ArtifactTypeDef('tosca.artifacts.Implementation.Bash') +artif_python_type = ArtifactTypeDef('tosca.artifacts.Implementation.Python') +artif_container_docker_type = ArtifactTypeDef('tosca.artifacts.' + 'Deployment.Image.' + 'Container.Docker') +artif_vm_iso_type = ArtifactTypeDef('tosca.artifacts.' + 'Deployment.Image.VM.ISO') +artif_vm_qcow2_type = ArtifactTypeDef('tosca.artifacts.' + 'Deployment.Image.VM.QCOW2') +policy_root_type = PolicyType('tosca.policies.Root') +policy_placement_type = PolicyType('tosca.policies.Placement') +policy_scaling_type = PolicyType('tosca.policies.Scaling') +policy_update_type = PolicyType('tosca.policies.Update') +policy_performance_type = PolicyType('tosca.policies.Performance') + + +class ToscaDefTest(TestCase): + def test_type(self): + self.assertEqual(compute_type.type, "tosca.nodes.Compute") + self.assertRaises(exception.InvalidTypeError, NodeType, + 'tosca.nodes.Invalid') + self.assertEqual(network_type.type, "tosca.nodes.network.Network") + self.assertEqual(network_port_type.type, "tosca.nodes.network.Port") + + def test_parent_type(self): + self.assertEqual(compute_type.parent_type.type, "tosca.nodes.Root") + self.assertEqual(network_type.parent_type.type, "tosca.nodes.Root") + self.assertEqual(network_port_type.parent_type.type, + "tosca.nodes.Root") + + def test_capabilities(self): + self.assertEqual( + sorted(['tosca.capabilities.Container', + 'tosca.capabilities.OperatingSystem', + 'tosca.capabilities.network.Bindable', + 'tosca.capabilities.Scalable']), + sorted([c.type for c in compute_type.get_capabilities_objects()])) + self.assertEqual( + ['tosca.capabilities.network.Linkable'], + [c.type for c in network_type.get_capabilities_objects()]) + endpoint_properties = ['initiator', 'network_name', 'port', + 'port_name', 'ports', 'protocol', + 'secure', 'url_path'] + endpoint_props_def_objects = \ + self._get_capability_properties_def_objects( + webserver_type.get_capabilities_objects(), + 'tosca.capabilities.Endpoint') + self.assertEqual( + endpoint_properties, + sorted([p.name for p in endpoint_props_def_objects])) + for p in endpoint_props_def_objects: + if p.name in endpoint_properties: + self.assertFalse(p.required) + endpoint_props_def = self._get_capability_properties_def( + webserver_type.get_capabilities_objects(), + 'tosca.capabilities.Endpoint') + self.assertEqual( + endpoint_properties, + sorted(endpoint_props_def.keys())) + endpoint_prop_def = self._get_capability_property_def( + webserver_type.get_capabilities_objects(), + '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') + self.assertEqual( + [('architecture', False), ('distribution', False), ('type', False), + ('version', False)], + sorted([(p.name, p.required) for p in os_props])) + + host_props = self._get_capability_properties_def_objects( + compute_type.get_capabilities_objects(), + 'tosca.capabilities.Container') + self.assertEqual( + [('cpu_frequency', False), ('disk_size', False), + ('mem_size', False), ('num_cpus', False)], + sorted([(p.name, p.required) for p in host_props])) + endpoint_admin_properties = 'secure' + endpoint_admin_props_def_objects = \ + self._get_capability_properties_def_objects( + webserver_type.get_capabilities_objects(), + 'tosca.capabilities.Endpoint.Admin') + self.assertIn( + endpoint_admin_properties, + sorted([p.name for p in endpoint_admin_props_def_objects])) + + def _get_capability_properties_def_objects(self, caps, type): + properties_def = None + for cap in caps: + if cap.type == type: + properties_def = cap.get_properties_def_objects() + break + return properties_def + + def _get_capability_properties_def(self, caps, type): + properties_def = None + for cap in caps: + if cap.type == type: + properties_def = cap.get_properties_def() + break + return properties_def + + def _get_capability_property_def(self, caps, type, property): + property_def = None + for cap in caps: + if cap.type == type: + property_def = cap.get_property_def_value(property) + break + return property_def + + def test_properties_def(self): + self.assertEqual( + ['name', 'password', 'user'], + sorted(database_type.get_properties_def().keys())) + + def test_attributes_def(self): + self.assertEqual( + ['private_address', 'public_address'], + sorted(compute_type.get_attributes_def().keys())) + + def test_requirements(self): + self.assertEqual( + [{'host': {'capability': 'tosca.capabilities.Container', + 'node': 'tosca.nodes.Compute', + 'relationship': 'tosca.relationships.HostedOn'}}], + [r for r in component_type.requirements]) + + def test_relationship(self): + self.assertEqual( + [('tosca.relationships.HostedOn', 'tosca.nodes.Compute')], + [(relation.type, node.type) for + relation, node in component_type.relationship.items()]) + self.assertIn( + ('tosca.relationships.HostedOn', ['tosca.capabilities.Container']), + [(relation.type, relation.valid_target_types) for + relation in list(component_type.relationship.keys())]) + self.assertIn( + ('tosca.relationships.network.BindsTo', 'tosca.nodes.Compute'), + [(relation.type, node.type) for + relation, node in network_port_type.relationship.items()]) + self.assertIn( + ('tosca.relationships.network.LinksTo', + 'tosca.nodes.network.Network'), + [(relation.type, node.type) for + relation, node in network_port_type.relationship.items()]) + + def test_interfaces(self): + self.assertEqual(compute_type.interfaces, None) + root_node = NodeType('tosca.nodes.Root') + self.assertIn(ifaces.LIFECYCLE_SHORTNAME, root_node.interfaces) + + def test_artifacts(self): + self.assertEqual('tosca.artifacts.Root', + artif_file_type.parent_type) + self.assertEqual({}, artif_file_type.parent_artifacts) + self.assertEqual(sorted(['tosca.artifacts.Root'], + key=lambda x: str(x)), + sorted([artif_file_type.get_artifact(name) + for name in artif_file_type.defs], + key=lambda x: str(x))) + + self.assertEqual('tosca.artifacts.Implementation', + artif_bash_type.parent_type) + self.assertEqual({'tosca.artifacts.Implementation': + {'derived_from': 'tosca.artifacts.Root', + 'description': + 'TOSCA base type for implementation artifacts'}}, + artif_bash_type.parent_artifacts) + self.assertEqual(sorted([['sh'], 'tosca.artifacts.Implementation', + 'Script artifact for the Unix Bash shell', + 'application/x-sh'], key=lambda x: str(x)), + sorted([artif_bash_type.get_artifact(name) + for name in artif_bash_type.defs], + key=lambda x: str(x))) + + self.assertEqual('tosca.artifacts.Implementation', + artif_python_type.parent_type) + self.assertEqual({'tosca.artifacts.Implementation': + {'derived_from': 'tosca.artifacts.Root', + 'description': + 'TOSCA base type for implementation artifacts'}}, + artif_python_type.parent_artifacts) + self.assertEqual(sorted([['py'], 'tosca.artifacts.Implementation', + 'Artifact for the interpreted Python' + ' language', 'application/x-python'], + key=lambda x: str(x)), + sorted([artif_python_type.get_artifact(name) + for name in artif_python_type.defs], + key=lambda x: str(x))) + + self.assertEqual('tosca.artifacts.Deployment.Image', + artif_container_docker_type.parent_type) + self.assertEqual({'tosca.artifacts.Deployment': + {'derived_from': 'tosca.artifacts.Root', + 'description': + 'TOSCA base type for deployment artifacts'}, + 'tosca.artifacts.Deployment.Image': + {'derived_from': 'tosca.artifacts.Deployment'}}, + artif_container_docker_type.parent_artifacts) + self.assertEqual(sorted(['tosca.artifacts.Deployment.Image', + 'Docker container image'], + key=lambda x: str(x)), + sorted([artif_container_docker_type. + get_artifact(name) for name in + artif_container_docker_type.defs], + key=lambda x: str(x))) + + self.assertEqual('tosca.artifacts.Deployment.Image', + artif_vm_iso_type.parent_type) + self.assertEqual({'tosca.artifacts.Deployment': + {'derived_from': 'tosca.artifacts.Root', + 'description': + 'TOSCA base type for deployment artifacts'}, + 'tosca.artifacts.Deployment.Image': + {'derived_from': 'tosca.artifacts.Deployment'}}, + artif_vm_iso_type.parent_artifacts) + self.assertEqual(sorted(['tosca.artifacts.Deployment.Image', + 'Virtual Machine (VM) image in ' + 'ISO disk format', + 'application/octet-stream', ['iso']], + key=lambda x: str(x)), + sorted([artif_vm_iso_type. + get_artifact(name) for name in + artif_vm_iso_type.defs], + key=lambda x: str(x))) + + self.assertEqual('tosca.artifacts.Deployment.Image', + artif_vm_qcow2_type.parent_type) + self.assertEqual({'tosca.artifacts.Deployment': + {'derived_from': 'tosca.artifacts.Root', + 'description': + 'TOSCA base type for deployment artifacts'}, + 'tosca.artifacts.Deployment.Image': + {'derived_from': 'tosca.artifacts.Deployment'}}, + artif_vm_qcow2_type.parent_artifacts) + self.assertEqual(sorted(['tosca.artifacts.Deployment.Image', + 'Virtual Machine (VM) image in QCOW v2 ' + 'standard disk format', + 'application/octet-stream', ['qcow2']], + key=lambda x: str(x)), + sorted([artif_vm_qcow2_type. + get_artifact(name) for name in + artif_vm_qcow2_type.defs], + key=lambda x: str(x))) + + def test_policies(self): + self.assertEqual('tosca.policies.Root', + policy_placement_type.parent_type) + self.assertEqual({}, policy_placement_type.parent_policies) + self.assertEqual(sorted(['tosca.policies.Root', + 'The TOSCA Policy Type definition that is ' + 'used to govern placement of TOSCA nodes or ' + 'groups of nodes.'], + key=lambda x: str(x)), + sorted([policy_placement_type.get_policy(name) + for name in policy_placement_type.defs], + key=lambda x: str(x))) + + self.assertEqual('tosca.policies.Root', + policy_scaling_type.parent_type) + self.assertEqual({}, policy_scaling_type.parent_policies) + self.assertEqual(sorted(['tosca.policies.Root', + 'The TOSCA Policy Type definition that is ' + 'used to govern scaling of TOSCA nodes or ' + 'groups of nodes.'], + key=lambda x: str(x)), + sorted([policy_scaling_type.get_policy(name) + for name in policy_scaling_type.defs], + key=lambda x: str(x))) + + self.assertEqual('tosca.policies.Root', + policy_update_type.parent_type) + self.assertEqual({}, policy_update_type.parent_policies) + self.assertEqual(sorted(['tosca.policies.Root', + 'The TOSCA Policy Type definition that is ' + 'used to govern update of TOSCA nodes or ' + 'groups of nodes.'], + key=lambda x: str(x)), + sorted([policy_update_type.get_policy(name) + for name in policy_update_type.defs], + key=lambda x: str(x))) + + self.assertEqual('tosca.policies.Root', + policy_performance_type.parent_type) + self.assertEqual({}, policy_performance_type.parent_policies) + self.assertEqual(sorted(['tosca.policies.Root', + 'The TOSCA Policy Type definition that is ' + 'used to declare performance requirements ' + 'for TOSCA nodes or groups of nodes.'], + key=lambda x: str(x)), + sorted([policy_performance_type.get_policy(name) + for name in policy_performance_type.defs], + key=lambda x: str(x))) + + def test_port_spec(self): + tosca_def = EntityType.TOSCA_DEF + port_spec = tosca_def.get('tosca.datatypes.network.PortSpec') + self.assertEqual(port_spec.get('derived_from'), + 'tosca.datatypes.Root') + properties = port_spec.get('properties') + self.assertEqual( + sorted(['protocol', 'target', 'target_range', 'source', + 'source_range']), + sorted(properties.keys())) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_toscatpl.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_toscatpl.py new file mode 100644 index 0000000..4372a83 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_toscatpl.py @@ -0,0 +1,544 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import os +import six + +from toscaparser.common import exception +import toscaparser.elements.interfaces as ifaces +from toscaparser.elements.nodetype import NodeType +from toscaparser.functions import GetInput +from toscaparser.functions import GetProperty +from toscaparser.nodetemplate import NodeTemplate +from toscaparser.tests.base import TestCase +from toscaparser.tosca_template import ToscaTemplate +from toscaparser.utils.gettextutils import _ +import toscaparser.utils.yamlparser + + +class ToscaTemplateTest(TestCase): + + '''TOSCA template.''' + tosca_tpl = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/tosca_single_instance_wordpress.yaml") + tosca = ToscaTemplate(tosca_tpl) + + tosca_elk_tpl = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/tosca_elk.yaml") + + def test_version(self): + self.assertEqual(self.tosca.version, "tosca_simple_yaml_1_0") + + def test_description(self): + expected_description = "TOSCA simple profile with wordpress, " \ + "web server and mysql on the same server." + self.assertEqual(self.tosca.description, expected_description) + + def test_inputs(self): + self.assertEqual( + ['cpus', 'db_name', 'db_port', + 'db_pwd', 'db_root_pwd', 'db_user'], + sorted([input.name for input in self.tosca.inputs])) + + input_name = "db_port" + expected_description = "Port for the MySQL database." + for input in self.tosca.inputs: + if input.name == input_name: + self.assertEqual(input.description, expected_description) + + def test_node_tpls(self): + '''Test nodetemplate names.''' + self.assertEqual( + ['mysql_database', 'mysql_dbms', 'server', + 'webserver', 'wordpress'], + sorted([tpl.name for tpl in self.tosca.nodetemplates])) + + tpl_name = "mysql_database" + expected_type = "tosca.nodes.Database" + expected_properties = ['name', 'password', 'user'] + expected_capabilities = ['database_endpoint'] + expected_requirements = [{'host': 'mysql_dbms'}] + ''' TODO: needs enhancement in tosca_elk.yaml.. + expected_relationshp = ['tosca.relationships.HostedOn'] + expected_host = ['mysql_dbms'] + ''' + expected_interface = [ifaces.LIFECYCLE_SHORTNAME] + + for tpl in self.tosca.nodetemplates: + if tpl_name == tpl.name: + '''Test node type.''' + self.assertEqual(tpl.type, expected_type) + + '''Test properties.''' + self.assertEqual( + expected_properties, + sorted(tpl.get_properties().keys())) + + '''Test capabilities.''' + self.assertEqual( + expected_capabilities, + sorted(tpl.get_capabilities().keys())) + + '''Test requirements.''' + self.assertEqual( + expected_requirements, tpl.requirements) + + '''Test relationship.''' + ''' needs enhancements in tosca_elk.yaml + self.assertEqual( + expected_relationshp, + [x.type for x in tpl.relationships.keys()]) + self.assertEqual( + expected_host, + [y.name for y in tpl.relationships.values()]) + ''' + '''Test interfaces.''' + self.assertEqual( + expected_interface, + [x.type for x in tpl.interfaces]) + + if tpl.name == 'server': + '''Test property value''' + props = tpl.get_properties() + if props and 'mem_size' in props.keys(): + self.assertEqual(props['mem_size'].value, '4096 MB') + '''Test capability''' + caps = tpl.get_capabilities() + self.assertIn('os', caps.keys()) + os_props_objs = None + os_props = None + os_type_prop = None + if caps and 'os' in caps.keys(): + capability = caps['os'] + os_props_objs = capability.get_properties_objects() + os_props = capability.get_properties() + os_type_prop = capability.get_property_value('type') + break + self.assertEqual( + ['Linux'], + [p.value for p in os_props_objs if p.name == 'type']) + self.assertEqual( + 'Linux', + os_props['type'].value if 'type' in os_props else '') + self.assertEqual('Linux', os_props['type'].value) + self.assertEqual('Linux', os_type_prop) + + def test_outputs(self): + self.assertEqual( + ['website_url'], + sorted([output.name for output in self.tosca.outputs])) + + def test_interfaces(self): + wordpress_node = [ + node for node in self.tosca.nodetemplates + if node.name == 'wordpress'][0] + interfaces = wordpress_node.interfaces + self.assertEqual(2, len(interfaces)) + for interface in interfaces: + if interface.name == 'create': + self.assertEqual(ifaces.LIFECYCLE_SHORTNAME, + interface.type) + self.assertEqual('wordpress/wordpress_install.sh', + interface.implementation) + self.assertIsNone(interface.inputs) + elif interface.name == 'configure': + self.assertEqual(ifaces.LIFECYCLE_SHORTNAME, + interface.type) + self.assertEqual('wordpress/wordpress_configure.sh', + interface.implementation) + self.assertEqual(3, len(interface.inputs)) + TestCase.skip(self, 'bug #1440247') + wp_db_port = interface.inputs['wp_db_port'] + self.assertTrue(isinstance(wp_db_port, GetProperty)) + self.assertEqual('get_property', wp_db_port.name) + self.assertEqual(['SELF', + 'database_endpoint', + 'port'], + wp_db_port.args) + result = wp_db_port.result() + self.assertTrue(isinstance(result, GetInput)) + else: + raise AssertionError( + 'Unexpected interface: {0}'.format(interface.name)) + + def test_normative_type_by_short_name(self): + # test template with a short name Compute + template = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/test_tosca_normative_type_by_shortname.yaml") + + tosca_tpl = ToscaTemplate(template) + expected_type = "tosca.nodes.Compute" + for tpl in tosca_tpl.nodetemplates: + self.assertEqual(tpl.type, expected_type) + for tpl in tosca_tpl.nodetemplates: + compute_type = NodeType(tpl.type) + self.assertEqual( + sorted(['tosca.capabilities.Container', + 'tosca.capabilities.OperatingSystem', + 'tosca.capabilities.network.Bindable', + 'tosca.capabilities.Scalable']), + sorted([c.type + for c in compute_type.get_capabilities_objects()])) + + def test_template_with_no_inputs(self): + tosca_tpl = self._load_template('test_no_inputs_in_template.yaml') + self.assertEqual(0, len(tosca_tpl.inputs)) + + def test_template_with_no_outputs(self): + tosca_tpl = self._load_template('test_no_outputs_in_template.yaml') + self.assertEqual(0, len(tosca_tpl.outputs)) + + def test_relationship_interface(self): + template = ToscaTemplate(self.tosca_elk_tpl) + for node_tpl in template.nodetemplates: + if node_tpl.name == 'logstash': + config_interface = 'Configure' + artifact = 'logstash/configure_elasticsearch.py' + relation = node_tpl.relationships + for key in relation.keys(): + rel_tpl = relation.get(key).get_relationship_template() + if rel_tpl: + interfaces = rel_tpl[0].interfaces + for interface in interfaces: + self.assertEqual(config_interface, + interface.type) + self.assertEqual('pre_configure_source', + interface.name) + self.assertEqual(artifact, + interface.implementation) + + def test_template_macro(self): + template = ToscaTemplate(self.tosca_elk_tpl) + for node_tpl in template.nodetemplates: + if node_tpl.name == 'mongo_server': + self.assertEqual( + ['disk_size', 'mem_size', 'num_cpus'], + sorted(node_tpl.get_capability('host'). + get_properties().keys())) + + def test_template_requirements(self): + """Test different formats of requirements + + The requirements can be defined in few different ways, + 1. Requirement expressed as a capability with an implicit relationship. + 2. Requirement expressed with explicit relationship. + 3. Requirement expressed with a relationship template. + 4. Requirement expressed via TOSCA types to provision a node + with explicit relationship. + 5. Requirement expressed via TOSCA types with a filter. + """ + tosca_tpl = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/test_requirements.yaml") + tosca = ToscaTemplate(tosca_tpl) + for node_tpl in tosca.nodetemplates: + if node_tpl.name == 'my_app': + expected_relationship = [ + ('tosca.relationships.ConnectsTo', 'mysql_database'), + ('tosca.relationships.HostedOn', 'my_webserver')] + actual_relationship = sorted([ + (relation.type, node.name) for + relation, node in node_tpl.relationships.items()]) + self.assertEqual(expected_relationship, actual_relationship) + if node_tpl.name == 'mysql_database': + self.assertEqual( + [('tosca.relationships.HostedOn', 'my_dbms')], + [(relation.type, node.name) for + relation, + node in node_tpl.relationships.items()]) + if node_tpl.name == 'my_server': + self.assertEqual( + [('tosca.relationships.AttachesTo', 'my_storage')], + [(relation.type, node.name) for + relation, + node in node_tpl.relationships.items()]) + + def test_template_requirements_not_implemented(self): + # TODO(spzala): replace this test with new one once TOSCA types look up + # support is implemented. + """Requirements that yet need to be implemented + + The following requirement formats are not yet implemented, + due to look up dependency: + 1. Requirement expressed via TOSCA types to provision a node + with explicit relationship. + 2. Requirement expressed via TOSCA types with a filter. + """ + tpl_snippet_1 = ''' + node_templates: + mysql_database: + type: tosca.nodes.Database + description: Requires a particular node type and relationship. + To be full-filled via lookup into node repository. + requirements: + - req1: + node: tosca.nodes.DBMS + relationship: tosca.relationships.HostedOn + ''' + + tpl_snippet_2 = ''' + node_templates: + my_webserver: + type: tosca.nodes.WebServer + description: Requires a particular node type with a filter. + To be full-filled via lookup into node repository. + requirements: + - req1: + node: tosca.nodes.Compute + target_filter: + properties: + num_cpus: { in_range: [ 1, 4 ] } + mem_size: { greater_or_equal: 2 } + capabilities: + - tosca.capabilities.OS: + properties: + architecture: x86_64 + type: linux + ''' + + tpl_snippet_3 = ''' + node_templates: + my_webserver2: + type: tosca.nodes.WebServer + description: Requires a node type with a particular capability. + To be full-filled via lookup into node repository. + requirements: + - req1: + node: tosca.nodes.Compute + relationship: tosca.relationships.HostedOn + capability: tosca.capabilities.Container + ''' + self._requirements_not_implemented(tpl_snippet_1, 'mysql_database') + self._requirements_not_implemented(tpl_snippet_2, 'my_webserver') + self._requirements_not_implemented(tpl_snippet_3, 'my_webserver2') + + def _requirements_not_implemented(self, tpl_snippet, tpl_name): + nodetemplates = (toscaparser.utils.yamlparser. + simple_parse(tpl_snippet))['node_templates'] + self.assertRaises( + NotImplementedError, + lambda: NodeTemplate(tpl_name, nodetemplates).relationships) + + def test_custom_capability_type_definition(self): + tpl_snippet = ''' + node_templates: + test_app: + type: tosca.nodes.WebApplication.TestApp + capabilities: + test_cap: + properties: + test: 1 + ''' + # custom definition with capability type definition + custom_def = ''' + tosca.nodes.WebApplication.TestApp: + derived_from: tosca.nodes.WebApplication + capabilities: + test_cap: + type: tosca.capabilities.TestCapability + tosca.capabilities.TestCapability: + derived_from: tosca.capabilities.Root + properties: + test: + type: integer + required: no + ''' + expected_capabilities = ['test_cap'] + nodetemplates = (toscaparser.utils.yamlparser. + simple_parse(tpl_snippet))['node_templates'] + custom_def = (toscaparser.utils.yamlparser. + simple_parse(custom_def)) + name = list(nodetemplates.keys())[0] + tpl = NodeTemplate(name, nodetemplates, custom_def) + self.assertEqual( + expected_capabilities, + sorted(tpl.get_capabilities().keys())) + + # custom definition without capability type definition + custom_def = ''' + tosca.nodes.WebApplication.TestApp: + derived_from: tosca.nodes.WebApplication + capabilities: + test_cap: + type: tosca.capabilities.TestCapability + ''' + custom_def = (toscaparser.utils.yamlparser. + simple_parse(custom_def)) + tpl = NodeTemplate(name, nodetemplates, custom_def) + err = self.assertRaises( + exception.InvalidTypeError, + lambda: NodeTemplate(name, nodetemplates, + custom_def).get_capabilities_objects()) + self.assertEqual('Type "tosca.capabilities.TestCapability" is not ' + 'a valid type.', six.text_type(err)) + + def test_local_template_with_local_relpath_import(self): + tosca_tpl = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/tosca_single_instance_wordpress.yaml") + tosca = ToscaTemplate(tosca_tpl) + self.assertTrue(tosca.topology_template.custom_defs) + + def test_local_template_with_url_import(self): + tosca_tpl = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/tosca_single_instance_wordpress_with_url_import.yaml") + tosca = ToscaTemplate(tosca_tpl) + self.assertTrue(tosca.topology_template.custom_defs) + + def test_url_template_with_local_relpath_import(self): + tosca_tpl = ('https://raw.githubusercontent.com/openstack/' + 'tosca-parser/master/toscaparser/tests/data/' + 'tosca_single_instance_wordpress.yaml') + tosca = ToscaTemplate(tosca_tpl, None, False) + self.assertTrue(tosca.topology_template.custom_defs) + + def test_url_template_with_local_abspath_import(self): + tosca_tpl = ('https://raw.githubusercontent.com/openstack/' + 'tosca-parser/master/toscaparser/tests/data/' + 'tosca_single_instance_wordpress_with_local_abspath_' + 'import.yaml') + self.assertRaises(exception.ValidationError, ToscaTemplate, tosca_tpl, + None, False) + err_msg = (_('Absolute file name "/tmp/tosca-parser/toscaparser/tests' + '/data/custom_types/wordpress.yaml" cannot be used in a ' + 'URL-based input template "%(tpl)s".') + % {'tpl': tosca_tpl}) + exception.ExceptionCollector.assertExceptionMessage(ImportError, + err_msg) + + def test_url_template_with_url_import(self): + tosca_tpl = ('https://raw.githubusercontent.com/openstack/' + 'tosca-parser/master/toscaparser/tests/data/' + 'tosca_single_instance_wordpress_with_url_import.yaml') + tosca = ToscaTemplate(tosca_tpl, None, False) + self.assertTrue(tosca.topology_template.custom_defs) + + def test_csar_parsing_wordpress(self): + csar_archive = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + 'data/CSAR/csar_wordpress.zip') + self.assertTrue(ToscaTemplate(csar_archive)) + + def test_csar_parsing_elk_url_based(self): + csar_archive = ('https://github.com/openstack/tosca-parser/raw/master/' + 'toscaparser/tests/data/CSAR/csar_elk.zip') + self.assertTrue(ToscaTemplate(csar_archive, None, False)) + + def test_nested_imports_in_templates(self): + tosca_tpl = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/test_instance_nested_imports.yaml") + tosca = ToscaTemplate(tosca_tpl) + expected_custom_types = ['tosca.nodes.WebApplication.WordPress', + 'tosca.nodes.SoftwareComponent.Rsyslog', + 'tosca.nodes.SoftwareComponent.Logstash', + 'tosca.nodes.SoftwareComponent.Rsyslog.' + 'TestRsyslogType'] + self.assertItemsEqual(tosca.topology_template.custom_defs.keys(), + expected_custom_types) + + def test_invalid_template_file(self): + template_file = 'invalid template file' + expected_msg = (_('"%s" is not a valid file.') % template_file) + self.assertRaises( + exception.ValidationError, + ToscaTemplate, template_file, None, False) + exception.ExceptionCollector.assertExceptionMessage(ValueError, + expected_msg) + + def test_multiple_validation_errors(self): + tosca_tpl = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/test_multiple_validation_errors.yaml") + self.assertRaises(exception.ValidationError, ToscaTemplate, tosca_tpl, + None) + err1_msg = _('The template version "tosca_simple_yaml_1" is invalid. ' + 'Valid versions are "tosca_simple_yaml_1_0".') + exception.ExceptionCollector.assertExceptionMessage( + exception.InvalidTemplateVersion, err1_msg) + + err2_msg = _('Import "custom_types/not_there.yaml" is not valid.') + exception.ExceptionCollector.assertExceptionMessage( + ImportError, err2_msg) + + err3_msg = _('Type "tosca.nodes.WebApplication.WordPress" is not a ' + 'valid type.') + exception.ExceptionCollector.assertExceptionMessage( + exception.InvalidTypeError, err3_msg) + + err4_msg = _('Node template "wordpress" contains unknown field ' + '"requirement". Refer to the definition to verify valid ' + 'values.') + exception.ExceptionCollector.assertExceptionMessage( + exception.UnknownFieldError, err4_msg) + + err5_msg = _('\'Property "passwords" was not found in node template ' + '"mysql_database".\'') + exception.ExceptionCollector.assertExceptionMessage( + KeyError, err5_msg) + + err6_msg = _('Template "mysql_dbms" is missing required field "type".') + exception.ExceptionCollector.assertExceptionMessage( + exception.MissingRequiredFieldError, err6_msg) + + err7_msg = _('Node template "mysql_dbms" contains unknown field ' + '"type1". Refer to the definition to verify valid ' + 'values.') + exception.ExceptionCollector.assertExceptionMessage( + exception.UnknownFieldError, err7_msg) + + err8_msg = _('\'Node template "server1" was not found.\'') + exception.ExceptionCollector.assertExceptionMessage( + KeyError, err8_msg) + + err9_msg = _('"relationship" used in template "webserver" is missing ' + 'required field "type".') + exception.ExceptionCollector.assertExceptionMessage( + exception.MissingRequiredFieldError, err9_msg) + + def test_invalid_section_names(self): + tosca_tpl = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/test_invalid_section_names.yaml") + self.assertRaises(exception.ValidationError, ToscaTemplate, tosca_tpl, + None) + err1_msg = _('Template contains unknown field ' + '"tosca_definitions_versions". Refer to the definition ' + 'to verify valid values.') + exception.ExceptionCollector.assertExceptionMessage( + exception.UnknownFieldError, err1_msg) + + err2_msg = _('Template contains unknown field "descriptions". ' + 'Refer to the definition to verify valid values.') + exception.ExceptionCollector.assertExceptionMessage( + exception.UnknownFieldError, err2_msg) + + err3_msg = _('Template contains unknown field "import". Refer to ' + 'the definition to verify valid values.') + exception.ExceptionCollector.assertExceptionMessage( + exception.UnknownFieldError, err3_msg) + + err4_msg = _('Template contains unknown field "topology_templates". ' + 'Refer to the definition to verify valid values.') + exception.ExceptionCollector.assertExceptionMessage( + exception.UnknownFieldError, err4_msg) + + def test_csar_with_alternate_extenstion(self): + tosca_tpl = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/CSAR/csar_elk.csar") + tosca = ToscaTemplate(tosca_tpl) + self.assertTrue(tosca.topology_template.custom_defs) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_toscatplvalidation.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_toscatplvalidation.py new file mode 100644 index 0000000..714534e --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_toscatplvalidation.py @@ -0,0 +1,1109 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import os +import six + +from toscaparser.common import exception +from toscaparser.imports import ImportsLoader +from toscaparser.nodetemplate import NodeTemplate +from toscaparser.parameters import Input +from toscaparser.parameters import Output +from toscaparser.relationship_template import RelationshipTemplate +from toscaparser.tests.base import TestCase +from toscaparser.tosca_template import ToscaTemplate +from toscaparser.utils.gettextutils import _ + +import toscaparser.utils.yamlparser + + +class ToscaTemplateValidationTest(TestCase): + + def test_well_defined_template(self): + tpl_path = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/tosca_single_instance_wordpress.yaml") + self.assertIsNotNone(ToscaTemplate(tpl_path)) + + def test_first_level_sections(self): + tpl_path = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/test_tosca_top_level_error1.yaml") + self.assertRaises(exception.ValidationError, ToscaTemplate, tpl_path) + exception.ExceptionCollector.assertExceptionMessage( + exception.MissingRequiredFieldError, + _('Template is missing required field ' + '"tosca_definitions_version".')) + + tpl_path = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/test_tosca_top_level_error2.yaml") + self.assertRaises(exception.ValidationError, ToscaTemplate, tpl_path) + exception.ExceptionCollector.assertExceptionMessage( + exception.UnknownFieldError, + _('Template contains unknown field "node_template". Refer to the ' + 'definition to verify valid values.')) + + def test_inputs(self): + tpl_snippet = ''' + inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraint: + - valid_values: [ 1, 2, 4, 8 ] + ''' + inputs = (toscaparser.utils.yamlparser. + simple_parse(tpl_snippet)['inputs']) + name, attrs = list(inputs.items())[0] + input = Input(name, attrs) + err = self.assertRaises(exception.UnknownFieldError, input.validate) + self.assertEqual(_('Input "cpus" contains unknown field "constraint". ' + 'Refer to the definition to verify valid values.'), + err.__str__()) + + def _imports_content_test(self, tpl_snippet, path, custom_type_def): + imports = (toscaparser.utils.yamlparser. + simple_parse(tpl_snippet)['imports']) + loader = ImportsLoader(imports, path, custom_type_def) + return loader.get_custom_defs() + + def test_imports_without_templates(self): + tpl_snippet = ''' + imports: + # omitted here for brevity + ''' + path = 'toscaparser/tests/data/tosca_elk.yaml' + errormsg = _('"imports" keyname is defined without including ' + 'templates.') + err = self.assertRaises(exception.ValidationError, + self._imports_content_test, + tpl_snippet, + path, + "node_types") + self.assertEqual(errormsg, err.__str__()) + + def test_imports_with_name_without_templates(self): + tpl_snippet = ''' + imports: + - some_definitions: + ''' + path = 'toscaparser/tests/data/tosca_elk.yaml' + errormsg = _('A template file name is not provided with import ' + 'definition "some_definitions".') + err = self.assertRaises(exception.ValidationError, + self._imports_content_test, + tpl_snippet, path, None) + self.assertEqual(errormsg, err.__str__()) + + def test_imports_without_import_name(self): + tpl_snippet = ''' + imports: + - custom_types/paypalpizzastore_nodejs_app.yaml + - https://raw.githubusercontent.com/openstack/\ +tosca-parser/master/toscaparser/tests/data/custom_types/wordpress.yaml + ''' + path = 'toscaparser/tests/data/tosca_elk.yaml' + custom_defs = self._imports_content_test(tpl_snippet, + path, + "node_types") + self.assertTrue(custom_defs) + + def test_imports_wth_import_name(self): + tpl_snippet = ''' + imports: + - some_definitions: custom_types/paypalpizzastore_nodejs_app.yaml + - more_definitions: + file: toscaparser/tests/data/custom_types/wordpress.yaml + repository: tosca-parser/master + namespace_uri: https://raw.githubusercontent.com/openstack + namespace_prefix: single_instance_wordpress + ''' + path = 'toscaparser/tests/data/tosca_elk.yaml' + custom_defs = self._imports_content_test(tpl_snippet, + path, + "node_types") + self.assertTrue(custom_defs.get("tosca.nodes." + "WebApplication.WordPress")) + + def test_imports_with_no_main_template(self): + tpl_snippet = ''' + imports: + - some_definitions: https://raw.githubusercontent.com/openstack/\ +tosca-parser/master/toscaparser/tests/data/custom_types/wordpress.yaml + - some_definitions: + file: my_defns/my_typesdefs_n.yaml + ''' + errormsg = _('Input tosca template is not provided.') + err = self.assertRaises(exception.ValidationError, + self._imports_content_test, + tpl_snippet, None, None) + self.assertEqual(errormsg, err.__str__()) + + def test_imports_duplicate_name(self): + tpl_snippet = ''' + imports: + - some_definitions: https://raw.githubusercontent.com/openstack/\ +tosca-parser/master/toscaparser/tests/data/custom_types/wordpress.yaml + - some_definitions: + file: my_defns/my_typesdefs_n.yaml + ''' + errormsg = _('Duplicate import name "some_definitions" was found.') + path = 'toscaparser/tests/data/tosca_elk.yaml' + err = self.assertRaises(exception.ValidationError, + self._imports_content_test, + tpl_snippet, path, None) + self.assertEqual(errormsg, err.__str__()) + + def test_imports_missing_req_field_in_def(self): + tpl_snippet = ''' + imports: + - more_definitions: + file1: my_defns/my_typesdefs_n.yaml + repository: my_company_repo + namespace_uri: http://mycompany.com/ns/tosca/2.0 + namespace_prefix: mycompany + ''' + errormsg = _('Import of template "more_definitions" is missing ' + 'required field "file".') + path = 'toscaparser/tests/data/tosca_elk.yaml' + err = self.assertRaises(exception.MissingRequiredFieldError, + self._imports_content_test, + tpl_snippet, path, None) + self.assertEqual(errormsg, err.__str__()) + + def test_imports_file_with_uri(self): + tpl_snippet = ''' + imports: + - more_definitions: + file: https://raw.githubusercontent.com/openstack/\ +tosca-parser/master/toscaparser/tests/data/custom_types/wordpress.yaml + namespace_prefix: mycompany + ''' + path = 'https://raw.githubusercontent.com/openstack/\ +tosca-parser/master/toscaparser/tests/data/\ +tosca_single_instance_wordpress_with_url_import.yaml' + custom_defs = self._imports_content_test(tpl_snippet, + path, + "node_types") + self.assertTrue(custom_defs.get("tosca.nodes." + "WebApplication.WordPress")) + + def test_imports_file_namespace_fields(self): + tpl_snippet = ''' + imports: + - more_definitions: + file: heat-translator/master/translator/tests/data/\ +custom_types/wordpress.yaml + namespace_uri: https://raw.githubusercontent.com/openstack/ + namespace_prefix: mycompany + ''' + path = 'toscaparser/tests/data/tosca_elk.yaml' + custom_defs = self._imports_content_test(tpl_snippet, + path, + "node_types") + self.assertTrue(custom_defs.get("tosca.nodes." + "WebApplication.WordPress")) + + def test_import_error_namespace_uri(self): + tpl_snippet = ''' + imports: + - more_definitions: + file: toscaparser/tests/data/tosca_elk.yaml + namespace_uri: mycompany.com/ns/tosca/2.0 + namespace_prefix: mycompany + ''' + errormsg = _('namespace_uri "mycompany.com/ns/tosca/2.0" is not ' + 'valid in import definition "more_definitions".') + path = 'toscaparser/tests/data/tosca_elk.yaml' + err = self.assertRaises(ImportError, + self._imports_content_test, + tpl_snippet, path, None) + self.assertEqual(errormsg, err.__str__()) + + def test_import_single_line_error(self): + tpl_snippet = ''' + imports: + - some_definitions: abc.com/tests/data/tosca_elk.yaml + ''' + errormsg = _('Import "abc.com/tests/data/tosca_elk.yaml" is not ' + 'valid.') + path = 'toscaparser/tests/data/tosca_elk.yaml' + err = self.assertRaises(ImportError, + self._imports_content_test, + tpl_snippet, path, None) + self.assertEqual(errormsg, err.__str__()) + + def test_outputs(self): + tpl_snippet = ''' + outputs: + server_address: + description: IP address of server instance. + values: { get_property: [server, private_address] } + ''' + outputs = (toscaparser.utils.yamlparser. + simple_parse(tpl_snippet)['outputs']) + name, attrs = list(outputs.items())[0] + output = Output(name, attrs) + try: + output.validate() + except Exception as err: + self.assertTrue( + isinstance(err, exception.MissingRequiredFieldError)) + self.assertEqual(_('Output "server_address" is missing required ' + 'field "value".'), err.__str__()) + + tpl_snippet = ''' + outputs: + server_address: + descriptions: IP address of server instance. + value: { get_property: [server, private_address] } + ''' + outputs = (toscaparser.utils.yamlparser. + simple_parse(tpl_snippet)['outputs']) + name, attrs = list(outputs.items())[0] + output = Output(name, attrs) + try: + output.validate() + except Exception as err: + self.assertTrue(isinstance(err, exception.UnknownFieldError)) + self.assertEqual(_('Output "server_address" contains unknown ' + 'field "descriptions". Refer to the definition ' + 'to verify valid values.'), + err.__str__()) + + def _custom_types(self): + custom_types = {} + def_file = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/custom_types/wordpress.yaml") + custom_type = toscaparser.utils.yamlparser.load_yaml(def_file) + node_types = custom_type['node_types'] + for name in node_types: + defintion = node_types[name] + custom_types[name] = defintion + return custom_types + + def _single_node_template_content_test(self, tpl_snippet): + nodetemplates = (toscaparser.utils.yamlparser. + simple_ordered_parse(tpl_snippet))['node_templates'] + name = list(nodetemplates.keys())[0] + nodetemplate = NodeTemplate(name, nodetemplates, + self._custom_types()) + nodetemplate.validate() + nodetemplate.requirements + nodetemplate.get_capabilities_objects() + nodetemplate.get_properties_objects() + nodetemplate.interfaces + + def test_node_templates(self): + tpl_snippet = ''' + node_templates: + server: + capabilities: + host: + properties: + disk_size: 10 + num_cpus: 4 + mem_size: 4096 + os: + properties: + architecture: x86_64 + type: Linux + distribution: Fedora + version: 18.0 + ''' + expectedmessage = _('Template "server" is missing required field ' + '"type".') + err = self.assertRaises( + exception.MissingRequiredFieldError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + def test_node_template_with_wrong_properties_keyname(self): + """Node template keyname 'properties' given as 'propertiessss'.""" + tpl_snippet = ''' + node_templates: + mysql_dbms: + type: tosca.nodes.DBMS + propertiessss: + root_password: aaa + port: 3376 + ''' + expectedmessage = _('Node template "mysql_dbms" contains unknown ' + 'field "propertiessss". Refer to the definition ' + 'to verify valid values.') + err = self.assertRaises( + exception.UnknownFieldError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + def test_node_template_with_wrong_requirements_keyname(self): + """Node template keyname 'requirements' given as 'requirement'.""" + tpl_snippet = ''' + node_templates: + mysql_dbms: + type: tosca.nodes.DBMS + properties: + root_password: aaa + port: 3376 + requirement: + - host: server + ''' + expectedmessage = _('Node template "mysql_dbms" contains unknown ' + 'field "requirement". Refer to the definition to ' + 'verify valid values.') + err = self.assertRaises( + exception.UnknownFieldError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + def test_node_template_with_wrong_interfaces_keyname(self): + """Node template keyname 'interfaces' given as 'interfac'.""" + tpl_snippet = ''' + node_templates: + mysql_dbms: + type: tosca.nodes.DBMS + properties: + root_password: aaa + port: 3376 + requirements: + - host: server + interfac: + Standard: + configure: mysql_database_configure.sh + ''' + expectedmessage = _('Node template "mysql_dbms" contains unknown ' + 'field "interfac". Refer to the definition to ' + 'verify valid values.') + err = self.assertRaises( + exception.UnknownFieldError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + def test_node_template_with_wrong_capabilities_keyname(self): + """Node template keyname 'capabilities' given as 'capabilitiis'.""" + tpl_snippet = ''' + node_templates: + 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 } + capabilitiis: + database_endpoint: + properties: + port: { get_input: db_port } + ''' + expectedmessage = _('Node template "mysql_database" contains unknown ' + 'field "capabilitiis". Refer to the definition to ' + 'verify valid values.') + err = self.assertRaises( + exception.UnknownFieldError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + def test_node_template_with_wrong_artifacts_keyname(self): + """Node template keyname 'artifacts' given as 'artifactsss'.""" + tpl_snippet = ''' + node_templates: + mysql_database: + type: tosca.nodes.Database + artifactsss: + db_content: + implementation: files/my_db_content.txt + type: tosca.artifacts.File + ''' + expectedmessage = _('Node template "mysql_database" contains unknown ' + 'field "artifactsss". Refer to the definition to ' + 'verify valid values.') + err = self.assertRaises( + exception.UnknownFieldError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + def test_node_template_with_multiple_wrong_keynames(self): + """Node templates given with multiple wrong keynames.""" + tpl_snippet = ''' + node_templates: + mysql_dbms: + type: tosca.nodes.DBMS + propertieees: + root_password: aaa + port: 3376 + requirements: + - host: server + interfacs: + Standard: + configure: mysql_database_configure.sh + ''' + expectedmessage = _('Node template "mysql_dbms" contains unknown ' + 'field "propertieees". Refer to the definition to ' + 'verify valid values.') + err = self.assertRaises( + exception.UnknownFieldError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + tpl_snippet = ''' + node_templates: + mysql_database: + type: tosca.nodes.Database + properties: + name: { get_input: db_name } + user: { get_input: db_user } + password: { get_input: db_pwd } + capabilitiiiies: + database_endpoint: + properties: + port: { get_input: db_port } + requirementsss: + - host: + node: mysql_dbms + interfac: + Standard: + configure: mysql_database_configure.sh + + ''' + expectedmessage = _('Node template "mysql_database" contains unknown ' + 'field "capabilitiiiies". Refer to the definition ' + 'to verify valid values.') + err = self.assertRaises( + exception.UnknownFieldError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + def test_node_template_type(self): + tpl_snippet = ''' + node_templates: + mysql_database: + type: tosca.nodes.Databases + 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: + Standard: + configure: mysql_database_configure.sh + ''' + expectedmessage = _('Type "tosca.nodes.Databases" is not ' + 'a valid type.') + err = self.assertRaises( + exception.InvalidTypeError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + def test_node_template_requirements(self): + tpl_snippet = ''' + node_templates: + webserver: + type: tosca.nodes.WebServer + requirements: + host: server + interfaces: + Standard: + create: webserver_install.sh + start: d.sh + ''' + expectedmessage = _('"requirements" of template "webserver" must be ' + 'of type "list".') + err = self.assertRaises( + exception.TypeMismatchError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + tpl_snippet = ''' + node_templates: + 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 + - database_endpoint: mysql_database + interfaces: + Standard: + configure: mysql_database_configure.sh + ''' + expectedmessage = _('"requirements" of template "mysql_database" ' + 'contains unknown field "database_endpoint". ' + 'Refer to the definition to verify valid values.') + err = self.assertRaises( + exception.UnknownFieldError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + def test_node_template_requirements_with_wrong_node_keyname(self): + """Node template requirements keyname 'node' given as 'nodes'.""" + tpl_snippet = ''' + node_templates: + mysql_database: + type: tosca.nodes.Database + requirements: + - host: + nodes: mysql_dbms + + ''' + expectedmessage = _('"requirements" of template "mysql_database" ' + 'contains unknown field "nodes". Refer to the ' + 'definition to verify valid values.') + err = self.assertRaises( + exception.UnknownFieldError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + def test_node_template_requirements_with_wrong_capability_keyname(self): + """Incorrect node template requirements keyname + + Node template requirements keyname 'capability' given as + 'capabilityy'. + """ + tpl_snippet = ''' + node_templates: + mysql_database: + type: tosca.nodes.Database + requirements: + - host: + node: mysql_dbms + - log_endpoint: + node: logstash + capabilityy: log_endpoint + relationship: + type: tosca.relationships.ConnectsTo + + ''' + expectedmessage = _('"requirements" of template "mysql_database" ' + 'contains unknown field "capabilityy". Refer to ' + 'the definition to verify valid values.') + err = self.assertRaises( + exception.UnknownFieldError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + def test_node_template_requirements_with_wrong_relationship_keyname(self): + """Incorrect node template requirements keyname + + Node template requirements keyname 'relationship' given as + 'relationshipppp'. + """ + tpl_snippet = ''' + node_templates: + mysql_database: + type: tosca.nodes.Database + requirements: + - host: + node: mysql_dbms + - log_endpoint: + node: logstash + capability: log_endpoint + relationshipppp: + type: tosca.relationships.ConnectsTo + + ''' + expectedmessage = _('"requirements" of template "mysql_database" ' + 'contains unknown field "relationshipppp". Refer ' + 'to the definition to verify valid values.') + err = self.assertRaises( + exception.UnknownFieldError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + def test_node_template_requirements_with_wrong_occurrences_keyname(self): + """Incorrect node template requirements keyname + + Node template requirements keyname 'occurrences' given as + 'occurences'. + """ + tpl_snippet = ''' + node_templates: + mysql_database: + type: tosca.nodes.Database + requirements: + - host: + node: mysql_dbms + - log_endpoint: + node: logstash + capability: log_endpoint + relationship: + type: tosca.relationships.ConnectsTo + occurences: [0, UNBOUNDED] + ''' + expectedmessage = _('"requirements" of template "mysql_database" ' + 'contains unknown field "occurences". Refer to ' + 'the definition to verify valid values.') + err = self.assertRaises( + exception.UnknownFieldError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + def test_node_template_requirements_with_multiple_wrong_keynames(self): + """Node templates given with multiple wrong requirements keynames.""" + tpl_snippet = ''' + node_templates: + mysql_database: + type: tosca.nodes.Database + requirements: + - host: + node: mysql_dbms + - log_endpoint: + nod: logstash + capabilit: log_endpoint + relationshipppp: + type: tosca.relationships.ConnectsTo + + ''' + expectedmessage = _('"requirements" of template "mysql_database" ' + 'contains unknown field "nod". Refer to the ' + 'definition to verify valid values.') + err = self.assertRaises( + exception.UnknownFieldError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + tpl_snippet = ''' + node_templates: + mysql_database: + type: tosca.nodes.Database + requirements: + - host: + node: mysql_dbms + - log_endpoint: + node: logstash + capabilit: log_endpoint + relationshipppp: + type: tosca.relationships.ConnectsTo + + ''' + expectedmessage = _('"requirements" of template "mysql_database" ' + 'contains unknown field "capabilit". Refer to the ' + 'definition to verify valid values.') + err = self.assertRaises( + exception.UnknownFieldError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + def test_node_template_requirements_invalid_occurrences(self): + tpl_snippet = ''' + node_templates: + server: + type: tosca.nodes.Compute + requirements: + - log_endpoint: + capability: log_endpoint + occurrences: [0, -1] + ''' + expectedmessage = _('Value of property "[0, -1]" is invalid.') + err = self.assertRaises( + exception.InvalidPropertyValueError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + tpl_snippet = ''' + node_templates: + server: + type: tosca.nodes.Compute + requirements: + - log_endpoint: + capability: log_endpoint + occurrences: [a, w] + ''' + expectedmessage = _('"a" is not an integer.') + err = self.assertRaises( + ValueError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + tpl_snippet = ''' + node_templates: + server: + type: tosca.nodes.Compute + requirements: + - log_endpoint: + capability: log_endpoint + occurrences: -1 + ''' + expectedmessage = _('"-1" is not a list.') + err = self.assertRaises( + ValueError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + tpl_snippet = ''' + node_templates: + server: + type: tosca.nodes.Compute + requirements: + - log_endpoint: + capability: log_endpoint + occurrences: [5, 1] + ''' + expectedmessage = _('Value of property "[5, 1]" is invalid.') + err = self.assertRaises( + exception.InvalidPropertyValueError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + tpl_snippet = ''' + node_templates: + server: + type: tosca.nodes.Compute + requirements: + - log_endpoint: + capability: log_endpoint + occurrences: [0, 0] + ''' + expectedmessage = _('Value of property "[0, 0]" is invalid.') + err = self.assertRaises( + exception.InvalidPropertyValueError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + def test_node_template_requirements_valid_occurrences(self): + tpl_snippet = ''' + node_templates: + server: + type: tosca.nodes.Compute + requirements: + - log_endpoint: + capability: log_endpoint + occurrences: [2, 2] + ''' + self._single_node_template_content_test(tpl_snippet) + + def test_node_template_capabilities(self): + tpl_snippet = ''' + node_templates: + 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: + http_endpoint: + properties: + port: { get_input: db_port } + requirements: + - host: mysql_dbms + interfaces: + Standard: + configure: mysql_database_configure.sh + ''' + expectedmessage = _('"capabilities" of template "mysql_database" ' + 'contains unknown field "http_endpoint". Refer to ' + 'the definition to verify valid values.') + err = self.assertRaises( + exception.UnknownFieldError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + def test_node_template_properties(self): + tpl_snippet = ''' + node_templates: + server: + type: tosca.nodes.Compute + properties: + os_image: F18_x86_64 + 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.0 + ''' + expectedmessage = _('"properties" of template "server" contains ' + 'unknown field "os_image". Refer to the ' + 'definition to verify valid values.') + err = self.assertRaises( + exception.UnknownFieldError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + def test_node_template_interfaces(self): + tpl_snippet = ''' + node_templates: + wordpress: + type: tosca.nodes.WebApplication.WordPress + requirements: + - host: webserver + - database_endpoint: mysql_database + interfaces: + Standards: + create: wordpress_install.sh + configure: + implementation: 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 ] } + ''' + expectedmessage = _('"interfaces" of template "wordpress" contains ' + 'unknown field "Standards". Refer to the ' + 'definition to verify valid values.') + err = self.assertRaises( + exception.UnknownFieldError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + tpl_snippet = ''' + node_templates: + wordpress: + type: tosca.nodes.WebApplication.WordPress + requirements: + - host: webserver + - database_endpoint: mysql_database + interfaces: + Standard: + create: wordpress_install.sh + config: + implementation: 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 ] } + ''' + expectedmessage = _('"interfaces" of template "wordpress" contains ' + 'unknown field "config". Refer to the definition ' + 'to verify valid values.') + err = self.assertRaises( + exception.UnknownFieldError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + tpl_snippet = ''' + node_templates: + wordpress: + type: tosca.nodes.WebApplication.WordPress + requirements: + - host: webserver + - database_endpoint: mysql_database + interfaces: + Standard: + create: wordpress_install.sh + configure: + implementation: wordpress_configure.sh + input: + 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_ref_property: [ database_endpoint, \ + database_endpoint, port ] } + ''' + expectedmessage = _('"interfaces" of template "wordpress" contains ' + 'unknown field "input". Refer to the definition ' + 'to verify valid values.') + err = self.assertRaises( + exception.UnknownFieldError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + def test_relationship_template_properties(self): + tpl_snippet = ''' + relationship_templates: + storage_attachto: + type: AttachesTo + properties: + device: test_device + ''' + expectedmessage = _('"properties" of template "storage_attachto" is ' + 'missing required field "[\'location\']".') + rel_template = (toscaparser.utils.yamlparser. + simple_parse(tpl_snippet))['relationship_templates'] + name = list(rel_template.keys())[0] + rel_template = RelationshipTemplate(rel_template[name], name) + err = self.assertRaises(exception.MissingRequiredFieldError, + rel_template.validate) + self.assertEqual(expectedmessage, six.text_type(err)) + + def test_invalid_template_version(self): + tosca_tpl = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/test_invalid_template_version.yaml") + self.assertRaises(exception.ValidationError, ToscaTemplate, tosca_tpl) + valid_versions = ', '.join(ToscaTemplate.VALID_TEMPLATE_VERSIONS) + exception.ExceptionCollector.assertExceptionMessage( + exception.InvalidTemplateVersion, + (_('The template version "tosca_xyz" is invalid. Valid versions ' + 'are "%s".') % valid_versions)) + + def test_node_template_capabilities_properties(self): + tpl_snippet = ''' + node_templates: + 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.0 + scalable: + properties: + min_instances: 1 + default_instances: 5 + ''' + expectedmessage = _('"properties" of template "server" is missing ' + 'required field "[\'max_instances\']".') + err = self.assertRaises( + exception.MissingRequiredFieldError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + # validating capability property values + tpl_snippet = ''' + node_templates: + server: + type: tosca.nodes.WebServer + capabilities: + data_endpoint: + properties: + initiator: test + ''' + expectedmessage = _('The value "test" of property "initiator" is ' + 'not valid. Expected a value from "[source, ' + 'target, peer]".') + + err = self.assertRaises( + exception.ValidationError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + tpl_snippet = ''' + node_templates: + 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.0 + scalable: + properties: + min_instances: 1 + max_instances: 3 + default_instances: 5 + ''' + expectedmessage = _('"properties" of template "server": ' + '"default_instances" value is not between ' + '"min_instances" and "max_instances".') + err = self.assertRaises( + exception.ValidationError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + def test_node_template_objectstorage_without_required_property(self): + tpl_snippet = ''' + node_templates: + server: + type: tosca.nodes.ObjectStorage + properties: + maxsize: 1 GB + ''' + expectedmessage = _('"properties" of template "server" is missing ' + 'required field "[\'name\']".') + err = self.assertRaises( + exception.MissingRequiredFieldError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + def test_node_template_objectstorage_with_invalid_scalar_unit(self): + tpl_snippet = ''' + node_templates: + server: + type: tosca.nodes.ObjectStorage + properties: + name: test + maxsize: -1 + ''' + expectedmessage = _('"-1" is not a valid scalar-unit.') + err = self.assertRaises( + ValueError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + def test_node_template_objectstorage_with_invalid_scalar_type(self): + tpl_snippet = ''' + node_templates: + server: + type: tosca.nodes.ObjectStorage + properties: + name: test + maxsize: 1 XB + ''' + expectedmessage = _('"1 XB" is not a valid scalar-unit.') + err = self.assertRaises( + ValueError, + lambda: self._single_node_template_content_test(tpl_snippet)) + self.assertEqual(expectedmessage, err.__str__()) + + def test_special_keywords(self): + """Test special keywords + + Test that special keywords, e.g. metadata, which are not part + of specification do not throw any validation error. + """ + tpl_snippet_metadata_map = ''' + node_templates: + server: + type: tosca.nodes.Compute + metadata: + name: server A + role: master + ''' + self._single_node_template_content_test(tpl_snippet_metadata_map) + + tpl_snippet_metadata_inline = ''' + node_templates: + server: + type: tosca.nodes.Compute + metadata: none + ''' + self._single_node_template_content_test(tpl_snippet_metadata_inline) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_utils.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_utils.py new file mode 100644 index 0000000..a0c8a6d --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_utils.py @@ -0,0 +1,60 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from toscaparser.common.exception import URLException +from toscaparser.tests.base import TestCase +from toscaparser.utils.gettextutils import _ +import toscaparser.utils.urlutils +import toscaparser.utils.yamlparser + +YAML_LOADER = toscaparser.utils.yamlparser.load_yaml + + +class UrlUtilsTest(TestCase): + + url_utils = toscaparser.utils.urlutils.UrlUtils + + def test_urlutils_validate_url(self): + self.assertTrue(self.url_utils.validate_url("http://www.github.com/")) + self.assertTrue( + self.url_utils.validate_url("https://github.com:81/a/2/a.b")) + self.assertTrue(self.url_utils.validate_url("ftp://github.com")) + self.assertFalse(self.url_utils.validate_url("github.com")) + self.assertFalse(self.url_utils.validate_url("123")) + self.assertFalse(self.url_utils.validate_url("a/b/c")) + + def test_urlutils_join_url(self): + self.assertEqual( + self.url_utils.join_url("http://github.com/proj1", "proj2"), + "http://github.com/proj2") + self.assertEqual( + self.url_utils.join_url("http://github.com/proj1/scripts/a.js", + "b.js"), + "http://github.com/proj1/scripts/b.js") + self.assertEqual( + self.url_utils.join_url("http://github.com/proj1/scripts", "b.js"), + "http://github.com/proj1/b.js") + self.assertEqual( + self.url_utils.join_url("http://github.com/proj1/scripts", + "scripts/b.js"), + "http://github.com/proj1/scripts/b.js") + + def test_load_url_errors(self): + url = "http://www.badurl." + err_msg = (_('Failed to reach server "%(url)s". Reason is: ' + '[Errno -2] Name or service not known.') + % {'url': url}) + err = self.assertRaises(URLException, + YAML_LOADER, + url, + False) + self.assertEqual(err_msg, err.__str__()) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_validate_tosca_version.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_validate_tosca_version.py new file mode 100644 index 0000000..e9a8ac2 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tests/test_validate_tosca_version.py @@ -0,0 +1,132 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from toscaparser.common.exception import ( + InvalidTOSCAVersionPropertyException) +from toscaparser.tests.base import TestCase +from toscaparser.utils.gettextutils import _ +from toscaparser.utils.validateutils import TOSCAVersionProperty + + +class TOSCAVersionPropertyTest(TestCase): + + def test_tosca_version_property(self): + version = '18.0.3.beta-1' + expected_output = '18.0.3.beta-1' + output = TOSCAVersionProperty(version).get_version() + self.assertEqual(output, expected_output) + + version = 18 + expected_output = '18.0' + output = TOSCAVersionProperty(version).get_version() + self.assertEqual(output, expected_output) + + version = 18.0 + expected_output = '18.0' + output = TOSCAVersionProperty(version).get_version() + self.assertEqual(output, expected_output) + + version = '18.0.3' + expected_output = '18.0.3' + output = TOSCAVersionProperty(version).get_version() + self.assertEqual(output, expected_output) + + version = 0 + expected_output = None + output = TOSCAVersionProperty(version).get_version() + self.assertEqual(output, expected_output) + + version = 00 + expected_output = None + output = TOSCAVersionProperty(version).get_version() + self.assertEqual(output, expected_output) + + version = 0.0 + expected_output = None + output = TOSCAVersionProperty(version).get_version() + self.assertEqual(output, expected_output) + + version = 00.00 + expected_output = None + output = TOSCAVersionProperty(version).get_version() + self.assertEqual(output, expected_output) + + version = '0.0.0' + expected_output = None + output = TOSCAVersionProperty(version).get_version() + self.assertEqual(output, expected_output) + + def test_tosca_version_property_invalid_major_version(self): + + version = 'x' + exp_msg = _('Value of TOSCA version property "x" is invalid.') + err = self.assertRaises(InvalidTOSCAVersionPropertyException, + TOSCAVersionProperty, version) + self.assertEqual(exp_msg, err.__str__()) + + def test_tosca_version_property_invalid_minor_version(self): + + version = '18.x' + exp_msg = _('Value of TOSCA version property "18.x" is invalid.') + err = self.assertRaises(InvalidTOSCAVersionPropertyException, + TOSCAVersionProperty, version) + self.assertEqual(exp_msg, err.__str__()) + + version = '18.x.y' + exp_msg = _('Value of TOSCA version property "18.x.y" is invalid.') + err = self.assertRaises(InvalidTOSCAVersionPropertyException, + TOSCAVersionProperty, version) + self.assertEqual(exp_msg, err.__str__()) + + version = '18-2' + exp_msg = _('Value of TOSCA version property "18-2" is invalid.') + err = self.assertRaises(InvalidTOSCAVersionPropertyException, + TOSCAVersionProperty, version) + self.assertEqual(exp_msg, err.__str__()) + + def test_tosca_version_property_invalid_fix_version(self): + + version = '18.0.a' + exp_msg = _('Value of TOSCA version property "18.0.a" is invalid.') + err = self.assertRaises(InvalidTOSCAVersionPropertyException, + TOSCAVersionProperty, version) + self.assertEqual(exp_msg, err.__str__()) + + def test_tosca_version_property_invalid_qualifier(self): + + version = '18.0.1-xyz' + exp_msg = _('Value of TOSCA version property "18.0.1-xyz" is invalid.') + err = self.assertRaises(InvalidTOSCAVersionPropertyException, + TOSCAVersionProperty, version) + self.assertEqual(exp_msg, err.__str__()) + + version = '0.0.0.abc' + exp_msg = _('Value of TOSCA version property "0.0.0.abc" is invalid.') + err = self.assertRaises(InvalidTOSCAVersionPropertyException, + TOSCAVersionProperty, version) + self.assertEqual(exp_msg, err.__str__()) + + def test_tosca_version_property_invalid_build_version(self): + + version = '18.0.1.abc-x' + exp_msg = _('Value of TOSCA version property ' + '"18.0.1.abc-x" is invalid.') + err = self.assertRaises(InvalidTOSCAVersionPropertyException, + TOSCAVersionProperty, version) + self.assertEqual(exp_msg, err.__str__()) + + version = '0.0.0.abc-x' + exp_msg = _('Value of TOSCA version property "0.0.0.abc-x" is ' + 'invalid.') + err = self.assertRaises(InvalidTOSCAVersionPropertyException, + TOSCAVersionProperty, version) + self.assertEqual(exp_msg, err.__str__()) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/topology_template.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/topology_template.py new file mode 100644 index 0000000..6c8f220 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/topology_template.py @@ -0,0 +1,222 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +import logging + +from toscaparser.common import exception +from toscaparser import functions +from toscaparser.groups import NodeGroup +from toscaparser.nodetemplate import NodeTemplate +from toscaparser.parameters import Input +from toscaparser.parameters import Output +from toscaparser.relationship_template import RelationshipTemplate +from toscaparser.tpl_relationship_graph import ToscaGraph + + +# Topology template key names +SECTIONS = (DESCRIPTION, INPUTS, NODE_TEMPLATES, + RELATIONSHIP_TEMPLATES, OUTPUTS, GROUPS, + SUBSTITUION_MAPPINGS) = \ + ('description', 'inputs', 'node_templates', + 'relationship_templates', 'outputs', 'groups', + 'substitution_mappings') + +log = logging.getLogger("tosca.model") + + +class TopologyTemplate(object): + + '''Load the template data.''' + def __init__(self, template, custom_defs, + rel_types=None, parsed_params=None): + self.tpl = template + if self.tpl: + self.custom_defs = custom_defs + self.rel_types = rel_types + self.parsed_params = parsed_params + self._validate_field() + self.description = self._tpl_description() + self.inputs = self._inputs() + self.relationship_templates = self._relationship_templates() + self.nodetemplates = self._nodetemplates() + self.outputs = self._outputs() + if hasattr(self, 'nodetemplates'): + self.graph = ToscaGraph(self.nodetemplates) + self.groups = self._groups() + self._process_intrinsic_functions() + + def _inputs(self): + inputs = [] + for name, attrs in self._tpl_inputs().items(): + input = Input(name, attrs) + if self.parsed_params and name in self.parsed_params: + input.validate(self.parsed_params[name]) + inputs.append(input) + return inputs + + def _nodetemplates(self): + nodetemplates = [] + tpls = self._tpl_nodetemplates() + if tpls: + for name in tpls: + tpl = NodeTemplate(name, tpls, self.custom_defs, + self.relationship_templates, + self.rel_types) + if (tpl.type_definition and + (tpl.type in tpl.type_definition.TOSCA_DEF or + (tpl.type not in tpl.type_definition.TOSCA_DEF and + bool(tpl.custom_def)))): + tpl.validate(self) + nodetemplates.append(tpl) + return nodetemplates + + def _relationship_templates(self): + rel_templates = [] + tpls = self._tpl_relationship_templates() + for name in tpls: + tpl = RelationshipTemplate(tpls[name], name, self.custom_defs) + rel_templates.append(tpl) + return rel_templates + + def _outputs(self): + outputs = [] + for name, attrs in self._tpl_outputs().items(): + output = Output(name, attrs) + output.validate() + outputs.append(output) + return outputs + + def _substitution_mappings(self): + pass + + def _groups(self): + groups = [] + for group_name, group_tpl in self._tpl_groups().items(): + member_names = group_tpl.get('members') + if member_names and len(member_names) > 1: + group = NodeGroup(group_name, group_tpl, + self._get_group_memerbs(member_names)) + groups.append(group) + else: + exception.ExceptionCollector.appendException(ValueError) + return groups + + def _get_group_memerbs(self, member_names): + member_nodes = [] + for member in member_names: + for node in self.nodetemplates: + if node.name == member: + member_nodes.append(node) + return member_nodes + + # topology template can act like node template + # it is exposed by substitution_mappings. + def nodetype(self): + pass + + def capabilities(self): + pass + + def requirements(self): + pass + + def _tpl_description(self): + description = self.tpl.get(DESCRIPTION) + if description: + return description.rstrip() + + def _tpl_inputs(self): + return self.tpl.get(INPUTS) or {} + + def _tpl_nodetemplates(self): + return self.tpl.get(NODE_TEMPLATES) + + def _tpl_relationship_templates(self): + return self.tpl.get(RELATIONSHIP_TEMPLATES) or {} + + def _tpl_outputs(self): + return self.tpl.get(OUTPUTS) or {} + + def _tpl_substitution_mappings(self): + return self.tpl.get(SUBSTITUION_MAPPINGS) or {} + + def _tpl_groups(self): + return self.tpl.get(GROUPS) or {} + + def _validate_field(self): + for name in self.tpl: + if name not in SECTIONS: + exception.ExceptionCollector.appendException( + exception.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. + """ + if hasattr(self, 'nodetemplates'): + 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: + rel = req + for req_name, req_item in req.items(): + if isinstance(req_item, dict): + rel = req_item.get('relationship') + break + if rel and 'properties' in rel: + for key, value in rel['properties'].items(): + rel['properties'][key] = \ + functions.get_function(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 rel, node in node_template.relationships.items(): + rel_tpls = node.relationship_tpl + if rel_tpls: + for rel_tpl in rel_tpls: + for interface in rel_tpl.interfaces: + if interface.inputs: + for name, value in \ + interface.inputs.items(): + interface.inputs[name] = \ + functions.get_function(self, + rel_tpl, + 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 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tosca_template.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tosca_template.py new file mode 100644 index 0000000..f58ea82 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tosca_template.py @@ -0,0 +1,211 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +import logging +import os + +from toscaparser.common.exception import ExceptionCollector +from toscaparser.common.exception import InvalidTemplateVersion +from toscaparser.common.exception import MissingRequiredFieldError +from toscaparser.common.exception import UnknownFieldError +from toscaparser.common.exception import ValidationError +import toscaparser.imports +from toscaparser.prereq.csar import CSAR +from toscaparser.topology_template import TopologyTemplate +from toscaparser.tpl_relationship_graph import ToscaGraph +from toscaparser.utils.gettextutils import _ +import toscaparser.utils.yamlparser + + +# TOSCA template key names +SECTIONS = (DEFINITION_VERSION, DEFAULT_NAMESPACE, TEMPLATE_NAME, + TOPOLOGY_TEMPLATE, TEMPLATE_AUTHOR, TEMPLATE_VERSION, + DESCRIPTION, IMPORTS, DSL_DEFINITIONS, NODE_TYPES, + RELATIONSHIP_TYPES, RELATIONSHIP_TEMPLATES, + CAPABILITY_TYPES, ARTIFACT_TYPES, DATATYPE_DEFINITIONS) = \ + ('tosca_definitions_version', 'tosca_default_namespace', + 'template_name', 'topology_template', 'template_author', + 'template_version', 'description', 'imports', 'dsl_definitions', + 'node_types', 'relationship_types', 'relationship_templates', + 'capability_types', 'artifact_types', 'datatype_definitions') +# Special key names +SPECIAL_SECTIONS = (METADATA) = ('metadata') + +log = logging.getLogger("tosca.model") + +YAML_LOADER = toscaparser.utils.yamlparser.load_yaml + + +class ToscaTemplate(object): + + VALID_TEMPLATE_VERSIONS = ['tosca_simple_yaml_1_0'] + + '''Load the template data.''' + def __init__(self, path, parsed_params=None, a_file=True): + ExceptionCollector.start() + self.a_file = a_file + self.input_path = path + self.path = self._get_path(path) + if self.path: + self.tpl = YAML_LOADER(self.path, self.a_file) + self.parsed_params = parsed_params + self._validate_field() + self.version = self._tpl_version() + self.relationship_types = self._tpl_relationship_types() + self.description = self._tpl_description() + self.topology_template = self._topology_template() + if self.topology_template.tpl: + self.inputs = self._inputs() + self.relationship_templates = self._relationship_templates() + self.nodetemplates = self._nodetemplates() + self.outputs = self._outputs() + self.graph = ToscaGraph(self.nodetemplates) + ExceptionCollector.stop() + self.verify_template() + + def _topology_template(self): + return TopologyTemplate(self._tpl_topology_template(), + self._get_all_custom_defs(), + self.relationship_types, + self.parsed_params) + + def _inputs(self): + return self.topology_template.inputs + + def _nodetemplates(self): + return self.topology_template.nodetemplates + + def _relationship_templates(self): + return self.topology_template.relationship_templates + + def _outputs(self): + return self.topology_template.outputs + + def _tpl_version(self): + return self.tpl.get(DEFINITION_VERSION) + + def _tpl_description(self): + desc = self.tpl.get(DESCRIPTION) + if desc: + return desc.rstrip() + + def _tpl_imports(self): + return self.tpl.get(IMPORTS) + + def _tpl_relationship_types(self): + return self._get_custom_types(RELATIONSHIP_TYPES) + + def _tpl_relationship_templates(self): + topology_template = self._tpl_topology_template() + return topology_template.get(RELATIONSHIP_TEMPLATES) + + def _tpl_topology_template(self): + return self.tpl.get(TOPOLOGY_TEMPLATE) + + def _get_all_custom_defs(self, imports=None): + types = [IMPORTS, NODE_TYPES, CAPABILITY_TYPES, RELATIONSHIP_TYPES, + DATATYPE_DEFINITIONS] + custom_defs_final = {} + custom_defs = self._get_custom_types(types, imports) + if custom_defs: + custom_defs_final.update(custom_defs) + if custom_defs.get(IMPORTS): + import_defs = self._get_all_custom_defs( + custom_defs.get(IMPORTS)) + custom_defs_final.update(import_defs) + + # As imports are not custom_types, removing from the dict + custom_defs_final.pop(IMPORTS, None) + return custom_defs_final + + def _get_custom_types(self, type_definitions, imports=None): + """Handle custom types defined in imported template files + + This method loads the custom type definitions referenced in "imports" + section of the TOSCA YAML template. + """ + + custom_defs = {} + type_defs = [] + if not isinstance(type_definitions, list): + type_defs.append(type_definitions) + else: + type_defs = type_definitions + + if not imports: + imports = self._tpl_imports() + + if imports: + custom_defs = toscaparser.imports.\ + ImportsLoader(imports, self.path, + type_defs).get_custom_defs() + if not custom_defs: + return + + # Handle custom types defined in current template file + for type_def in type_defs: + if type_def != IMPORTS: + inner_custom_types = self.tpl.get(type_def) or {} + if inner_custom_types: + custom_defs.update(inner_custom_types) + return custom_defs + + def _validate_field(self): + version = self._tpl_version() + if not version: + ExceptionCollector.appendException( + MissingRequiredFieldError(what='Template', + required=DEFINITION_VERSION)) + else: + self._validate_version(version) + self.version = version + + for name in self.tpl: + if name not in SECTIONS and name not in SPECIAL_SECTIONS: + ExceptionCollector.appendException( + UnknownFieldError(what='Template', field=name)) + + def _validate_version(self, version): + if version not in self.VALID_TEMPLATE_VERSIONS: + ExceptionCollector.appendException( + InvalidTemplateVersion( + what=version, + valid_versions=', '. join(self.VALID_TEMPLATE_VERSIONS))) + + def _get_path(self, path): + if path.lower().endswith('.yaml'): + return path + elif path.lower().endswith(('.zip', '.csar')): + # a CSAR archive + csar = CSAR(path, self.a_file) + if csar.validate(): + csar.decompress() + self.a_file = True # the file has been decompressed locally + return os.path.join(csar.temp_dir, csar.get_main_template()) + else: + ExceptionCollector.appendException( + ValueError(_('"%(path)s" is not a valid file.') + % {'path': path})) + + def verify_template(self): + if ExceptionCollector.exceptionsCaught(): + raise ValidationError( + message=(_('\nThe input "%(path)s" failed validation with the ' + 'following error(s): \n\n\t') + % {'path': self.input_path}) + + '\n\t'.join(ExceptionCollector.getExceptionsReport())) + else: + msg = (_('The input "%(path)s" successfully passed validation.') % + {'path': self.input_path}) + log.info(msg) + print(msg) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/tpl_relationship_graph.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/tpl_relationship_graph.py new file mode 100644 index 0000000..1a5ea7b --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/tpl_relationship_graph.py @@ -0,0 +1,46 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +class ToscaGraph(object): + '''Graph of Tosca Node Templates.''' + def __init__(self, nodetemplates): + self.nodetemplates = nodetemplates + self.vertices = {} + self._create() + + def _create_vertex(self, node): + if node not in self.vertices: + self.vertices[node.name] = node + + def _create_edge(self, node1, node2, relationship): + if node1 not in self.vertices: + self._create_vertex(node1) + self.vertices[node1.name]._add_next(node2, + relationship) + + def vertex(self, node): + if node in self.vertices: + return self.vertices[node] + + def __iter__(self): + return iter(self.vertices.values()) + + def _create(self): + for node in self.nodetemplates: + relation = node.relationships + if relation: + for rel, nodetpls in relation.items(): + for tpl in self.nodetemplates: + if tpl.name == nodetpls.name: + self._create_edge(node, tpl, rel) + self._create_vertex(node) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/utils/__init__.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/utils/gettextutils.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/utils/gettextutils.py new file mode 100644 index 0000000..f5562e2 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/utils/gettextutils.py @@ -0,0 +1,22 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import gettext +import os + +_localedir = os.environ.get('tosca-parser'.upper() + '_LOCALEDIR') +_t = gettext.translation('tosca-parser', localedir=_localedir, + fallback=True) + + +def _(msg): + return _t.gettext(msg) diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/utils/urlutils.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/utils/urlutils.py new file mode 100644 index 0000000..8022158 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/utils/urlutils.py @@ -0,0 +1,61 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +from six.moves.urllib.parse import urljoin +from six.moves.urllib.parse import urlparse +from toscaparser.common.exception import ExceptionCollector +from toscaparser.utils.gettextutils import _ + +try: + # Python 3.x + import urllib.request as urllib +except ImportError: + # Python 2.x + import urllib + + +class UrlUtils(object): + + @staticmethod + def validate_url(path): + """Validates whether the given path is a URL or not. + + If the given path includes a scheme (http, https, ftp, ...) and a net + location (a domain name such as www.github.com) it is validated as a + URL. + """ + parsed = urlparse(path) + return bool(parsed.scheme) and bool(parsed.netloc) + + @staticmethod + def join_url(url, relative_path): + """Builds a new URL from the given URL and the relative path. + + Example: + url: http://www.githib.com/openstack/heat + relative_path: heat-translator + - joined: http://www.githib.com/openstack/heat-translator + """ + if not UrlUtils.validate_url(url): + ExceptionCollector.appendException( + ValueError(_('"%s" is not a valid URL.') % url)) + return urljoin(url, relative_path) + + @staticmethod + def url_accessible(url): + """Validates whether the given URL is accessible. + + Returns true if the get call returns a 200 response code. + Otherwise, returns false. + """ + return urllib.urlopen(url).getcode() == 200 diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/utils/validateutils.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/utils/validateutils.py new file mode 100644 index 0000000..d2b8504 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/utils/validateutils.py @@ -0,0 +1,165 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import collections +import dateutil.parser +import logging +import numbers +import re +import six + +from toscaparser.common.exception import ExceptionCollector +from toscaparser.common.exception import InvalidTOSCAVersionPropertyException +from toscaparser.utils.gettextutils import _ +log = logging.getLogger('tosca') + + +def str_to_num(value): + '''Convert a string representation of a number into a numeric type.''' + if isinstance(value, numbers.Number): + return value + try: + return int(value) + except ValueError: + return float(value) + + +def validate_number(value): + return str_to_num(value) + + +def validate_integer(value): + if not isinstance(value, int): + try: + value = int(value) + except Exception: + ExceptionCollector.appendException( + ValueError(_('"%s" is not an integer.') % value)) + return value + + +def validate_float(value): + if not isinstance(value, float): + ExceptionCollector.appendException( + ValueError(_('"%s" is not a float.') % value)) + return validate_number(value) + + +def validate_string(value): + if not isinstance(value, six.string_types): + ExceptionCollector.appendException( + ValueError(_('"%s" is not a string.') % value)) + return value + + +def validate_list(value): + if not isinstance(value, list): + ExceptionCollector.appendException( + ValueError(_('"%s" is not a list.') % value)) + return value + + +def validate_map(value): + if not isinstance(value, collections.Mapping): + ExceptionCollector.appendException( + ValueError(_('"%s" is not a map.') % value)) + return value + + +def validate_boolean(value): + if isinstance(value, bool): + return value + + if isinstance(value, str): + normalised = value.lower() + if normalised in ['true', 'false']: + return normalised == 'true' + + ExceptionCollector.appendException( + ValueError(_('"%s" is not a boolean.') % value)) + + +def validate_timestamp(value): + return dateutil.parser.parse(value) + + +class TOSCAVersionProperty(object): + + VERSION_RE = re.compile('^(?P([0-9][0-9]*))' + '(\.(?P([0-9][0-9]*)))?' + '(\.(?P([0-9][0-9]*)))?' + '(\.(?P([0-9A-Za-z]+)))?' + '(\-(?P[0-9])*)?$') + + def __init__(self, version): + self.version = str(version) + match = self.VERSION_RE.match(self.version) + if not match: + ExceptionCollector.appendException( + InvalidTOSCAVersionPropertyException(what=(self.version))) + return + ver = match.groupdict() + if self.version in ['0', '0.0', '0.0.0']: + log.warning(_('Version assumed as not provided')) + self.version = None + self.minor_version = ver['minor_version'] + self.major_version = ver['major_version'] + self.fix_version = ver['fix_version'] + self.qualifier = self._validate_qualifier(ver['qualifier']) + self.build_version = self._validate_build(ver['build_version']) + self._validate_major_version(self.major_version) + + def _validate_major_version(self, value): + """Validate major version + + Checks if only major version is provided and assumes + minor version as 0. + Eg: If version = 18, then it returns version = '18.0' + """ + + if self.minor_version is None and self.build_version is None and \ + value != '0': + log.warning(_('Minor version assumed "0".')) + self.version = '.'.join([value, '0']) + return value + + def _validate_qualifier(self, value): + """Validate qualifier + + TOSCA version is invalid if a qualifier is present without the + fix version or with all of major, minor and fix version 0s. + + For example, the following versions are invalid + 18.0.abc + 0.0.0.abc + """ + if (self.fix_version is None and value) or \ + (self.minor_version == self.major_version == + self.fix_version == '0' and value): + ExceptionCollector.appendException( + InvalidTOSCAVersionPropertyException(what=(self.version))) + return value + + def _validate_build(self, value): + """Validate build version + + TOSCA version is invalid if build version is present without the + qualifier. + Eg: version = 18.0.0-1 is invalid. + """ + if not self.qualifier and value: + ExceptionCollector.appendException( + InvalidTOSCAVersionPropertyException(what=(self.version))) + return value + + def get_version(self): + return self.version diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/utils/yamlparser.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/utils/yamlparser.py new file mode 100644 index 0000000..a4794e7 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/toscaparser/utils/yamlparser.py @@ -0,0 +1,89 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import codecs +from collections import OrderedDict +from toscaparser.common.exception import ExceptionCollector +from toscaparser.common.exception import URLException +from toscaparser.utils.gettextutils import _ +import yaml + +try: + # Python 3.x + import urllib.request as urllib2 +except ImportError: + # Python 2.x + import urllib2 + +if hasattr(yaml, 'CSafeLoader'): + yaml_loader = yaml.CSafeLoader +else: + yaml_loader = yaml.SafeLoader + + +def load_yaml(path, a_file=True): + f = None + try: + f = codecs.open(path, encoding='utf-8', errors='strict') if a_file \ + else urllib2.urlopen(path) + except urllib2.URLError as e: + if hasattr(e, 'reason'): + msg = (_('Failed to reach server "%(path)s". Reason is: ' + '%(reason)s.') + % {'path': path, 'reason': e.reason}) + ExceptionCollector.appendException(URLException(what=msg)) + return + elif hasattr(e, 'code'): + msg = (_('The server "%(path)s" couldn\'t fulfill the request. ' + 'Error code: "%(code)s".') + % {'path': path, 'code': e.code}) + ExceptionCollector.appendException(URLException(what=msg)) + return + except Exception as e: + raise + return yaml.load(f.read(), Loader=yaml_loader) + + +def simple_parse(tmpl_str): + try: + tpl = yaml.load(tmpl_str, Loader=yaml_loader) + except yaml.YAMLError as yea: + ExceptionCollector.appendException(ValueError(yea)) + else: + if tpl is None: + tpl = {} + return tpl + + +def ordered_load(stream, Loader=yaml.Loader, object_pairs_hook=OrderedDict): + class OrderedLoader(Loader): + pass + + def construct_mapping(loader, node): + loader.flatten_mapping(node) + return object_pairs_hook(loader.construct_pairs(node)) + + OrderedLoader.add_constructor( + yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG, + construct_mapping) + return yaml.load(stream, OrderedLoader) + + +def simple_ordered_parse(tmpl_str): + try: + tpl = ordered_load(tmpl_str) + except yaml.YAMLError as yea: + ExceptionCollector.appendException(ValueError(yea)) + else: + if tpl is None: + tpl = {} + return tpl diff --git a/tosca2heat/tosca-parser-0.3.0/tox.ini b/tosca2heat/tosca-parser-0.3.0/tox.ini new file mode 100644 index 0000000..321d712 --- /dev/null +++ b/tosca2heat/tosca-parser-0.3.0/tox.ini @@ -0,0 +1,37 @@ +[tox] +minversion = 1.6 +envlist = py27,py34,pypy,pep8 +skipsdist = True + +[testenv] +usedevelop = True +install_command = pip install -U {opts} {packages} +setenv = + VIRTUAL_ENV={envdir} +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt +commands = python setup.py test --slowest --testr-args='{posargs}' + +[testenv:pep8] +commands = flake8 + +[testenv:venv] +commands = {posargs} + +[testenv:cover] +commands = python setup.py test --coverage --coverage-package-name=toscaparser --testr-args='{posargs}' + +[testenv:docs] +commands = python setup.py build_sphinx + +[testenv:debug] +commands = oslo_debug_helper -t toscaparser/tests {posargs} + +[flake8] +# H803 skipped on purpose per list discussion. +# E123, E125 skipped as they are invalid PEP-8. + +show-source = True +ignore = E123,E125,H803 +builtins = _ +exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build -- 2.16.6