From 7223a66149476bb478f0a44908a1e12bf9f9a9e9 Mon Sep 17 00:00:00 2001 From: spzala Date: Tue, 7 Oct 2014 18:06:00 -0700 Subject: [PATCH] Create a TOSCA CSAR for Wordpress template Create a test Cloud Service Archive (CSAR) structure for TOSCA single instance Wordpress template. Change-Id: I828de628f0ab20996d0ce8a2e55ca1bd0910e2dd Closes-Bug: #1378593 --- .../tosca_single_instance_wordpress.yaml | 106 ++++++++++++++++++ .../Definitions/wordpress.yaml | 25 +++++ .../README.txt | 22 ++++ .../Scripts/MYSQLDBMS/configure.sh | 3 + .../Scripts/MYSQLDBMS/install.sh | 4 + .../Scripts/MYSQLDBMS/start.sh | 3 + .../Scripts/MYSQLDatabase/configure.sh | 9 ++ .../Scripts/WebServer/install.sh | 3 + .../Scripts/WebServer/start.sh | 3 + .../Scripts/WordPress/configure.sh | 7 ++ .../Scripts/WordPress/install.sh | 2 + .../TOSCA-Metadata/TOSCA.meta | 8 ++ 12 files changed, 195 insertions(+) create mode 100644 translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Definitions/tosca_single_instance_wordpress.yaml create mode 100644 translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Definitions/wordpress.yaml create mode 100644 translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/README.txt create mode 100644 translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/configure.sh create mode 100644 translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/install.sh create mode 100644 translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/start.sh create mode 100644 translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDatabase/configure.sh create mode 100644 translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WebServer/install.sh create mode 100644 translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WebServer/start.sh create mode 100644 translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WordPress/configure.sh create mode 100644 translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WordPress/install.sh create mode 100644 translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/TOSCA-Metadata/TOSCA.meta diff --git a/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Definitions/tosca_single_instance_wordpress.yaml b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Definitions/tosca_single_instance_wordpress.yaml new file mode 100644 index 0000000..b935a36 --- /dev/null +++ b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Definitions/tosca_single_instance_wordpress.yaml @@ -0,0 +1,106 @@ +tosca_definitions_version: tosca_simple_1.0 + +description: > + TOSCA simple profile with wordpress, web server and mysql on the same server. + +imports: + - wordpress.yaml + +inputs: + cpus: + type: integer + description: Number of CPUs for the server. + constraints: + - valid_values: [ 1, 2, 4, 8 ] + db_name: + type: string + description: The name of the database. + db_user: + type: string + description: The user name of the DB user. + db_pwd: + type: string + description: The WordPress database admin account password. + db_root_pwd: + type: string + description: Root password for MySQL. + db_port: + type: integer + description: Port for the MySQL database. + +node_templates: + wordpress: + type: tosca.nodes.WebApplication.WordPress + requirements: + - host: webserver + - database_endpoint: mysql_database + interfaces: + tosca.interfaces.node.Lifecycle: + create: Scripts/WordPress/install.sh + configure: + implementation: Scripts/WordPress/configure.sh + input: + wp_db_name: { get_property: [ mysql_database, db_name ] } + wp_db_user: { get_property: [ mysql_database, db_user ] } + wp_db_password: { get_property: [ mysql_database, db_password ] } + + mysql_database: + type: tosca.nodes.Database + properties: + db_name: { get_input: db_name } + db_user: { get_input: db_user } + db_password: { get_input: db_pwd } + requirements: + - host: mysql_dbms + interfaces: + tosca.interfaces.node.Lifecycle: + configure: + implementation: Scripts/MYSQLDatabase/configure.sh + input: + db_name: { get_property: [ SELF, db_name ] } + db_user: { get_property: [ SELF, db_user ] } + db_password: { get_property: [ SELF, db_password ] } + db_root_password: { get_property: [ mysql_dbms, dbms_root_password ] } + + mysql_dbms: + type: tosca.nodes.DBMS + properties: + dbms_root_password: { get_input: db_root_pwd } + dbms_port: { get_input: db_port } + requirements: + - host: server + interfaces: + tosca.interfaces.node.Lifecycle: + create: Scripts/MYSQLDBMS/install.sh + start: Scripts/MYSQLDBMS/start.sh + configure: + implementation: Scripts/MYSQLDBMS/configure.sh + input: + db_root_password: { get_property: [ mysql_dbms, dbms_root_password ] } + + webserver: + type: tosca.nodes.WebServer + requirements: + - host: server + interfaces: + tosca.interfaces.node.Lifecycle: + create: Scripts/WebServer/install.sh + start: Scripts/WebServer/start.sh + + server: + type: tosca.nodes.Compute + properties: + # compute properties (flavor) + disk_size: 10 + num_cpus: { get_input: cpus } + mem_size: 4096 + # host image properties + os_arch: x86_64 + os_type: Linux + os_distribution: Fedora + os_version: 18 + +outputs: + website_url: + description: IP address for Wordpress wiki. + value: { get_attribute: [server, ip_address] } diff --git a/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Definitions/wordpress.yaml b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Definitions/wordpress.yaml new file mode 100644 index 0000000..01b4836 --- /dev/null +++ b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Definitions/wordpress.yaml @@ -0,0 +1,25 @@ +tosca_definitions_version: tosca_simple_1.0 + +node_types: + tosca.nodes.WebApplication.WordPress: + derived_from: tosca.nodes.WebApplication + properties: + admin_user: + required: no + type: string + admin_password: + required: no + type: string + requirements: + - database_endpoint: tosca.nodes.Database + interfaces: + tosca.interfaces.node.Lifecycle: + inputs: + db_port: + type: integer + db_name: + type: string + db_user: + type: string + db_password: + type: string \ No newline at end of file diff --git a/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/README.txt b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/README.txt new file mode 100644 index 0000000..e882ff6 --- /dev/null +++ b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/README.txt @@ -0,0 +1,22 @@ +README: + +This CSAR contains all definitions that are required for deploying WordPress +and MySQL on a single compute instance. + +Entry information for processing through an orchestrator is contained in file +TOSCA-Metadata/TOSCA.meta. This file provides high-level information such as +CSAR version or creator of the CSAR. Furthermore, it provides pointers to the +various TOSCA definitions files that contain the real details. +The entry 'Entry-Definitions' points to the definitions file which holds the +service template for the workload. +'Entry-Definitions' is optional. An orchestrator can also process the contents +like this: +1) Read in and process each definitions file. +2) For each definitions file: + 2.1) Read in all * type definitions (node types, capability types, etc.) and + store them in an internal map +3) Verify and build dependencies (e.g. inheritance) between all type definitions + previously read in. Orchestrator built-in types (e.g. TOSCA base types) are + also considered in this step. +4) Process the actual service template (the file with a node_templates section). + Validate using previously obtained type information. diff --git a/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/configure.sh b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/configure.sh new file mode 100644 index 0000000..7fddd9b --- /dev/null +++ b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/configure.sh @@ -0,0 +1,3 @@ +#!/bin/sh -x +# Set the MySQL server root password +mysqladmin -u root password db_root_password diff --git a/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/install.sh b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/install.sh new file mode 100644 index 0000000..4a7d138 --- /dev/null +++ b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/install.sh @@ -0,0 +1,4 @@ +#!/bin/sh -x +yum -y install mysql mysql-server +# Use systemd to start MySQL server at system boot time +#systemctl enable mysqld.service diff --git a/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/start.sh b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/start.sh new file mode 100644 index 0000000..de61955 --- /dev/null +++ b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDBMS/start.sh @@ -0,0 +1,3 @@ +#!/bin/sh -x +# Start the MySQL service (NOTE: may already be started at image boot time) +systemctl start mysqld.service diff --git a/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDatabase/configure.sh b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDatabase/configure.sh new file mode 100644 index 0000000..41d6ce2 --- /dev/null +++ b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/MYSQLDatabase/configure.sh @@ -0,0 +1,9 @@ +#!/bin/sh -x +# Setup MySQL root password and create user +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 diff --git a/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WebServer/install.sh b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WebServer/install.sh new file mode 100644 index 0000000..8948064 --- /dev/null +++ b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WebServer/install.sh @@ -0,0 +1,3 @@ +#!/bin/sh -x +yum -y install httpd +systemctl enable httpd.service diff --git a/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WebServer/start.sh b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WebServer/start.sh new file mode 100644 index 0000000..7e69fce --- /dev/null +++ b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WebServer/start.sh @@ -0,0 +1,3 @@ +#!/bin/sh -x +# Start the httpd service (NOTE: may already be started at image boot time) +systemctl start httpd.service diff --git a/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WordPress/configure.sh b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WordPress/configure.sh new file mode 100644 index 0000000..bbf98cb --- /dev/null +++ b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WordPress/configure.sh @@ -0,0 +1,7 @@ +#!/bin/sh -x +sed -i "/Deny from All/d" /etc/httpd/conf.d/wordpress.conf +sed -i "s/Require local/Require all granted/" /etc/httpd/conf.d/wordpress.conf +sed -i s/database_name_here/wp_db_name/ /etc/wordpress/wp-config.php +sed -i s/username_here/wp_db_user/ /etc/wordpress/wp-config.php +sed -i s/password_here/wp_db_password/ /etc/wordpress/wp-config.php +systemctl restart httpd.service diff --git a/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WordPress/install.sh b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WordPress/install.sh new file mode 100644 index 0000000..09dd0dc --- /dev/null +++ b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/Scripts/WordPress/install.sh @@ -0,0 +1,2 @@ +#!/bin/sh -x +yum -y install wordpress diff --git a/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/TOSCA-Metadata/TOSCA.meta b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 0000000..a3514fa --- /dev/null +++ b/translator/toscalib/tests/data/CSAR/tosca_single_instance_wordpress/TOSCA-Metadata/TOSCA.meta @@ -0,0 +1,8 @@ +TOSCA-Meta-File-Version: 1.0 +CSAR-Version: 1.1 +Created-By: OASIS TOSCA TC +Entry-Definitions: Definitions/wordpress_mysql_single_instance.yaml + +Name: Definitions/tosca_single_instance_wordpress.yaml +Content-Type: application/vnd.oasis.tosca.definitions.yaml +