From 16892681fe2f998f1e1a526eb31d5387a6e4508e Mon Sep 17 00:00:00 2001 From: Vahid Hashemian Date: Tue, 28 Jul 2015 14:48:11 -0700 Subject: [PATCH] Separate implementation of custom types and base types Separate custom and based type implementation by moving the custom type implementations into a subfolder. Change-Id: I8baefd582d67c239aaa483794948c79a9a0a92b2 Closes-Bug: #1334975 --- translator/hot/tosca/custom_types/__init__.py | 0 .../{ => custom_types}/tosca_collectd.py | 0 .../{ => custom_types}/tosca_elasticsearch.py | 0 .../tosca/{ => custom_types}/tosca_kibana.py | 0 .../{ => custom_types}/tosca_logstash.py | 0 .../tosca/{ => custom_types}/tosca_nodejs.py | 0 .../tosca_paypalpizzastore.py | 0 .../tosca/{ => custom_types}/tosca_rsyslog.py | 0 .../{ => custom_types}/tosca_wordpress.py | 0 .../tosca/tests/test_tosca_elasticsearch.py | 8 +++++--- .../hot/tosca/tests/test_tosca_kibana.py | 8 +++++--- translator/hot/translate_node_templates.py | 20 +++++++++++-------- 12 files changed, 22 insertions(+), 14 deletions(-) create mode 100644 translator/hot/tosca/custom_types/__init__.py rename translator/hot/tosca/{ => custom_types}/tosca_collectd.py (100%) rename translator/hot/tosca/{ => custom_types}/tosca_elasticsearch.py (100%) rename translator/hot/tosca/{ => custom_types}/tosca_kibana.py (100%) rename translator/hot/tosca/{ => custom_types}/tosca_logstash.py (100%) rename translator/hot/tosca/{ => custom_types}/tosca_nodejs.py (100%) rename translator/hot/tosca/{ => custom_types}/tosca_paypalpizzastore.py (100%) rename translator/hot/tosca/{ => custom_types}/tosca_rsyslog.py (100%) rename translator/hot/tosca/{ => custom_types}/tosca_wordpress.py (100%) diff --git a/translator/hot/tosca/custom_types/__init__.py b/translator/hot/tosca/custom_types/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/translator/hot/tosca/tosca_collectd.py b/translator/hot/tosca/custom_types/tosca_collectd.py similarity index 100% rename from translator/hot/tosca/tosca_collectd.py rename to translator/hot/tosca/custom_types/tosca_collectd.py diff --git a/translator/hot/tosca/tosca_elasticsearch.py b/translator/hot/tosca/custom_types/tosca_elasticsearch.py similarity index 100% rename from translator/hot/tosca/tosca_elasticsearch.py rename to translator/hot/tosca/custom_types/tosca_elasticsearch.py diff --git a/translator/hot/tosca/tosca_kibana.py b/translator/hot/tosca/custom_types/tosca_kibana.py similarity index 100% rename from translator/hot/tosca/tosca_kibana.py rename to translator/hot/tosca/custom_types/tosca_kibana.py diff --git a/translator/hot/tosca/tosca_logstash.py b/translator/hot/tosca/custom_types/tosca_logstash.py similarity index 100% rename from translator/hot/tosca/tosca_logstash.py rename to translator/hot/tosca/custom_types/tosca_logstash.py diff --git a/translator/hot/tosca/tosca_nodejs.py b/translator/hot/tosca/custom_types/tosca_nodejs.py similarity index 100% rename from translator/hot/tosca/tosca_nodejs.py rename to translator/hot/tosca/custom_types/tosca_nodejs.py diff --git a/translator/hot/tosca/tosca_paypalpizzastore.py b/translator/hot/tosca/custom_types/tosca_paypalpizzastore.py similarity index 100% rename from translator/hot/tosca/tosca_paypalpizzastore.py rename to translator/hot/tosca/custom_types/tosca_paypalpizzastore.py diff --git a/translator/hot/tosca/tosca_rsyslog.py b/translator/hot/tosca/custom_types/tosca_rsyslog.py similarity index 100% rename from translator/hot/tosca/tosca_rsyslog.py rename to translator/hot/tosca/custom_types/tosca_rsyslog.py diff --git a/translator/hot/tosca/tosca_wordpress.py b/translator/hot/tosca/custom_types/tosca_wordpress.py similarity index 100% rename from translator/hot/tosca/tosca_wordpress.py rename to translator/hot/tosca/custom_types/tosca_wordpress.py diff --git a/translator/hot/tosca/tests/test_tosca_elasticsearch.py b/translator/hot/tosca/tests/test_tosca_elasticsearch.py index 6dea5ed..d4fa84f 100644 --- a/translator/hot/tosca/tests/test_tosca_elasticsearch.py +++ b/translator/hot/tosca/tests/test_tosca_elasticsearch.py @@ -11,14 +11,16 @@ # under the License. import mock -from translator.hot.tosca.tosca_elasticsearch import ToscaElasticsearch +from translator.hot.tosca.custom_types.tosca_elasticsearch import ( + ToscaElasticsearch + ) from translator.toscalib.tests.base import TestCase class ToscaElasticsearchTest(TestCase): @mock.patch('translator.toscalib.nodetemplate.NodeTemplate') - @mock.patch('translator.hot.tosca.tosca_elasticsearch.' + @mock.patch('translator.hot.tosca.custom_types.tosca_elasticsearch.' 'HotResource.__init__') def test_init(self, mock_hotres_init, mock_node): ToscaElasticsearch(mock_node) @@ -28,7 +30,7 @@ class ToscaElasticsearchTest(TestCase): 'tosca.nodes.SoftwareComponent.Elasticsearch') @mock.patch('translator.toscalib.nodetemplate.NodeTemplate') - @mock.patch('translator.hot.tosca.tosca_elasticsearch.' + @mock.patch('translator.hot.tosca.custom_types.tosca_elasticsearch.' 'HotResource.__init__') def test_handle_properties(self, mock_hotres_init, mock_node): p = ToscaElasticsearch(mock_node) diff --git a/translator/hot/tosca/tests/test_tosca_kibana.py b/translator/hot/tosca/tests/test_tosca_kibana.py index 34f1e79..3c8b640 100644 --- a/translator/hot/tosca/tests/test_tosca_kibana.py +++ b/translator/hot/tosca/tests/test_tosca_kibana.py @@ -11,14 +11,15 @@ # under the License. import mock -from translator.hot.tosca.tosca_kibana import ToscaKibana +from translator.hot.tosca.custom_types.tosca_kibana import ToscaKibana from translator.toscalib.tests.base import TestCase class ToscaKibanaTest(TestCase): @mock.patch('translator.toscalib.nodetemplate.NodeTemplate') - @mock.patch('translator.hot.tosca.tosca_kibana.HotResource.__init__') + @mock.patch('translator.hot.tosca.custom_types.tosca_kibana.' + 'HotResource.__init__') def test_init(self, mock_hotres_init, mock_node): ToscaKibana(mock_node) # Make sure base class gets called @@ -27,7 +28,8 @@ class ToscaKibanaTest(TestCase): 'tosca.nodes.SoftwareComponent.Kibana') @mock.patch('translator.toscalib.nodetemplate.NodeTemplate') - @mock.patch('translator.hot.tosca.tosca_kibana.HotResource.__init__') + @mock.patch('translator.hot.tosca.custom_types.tosca_kibana.' + 'HotResource.__init__') def test_handle_properties(self, mock_hotres_init, mock_node): p = ToscaKibana(mock_node) self.assertIsNone(p.handle_properties()) diff --git a/translator/hot/translate_node_templates.py b/translator/hot/translate_node_templates.py index a90fad3..f80fdd2 100644 --- a/translator/hot/translate_node_templates.py +++ b/translator/hot/translate_node_templates.py @@ -14,25 +14,29 @@ import six from translator.hot.syntax.hot_resource import HotResource +from translator.hot.tosca.custom_types.tosca_collectd import ToscaCollectd +from translator.hot.tosca.custom_types.tosca_elasticsearch import ( + ToscaElasticsearch + ) +from translator.hot.tosca.custom_types.tosca_kibana import ToscaKibana +from translator.hot.tosca.custom_types.tosca_logstash import ToscaLogstash +from translator.hot.tosca.custom_types.tosca_nodejs import ToscaNodejs +from translator.hot.tosca.custom_types.tosca_paypalpizzastore import ( + ToscaPaypalPizzaStore + ) +from translator.hot.tosca.custom_types.tosca_rsyslog import ToscaRsyslog +from translator.hot.tosca.custom_types.tosca_wordpress import ToscaWordpress from translator.hot.tosca.tosca_block_storage import ToscaBlockStorage from translator.hot.tosca.tosca_block_storage_attachment import ( ToscaBlockStorageAttachment ) -from translator.hot.tosca.tosca_collectd import ToscaCollectd from translator.hot.tosca.tosca_compute import ToscaCompute from translator.hot.tosca.tosca_database import ToscaDatabase from translator.hot.tosca.tosca_dbms import ToscaDbms -from translator.hot.tosca.tosca_elasticsearch import ToscaElasticsearch -from translator.hot.tosca.tosca_kibana import ToscaKibana -from translator.hot.tosca.tosca_logstash import ToscaLogstash from translator.hot.tosca.tosca_network_network import ToscaNetwork from translator.hot.tosca.tosca_network_port import ToscaNetworkPort -from translator.hot.tosca.tosca_nodejs import ToscaNodejs from translator.hot.tosca.tosca_object_storage import ToscaObjectStorage -from translator.hot.tosca.tosca_paypalpizzastore import ToscaPaypalPizzaStore -from translator.hot.tosca.tosca_rsyslog import ToscaRsyslog from translator.hot.tosca.tosca_webserver import ToscaWebserver -from translator.hot.tosca.tosca_wordpress import ToscaWordpress from translator.toscalib.functions import GetAttribute from translator.toscalib.functions import GetInput from translator.toscalib.functions import GetProperty