summaryrefslogtreecommitdiffstats
path: root/azure/aria/aria-extension-cloudify/examples
diff options
context:
space:
mode:
Diffstat (limited to 'azure/aria/aria-extension-cloudify/examples')
-rw-r--r--azure/aria/aria-extension-cloudify/examples/aws-hello-world/aws-helloworld.yaml101
-rw-r--r--azure/aria/aria-extension-cloudify/examples/aws-hello-world/images/aria-logo.pngbin0 -> 23601 bytes
-rw-r--r--azure/aria/aria-extension-cloudify/examples/aws-hello-world/index.html14
-rw-r--r--azure/aria/aria-extension-cloudify/examples/aws-hello-world/scripts/configure.sh22
-rw-r--r--azure/aria/aria-extension-cloudify/examples/aws-hello-world/scripts/start.sh50
-rw-r--r--azure/aria/aria-extension-cloudify/examples/aws-hello-world/scripts/stop.sh14
-rw-r--r--azure/aria/aria-extension-cloudify/examples/openstack-hello-world/images/aria-logo.pngbin0 -> 23601 bytes
-rw-r--r--azure/aria/aria-extension-cloudify/examples/openstack-hello-world/index.html14
-rw-r--r--azure/aria/aria-extension-cloudify/examples/openstack-hello-world/openstack-helloworld.yaml144
-rw-r--r--azure/aria/aria-extension-cloudify/examples/openstack-hello-world/scripts/configure.sh20
-rw-r--r--azure/aria/aria-extension-cloudify/examples/openstack-hello-world/scripts/start.sh50
-rw-r--r--azure/aria/aria-extension-cloudify/examples/openstack-hello-world/scripts/stop.sh14
12 files changed, 443 insertions, 0 deletions
diff --git a/azure/aria/aria-extension-cloudify/examples/aws-hello-world/aws-helloworld.yaml b/azure/aria/aria-extension-cloudify/examples/aws-hello-world/aws-helloworld.yaml
new file mode 100644
index 0000000..52fd458
--- /dev/null
+++ b/azure/aria/aria-extension-cloudify/examples/aws-hello-world/aws-helloworld.yaml
@@ -0,0 +1,101 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+imports:
+ - https://raw.githubusercontent.com/cloudify-cosmo/aria-extension-cloudify/master/plugins/aws/plugin.yaml
+ - aria-1.0
+
+node_types:
+ http_web_server:
+ derived_from: tosca.nodes.WebApplication
+ properties:
+ port:
+ type: integer
+
+topology_template:
+ inputs:
+ webserver_port:
+ description: The HTTP web server port
+ type: integer
+ default: 8080
+ image_id:
+ description: AWS EC2 image id to use for the server
+ type: string
+ instance_type:
+ description: AWS EC2 instance type to use for the server
+ type: string
+ default: m3.medium
+ ssh_username:
+ type: string
+ default: ubuntu
+ ssh_port:
+ type: integer
+ default: 22
+ private_key_path:
+ description: Path to the private key used to authenticate into the instance
+ type: string
+
+ node_templates:
+ elastic_ip:
+ type: aria.aws.nodes.ElasticIP
+
+ security_group:
+ type: aria.aws.nodes.SecurityGroup
+ properties:
+ description: Security group for Hello World VM
+ rules:
+ - ip_protocol: tcp
+ cidr_ip: 0.0.0.0/0
+ from_port: { get_property: [ http_web_server, port ] }
+ to_port: { get_property: [ http_web_server, port ] }
+ - ip_protocol: tcp
+ cidr_ip: 0.0.0.0/0
+ from_port: { get_input: ssh_port }
+ to_port: { get_input: ssh_port }
+
+ vm:
+ type: aria.aws.nodes.Instance
+ properties:
+ image_id: { get_input: image_id }
+ instance_type: { get_input: instance_type }
+ name: aria-aws-hello-world-instance
+ parameters:
+ key_name: { get_attribute: [ keypair, aws_resource_id ] }
+ requirements:
+ - elastic_ip: elastic_ip
+ - security_group: security_group
+ - keypair: keypair
+
+ keypair:
+ type: aria.aws.nodes.KeyPair
+ properties:
+ private_key_path: { get_input: private_key_path }
+
+ http_web_server:
+ type: http_web_server
+ properties:
+ port: { get_input: webserver_port }
+ requirements:
+ - host: vm
+ interfaces:
+ Standard:
+ configure:
+ implementation:
+ primary: scripts/configure.sh
+ dependencies:
+ - "ssh.user > { get_input: ssh_username }"
+ - "ssh.key_filename > { get_input: private_key_path }"
+ - "ssh.address > { get_attribute: [ vm, public_ip_address ] }"
+ start:
+ implementation:
+ primary: scripts/start.sh
+ dependencies:
+ - "ssh.user > { get_input: ssh_username }"
+ - "ssh.key_filename > { get_input: private_key_path }"
+ - "ssh.address > { get_attribute: [ vm, public_ip_address ] }"
+ stop:
+ implementation:
+ primary: scripts/stop.sh
+ dependencies:
+ - "ssh.user > { get_input: ssh_username }"
+ - "ssh.key_filename > { get_input: private_key_path }"
+ - "ssh.address > { get_attribute: [ vm, public_ip_address ] }" \ No newline at end of file
diff --git a/azure/aria/aria-extension-cloudify/examples/aws-hello-world/images/aria-logo.png b/azure/aria/aria-extension-cloudify/examples/aws-hello-world/images/aria-logo.png
new file mode 100644
index 0000000..3505844
--- /dev/null
+++ b/azure/aria/aria-extension-cloudify/examples/aws-hello-world/images/aria-logo.png
Binary files differ
diff --git a/azure/aria/aria-extension-cloudify/examples/aws-hello-world/index.html b/azure/aria/aria-extension-cloudify/examples/aws-hello-world/index.html
new file mode 100644
index 0000000..597632b
--- /dev/null
+++ b/azure/aria/aria-extension-cloudify/examples/aws-hello-world/index.html
@@ -0,0 +1,14 @@
+<html>
+ <header>
+ <title>ARIA Hello World</title>
+ </header>
+<body>
+ <h1>Hello, World!</h1>
+ <p>
+ service_template_name = {{ ctx.service_template.name }}<br/>
+ service_name = {{ ctx.service.name }}<br/>
+ node_name = {{ ctx.node.name }}
+ </p>
+ <img src="aria-logo.png">
+</body>
+</html> \ No newline at end of file
diff --git a/azure/aria/aria-extension-cloudify/examples/aws-hello-world/scripts/configure.sh b/azure/aria/aria-extension-cloudify/examples/aws-hello-world/scripts/configure.sh
new file mode 100644
index 0000000..aa3ea5f
--- /dev/null
+++ b/azure/aria/aria-extension-cloudify/examples/aws-hello-world/scripts/configure.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+set -e
+
+TEMP_DIR=/tmp
+PYTHON_FILE_SERVER_ROOT="$TEMP_DIR/python-simple-http-webserver"
+INDEX_PATH=index.html
+IMAGE_PATH=images/aria-logo.png
+
+if [ -d "$PYTHON_FILE_SERVER_ROOT" ]; then
+ ctx logger info [ "Removing old web server root folder: $PYTHON_FILE_SERVER_ROOT." ]
+ rm -rf "$PYTHON_FILE_SERVER_ROOT"
+fi
+
+ctx logger info [ "Creating web server root folder: $PYTHON_FILE_SERVER_ROOT." ]
+
+mkdir -p "$PYTHON_FILE_SERVER_ROOT"
+cd "$PYTHON_FILE_SERVER_ROOT"
+
+ctx logger info [ "Downloading service template resources..." ]
+ctx download-resource-and-render [ "$PYTHON_FILE_SERVER_ROOT/index.html" "$INDEX_PATH" ]
+ctx download-resource [ "$PYTHON_FILE_SERVER_ROOT/aria-logo.png" "$IMAGE_PATH" ]
diff --git a/azure/aria/aria-extension-cloudify/examples/aws-hello-world/scripts/start.sh b/azure/aria/aria-extension-cloudify/examples/aws-hello-world/scripts/start.sh
new file mode 100644
index 0000000..7471cfc
--- /dev/null
+++ b/azure/aria/aria-extension-cloudify/examples/aws-hello-world/scripts/start.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+set -e
+
+TEMP_DIR=/tmp
+PYTHON_FILE_SERVER_ROOT="$TEMP_DIR/python-simple-http-webserver"
+PID_FILE=server.pid
+PORT=$(ctx node properties port)
+URL="http://localhost:$PORT"
+
+ctx logger info [ "Starting web server at: $PYTHON_FILE_SERVER_ROOT." ]
+
+cd "$PYTHON_FILE_SERVER_ROOT"
+nohup python -m SimpleHTTPServer "$PORT" > /dev/null 2>&1 &
+echo $! > "$PID_FILE"
+
+server_is_up() {
+ if which wget >/dev/null; then
+ if wget "$URL" >/dev/null; then
+ return 0
+ fi
+ elif which curl >/dev/null; then
+ if curl "$URL" >/dev/null; then
+ return 0
+ fi
+ else
+ ctx logger error [ "Both curl and wget were not found in path." ]
+ exit 1
+ fi
+ return 1
+}
+
+ctx logger info [ "Waiting for web server to launch on port $PORT..." ]
+STARTED=false
+for i in $(seq 1 15)
+do
+ if server_is_up; then
+ ctx logger info [ "Web server is up." ]
+ STARTED=true
+ break
+ else
+ ctx logger info [ "Web server not up. waiting 1 second." ]
+ sleep 1
+ fi
+done
+
+if [ "$STARTED" = false ]; then
+ ctx logger error [ "Web server did not start within 15 seconds." ]
+ exit 1
+fi
diff --git a/azure/aria/aria-extension-cloudify/examples/aws-hello-world/scripts/stop.sh b/azure/aria/aria-extension-cloudify/examples/aws-hello-world/scripts/stop.sh
new file mode 100644
index 0000000..9f3bfc5
--- /dev/null
+++ b/azure/aria/aria-extension-cloudify/examples/aws-hello-world/scripts/stop.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -e
+
+TEMP_DIR=/tmp
+PYTHON_FILE_SERVER_ROOT="${TEMP_DIR}/python-simple-http-webserver"
+PID_FILE=server.pid
+PID=$(cat "$PYTHON_FILE_SERVER_ROOT/$PID_FILE")
+
+ctx logger info [ "Shutting down web server, pid = ${PID}." ]
+kill -9 "$PID" || exit $?
+
+ctx logger info [ "Removing web server root folder: $PYTHON_FILE_SERVER_ROOT." ]
+rm -rf "$PYTHON_FILE_SERVER_ROOT"
diff --git a/azure/aria/aria-extension-cloudify/examples/openstack-hello-world/images/aria-logo.png b/azure/aria/aria-extension-cloudify/examples/openstack-hello-world/images/aria-logo.png
new file mode 100644
index 0000000..3505844
--- /dev/null
+++ b/azure/aria/aria-extension-cloudify/examples/openstack-hello-world/images/aria-logo.png
Binary files differ
diff --git a/azure/aria/aria-extension-cloudify/examples/openstack-hello-world/index.html b/azure/aria/aria-extension-cloudify/examples/openstack-hello-world/index.html
new file mode 100644
index 0000000..597632b
--- /dev/null
+++ b/azure/aria/aria-extension-cloudify/examples/openstack-hello-world/index.html
@@ -0,0 +1,14 @@
+<html>
+ <header>
+ <title>ARIA Hello World</title>
+ </header>
+<body>
+ <h1>Hello, World!</h1>
+ <p>
+ service_template_name = {{ ctx.service_template.name }}<br/>
+ service_name = {{ ctx.service.name }}<br/>
+ node_name = {{ ctx.node.name }}
+ </p>
+ <img src="aria-logo.png">
+</body>
+</html> \ No newline at end of file
diff --git a/azure/aria/aria-extension-cloudify/examples/openstack-hello-world/openstack-helloworld.yaml b/azure/aria/aria-extension-cloudify/examples/openstack-hello-world/openstack-helloworld.yaml
new file mode 100644
index 0000000..1fb031c
--- /dev/null
+++ b/azure/aria/aria-extension-cloudify/examples/openstack-hello-world/openstack-helloworld.yaml
@@ -0,0 +1,144 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+imports:
+ - https://raw.githubusercontent.com/cloudify-cosmo/aria-extension-cloudify/master/plugins/openstack/plugin.yaml
+ - aria-1.0
+
+node_types:
+ web_app:
+ derived_from: tosca.nodes.WebApplication
+ properties:
+ port:
+ type: integer
+ default:
+
+topology_template:
+
+ inputs:
+ ssh_username:
+ type: string
+ default: ubuntu
+ external_network_name:
+ type: string
+ webserver_port:
+ type: integer
+ private_key_path:
+ type: string
+ image:
+ type: string
+ flavor:
+ type: string
+ openstack_config:
+ type: map
+ entry_schema: string
+
+ node_templates:
+ network:
+ type: aria.openstack.nodes.Network
+ properties:
+ resource_id: aria_helloworld_network
+ create_if_missing: true
+ openstack_config: { get_input: openstack_config }
+
+ router:
+ type: aria.openstack.nodes.Router
+ properties:
+ external_network: { get_input: external_network_name }
+ create_if_missing: true
+ resource_id: aria_helloworld_rtr
+ openstack_config: { get_input: openstack_config }
+
+ subnet:
+ type: aria.openstack.nodes.Subnet
+ properties:
+ resource_id: aria_helloworld_subnet
+ create_if_missing: true
+ openstack_config: { get_input: openstack_config }
+ requirements:
+ - router: router
+ - network: network
+
+ port:
+ type: aria.openstack.nodes.Port
+ properties:
+ create_if_missing: true
+ resource_id: aria_helloworld_port
+ openstack_config: { get_input: openstack_config }
+ requirements:
+ - security_group: security_group
+ - subnet: subnet
+ - network: network
+
+ virtual_ip:
+ type: aria.openstack.nodes.FloatingIP
+ properties:
+ resource_id: aria_helloworld_floatingip
+ create_if_missing: true
+ openstack_config: { get_input: openstack_config }
+ floatingip:
+ floating_network_name: { get_input: external_network_name }
+
+ security_group:
+ type: aria.openstack.nodes.SecurityGroup
+ properties:
+ create_if_missing: true
+ resource_id: aria_helloworld_sg
+ openstack_config: { get_input: openstack_config }
+ rules:
+ - remote_ip_prefix: 0.0.0.0/0
+ port: { get_input: webserver_port }
+ - port: 22
+ remote_ip_prefix: 0.0.0.0/0
+
+ keypair:
+ type: aria.openstack.nodes.KeyPair
+ properties:
+ create_if_missing: true
+ resource_id: aria_helloworld_kp
+ private_key_path: { get_input: private_key_path }
+ openstack_config: { get_input: openstack_config }
+
+ vm:
+ type: aria.openstack.nodes.Server
+ properties:
+ image: { get_input: image }
+ flavor: { get_input: flavor }
+ create_if_missing: true
+ resource_id: aria_helloworld_vm
+ management_network_name: aria_helloworld_network
+ openstack_config: { get_input: openstack_config }
+ requirements:
+ - floating_ip: virtual_ip
+ - security_group: security_group
+ - key_pair: keypair
+ - port: port
+
+ web_app:
+ type: web_app
+ properties:
+ port: { get_input: webserver_port }
+ requirements:
+ - host: vm
+ interfaces:
+ Standard:
+ configure:
+ implementation:
+ primary: scripts/configure.sh
+ dependencies:
+ - "ssh.user > { get_input: ssh_username }"
+ - "ssh.key_filename > { get_input: private_key_path }"
+ - "ssh.address > { get_attribute: [ virtual_ip, floating_ip_address ] }"
+ start:
+ implementation:
+ primary: scripts/start.sh
+ dependencies:
+ - "ssh.user > { get_input: ssh_username }"
+ - "ssh.key_filename > { get_input: private_key_path }"
+ - "ssh.address > { get_attribute: [ virtual_ip, floating_ip_address ] }"
+ stop:
+ implementation:
+ primary: scripts/stop.sh
+ dependencies:
+ - "ssh.user > { get_input: ssh_username }"
+ - "ssh.key_filename > { get_input: private_key_path }"
+ - "ssh.address > { get_attribute: [ virtual_ip, floating_ip_address ] }"
diff --git a/azure/aria/aria-extension-cloudify/examples/openstack-hello-world/scripts/configure.sh b/azure/aria/aria-extension-cloudify/examples/openstack-hello-world/scripts/configure.sh
new file mode 100644
index 0000000..400ae71
--- /dev/null
+++ b/azure/aria/aria-extension-cloudify/examples/openstack-hello-world/scripts/configure.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+TEMP_DIR=/tmp
+PYTHON_FILE_SERVER_ROOT="$TEMP_DIR/python-simple-http-webserver"
+INDEX_PATH=index.html
+IMAGE_PATH=images/aria-logo.png
+
+if [ -d "$PYTHON_FILE_SERVER_ROOT" ]; then
+ ctx logger info [ "Removing old web server root folder: $PYTHON_FILE_SERVER_ROOT." ]
+ rm -rf "$PYTHON_FILE_SERVER_ROOT"
+fi
+
+ctx logger info [ "Creating web server root folder: $PYTHON_FILE_SERVER_ROOT." ]
+
+mkdir -p "$PYTHON_FILE_SERVER_ROOT"
+cd "$PYTHON_FILE_SERVER_ROOT"
+
+ctx logger info [ "Downloading service template resources..." ]
+ctx download-resource-and-render [ "$PYTHON_FILE_SERVER_ROOT/index.html" "$INDEX_PATH" ]
+ctx download-resource [ "$PYTHON_FILE_SERVER_ROOT/aria-logo.png" "$IMAGE_PATH" ]
diff --git a/azure/aria/aria-extension-cloudify/examples/openstack-hello-world/scripts/start.sh b/azure/aria/aria-extension-cloudify/examples/openstack-hello-world/scripts/start.sh
new file mode 100644
index 0000000..7471cfc
--- /dev/null
+++ b/azure/aria/aria-extension-cloudify/examples/openstack-hello-world/scripts/start.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+set -e
+
+TEMP_DIR=/tmp
+PYTHON_FILE_SERVER_ROOT="$TEMP_DIR/python-simple-http-webserver"
+PID_FILE=server.pid
+PORT=$(ctx node properties port)
+URL="http://localhost:$PORT"
+
+ctx logger info [ "Starting web server at: $PYTHON_FILE_SERVER_ROOT." ]
+
+cd "$PYTHON_FILE_SERVER_ROOT"
+nohup python -m SimpleHTTPServer "$PORT" > /dev/null 2>&1 &
+echo $! > "$PID_FILE"
+
+server_is_up() {
+ if which wget >/dev/null; then
+ if wget "$URL" >/dev/null; then
+ return 0
+ fi
+ elif which curl >/dev/null; then
+ if curl "$URL" >/dev/null; then
+ return 0
+ fi
+ else
+ ctx logger error [ "Both curl and wget were not found in path." ]
+ exit 1
+ fi
+ return 1
+}
+
+ctx logger info [ "Waiting for web server to launch on port $PORT..." ]
+STARTED=false
+for i in $(seq 1 15)
+do
+ if server_is_up; then
+ ctx logger info [ "Web server is up." ]
+ STARTED=true
+ break
+ else
+ ctx logger info [ "Web server not up. waiting 1 second." ]
+ sleep 1
+ fi
+done
+
+if [ "$STARTED" = false ]; then
+ ctx logger error [ "Web server did not start within 15 seconds." ]
+ exit 1
+fi
diff --git a/azure/aria/aria-extension-cloudify/examples/openstack-hello-world/scripts/stop.sh b/azure/aria/aria-extension-cloudify/examples/openstack-hello-world/scripts/stop.sh
new file mode 100644
index 0000000..9f3bfc5
--- /dev/null
+++ b/azure/aria/aria-extension-cloudify/examples/openstack-hello-world/scripts/stop.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -e
+
+TEMP_DIR=/tmp
+PYTHON_FILE_SERVER_ROOT="${TEMP_DIR}/python-simple-http-webserver"
+PID_FILE=server.pid
+PID=$(cat "$PYTHON_FILE_SERVER_ROOT/$PID_FILE")
+
+ctx logger info [ "Shutting down web server, pid = ${PID}." ]
+kill -9 "$PID" || exit $?
+
+ctx logger info [ "Removing web server root folder: $PYTHON_FILE_SERVER_ROOT." ]
+rm -rf "$PYTHON_FILE_SERVER_ROOT"