You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ma...@apache.org on 2014/07/08 11:03:12 UTC

git commit: Cartridge agent puppet module changes

Repository: stratos
Updated Branches:
  refs/heads/4.0.0 e1c15c4e9 -> ae58fb911


Cartridge agent puppet module changes


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/ae58fb91
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/ae58fb91
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/ae58fb91

Branch: refs/heads/4.0.0
Commit: ae58fb91107a55b0a56a94ab4a2a1aa5cd2f8fb8
Parents: e1c15c4
Author: Manula Thantriwatte <ma...@apache.org>
Authored: Tue Jul 8 09:02:24 2014 +0000
Committer: Manula Thantriwatte <ma...@apache.org>
Committed: Tue Jul 8 09:02:24 2014 +0000

----------------------------------------------------------------------
 .../modules/agent/files/activemq/README.txt     |   1 +
 tools/puppet3/modules/agent/manifests/init.pp   |  25 +-
 .../modules/agent/manifests/initialize.pp       |  31 +-
 tools/puppet3/modules/agent/manifests/start.pp  |   1 +
 .../modules/agent/templates/bin/stratos.sh.erb  |  36 ++-
 .../agent/templates/conf/log4j.properties.erb   |  40 +++
 .../templates/extensions/artifacts-copy.sh.erb  |  29 ++
 .../extensions/artifacts-updated.sh.erb         |   2 +-
 .../agent/templates/extensions/clean.sh.erb     |   2 +-
 .../templates/extensions/complete-tenant.sh.erb |  30 ++
 .../extensions/complete-topology.sh.erb         |  34 +++
 .../extensions/instance-activated.sh.erb        |   2 +-
 .../extensions/instance-started.sh.erb          |  11 +-
 .../extensions/member-activated.sh.erb          | 303 +++++++++++++++++++
 .../templates/extensions/member-started.sh.erb  |  43 +++
 .../extensions/member-suspended.sh.erb          |  43 +++
 .../extensions/member-terminated.sh.erb         |  43 +++
 .../templates/extensions/mount-volumes.sh.erb   |  87 ++++++
 .../templates/extensions/start-servers.sh.erb   | 285 ++++++++++++++++-
 .../extensions/subscription-domain-added.sh.erb |  35 +++
 .../subscription-domain-removed.sh.erb          |  34 +++
 21 files changed, 1066 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/ae58fb91/tools/puppet3/modules/agent/files/activemq/README.txt
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/agent/files/activemq/README.txt b/tools/puppet3/modules/agent/files/activemq/README.txt
new file mode 100644
index 0000000..dff519c
--- /dev/null
+++ b/tools/puppet3/modules/agent/files/activemq/README.txt
@@ -0,0 +1 @@
+please add all the client jars

