diff options
Diffstat (limited to 'tosca2heat/heat-translator-0.3.0/translator/tests')
102 files changed, 6335 insertions, 0 deletions
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 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/__init__.py 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 + <Plugin network> + Server "%s" "25826" + </Plugin> + """ % (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 = <IP for Mongo server> +# 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" </etc/mysql/my.cnf >/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 <<EOS +description "node.js app" + +start on (net-device-up + and local-filesystems + and runlevel [2345]) +stop on runlevel [!2345] + +expect fork +respawn + +script + export HOME=/ + export NODE_PATH=/usr/lib/node + exec /usr/bin/node ${app_dir}/app.js >> /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 Binary files differnew file mode 100644 index 0000000..5fae801 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_elk.zip 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 Binary files differnew file mode 100644 index 0000000..43ffbbc --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_hello_world.zip diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_metadata_not_yaml.zip b/tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_metadata_not_yaml.zip Binary files differnew file mode 100644 index 0000000..3e6120b --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_metadata_not_yaml.zip 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 Binary files differnew file mode 100644 index 0000000..5df7b48 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_single_instance_wordpress.zip 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 Binary files differnew file mode 100644 index 0000000..d644259 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_wordpress_invalid_import_path.zip 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 Binary files differnew file mode 100644 index 0000000..6014f92 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_wordpress_invalid_script_url.zip 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 Binary files differnew file mode 100644 index 0000000..85d660a --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/tests/data/csar_wrong_metadata_file.zip diff --git a/tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/collectd.yaml b/tosca2heat/heat-translator-0.3.0/translator/tests/data/custom_types/collectd.yaml new file mode 100644 index 0000000..1ac0935 --- /dev/null +++ b/tosca2heat/heat-translator-0.3.0/translator/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/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://<IP>: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://<IP>: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://<IP>: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://<IP>: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://<IP>: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, '<difference> : ' + + 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, '<difference> : ' + + json.dumps(diff1, indent=4, separators=(', ', ': '))) + + params2 = {} + diff2 = TranslationUtils.compare_tosca_translation_with_hot( + tosca_file, hot_file_without_input, params2) + self.assertEqual({}, diff2, '<difference> : ' + + 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, '<difference> : ' + + 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, '<difference> : ' + + 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, '<difference> : ' + + 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, '<difference> : ' + + 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, '<difference> : ' + + 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, '<difference> : ' + + 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, '<difference> : ' + + 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, '<difference> : ' + + 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, '<difference> : ' + + json.dumps(diff1, indent=4, + separators=(', ', ': '))) + except Exception: + diff2 = TranslationUtils.compare_tosca_translation_with_hot( + tosca_file, hot_file2, params) + self.assertEqual({}, diff2, '<difference> : ' + + 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, '<difference> : ' + + json.dumps(diff1, indent=4, + separators=(', ', ': '))) + except Exception: + diff2 = TranslationUtils.compare_tosca_translation_with_hot( + tosca_file, hot_file2, params) + self.assertEqual({}, diff2, '<difference> : ' + + 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, '<difference> : ' + + json.dumps(diff1, indent=4, + separators=(', ', ': '))) + except Exception: + diff2 = TranslationUtils.compare_tosca_translation_with_hot( + tosca_file, hot_file2, params) + self.assertEqual({}, diff2, '<difference> : ' + + 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, '<difference> : ' + + 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, '<difference> : ' + + 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, '<difference> : ' + + 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, '<difference> : ' + + 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, '<difference> : ' + + 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, '<difference> : ' + + 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, '<difference> : ' + + 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, '<difference> : ' + + 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, '<difference> : ' + + 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, '<difference> : ' + + 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, '<difference> : ' + + 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, '<difference> : ' + + 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, '<difference> : ' + + 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")) |