From 451a3400b76511393c62a444f588a4ed15f4a549 Mon Sep 17 00:00:00 2001 From: Michael Lando Date: Sun, 19 Feb 2017 10:28:42 +0200 Subject: Initial OpenECOMP SDC commit Change-Id: I0924d5a6ae9cdc161ae17c68d3689a30d10f407b Signed-off-by: Michael Lando --- .../resources/CI/components/apache/apache-type.yml | 50 +++++++++++++++++++ .../CI/components/apache/images/apache.png | Bin 0 -> 10518 bytes .../CI/components/apache/scripts/install_apache.sh | 53 +++++++++++++++++++++ .../CI/components/apache/scripts/start_apache.sh | 10 ++++ 4 files changed, 113 insertions(+) create mode 100644 asdc-tests/src/test/resources/CI/components/apache/apache-type.yml create mode 100644 asdc-tests/src/test/resources/CI/components/apache/images/apache.png create mode 100644 asdc-tests/src/test/resources/CI/components/apache/scripts/install_apache.sh create mode 100644 asdc-tests/src/test/resources/CI/components/apache/scripts/start_apache.sh (limited to 'asdc-tests/src/test/resources/CI/components/apache') diff --git a/asdc-tests/src/test/resources/CI/components/apache/apache-type.yml b/asdc-tests/src/test/resources/CI/components/apache/apache-type.yml new file mode 100644 index 0000000000..360b1a2d60 --- /dev/null +++ b/asdc-tests/src/test/resources/CI/components/apache/apache-type.yml @@ -0,0 +1,50 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0_wd03 +description: TOSCA simple profile with Apache. +template_name: apache-type +template_version: 2.0.0-SNAPSHOT +template_author: FastConnect + +imports: + - "tosca-normative-types-root:1.0.0.wd03-SNAPSHOT" + - "tosca-normative-types-webServer:1.0.0.wd03-SNAPSHOT" + +node_types: + alien.nodes.Apache: + derived_from: tosca.nodes.WebServer + description: > + The TOSCA Apache Node Type represents an apache component + that can be managed and run by a TOSCA Compute Node Type. + capabilities: + host: + type: alien.capabilities.ApacheContainer + properties: + valid_node_types: [ tosca.nodes.WebApplication ] + tags: + icon: /images/apache.png + properties: + version: + type: version + default: 2.4 + constraints: + - equal: 2.4 + port: + type: integer + description: Port for the Apache server + default: 80 + constraints: + - greater_or_equal: 1 + document_root: + type: string + default: "/var/www" + interfaces: + Standard: + create: + inputs: + PORT: { get_property: [SELF, port] } + DOC_ROOT: { get_property: [SELF, document_root] } + implementation: scripts/install_apache.sh + start: scripts/start_apache.sh + +capability_types: + alien.capabilities.ApacheContainer: + derived_from: tosca.capabilities.Container diff --git a/asdc-tests/src/test/resources/CI/components/apache/images/apache.png b/asdc-tests/src/test/resources/CI/components/apache/images/apache.png new file mode 100644 index 0000000000..8e9f402d90 Binary files /dev/null and b/asdc-tests/src/test/resources/CI/components/apache/images/apache.png differ diff --git a/asdc-tests/src/test/resources/CI/components/apache/scripts/install_apache.sh b/asdc-tests/src/test/resources/CI/components/apache/scripts/install_apache.sh new file mode 100644 index 0000000000..a77f9a13f8 --- /dev/null +++ b/asdc-tests/src/test/resources/CI/components/apache/scripts/install_apache.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +echo "Using apt-get. Installing apache2 on one of the following : Debian, Ubuntu, Mint" +LOCK="/tmp/lockaptget" +DEFAULT_PORT=80 + +while true; do + if mkdir "${LOCK}" &>/dev/null; then + echo "Apache take the lock" + break; + fi + echo "Waiting the end of one of our recipes..." + sleep 0.5 +done + +while sudo fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do + echo "Waiting for other software managers to finish..." + sleep 0.5 +done + +sudo rm -f /var/lib/dpkg/lock +sudo apt-get update || (sleep 15; sudo apt-get update || exit ${1}) +sudo apt-get install -y -q apache2 || exit ${1} +rm -rf "${LOCK}" + +sudo /etc/init.d/apache2 stop +if [ ! -d $DOC_ROOT ]; then + eval "sudo mkdir -p $DOC_ROOT" +fi +eval "sudo chown -R www-data:www-data $DOC_ROOT" + +if [[ ("$PORT" == "$DEFAULT_PORT") ]]; then + echo "Use default port for Apache : $DEFAULT_PORT" +else + echo "Replacing port $DEFAULT_PORT with $PORT..." + sudo sed -i -e "s/$DEFAULT_PORT/$PORT/g" /etc/apache2/ports.conf || exit ${1} +fi + +echo "Change config of apache2" +if sudo test -f "/etc/apache2/sites-available/default"; then + echo "Change the DocumentRoot of apache2 on Ubuntu < 14.04" + sudo sed -i -e "s#DocumentRoot /var/www#DocumentRoot $DOC_ROOT#g" /etc/apache2/sites-available/default +fi +if sudo test -f "/etc/apache2/sites-available/000-default.conf"; then + echo "Change the DocumentRoot of Apache2 on Ubuntu >= 14.04" + sudo sed -i -e "s#DocumentRoot /var/www/html#DocumentRoot $DOC_ROOT#g" /etc/apache2/sites-available/000-default.conf +fi + +sudo bash -c "echo ServerName localhost >> /etc/apache2/apache2.conf" + +echo "Start apache2 whith new conf" +sudo /etc/init.d/apache2 start +echo "End of $0" diff --git a/asdc-tests/src/test/resources/CI/components/apache/scripts/start_apache.sh b/asdc-tests/src/test/resources/CI/components/apache/scripts/start_apache.sh new file mode 100644 index 0000000000..478c56edf5 --- /dev/null +++ b/asdc-tests/src/test/resources/CI/components/apache/scripts/start_apache.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +service="apache2" + +if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 )) +then + sudo /etc/init.d/$service restart +else + sudo /etc/init.d/$service start +fi -- cgit 1.2.3-korg