http://git-wip-us.apache.org/repos/asf/stratos/blob/ae58fb91/tools/puppet3/modules/agent/manifests/init.pp
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/agent/manifests/init.pp b/tools/puppet3/modules/agent/manifests/init.pp
index 4a6300a..f1074f2 100644
--- a/tools/puppet3/modules/agent/manifests/init.pp
+++ b/tools/puppet3/modules/agent/manifests/init.pp
@@ -16,11 +16,14 @@
 # under the License.
 
 class agent(
-  $version = '4.0.0',
-  $owner   = 'root',
-  $group   = 'root',
-  $target  = '/mnt',
-  $type    = 'default',
+  $version                = '4.0.0',
+  $owner                  = 'root',
+  $group                  = 'root',
+  $target                 = "/mnt/${server_ip}",
+  $type                   = 'default',
+  $enable_artifact_update = true,
+  $auto_commit            = false,
+  $auto_checkout          = true,
 ){
 
   $deployment_code = 'cartridge-agent'
@@ -33,11 +36,21 @@ class agent(
   $service_templates = [
     'bin/stratos.sh',
     'conf/templates/jndi.properties.template',
-    'extensions/artifacts-updated.sh',
+    'conf/log4j.properties',   
     'extensions/clean.sh',
     'extensions/instance-activated.sh',
     'extensions/instance-started.sh',
     'extensions/start-servers.sh',
+    'extensions/artifacts-copy.sh',
+    'extensions/artifacts-updated.sh',
+    'extensions/complete-tenant.sh',
+    'extensions/complete-topology.sh',
+    'extensions/member-activated.sh',
+    'extensions/member-suspended.sh',
+    'extensions/member-terminated.sh',
+    'extensions/mount-volumes.sh',
+    'extensions/subscription-domain-added.sh',
+    'extensions/subscription-domain-removed.sh',
     ]
 
   agent::initialize { $deployment_code:

http://git-wip-us.apache.org/repos/asf/stratos/blob/ae58fb91/tools/puppet3/modules/agent/manifests/initialize.pp
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/agent/manifests/initialize.pp b/tools/puppet3/modules/agent/manifests/initialize.pp
index 2eaadd0..00b4902 100755
--- a/tools/puppet3/modules/agent/manifests/initialize.pp
+++ b/tools/puppet3/modules/agent/manifests/initialize.pp
@@ -18,37 +18,26 @@
 # Initializing the deployment
 
 define agent::initialize ($repo, $version, $service, $local_dir, $target, $owner,) {
-  file {
-    "/${local_dir}/":
-      ensure => present;
-  }
-  file {
-    "/${local_dir}/apache-stratos-${service}-${version}.zip":
-      ensure => present,
-      source => "puppet:///modules/agent/apache-stratos-${service}-${version}.zip",
-      require => File["/${local_dir}/"];
-  }
+
   exec {
     "creating_target_for_${name}":
       path    => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
-      command => "mkdir -p ${target}",
-      require => File["/${local_dir}/apache-stratos-${service}-${version}.zip"];
+      command => "mkdir -p ${target}";
 
     "creating_local_package_repo_for_${name}":
       path    => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/java/bin/',
       unless  => "test -d ${local_dir}",
       command => "mkdir -p ${local_dir}";
+  }
 
-    "downloading_apache-stratos-${service}-${version}.zip":
-      path      => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
-      cwd       => $local_dir,
-      unless    => "test -f ${local_dir}/apache-stratos-${service}-${version}.zip",
-      command   => "puppet:///modules/agent/apache-stratos-${service}-${version}.zip",
-      logoutput => 'on_failure',
-      creates   => "${local_dir}/apache-stratos-${service}-${version}.zip",
-      timeout   => 10,
+  file {
+    "/${local_dir}/apache-stratos-${service}-${version}.zip":
+      ensure => present,
+      source => ["puppet:///modules/agent/apache-stratos-${service}-${version}.zip", "puppet:///packs/apache-stratos-${service}-${version}.zip"],
       require   => Exec["creating_local_package_repo_for_${name}", "creating_target_for_${name}"];
+  }
 
+  exec {
     "extracting_stratos${service}-${version}.zip_for_${name}":
       path      => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
       cwd       => $target,
@@ -57,7 +46,7 @@ define agent::initialize ($repo, $version, $service, $local_dir, $target, $owner
       logoutput => 'on_failure',
       creates   => "${target}/apache-stratos-${service}-${version}/repository",
       timeout   => 0,
-      require   => Exec["downloading_apache-stratos-${service}-${version}.zip"];
+      require   => File["/${local_dir}/apache-stratos-${service}-${version}.zip"];
 
     "setting_permission_for_${name}":
       path      => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',

http://git-wip-us.apache.org/repos/asf/stratos/blob/ae58fb91/tools/puppet3/modules/agent/manifests/start.pp
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/agent/manifests/start.pp b/tools/puppet3/modules/agent/manifests/start.pp
index 034834c..2ee5d4d 100755
--- a/tools/puppet3/modules/agent/manifests/start.pp
+++ b/tools/puppet3/modules/agent/manifests/start.pp
@@ -20,6 +20,7 @@
 define agent::start ($target, $owner) {
   exec { "starting_${name}":
     user    => $owner,
+    environment => "JAVA_HOME=$java_home",
     path    => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/java/bin/',
     unless  => "test -f ${target}/wso2carbon.lck",
     cwd     => "${target}/bin/",

http://git-wip-us.apache.org/repos/asf/stratos/blob/ae58fb91/tools/puppet3/modules/agent/templates/bin/stratos.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/agent/templates/bin/stratos.sh.erb b/tools/puppet3/modules/agent/templates/bin/stratos.sh.erb
index 02814f9..03b50ab 100644
--- a/tools/puppet3/modules/agent/templates/bin/stratos.sh.erb
+++ b/tools/puppet3/modules/agent/templates/bin/stratos.sh.erb
@@ -31,25 +31,47 @@ properties="-Dmb.ip=<%= @mb_ip %>
             -Dthrift.receiver.port=<%= @cep_port %>
             -Djndi.properties.template.file.path=<%= @carbon_home %>/conf/templates/jndi.properties.template
             -Djndi.properties.dir=<%= @carbon_home %>/conf
-            -Dlog4j.properties.file.path=<%= @carbon_home %>/conf/log4j.properties
+            -Dlog4j.configuration=file://<%= @carbon_home %>/conf/log4j.properties
             -Dparam.file.path=<%= @carbon_home %>/payload/launch-params
-            -Dextensions.dir=${script_path}/../extensions
+            -Dextensions.dir=<%= @carbon_home %>/extensions
             -Dcep.stats.publisher.enabled=true
+	    -Dlb.private.ip=<%= @lb_private_ip %>
+	    -Dlb.public.ip=<%= @lb_public_ip %>
             -Djavax.net.ssl.trustStore=<%= @carbon_home %>/security/client-truststore.jks
             -Djavax.net.ssl.trustStorePassword=<%= @truststore_password %>
-	    -Denable.artifact.update=true
-	    -Dartifact.update.interval=15
-	    -Denable.data.publisher=<%= @enable_log_publisher %>
+	     -Denable.artifact.update=<%= @enable_artifact_update %>
+            -Dauto.commit=<%= @auto_commit %>
+            -Dauto.checkout=<%= @auto_checkout %>
+            -Dartifact.update.interval=15
+            -Denable.data.publisher=<%= @enable_log_publisher %>
             -Dmonitoring.server.ip=<%= @bam_ip %>
             -Dmonitoring.server.port=<%= @bam_port %>
             -Dmonitoring.server.secure.port=<%= @bam_secure_port %>
             -Dmonitoring.server.admin.username=<%= @bam_username %>
             -Dmonitoring.server.admin.password=<%= @bam_password %>
-	    -DAPP_PATH=<%= @docroot %>"
+	    -DAPP_PATH=<%= @docroot %>
+	    -Dsuper.tenant.repository.path=<%= @super_tenant_repository_path %>
+            -Dtenant.repository.path=<%= @tenant_repository_path %>
+	    -Dlog.file.paths=<%= @log_file_paths %>
+            -Dextension.instance.started=<%= @extension_instance_started %>
+            -Dextension.start.servers=<%= @extension_start_servers %>
+            -Dextension.instance.activated=<%= @extension_instance_activated %>
+            -Dextension.artifacts.updated=<%= @extension_artifacts_updated %>
+            -Dextension.clean=<%= @extension_clean %>
+            -Dextension.mount.volumes=<%= @extension_mount_volumes %>
+            -Dextension.member.started=<%= @extension_member_started %>
+            -Dextension.member.activated=<%= @extension_member_activated %>
+	    -Dextension.member.terminated=<%= @extension_member_terminated %>
+	    -Dextension.member.suspended=<%= @extension_member_suspended %>
+            -Dextension.complete.topology=<%= @extension_complete_topology %>
+            -Dextension.complete.tenant=<%= @extension_complete_tenant %>
+            -Dextension.subscription.domain.added=<%= @extension_subscription_domain_added %>
+            -Dextension.subscription.domain.removed=<%= @extension_subscription_domain_removed %>
+            -Dextension.artifacts.copy=<%= @extension_artifacts_copy %>"
 
 # Uncomment below line to enable remote debugging
 #debug="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"
 
-/opt/java/bin/java -cp "${class_path}" ${properties} ${debug} org.apache.stratos.cartridge.agent.Main
+<%= @java_home %>/bin/java -cp "${class_path}" ${properties} ${debug} org.apache.stratos.cartridge.agent.Main
 
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/ae58fb91/tools/puppet3/modules/agent/templates/conf/log4j.properties.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/agent/templates/conf/log4j.properties.erb b/tools/puppet3/modules/agent/templates/conf/log4j.properties.erb
new file mode 100644
index 0000000..04cdb75
--- /dev/null
+++ b/tools/puppet3/modules/agent/templates/conf/log4j.properties.erb
@@ -0,0 +1,40 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+#
+
+# Set root logger level and appenders
+log4j.rootLogger=INFO, CONSOLE_APPENDER, FILE_APPENDER
+
+# CONSOLE_APPENDER is set to be a ConsoleAppender.
+log4j.appender.CONSOLE_APPENDER=org.apache.log4j.ConsoleAppender
+
+# The standard error log where all the warnings, errors and fatal errors will be logged
+log4j.appender.FILE_APPENDER=org.apache.log4j.FileAppender
+log4j.appender.FILE_APPENDER.File=/var/log/apache-stratos/cartridge-agent.log
+log4j.appender.FILE_APPENDER.layout=org.apache.log4j.PatternLayout
+log4j.appender.FILE_APPENDER.layout.ConversionPattern=%d{ISO8601} [%X{ip}-%X{host}] [%t] %5p %c{1} %m%n
+log4j.appender.FILE_APPENDER.threshold=DEBUG
+
+# CONSOLE_APPENDER uses PatternLayout.
+log4j.appender.CONSOLE_APPENDER.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE_APPENDER.layout.ConversionPattern=[%d{ISO8601}] %5p - [%c{1}] %m%n
+
+log4j.logger.org.apache.stratos.cartridge.agent=<%= @agent_log_level %>
+log4j.logger.org.apache.stratos.cartridge.agent.statistics.publisher=INFO
+log4j.logger.org.apache.stratos.messaging=INFO
+log4j.logger.org.wso2.andes.client=ERROR

http://git-wip-us.apache.org/repos/asf/stratos/blob/ae58fb91/tools/puppet3/modules/agent/templates/extensions/artifacts-copy.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/agent/templates/extensions/artifacts-copy.sh.erb b/tools/puppet3/modules/agent/templates/extensions/artifacts-copy.sh.erb
new file mode 100644
index 0000000..5cad830
--- /dev/null
+++ b/tools/puppet3/modules/agent/templates/extensions/artifacts-copy.sh.erb
@@ -0,0 +1,29 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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 extension script will be executed once the update artifacts
+# event is received and they are copied to the given path.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+cp -rf $1* $2
+echo "Artifacts Copied" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/ae58fb91/tools/puppet3/modules/agent/templates/extensions/artifacts-updated.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/agent/templates/extensions/artifacts-updated.sh.erb b/tools/puppet3/modules/agent/templates/extensions/artifacts-updated.sh.erb
index 19bb846..37b7791 100755
--- a/tools/puppet3/modules/agent/templates/extensions/artifacts-updated.sh.erb
+++ b/tools/puppet3/modules/agent/templates/extensions/artifacts-updated.sh.erb
@@ -25,7 +25,7 @@
 #
 
 log=/var/log/apache-stratos/cartridge-agent-extensions.log
-echo "Artifacts updated" | tee -a $log
+echo `date`": Artifacts Updated Event" | tee -a $log
 
 
 <%- if @type == 'php' -%>

http://git-wip-us.apache.org/repos/asf/stratos/blob/ae58fb91/tools/puppet3/modules/agent/templates/extensions/clean.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/agent/templates/extensions/clean.sh.erb b/tools/puppet3/modules/agent/templates/extensions/clean.sh.erb
index 3b87d36..c62ad35 100755
--- a/tools/puppet3/modules/agent/templates/extensions/clean.sh.erb
+++ b/tools/puppet3/modules/agent/templates/extensions/clean.sh.erb
@@ -25,4 +25,4 @@
 #
 
 log=/var/log/apache-stratos/cartridge-agent-extensions.log
-echo "Cleaning the cartridge" | tee -a $log
\ No newline at end of file
+echo `date`": Cleaning the cartridge" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/ae58fb91/tools/puppet3/modules/agent/templates/extensions/complete-tenant.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/agent/templates/extensions/complete-tenant.sh.erb b/tools/puppet3/modules/agent/templates/extensions/complete-tenant.sh.erb
new file mode 100644
index 0000000..2586474
--- /dev/null
+++ b/tools/puppet3/modules/agent/templates/extensions/complete-tenant.sh.erb
@@ -0,0 +1,30 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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 extension script will be executed when complete tenant
+# event is received.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+echo `date`": Complete Tenant Event: " | tee -a $log
+echo "Member List: ${STRATOS_MEMBER_LIST_JSON}" | tee -a $log
+echo "Tenant List: ${STRATOS_TENANT_LIST_JSON}" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/ae58fb91/tools/puppet3/modules/agent/templates/extensions/complete-topology.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/agent/templates/extensions/complete-topology.sh.erb b/tools/puppet3/modules/agent/templates/extensions/complete-topology.sh.erb
new file mode 100644
index 0000000..ea2e941
--- /dev/null
+++ b/tools/puppet3/modules/agent/templates/extensions/complete-topology.sh.erb
@@ -0,0 +1,34 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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 extension script will be executed when complete topology 
+# event is received.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+echo `date`": Complete Topology Event: " | tee -a $log
+echo "LB IP: ${STRATOS_LB_IP}" | tee -a $log
+echo "LB PUBLIC IP: $STRATOS_LB_PUBLIC_IP}" | tee -a $log
+echo "STRATOS_PARAM_FILE_PATH: ${STRATOS_PARAM_FILE_PATH}"
+echo "Member List: ${STRATOS_MEMBER_LIST_JSON}" | tee -a $log
+echo "Complete Topology: ${STRATOS_TOPOLOGY_JSON}" | tee -a $log
+echo "Members in LB: ${STRATOS_MEMBERS_IN_LB_JSON}" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/ae58fb91/tools/puppet3/modules/agent/templates/extensions/instance-activated.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/agent/templates/extensions/instance-activated.sh.erb b/tools/puppet3/modules/agent/templates/extensions/instance-activated.sh.erb
index c892ca7..f5d60e8 100755
--- a/tools/puppet3/modules/agent/templates/extensions/instance-activated.sh.erb
+++ b/tools/puppet3/modules/agent/templates/extensions/instance-activated.sh.erb
@@ -25,4 +25,4 @@
 #
 
 log=/var/log/apache-stratos/cartridge-agent-extensions.log
-echo "Instance activated" | tee -a $log
\ No newline at end of file
+echo `date`": Instance activated" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/ae58fb91/tools/puppet3/modules/agent/templates/extensions/instance-started.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/agent/templates/extensions/instance-started.sh.erb b/tools/puppet3/modules/agent/templates/extensions/instance-started.sh.erb
index 6d9d854..7b5aa6a 100755
--- a/tools/puppet3/modules/agent/templates/extensions/instance-started.sh.erb
+++ b/tools/puppet3/modules/agent/templates/extensions/instance-started.sh.erb
@@ -24,13 +24,4 @@
 #
 
 log=/var/log/apache-stratos/cartridge-agent-extensions.log
-echo "Instance started" | tee -a $log
-
-
-<%- if @type == 'mysql' -%>
-<%= scope.function_template(['agent/extensions/addons/_mysql.erb']) -%>
-<%- end -%>
-
-<%- if @type == 'ruby' -%>
-<%= scope.function_template(['agent/extensions/addons/_ruby.erb']) -%>
-<%- end -%>
+echo `date`": Instance Started Event: " | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/ae58fb91/tools/puppet3/modules/agent/templates/extensions/member-activated.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/agent/templates/extensions/member-activated.sh.erb b/tools/puppet3/modules/agent/templates/extensions/member-activated.sh.erb
new file mode 100644
index 0000000..f01d028
--- /dev/null
+++ b/tools/puppet3/modules/agent/templates/extensions/member-activated.sh.erb
@@ -0,0 +1,303 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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 extension script will be executed when member activated
+# event is received.
+# --------------------------------------------------------------
+#
+
+# Execute error_handler function on script error
+trap 'error_handler ${LINENO} $?' ERR
+
+log=/var/log/apache-stratos/cartridge-agent-extensions-member.activated.log
+VERBOSE=1
+DATE=`which date` || print_error "date command not found"
+ECHO=`which echo` || print_error "echo command not found"
+GREP=`which grep` || print_error "grep command not found"
+PS=`which ps` || print_error "ps command not found"
+SED=`which sed` || print_error "sed command not found"
+
+function printParameters(){
+	${ECHO} -e  "LB IP: ${STRATOS_LB_IP}" | tee -a $log
+	${ECHO} -e  "LB PUBLIC IP: ${STRATOS_LB_PUBLIC_IP}" | tee -a $log
+	${ECHO} -e  "STRATOS_PARAM_FILE_PATH: ${STRATOS_PARAM_FILE_PATH}"
+	${ECHO} -e  "Member List: ${STRATOS_MEMBER_LIST_JSON}" | tee -a $log
+	${ECHO} -e  "Complete Topology: ${STRATOS_TOPOLOGY_JSON}" | tee -a $log
+	${ECHO} -e  "Members in LB: ${STRATOS_MEMBERS_IN_LB_JSON}" | tee -a $log
+	${ECHO} -e  "APP_PATH: ${STRATOS_APP_PATH}" | tee -a $log
+}
+
+function error_handler(){
+        MYSELF="$0"               # equals to script name
+        LASTLINE="$1"            # argument 1: last line of error occurence
+        LASTERR="$2"             # argument 2: error code of last command
+        echo "ERROR in ${MYSELF}: line ${LASTLINE}: exit status of last command: ${LASTERR}"
+	exit 1       
+}
+
+function print_message(){
+	if [ ${VERBOSE} -eq 1 ]; then
+    		${ECHO} -e "[INFO] " $1 | tee -a $log
+	fi    
+}
+
+function print_error(){
+	${ECHO} -e "[Error] " $1 | tee -a $log	
+	exit 1
+}
+
+function verify_file_exists(){
+	if [[ ! -f $1 ]] ; then
+		print_error "File not found: $1"
+	fi
+}
+
+function update_hosts_file(){
+	instance_hostname="<%= @stratos_instance_data_host_name %>"
+	(${GREP} -q "${instance_hostname}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP}  ${instance_hostname} # Stratos LB instance private IP" >> /etc/hosts \
+	  && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP}  ${instance_hostname}")) \
+	  || print_error "Failed to update '/etc/hosts' file. "
+
+	map_to_lb="<%= @stratos_instance_data_map_to_lb %>"
+        arr=$(${ECHO} ${map_to_lb} | tr "," "\n")
+
+	for map_hostname in $arr
+	do
+ 		(${GREP} -q "${map_hostname}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP}  ${map_hostname} # Stratos LB instance private IP" >> /etc/hosts \
+          && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP}  ${map_hostname}")) \
+          || print_error "Failed to update '/etc/hosts' file. "
+	done
+
+	<%- if @stratos_instance_data_worker_host_name -%>
+         worker_hostname="<%= @stratos_instance_data_worker_host_name %>"
+ 	 (${GREP} -q " ${worker_hostname}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP}  ${worker_hostname} # Stratos LB worker private IP" >> /etc/hosts \
+          && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP}  ${worker_hostname}")) \
+          || print_error "Failed to update '/etc/hosts' file. "
+         <%- end -%>
+
+        if [[ "${STRATOS_SERVICE_NAME}" = "apistore" ||  "${STRATOS_SERVICE_NAME}" = "publisher" ]] ; then
+		gateway_host_name="<%= @stratos_instance_data_gateway_host_name %>"
+		gateway_mgt_host_name="<%= @stratos_instance_data_gateway_mgt_host_name %>"
+		keymanager_host_name="<%= @stratos_instance_data_keymanager_host_name %>"
+
+		(${GREP} -q "${gateway_host_name}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP}  ${gateway_host_name} # Stratos LB instance private IP" >> /etc/hosts \
+	  && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP}  ${gateway_host_name}")) \
+	  || print_error "Failed to update '/etc/hosts' file. "
+
+		(${GREP} -q "${gateway_mgt_host_name}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP}  ${gateway_mgt_host_name} # Stratos LB instance private IP" >> /etc/hosts \
+	  && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP}  ${gateway_mgt_host_name}")) \
+	  || print_error "Failed to update '/etc/hosts' file. "
+
+
+	  (${GREP} -q "${keymanager_host_name}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP}  ${keymanager_host_name} # Stratos LB instance private IP" >> /etc/hosts \
+          && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP}  ${keymanager_host_name}")) \
+          || print_error "Failed to update '/etc/hosts' file. "
+
+	 elif [[ "${STRATOS_SERVICE_NAME}" = "gateway" || "${STRATOS_SERVICE_NAME}" = "gatewaymgt" ]] ; then
+                keymanager_hostname="<%= @stratos_instance_data_keymanager_host_name %>"
+
+                (${GREP} -q "${keymanager_hostname}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP}  ${keymanager_hostname} # Stratos LB instance private IP" >> /etc/hosts \
+          && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP}  ${keymanager_hostname}")) \
+          || print_error "Failed to update '/etc/hosts' file. "
+
+        fi	
+}
+
+function backup_file(){
+    if [[  -f "$1.orig" ]];
+    then
+        print_message "Restoring from the Original template file $1"
+        cp -f "$1.orig" "$1"
+    else
+        print_message "Creating a backup of the file $1"
+        cp -f "$1" "$1.orig"
+    fi
+}
+
+function configure_manager_worker_wka_members(){
+
+        print_message "function  configure_manager_worker_wka_members  ..... "
+
+    # generic worker manager seperation :D
+    if [[ -z ${STRATOS_WK_MANAGER_MEMBER_COUNT} || ${STRATOS_WK_MANAGER_MEMBER_COUNT} -eq 0 ]] ; then
+        print_message "manager WKA member count is zero or unavailable"
+    else
+        print_message "Configuring manager..."
+        print_message "configure_manager_worker_wka_members STRATOS_WK_MANAGER_MEMBER_COUNT  ${STRATOS_WK_MANAGER_MEMBER_COUNT}  ..... "
+        for i in `seq 0 $(( ${STRATOS_WK_MANAGER_MEMBER_COUNT} - 1 ))`
+            do
+                member_ip_name="STRATOS_WK_MANAGER_MEMBER_${i}_IP"
+                member_ip=${member_ip_name}
+                if [[ -z ${member_ip} ]] ; then
+                    print_error "WKA is null for STRATOS_WK_MANAGER_MEMBER_${i}_IP"
+                fi
+                print_message  "$i => ${member_ip}"
+                WKA_XML=$"${WKA_XML}<member><hostName>${!member_ip}</hostName><port>4000</port></member>\n"
+           done
+     fi
+
+     if [[ -z ${STRATOS_WK_WORKER_MEMBER_COUNT} || ${STRATOS_WK_WORKER_MEMBER_COUNT} -eq 0 ]] ; then
+         print_message "worker WKA member count is zero or unavailable"
+     else
+         print_message "Configuring worker..."
+	 print_message "STRATOS_WK_WORKER_MEMBER_COUNT ${STRATOS_WK_WORKER_MEMBER_COUNT}  ..... "
+         for i in `seq 0 $(( ${STRATOS_WK_WORKER_MEMBER_COUNT} - 1 ))`
+             do
+                 member_ip_name="STRATOS_WK_WORKER_MEMBER_${i}_IP"
+                 member_ip=${member_ip_name}
+                 if [[ -z ${member_ip} ]] ; then
+                     print_error "WKA is null for STRATOS_WK_WORKER_MEMBER_${i}_IP"
+                 fi
+                     print_message  "$i => ${member_ip}"
+                     WKA_XML=$"${WKA_XML}<member><hostName>${!member_ip}</hostName><port>4000</port></member>\n"
+             done
+     fi
+
+     print_message "${STRATOS_SERVICE_NAME} WKA_XML => ${WKA_XML}"
+     verify_file_exists ${AXIS2_XML_FILE}
+     ${SED} -i "s%${WKA_LINE}%${WKA_XML}%g" ${AXIS2_XML_FILE} && print_message "gateway WKA configuration successful" || print_error "Failed to configure well known members"
+
+}
+
+
+function configure_wk_members(){
+
+	print_message "Performing clustering configuration for ${STRATOS_SERVICE_NAME}..."
+
+	WKA_XML=""
+        KEYMGR_XML=""
+	WKA_LINE="@WELL_KNOWN_MEMBERS"
+	KEYMGR_LINE="@KEYMANAGER_SERVER_URL"
+
+	AXIS2_XML_FILE=${STRATOS_APP_PATH}/repository/conf/axis2/axis2.xml
+	backup_file ${AXIS2_XML_FILE}
+	
+
+	if [[ (! -z $STRATOS_SERVICE_GROUP) && "${STRATOS_SERVICE_GROUP}" = "apim" ]] ; then
+	print_message " STRATOS_SERVICE_GROUP_APIM  ${STRATOS_SERVICE_GROUP} ..... "
+		API_MANAGER_XML_FILE=${STRATOS_APP_PATH}/repository/conf/api-manager.xml
+		backup_file ${API_MANAGER_XML_FILE}
+
+		if [[ "${STRATOS_SERVICE_NAME}" = "apistore" ||  "${STRATOS_SERVICE_NAME}" = "publisher" ]] ; then
+
+			print_message "Configuring axis2.xml for ${STRATOS_SERVICE_NAME}..."
+			WKA_XML=$"${WKA_XML}<member><hostName>${STRATOS_WK_APISTORE_MEMBER_IP}</hostName><port>4000</port></member>\n"
+			WKA_XML=$"${WKA_XML}<member><hostName>${STRATOS_WK_PUBLISHER_MEMBER_IP}</hostName><port>4000</port></member>\n"
+			print_message "${STRATOS_SERVICE_NAME} WKA_XML => ${WKA_XML}"
+			verify_file_exists ${AXIS2_XML_FILE}
+			${SED} -i "s%${WKA_LINE}%${WKA_XML}%g" ${AXIS2_XML_FILE} && print_message "${STRATOS_SERVICE_NAME} WKA configuration successful" || print_error "Failed to configure well known members"
+
+		elif [[ "${STRATOS_SERVICE_NAME}" = "keymanager" ]] ; then
+
+			print_message "In keymanager...nothing to do"
+
+		elif [[ "${STRATOS_SERVICE_NAME}" = "gateway"  ||  "${STRATOS_SERVICE_NAME}" = "gatewaymgt" ]] ; then
+			
+                        if [[ "${DEPLOYMENT}" = "manager" || "${DEPLOYMENT}" = "worker" ]] ; then
+
+                                configure_manager_worker_wka_members
+                        fi
+			
+		fi
+	elif [[ "${DEPLOYMENT}" = "manager" || "${DEPLOYMENT}" = "worker" ]] ; then
+		print_message " Worker / Manager ..... ${DEPLOYMENT} "
+		configure_manager_worker_wka_members
+	else
+		print_message "Configuring ${STRATOS_SERVICE_NAME}..."
+		print_message "STRATOS_WK_MEMBER_COUNT ....... ${STRATOS_WK_MEMBER_COUNT} "
+		for i in `seq 0 $(( ${STRATOS_WK_MEMBER_COUNT} - 1 ))`
+		do		    				
+	 		member_ip="STRATOS_WK_MEMBER_${i}_IP"
+			print_message " memberip ${member_ip} ....... "
+			if [[ -z ${!member_ip} ]] ; then
+				print_error "WKA is null for STRATOS_WK_MEMBER_${i}_IP"
+			fi
+			print_message  "$i => ${!member_ip}"
+			WKA_XML=$"${WKA_XML}<member><hostName>${!member_ip}</hostName><port>4000</port></member>\n"			
+		done
+
+		print_message "${STRATOS_SERVICE_NAME} WKA_XML => ${WKA_XML}"
+		verify_file_exists ${AXIS2_XML_FILE}
+		${SED} -i "s%${WKA_LINE}%${WKA_XML}%g" ${AXIS2_XML_FILE} && print_message "${STRATOS_SERVICE_NAME} WKA configuration successful" || print_error "Failed to configure well known members"
+	fi
+}
+
+function updateWKMembers() {
+   print_message "Update WKA Members...... "
+   # Check if APP_PATH exists
+   print_message "Stratos App path $STRATOS_APP_PATH ...... "
+   if [[ ! -d $STRATOS_APP_PATH ]] ; then
+   	print_error "APP_PATH is not found at: ${STRATOS_APP_PATH}"
+   fi
+
+   # Set JAVA_HOME if it is not already set
+   if [[ -z $JAVA_HOME ]] ; then
+   	print_message "Setting JAVA_HOME to /opt/java"
+	export JAVA_HOME=/opt/java
+   fi
+
+   print_message "Stopping wso2server.sh ...... " 
+   # Kill Product server
+   $STRATOS_APP_PATH/bin/wso2server.sh stop > /dev/null 2>&1 &
+   sleep 10
+
+   # Check if clustering is enabled for this product
+   if [[ -z $STRATOS_CLUSTERING ]] ; then
+      ${ECHO} -e  `date`": starting servers in stand-alone mode..." | tee -a $log
+      if [[ ${VERBOSE} -eq 1 ]]; then
+         printParameters
+      fi
+
+   else
+      ${ECHO} -e  `date`": starting servers in clustering mode..." | tee -a $log
+      if [[ ${VERBOSE} -eq 1 ]] ; then
+         printParameters
+      fi
+      # Do the WKA configuration to support clustering
+      configure_wk_members
+   fi
+
+   #Backup hosts file
+   backup_file /etc/hosts
+   # Update the /etc/hosts file with LB instance IP
+   update_hosts_file
+
+   # Run start server command
+   verify_file_exists $STRATOS_APP_PATH/bin/wso2server.sh
+   $STRATOS_APP_PATH/bin/wso2server.sh $* > /dev/null 2>&1 &
+   print_message "Executed run command: $STRATOS_APP_PATH/bin/wso2server.sh $*"
+   print_message "WK Members successfully updated."
+}
+
+# -----------------------
+# Execution starts here
+# -----------------------
+
+   print_message " Executing member activated extension "
+   print_message " Stratos UpdateWK_IP  [$STRATOS_UPDATE_WK_IP] "
+# Check if WK Update flag is set
+if [[ $STRATOS_UPDATE_WK_IP = "true" ]]; then
+   print_message " Conditions successful for  [$STRATOS_UPDATE_WK_IP] . Executing updateWKMembers "
+   updateWKMembers   
+fi
+
+${ECHO} -e `date`": member activated extension successfully completed."
+# END

http://git-wip-us.apache.org/repos/asf/stratos/blob/ae58fb91/tools/puppet3/modules/agent/templates/extensions/member-started.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/agent/templates/extensions/member-started.sh.erb b/tools/puppet3/modules/agent/templates/extensions/member-started.sh.erb
new file mode 100644
index 0000000..29f45c3
--- /dev/null
+++ b/tools/puppet3/modules/agent/templates/extensions/member-started.sh.erb
@@ -0,0 +1,43 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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 extension script will be executed when member suspended
+# event is received.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+OUTPUT=`date`": Member Started Event: "
+OUTPUT="$OUTPUT MEMBER_ID: ${STRATOS_MEMBER_ID}, "
+OUTPUT="$OUTPUT MEMBER_IP: ${STRATOS_MEMBER_IP}, "
+OUTPUT="$OUTPUT CLUSTER_ID: ${STRATOS_CLUSTER_ID}, "
+OUTPUT="$OUTPUT LB_CLUSTER_ID: ${STRATOS_LB_CLUSTER_ID}, "
+OUTPUT="$OUTPUT NETWORK_PARTITION_ID: ${STRATOS_NETWORK_PARTITION_ID}, "
+OUTPUT="$OUTPUT SERVICE_NAME: ${STRATOS_SERVICE_NAME}, "
+OUTPUT="$OUTPUT PORTS: ${STRATOS_PORTS},"
+OUTPUT="$OUTPUT STRATOS_LB_IP: ${STRATOS_LB_IP},"
+OUTPUT="$OUTPUT STRATOS_LB_PUBLIC_IP: ${STRATOS_LB_PUBLIC_IP},"
+OUTPUT="$OUTPUT APP_PATH: ${APP_PATH},"
+OUTPUT="$OUTPUT STRATOS_PARAM_FILE_PATH: ${STRATOS_PARAM_FILE_PATH}"
+echo $OUTPUT | tee -a $log
+echo "Member List: ${STRATOS_MEMBER_LIST_JSON}" | tee -a $log
+echo "Topology: ${STRATOS_TOPOLOGY_JSON}" | tee -a $log
+echo "---------------" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/ae58fb91/tools/puppet3/modules/agent/templates/extensions/member-suspended.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/agent/templates/extensions/member-suspended.sh.erb b/tools/puppet3/modules/agent/templates/extensions/member-suspended.sh.erb
new file mode 100644
index 0000000..866aa0d
--- /dev/null
+++ b/tools/puppet3/modules/agent/templates/extensions/member-suspended.sh.erb
@@ -0,0 +1,43 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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 extension script will be executed when member suspended
+# event is received.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+OUTPUT=`date`": Member Suspended Event: "
+OUTPUT="$OUTPUT MEMBER_ID: ${STRATOS_MEMBER_ID}, "
+OUTPUT="$OUTPUT MEMBER_IP: ${STRATOS_MEMBER_IP}, "
+OUTPUT="$OUTPUT CLUSTER_ID: ${STRATOS_CLUSTER_ID}, "
+OUTPUT="$OUTPUT LB_CLUSTER_ID: ${STRATOS_LB_CLUSTER_ID}, "
+OUTPUT="$OUTPUT NETWORK_PARTITION_ID: ${STRATOS_NETWORK_PARTITION_ID}, "
+OUTPUT="$OUTPUT SERVICE_NAME: ${STRATOS_SERVICE_NAME}, "
+OUTPUT="$OUTPUT PORTS: ${STRATOS_PORTS},"
+OUTPUT="$OUTPUT STRATOS_LB_IP: ${STRATOS_LB_IP},"
+OUTPUT="$OUTPUT STRATOS_LB_PUBLIC_IP: ${STRATOS_LB_PUBLIC_IP},"
+OUTPUT="$OUTPUT APP_PATH: ${APP_PATH},"
+OUTPUT="$OUTPUT STRATOS_PARAM_FILE_PATH: ${STRATOS_PARAM_FILE_PATH}"
+echo $OUTPUT | tee -a $log
+echo "Member List: ${STRATOS_MEMBER_LIST_JSON}" | tee -a $log
+echo "Topology: ${STRATOS_TOPOLOGY_JSON}" | tee -a $log
+echo "---------------" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/ae58fb91/tools/puppet3/modules/agent/templates/extensions/member-terminated.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/agent/templates/extensions/member-terminated.sh.erb b/tools/puppet3/modules/agent/templates/extensions/member-terminated.sh.erb
new file mode 100644
index 0000000..89cedf6
--- /dev/null
+++ b/tools/puppet3/modules/agent/templates/extensions/member-terminated.sh.erb
@@ -0,0 +1,43 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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 extension script will be executed when member terminated
+# event is received.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+OUTPUT=`date`": Member Terminated Event: "
+OUTPUT="$OUTPUT MEMBER_ID: ${STRATOS_MEMBER_ID}, "
+OUTPUT="$OUTPUT MEMBER_IP: ${STRATOS_MEMBER_IP}, "
+OUTPUT="$OUTPUT CLUSTER_ID: ${STRATOS_CLUSTER_ID}, "
+OUTPUT="$OUTPUT LB_CLUSTER_ID: ${STRATOS_LB_CLUSTER_ID}, "
+OUTPUT="$OUTPUT NETWORK_PARTITION_ID: ${STRATOS_NETWORK_PARTITION_ID}, "
+OUTPUT="$OUTPUT SERVICE_NAME: ${STRATOS_SERVICE_NAME}, "
+OUTPUT="$OUTPUT PORTS: ${STRATOS_PORTS},"
+OUTPUT="$OUTPUT STRATOS_LB_IP: ${STRATOS_LB_IP},"
+OUTPUT="$OUTPUT STRATOS_LB_PUBLIC_IP: ${STRATOS_LB_PUBLIC_IP},"
+OUTPUT="$OUTPUT APP_PATH: ${APP_PATH},"
+OUTPUT="$OUTPUT STRATOS_PARAM_FILE_PATH: ${STRATOS_PARAM_FILE_PATH}"
+echo $OUTPUT | tee -a $log
+echo "Member List: ${STRATOS_MEMBER_LIST_JSON}" | tee -a $log
+echo "Topology: ${STRATOS_TOPOLOGY_JSON}" | tee -a $log
+echo "---------------" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/ae58fb91/tools/puppet3/modules/agent/templates/extensions/mount-volumes.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/agent/templates/extensions/mount-volumes.sh.erb b/tools/puppet3/modules/agent/templates/extensions/mount-volumes.sh.erb
new file mode 100755
index 0000000..2e649bd
--- /dev/null
+++ b/tools/puppet3/modules/agent/templates/extensions/mount-volumes.sh.erb
@@ -0,0 +1,87 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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 extension script will be executed to mount volumes
+# to the instance.
+# --------------------------------------------------------------
+#
+
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+echo -e "Starting mounting volumes" 2>&1 | tee -a $log
+
+# $1  is passed from Cartridge Agent code.
+echo -e "launh param file location $1" | tee -a $log
+#source /opt/apache-stratos-cartridge-agent/launch.params
+PERSISTENCE_MAPPING=$1
+echo -e "Persistance mappings : $PERSISTENCE_MAPPING" 2>&1 | tee -a $log
+
+mount_volume(){
+
+        device=$1;
+        mount_point=$2;
+        echo "device $device"
+        echo "point  $mount_point"
+        # check if the volume has a file system
+        output=`sudo file -s $device`;
+        echo $output | tee -a $log
+
+        # this is the pattern of the output of file -s if the volume does not have a file system
+        # refer to http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html
+        pattern="$device: data"
+
+        if [[ $output ==  $pattern ]]
+        then
+                echo -e "Volume is not formatted. So formating the device $device \n" | tee -a $log
+                sudo mkfs -t ext4 $device
+        fi
+
+        echo "Mounting  the device $device to the mount point $mount_point \n" | tee -a $log
+        device_mounted=$(mount | grep "$device")
+
+        if [ ! -d "$mount_point" ]
+        then
+              echo "creating the  mount point directory $mount_point since it does not exist." | tee -a $log
+              sudo mkdir $mount_point
+        fi
+
+        #mounting the device if it is not already mounted
+        if [ ! "$device_mounted" = "" ]
+        then
+              echo -e "Device $device is already mounted." | tee -a $log
+        else
+              sudo mount $device $mount_point
+        fi
+
+}
+
+IFS='|' read -ra ADDR <<< "${PERSISTENCE_MAPPING}"
+echo "${ADDR[@]}" | tee -a $log
+
+for i in "${!ADDR[@]}"; do
+        # expected PERSISTANCE_MAPPING format is device1|mountPoint1|device2|mountpoint2...
+        # so that even indexes are devices and odd indexes are mount points..
+        if (( $i  % 2 == 0 ))
+        then
+           mount_volume ${ADDR[$i]} ${ADDR[$i + 1]}
+        fi
+done
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/ae58fb91/tools/puppet3/modules/agent/templates/extensions/start-servers.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/agent/templates/extensions/start-servers.sh.erb b/tools/puppet3/modules/agent/templates/extensions/start-servers.sh.erb
index d660441..6e34902 100755
--- a/tools/puppet3/modules/agent/templates/extensions/start-servers.sh.erb
+++ b/tools/puppet3/modules/agent/templates/extensions/start-servers.sh.erb
@@ -23,9 +23,286 @@
 # --------------------------------------------------------------
 #
 
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-echo "Starting servers" | tee -a $log
+# Execute error_handler function on script error
+trap 'error_handler ${LINENO} $?' ERR
 
-<%- if @type == 'nodejs' -%>
-<%= scope.function_template(['agent/extensions/addons/_nodejs.erb']) -%>
+log=/var/log/apache-stratos/cartridge-agent-extensions-start.servers.log
+VERBOSE=1
+DATE=`which date` || print_error "date command not found"
+ECHO=`which echo` || print_error "echo command not found"
+GREP=`which grep` || print_error "grep command not found"
+PS=`which ps` || print_error "ps command not found"
+SED=`which sed` || print_error "sed command not found"
+
+function printParameters(){
+	${ECHO} -e  "LB IP: ${STRATOS_LB_IP}" | tee -a $log
+	${ECHO} -e  "LB PUBLIC IP: ${STRATOS_LB_PUBLIC_IP}" | tee -a $log
+	${ECHO} -e  "STRATOS_PARAM_FILE_PATH: ${STRATOS_PARAM_FILE_PATH}"
+	${ECHO} -e  "Member List: ${STRATOS_MEMBER_LIST_JSON}" | tee -a $log
+	${ECHO} -e  "Complete Topology: ${STRATOS_TOPOLOGY_JSON}" | tee -a $log
+	${ECHO} -e  "Members in LB: ${STRATOS_MEMBERS_IN_LB_JSON}" | tee -a $log
+	${ECHO} -e  "APP_PATH: ${STRATOS_APP_PATH}" | tee -a $log
+}
+
+function error_handler(){
+        MYSELF="$0"               # equals to script name
+        LASTLINE="$1"            # argument 1: last line of error occurence
+        LASTERR="$2"             # argument 2: error code of last command
+        echo "ERROR in ${MYSELF}: line ${LASTLINE}: exit status of last command: ${LASTERR}"
+	exit 1       
+}
+
+function print_message(){
+	if [ ${VERBOSE} -eq 1 ]; then
+    		${ECHO} -e "[INFO] " $1 | tee -a $log
+	fi    
+}
+
+function print_error(){
+	${ECHO} -e "[Error] " $1 | tee -a $log	
+	exit 1
+}
+
+function verify_file_exists(){
+	if [[ ! -f $1 ]] ; then
+		print_error "File not found: $1"
+	fi
+}
+
+function update_hosts_file(){
+	instance_hostname="<%= @stratos_instance_data_host_name %>"
+	(${GREP} -q "${instance_hostname}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP}  ${instance_hostname} # Stratos LB instance private IP" >> /etc/hosts \
+	  && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP}  ${instance_hostname}")) \
+	  || print_error "Failed to update '/etc/hosts' file. "
+
+	map_to_lb="<%= @stratos_instance_data_map_to_lb %>"
+        arr=$(${ECHO} ${map_to_lb} | tr "," "\n")
+
+	for map_hostname in $arr
+	do
+ 		(${GREP} -q "${map_hostname}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP}  ${map_hostname} # Stratos LB instance private IP" >> /etc/hosts \
+          && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP}  ${map_hostname}")) \
+          || print_error "Failed to update '/etc/hosts' file. "
+	done
+
+	map_to_ip="<%= @stratos_instance_data_map_to_ip %>"
+        arr=$(${ECHO} ${map_to_ip} | tr "," "\n")
+
+        for mapping in $arr
+        do
+
+	  arrr=$(${ECHO} ${mapping} | tr "#" "\n")
+	  map_hostname=${arrr[1]}
+	  ip_to_map=${arrr[0]}
+
+                (${GREP} -q "${map_hostname}" /etc/hosts || (${ECHO} "${ip_to_map}  ${map_hostname} # Additional Mappings" >> /etc/hosts \
+          && print_message "Updated /etc/hosts file with: ${ip_to_map}  ${map_hostname}")) \
+          || print_error "Failed to update '/etc/hosts' file. "
+     done
+
+
+	<%- if @stratos_instance_data_worker_host_name -%>
+         worker_hostname="<%= @stratos_instance_data_worker_host_name %>"
+ 	 (${GREP} -q " ${worker_hostname}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP}  ${worker_hostname} # Stratos LB worker private IP" >> /etc/hosts \
+          && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP}  ${worker_hostname}")) \
+          || print_error "Failed to update '/etc/hosts' file. "
+         <%- end -%>
+
+        if [[ "${STRATOS_SERVICE_NAME}" = "apistore" ||  "${STRATOS_SERVICE_NAME}" = "publisher" ]] ; then
+		gateway_host_name="<%= @stratos_instance_data_gateway_host_name %>"
+		gateway_mgt_host_name="<%= @stratos_instance_data_gateway_mgt_host_name %>"
+		keymanager_host_name="<%= @stratos_instance_data_keymanager_host_name %>"
+
+		(${GREP} -q "${gateway_host_name}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP}  ${gateway_host_name} # Stratos LB instance private IP" >> /etc/hosts \
+	  && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP}  ${gateway_host_name}")) \
+	  || print_error "Failed to update '/etc/hosts' file. "
+
+		(${GREP} -q "${gateway_mgt_host_name}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP}  ${gateway_mgt_host_name} # Stratos LB instance private IP" >> /etc/hosts \
+	  && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP}  ${gateway_mgt_host_name}")) \
+	  || print_error "Failed to update '/etc/hosts' file. "
+
+
+	  (${GREP} -q "${keymanager_host_name}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP}  ${keymanager_host_name} # Stratos LB instance private IP" >> /etc/hosts \
+          && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP}  ${keymanager_host_name}")) \
+          || print_error "Failed to update '/etc/hosts' file. "
+
+	 elif [[ "${STRATOS_SERVICE_NAME}" = "gateway" || "${STRATOS_SERVICE_NAME}" = "gatewaymgt" ]] ; then
+                keymanager_hostname="<%= @stratos_instance_data_keymanager_host_name %>"
+
+                (${GREP} -q "${keymanager_hostname}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP}  ${keymanager_hostname} # Stratos LB instance private IP" >> /etc/hosts \
+          && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP}  ${keymanager_hostname}")) \
+          || print_error "Failed to update '/etc/hosts' file. "
+
+	elif [[ "${STRATOS_SERVICE_NAME}" = "keymanager" ]] ; then
+                gateway_host_name="<%= @stratos_instance_data_gateway_host_name %>"
+
+                (${GREP} -q "${gateway_host_name}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP}  ${gateway_host_name} # Stratos LB instance private IP" >> /etc/hosts \
+          && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP}  ${gateway_host_name}")) \
+          || print_error "Failed to update '/etc/hosts' file. "
+
+
+        fi	
+}
+
+function backup_file(){
+    if [[  -f "$1.orig" ]];
+    then
+        print_message "Restoring from the Original template file $1"
+        cp -f "$1.orig" "$1"
+    else
+        print_message "Creating a backup of the file $1"
+        cp -f "$1" "$1.orig"
+    fi
+}
+
+function configure_manager_worker_wka_members(){
+
+    # generic worker manager seperation :D
+    if [[ -z ${STRATOS_WK_MANAGER_MEMBER_COUNT} || ${STRATOS_WK_MANAGER_MEMBER_COUNT} -eq 0 ]] ; then
+        print_message "manager WKA member count is zero or unavailable"
+    else
+        print_message "Configuring manager..."
+        for i in `seq 0 $(( ${STRATOS_WK_MANAGER_MEMBER_COUNT} - 1 ))`
+            do
+                member_ip_name="STRATOS_WK_MANAGER_MEMBER_${i}_IP"
+                member_ip=${member_ip_name}
+                if [[ -z ${member_ip} ]] ; then
+                    print_error "WKA is null for STRATOS_WK_MANAGER_MEMBER_${i}_IP"
+                fi
+                print_message  "$i => ${member_ip}"
+                WKA_XML=$"${WKA_XML}<member><hostName>${!member_ip}</hostName><port>4000</port></member>\n"
+           done
+     fi
+
+     if [[ -z ${STRATOS_WK_WORKER_MEMBER_COUNT} || ${STRATOS_WK_WORKER_MEMBER_COUNT} -eq 0 ]] ; then
+         print_message "worker WKA member count is zero or unavailable"
+     else
+         print_message "Configuring worker..."
+         for i in `seq 0 $(( ${STRATOS_WK_WORKER_MEMBER_COUNT} - 1 ))`
+             do
+                 member_ip_name="STRATOS_WK_WORKER_MEMBER_${i}_IP"
+                 member_ip=${member_ip_name}
+                 if [[ -z ${member_ip} ]] ; then
+                     print_error "WKA is null for STRATOS_WK_WORKER_MEMBER_${i}_IP"
+                 fi
+                     print_message  "$i => ${member_ip}"
+                     WKA_XML=$"${WKA_XML}<member><hostName>${!member_ip}</hostName><port>4000</port></member>\n"
+             done
+     fi
+
+     print_message "${STRATOS_SERVICE_NAME} WKA_XML => ${WKA_XML}"
+     verify_file_exists ${AXIS2_XML_FILE}
+     ${SED} -i "s%${WKA_LINE}%${WKA_XML}%g" ${AXIS2_XML_FILE} && print_message "gateway WKA configuration successful" || print_error "Failed to configure well known members"
+
+}
+
+
+function configure_wk_members(){
+
+	print_message "Performing clustering configuration for ${STRATOS_SERVICE_NAME}..."
+
+	WKA_XML=""
+        KEYMGR_XML=""
+	WKA_LINE="@WELL_KNOWN_MEMBERS"
+	KEYMGR_LINE="@KEYMANAGER_SERVER_URL"
+
+	AXIS2_XML_FILE=${STRATOS_APP_PATH}/repository/conf/axis2/axis2.xml
+	backup_file ${AXIS2_XML_FILE}
+	
+
+	if [[ (! -z $STRATOS_SERVICE_GROUP) && "${STRATOS_SERVICE_GROUP}" = "apim" ]] ; then
+		API_MANAGER_XML_FILE=${STRATOS_APP_PATH}/repository/conf/api-manager.xml
+		backup_file ${API_MANAGER_XML_FILE}
+
+		if [[ "${STRATOS_SERVICE_NAME}" = "apistore" ||  "${STRATOS_SERVICE_NAME}" = "publisher" ]] ; then
+
+			print_message "Configuring axis2.xml for ${STRATOS_SERVICE_NAME}..."
+			WKA_XML=$"${WKA_XML}<member><hostName>${STRATOS_WK_APISTORE_MEMBER_IP}</hostName><port>4000</port></member>\n"
+			WKA_XML=$"${WKA_XML}<member><hostName>${STRATOS_WK_PUBLISHER_MEMBER_IP}</hostName><port>4000</port></member>\n"
+			print_message "${STRATOS_SERVICE_NAME} WKA_XML => ${WKA_XML}"
+			verify_file_exists ${AXIS2_XML_FILE}
+			${SED} -i "s%${WKA_LINE}%${WKA_XML}%g" ${AXIS2_XML_FILE} && print_message "${STRATOS_SERVICE_NAME} WKA configuration successful" || print_error "Failed to configure well known members"
+
+		elif [[ "${STRATOS_SERVICE_NAME}" = "keymanager" ]] ; then
+
+			print_message "In keymanager...nothing to do"
+
+		elif [[ "${STRATOS_SERVICE_NAME}" = "gateway"  ||  "${STRATOS_SERVICE_NAME}" = "gatewaymgt" ]] ; then
+			
+                        if [[ "${DEPLOYMENT}" = "manager" || "${DEPLOYMENT}" = "worker" ]] ; then
+
+                                configure_manager_worker_wka_members
+                        fi
+			
+		fi
+	elif [[ "${DEPLOYMENT}" = "manager" || "${DEPLOYMENT}" = "worker" ]] ; then
+
+		configure_manager_worker_wka_members
+	else
+		print_message "Configuring ${STRATOS_SERVICE_NAME}..."
+		for i in `seq 0 $(( ${STRATOS_WK_MEMBER_COUNT} - 1 ))`
+		do		    		
+	 		member_ip="STRATOS_WK_MEMBER_${i}_IP"
+			if [[ -z ${!member_ip} ]] ; then
+				print_error "WKA is null for STRATOS_WK_MEMBER_${i}_IP"
+			fi
+			print_message  "$i => ${!member_ip}"
+			WKA_XML=$"${WKA_XML}<member><hostName>${!member_ip}</hostName><port>4000</port></member>\n"			
+		done
+
+		print_message "${STRATOS_SERVICE_NAME} WKA_XML => ${WKA_XML}"
+		verify_file_exists ${AXIS2_XML_FILE}
+		${SED} -i "s%${WKA_LINE}%${WKA_XML}%g" ${AXIS2_XML_FILE} && print_message "${STRATOS_SERVICE_NAME} WKA configuration successful" || print_error "Failed to configure well known members"
+	fi
+}
+
+# Check if APP_PATH exists
+if [[ ! -d $STRATOS_APP_PATH ]] ; then
+	print_error "APP_PATH is not found at: ${STRATOS_APP_PATH}"
+fi
+
+# Check if product server is already running
+if [[ -f $STRATOS_APP_PATH/wso2carbon.pid ]] ; then
+    PID=`cat $STRATOS_APP_PATH/wso2carbon.pid`
+    if  ${PS} -p $PID > /dev/null ; then
+      ${ECHO} -e `date`": process is already running...skipping start servers"      
+      exit 0
+    fi   
+fi
+
+# Set JAVA_HOME if it is not already set
+if [[ -z $JAVA_HOME ]] ; then
+	print_message "Setting JAVA_HOME to /opt/java"
+	export JAVA_HOME=/opt/java
+fi
+
+# Check if clustering is enabled for this product
+if [[ -z $STRATOS_CLUSTERING ]] ; then
+   ${ECHO} -e  `date`": starting servers in stand-alone mode..." | tee -a $log
+   if [[ ${VERBOSE} -eq 1 ]]; then
+      printParameters
+   fi
+
+else
+   ${ECHO} -e  `date`": starting servers in clustering mode..." | tee -a $log
+   if [[ ${VERBOSE} -eq 1 ]] ; then
+      printParameters
+   fi
+   # Do the WKA configuration to support clustering
+   configure_wk_members
+fi
+
+<%- if @using_dns == true -%>
+     #Update the DNS mapping
+<%- else -%>
+    # Update the /etc/hosts file with LB instance IP
+    update_hosts_file
 <%- end -%>
+
+
+# Run start server command
+verify_file_exists $STRATOS_APP_PATH/bin/wso2server.sh
+$STRATOS_APP_PATH/bin/wso2server.sh $* > /dev/null 2>&1 &
+print_message "Executed run command: $STRATOS_APP_PATH/bin/wso2server.sh $*"
+${ECHO} -e `date`": start servers extension successfully completed."
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/ae58fb91/tools/puppet3/modules/agent/templates/extensions/subscription-domain-added.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/agent/templates/extensions/subscription-domain-added.sh.erb b/tools/puppet3/modules/agent/templates/extensions/subscription-domain-added.sh.erb
new file mode 100644
index 0000000..9ef88a2
--- /dev/null
+++ b/tools/puppet3/modules/agent/templates/extensions/subscription-domain-added.sh.erb
@@ -0,0 +1,35 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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 extension script will be executed when subscription domain
+# added event is received.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+OUTPUT=`date`": Subscription Domain Added Event"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_SERVICE_NAME: ${STRATOS_SUBSCRIPTION_SERVICE_NAME},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_DOMAIN_NAME: ${STRATOS_SUBSCRIPTION_DOMAIN_NAME},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_ID: ${STRATOS_SUBSCRIPTION_TENANT_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_DOMAIN: $STRATOS_SUBSCRIPTION_TENANT_DOMAIN},"
+OUTPUT="$OUTPUT APP_PATH: ${APP_PATH},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_APPLICATION_CONTEXT: ${STRATOS_SUBSCRIPTION_APPLICATION_CONTEXT}"
+echo $OUTPUT | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/ae58fb91/tools/puppet3/modules/agent/templates/extensions/subscription-domain-removed.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/agent/templates/extensions/subscription-domain-removed.sh.erb b/tools/puppet3/modules/agent/templates/extensions/subscription-domain-removed.sh.erb
new file mode 100644
index 0000000..ff7b56b
--- /dev/null
+++ b/tools/puppet3/modules/agent/templates/extensions/subscription-domain-removed.sh.erb
@@ -0,0 +1,34 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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 extension script will be executed when subscription domain
+# removed event is received.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+OUTPUT=`date`": Subscription Domain Removed Event"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_SERVICE_NAME: ${STRATOS_SUBSCRIPTION_SERVICE_NAME},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_DOMAIN_NAME: ${STRATOS_SUBSCRIPTION_DOMAIN_NAME},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_ID: ${STRATOS_SUBSCRIPTION_TENANT_ID},"
+OUTPUT="$OUTPUT APP_PATH: ${APP_PATH},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_DOMAIN: $STRATOS_SUBSCRIPTION_TENANT_DOMAIN}"
+echo $OUTPUT | tee -a $log