You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2015/03/05 07:45:38 UTC

[1/9] stratos git commit: JCA - Renamed SubscriptionDomain*Event to DomainMapping*Event PCA - Refactored constant names, event names related to above change

Repository: stratos
Updated Branches:
  refs/heads/master ee66a9cba -> f97407f30


JCA - Renamed SubscriptionDomain*Event to DomainMapping*Event
PCA - Refactored constant names, event names related to above change


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

Branch: refs/heads/master
Commit: a78e37749faa53c419babaf4fc2ebaf97c9ae93f
Parents: da24390
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Mon Feb 23 14:59:32 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Thu Mar 5 12:15:29 2015 +0530

----------------------------------------------------------------------
 .../extensions/DefaultExtensionHandler.java     | 38 +++++++++++---------
 .../agent/extensions/ExtensionHandler.java      |  4 +--
 .../agent/util/CartridgeAgentConstants.java     |  4 +--
 .../cartridge/agent/util/ExtensionUtils.java    | 20 +++++------
 .../cartridge.agent/cartridge.agent/agent.conf  |  4 +--
 .../cartridge.agent/constants.py                |  4 +--
 .../src/test/resources/agent.conf               |  4 +--
 .../distribution/src/main/bin/stratos.sh        |  4 +--
 .../modules/agent/templates/bin/stratos.sh.erb  |  4 +--
 .../python_agent/templates/agent.conf.erb       |  4 +--
 10 files changed, 47 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/a78e3774/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/extensions/DefaultExtensionHandler.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/extensions/DefaultExtensionHandler.java b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/extensions/DefaultExtensionHandler.java
index 8615475..421deb0 100644
--- a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/extensions/DefaultExtensionHandler.java
+++ b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/extensions/DefaultExtensionHandler.java
@@ -442,30 +442,32 @@ public class DefaultExtensionHandler implements ExtensionHandler {
     }
 
     @Override
-    public void onSubscriptionDomainAddedEvent(DomainMappingAddedEvent subscriptionDomainAddedEvent) {
-        String tenantDomain = findTenantDomain(subscriptionDomainAddedEvent.getTenantId());
+    public void onDomainMappingAddedEvent(DomainMappingAddedEvent domainMappingAddedEvent) {
+        String tenantDomain = findTenantDomain(domainMappingAddedEvent.getTenantId());
         if (log.isInfoEnabled()) {
-            log.info(String.format("Subscription domain added event received: [tenant-id] %d [tenant-domain] %s " +
+            log.info(String.format("Domain mapping added event received: [tenant-id] %d [tenant-domain] %s " +
                             "[domain-name] %s [application-context] %s",
-                    subscriptionDomainAddedEvent.getTenantId(),
+                    domainMappingAddedEvent.getTenantId(),
                     tenantDomain,
-                    subscriptionDomainAddedEvent.getDomainName(),
-                    subscriptionDomainAddedEvent.getContextPath()
+                    domainMappingAddedEvent.getDomainName(),
+                    domainMappingAddedEvent.getContextPath()
             ));
         }
 
         if (log.isDebugEnabled()) {
-            String msg = gson.toJson(subscriptionDomainAddedEvent);
-            log.debug("Subscription domain added event msg:" + msg);
+            String msg = gson.toJson(domainMappingAddedEvent);
+            log.debug("Domain mapping added event msg:" + msg);
         }
 
         Map<String, String> env = new HashMap<String, String>();
-        env.put("STRATOS_SUBSCRIPTION_SERVICE_NAME", subscriptionDomainAddedEvent.getServiceName());
-        env.put("STRATOS_SUBSCRIPTION_DOMAIN_NAME", subscriptionDomainAddedEvent.getDomainName());
-        env.put("STRATOS_SUBSCRIPTION_TENANT_ID", Integer.toString(subscriptionDomainAddedEvent.getTenantId()));
+        env.put("STRATOS_SUBSCRIPTION_APPLICATION_ID", domainMappingAddedEvent.getApplicationId());
+        env.put("STRATOS_SUBSCRIPTION_SERVICE_NAME", domainMappingAddedEvent.getServiceName());
+        env.put("STRATOS_SUBSCRIPTION_DOMAIN_NAME", domainMappingAddedEvent.getDomainName());
+        env.put("STRATOS_SUBSCRIPTION_CLUSTER_ID", domainMappingAddedEvent.getClusterId());
+        env.put("STRATOS_SUBSCRIPTION_TENANT_ID", Integer.toString(domainMappingAddedEvent.getTenantId()));
         env.put("STRATOS_SUBSCRIPTION_TENANT_DOMAIN", tenantDomain);
-        env.put("STRATOS_SUBSCRIPTION_APPLICATION_CONTEXT", subscriptionDomainAddedEvent.getContextPath());
-        ExtensionUtils.executeSubscriptionDomainAddedExtension(env);
+        env.put("STRATOS_SUBSCRIPTION_CONTEXT_PATH", domainMappingAddedEvent.getContextPath());
+        ExtensionUtils.executeDomainMappingAddedExtension(env);
     }
 
     private String findTenantDomain(int tenantId) {
@@ -482,10 +484,10 @@ public class DefaultExtensionHandler implements ExtensionHandler {
     }
 
     @Override
-    public void onSubscriptionDomainRemovedEvent(DomainMappingRemovedEvent subscriptionDomainRemovedEvent) {
+    public void onDomainMappingRemovedEvent(DomainMappingRemovedEvent subscriptionDomainRemovedEvent) {
         String tenantDomain = findTenantDomain(subscriptionDomainRemovedEvent.getTenantId());
         if (log.isInfoEnabled()) {
-            log.info(String.format("Subscription domain removed event received: [tenant-id] %d [tenant-domain] %s " +
+            log.info(String.format("Domain mapping removed event received: [tenant-id] %d [tenant-domain] %s " +
                             "[domain-name] %s",
                     subscriptionDomainRemovedEvent.getTenantId(),
                     tenantDomain,
@@ -495,15 +497,17 @@ public class DefaultExtensionHandler implements ExtensionHandler {
 
         if (log.isDebugEnabled()) {
             String msg = gson.toJson(subscriptionDomainRemovedEvent);
-            log.debug("Subscription domain removed event msg:" + msg);
+            log.debug("Domain mapping removed event msg:" + msg);
         }
 
         Map<String, String> env = new HashMap<String, String>();
+        env.put("STRATOS_SUBSCRIPTION_APPLICATION_ID", subscriptionDomainRemovedEvent.getApplicationId());
         env.put("STRATOS_SUBSCRIPTION_SERVICE_NAME", subscriptionDomainRemovedEvent.getServiceName());
         env.put("STRATOS_SUBSCRIPTION_DOMAIN_NAME", subscriptionDomainRemovedEvent.getDomainName());
+        env.put("STRATOS_SUBSCRIPTION_CLUSTER_ID", subscriptionDomainRemovedEvent.getClusterId());
         env.put("STRATOS_SUBSCRIPTION_TENANT_ID", Integer.toString(subscriptionDomainRemovedEvent.getTenantId()));
         env.put("STRATOS_SUBSCRIPTION_TENANT_DOMAIN", tenantDomain);
-        ExtensionUtils.executeSubscriptionDomainRemovedExtension(env);
+        ExtensionUtils.executeDomainMappingRemovedExtension(env);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/stratos/blob/a78e3774/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/extensions/ExtensionHandler.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/extensions/ExtensionHandler.java b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/extensions/ExtensionHandler.java
index 576750f..74cc6dd 100644
--- a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/extensions/ExtensionHandler.java
+++ b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/extensions/ExtensionHandler.java
@@ -64,9 +64,9 @@ public interface ExtensionHandler {
 
     public void volumeMountExtension(String persistenceMappingsPayload);
 
-    public void onSubscriptionDomainAddedEvent(DomainMappingAddedEvent subscriptionDomainAddedEvent);
+    public void onDomainMappingAddedEvent(DomainMappingAddedEvent subscriptionDomainAddedEvent);
 
-    public void onSubscriptionDomainRemovedEvent(DomainMappingRemovedEvent subscriptionDomainRemovedEvent);
+    public void onDomainMappingRemovedEvent(DomainMappingRemovedEvent subscriptionDomainRemovedEvent);
 
     public void onCopyArtifactsExtension(String src, String des);
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/a78e3774/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/CartridgeAgentConstants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/CartridgeAgentConstants.java b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/CartridgeAgentConstants.java
index b306d9f..550a3a2 100644
--- a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/CartridgeAgentConstants.java
+++ b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/CartridgeAgentConstants.java
@@ -78,8 +78,8 @@ public class CartridgeAgentConstants implements Serializable{
     public static final String MEMBER_STARTED_SCRIPT = "extension.member.started";
     public static final String COMPLETE_TOPOLOGY_SCRIPT = "extension.complete.topology";
     public static final String COMPLETE_TENANT_SCRIPT = "extension.complete.tenant";
-    public static final String SUBSCRIPTION_DOMAIN_ADDED_SCRIPT = "extension.subscription.domain.added";
-    public static final String SUBSCRIPTION_DOMAIN_REMOVED_SCRIPT = "extension.subscription.domain.removed";
+    public static final String DOMAIN_MAPPING_ADDED_SCRIPT = "extension.domain.mapping.added";
+    public static final String DOMAIN_MAPPING_REMOVED_SCRIPT = "extension.domain.mapping.removed";
     public static final String ARTIFACTS_COPY_SCRIPT = "extension.artifacts.copy";
     public static final String TENANT_SUBSCRIBED_SCRIPT = "extension.tenant.subscribed";
     public static final String TENANT_UNSUBSCRIBED_SCRIPT = "extension.tenant.unsubscribed";

http://git-wip-us.apache.org/repos/asf/stratos/blob/a78e3774/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/ExtensionUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/ExtensionUtils.java b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/ExtensionUtils.java
index 306f965..ff7ee60 100644
--- a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/ExtensionUtils.java
+++ b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/ExtensionUtils.java
@@ -397,42 +397,42 @@ public class ExtensionUtils {
         }
     }
 
-    public static void executeSubscriptionDomainAddedExtension(Map<String, String> envParameters) {
+    public static void executeDomainMappingAddedExtension(Map<String, String> envParameters) {
         try {
             if (log.isDebugEnabled()) {
-                log.debug("Executing subscription domain added extension");
+                log.debug("Executing domain mapping added extension");
             }
-            String script = System.getProperty(CartridgeAgentConstants.SUBSCRIPTION_DOMAIN_ADDED_SCRIPT);
+            String script = System.getProperty(CartridgeAgentConstants.DOMAIN_MAPPING_ADDED_SCRIPT);
             String command = prepareCommand(script);
             addPayloadParameters(envParameters);
             cleanProcessParameters(envParameters);
             String output = CommandUtils.executeCommand(command, envParameters);
             if (log.isDebugEnabled()) {
-                log.debug("Subscription domain added script returned:" + output);
+                log.debug("Domain mapping added script returned:" + output);
             }
         } catch (Exception e) {
             if (log.isErrorEnabled()) {
-                log.error("Could not execute subscription domain added extension", e);
+                log.error("Could not execute domain mapping added extension", e);
             }
         }
     }
 
-    public static void executeSubscriptionDomainRemovedExtension(Map<String, String> envParameters) {
+    public static void executeDomainMappingRemovedExtension(Map<String, String> envParameters) {
         try {
             if (log.isDebugEnabled()) {
-                log.debug("Executing subscription domain removed extension");
+                log.debug("Executing domain mapping removed extension");
             }
-            String script = System.getProperty(CartridgeAgentConstants.SUBSCRIPTION_DOMAIN_REMOVED_SCRIPT);
+            String script = System.getProperty(CartridgeAgentConstants.DOMAIN_MAPPING_REMOVED_SCRIPT);
             String command = prepareCommand(script);
             addPayloadParameters(envParameters);
             cleanProcessParameters(envParameters);
             String output = CommandUtils.executeCommand(command, envParameters);
             if (log.isDebugEnabled()) {
-                log.debug("Subscription domain removed script returned:" + output);
+                log.debug("Domain mapping removed script returned:" + output);
             }
         } catch (Exception e) {
             if (log.isErrorEnabled()) {
-                log.error("Could not execute subscription domain removed extension", e);
+                log.error("Could not execute domain mapping removed extension", e);
             }
 
         }

http://git-wip-us.apache.org/repos/asf/stratos/blob/a78e3774/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/agent.conf
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/agent.conf b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/agent.conf
index 51f5831..468ab74 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/agent.conf
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/agent.conf
@@ -54,8 +54,8 @@ extension.member.suspended            =member-suspended.sh
 extension.member.terminated           =member-terminated.sh
 extension.complete.topology           =complete-topology.sh
 extension.complete.tenant             =complete-tenant.sh
-extension.subscription.domain.added   =subscription-domain-added.sh
-extension.subscription.domain.removed =subscription-domain-removed.sh
+extension.domain.mapping.added        =domain-mapping-added.sh
+extension.domain.mapping.removed      =domain-mapping-removed.sh
 extension.artifacts.copy              =artifacts-copy.sh
 extension.tenant.subscribed           =tenant-subscribed.sh
 extension.tenant.unsubscribed         =tenant-unsubscribed.sh
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/a78e3774/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py
index 7331d7f..fb3a341 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py
@@ -79,8 +79,8 @@ MEMBER_SUSPENDED_SCRIPT = "extension.member.suspended"
 MEMBER_STARTED_SCRIPT = "extension.member.started"
 COMPLETE_TOPOLOGY_SCRIPT = "extension.complete.topology"
 COMPLETE_TENANT_SCRIPT = "extension.complete.tenant"
-SUBSCRIPTION_DOMAIN_ADDED_SCRIPT = "extension.subscription.domain.added"
-SUBSCRIPTION_DOMAIN_REMOVED_SCRIPT = "extension.subscription.domain.removed"
+DOMAIN_MAPPING_ADDED_SCRIPT = "extension.domain.mapping.added"
+DOMAIN_MAPPING_REMOVED_SCRIPT = "extension.domain.mapping.removed"
 ARTIFACTS_COPY_SCRIPT = "extension.artifacts.copy"
 TENANT_SUBSCRIBED_SCRIPT = "extension.tenant.subscribed"
 TENANT_UNSUBSCRIBED_SCRIPT = "extension.tenant.unsubscribed"

http://git-wip-us.apache.org/repos/asf/stratos/blob/a78e3774/components/org.apache.stratos.python.cartridge.agent/src/test/resources/agent.conf
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/test/resources/agent.conf b/components/org.apache.stratos.python.cartridge.agent/src/test/resources/agent.conf
index eeee06e..f432e6f 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/test/resources/agent.conf
+++ b/components/org.apache.stratos.python.cartridge.agent/src/test/resources/agent.conf
@@ -53,8 +53,8 @@ extension.member.suspended            =member-suspended.sh
 extension.member.terminated           =member-terminated.sh
 extension.complete.topology           =complete-topology.sh
 extension.complete.tenant             =complete-tenant.sh
-extension.subscription.domain.added   =subscription-domain-added.sh
-extension.subscription.domain.removed =subscription-domain-removed.sh
+extension.domain.mapping.added        =domain-mapping-added.sh
+extension.domain.mapping.removed      =domain-mapping-removed.sh
 extension.artifacts.copy              =artifacts-copy.sh
 extension.tenant.subscribed           =tenant-subscribed.sh
 extension.tenant.unsubscribed         =tenant-unsubscribed.sh
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/a78e3774/products/cartridge-agent/modules/distribution/src/main/bin/stratos.sh
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/modules/distribution/src/main/bin/stratos.sh b/products/cartridge-agent/modules/distribution/src/main/bin/stratos.sh
index f92575a..89a6652 100755
--- a/products/cartridge-agent/modules/distribution/src/main/bin/stratos.sh
+++ b/products/cartridge-agent/modules/distribution/src/main/bin/stratos.sh
@@ -64,8 +64,8 @@ properties="-Dmb.ip=MB-IP
             -Dextension.member.terminated=member-terminated.sh
             -Dextension.complete.topology=complete-topology.sh
             -Dextension.complete.tenant=complete-tenant.sh
-            -Dextension.subscription.domain.added=subscription-domain-added.sh
-            -Dextension.subscription.domain.removed=subscription-domain-removed.sh
+            -Dextension.domain.mapping.added=domain-mapping-added.sh
+            -Dextension.domain.mapping.removed=domain-mapping-removed.sh
             -Dextension.artifacts.copy=artifacts-copy.sh
             -Dextension.tenant.subscribed=tenant-subscribed.sh
             -Dextension.tenant.unsubscribed=tenant-unsubscribed.sh"

http://git-wip-us.apache.org/repos/asf/stratos/blob/a78e3774/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 4b776b0..02b2f4b 100644
--- a/tools/puppet3/modules/agent/templates/bin/stratos.sh.erb
+++ b/tools/puppet3/modules/agent/templates/bin/stratos.sh.erb
@@ -63,8 +63,8 @@ properties="-Dlisten.address=localhost
 	    -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.domain.mapping.added=<%= @extension_domain_mapping_added %>
+            -Dextension.domain.mapping.removed=<%= @extension_domain_mapping_removed %>
             -Dextension.artifacts.copy=<%= @extension_artifacts_copy %>"
 
 # Uncomment below line to enable remote debugging

http://git-wip-us.apache.org/repos/asf/stratos/blob/a78e3774/tools/puppet3/modules/python_agent/templates/agent.conf.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/templates/agent.conf.erb b/tools/puppet3/modules/python_agent/templates/agent.conf.erb
index 4696648..e37de56 100644
--- a/tools/puppet3/modules/python_agent/templates/agent.conf.erb
+++ b/tools/puppet3/modules/python_agent/templates/agent.conf.erb
@@ -53,8 +53,8 @@ extension.member.suspended            =member-suspended.sh
 extension.member.terminated           =member-terminated.sh
 extension.complete.topology           =complete-topology.sh
 extension.complete.tenant             =complete-tenant.sh
-extension.subscription.domain.added   =subscription-domain-added.sh
-extension.subscription.domain.removed =subscription-domain-removed.sh
+extension.domain.mapping.added        =domain-mapping-added.sh
+extension.domain.mapping.removed      =domain-mapping-removed.sh
 extension.artifacts.copy              =artifacts-copy.sh
 extension.tenant.subscribed           =tenant-subscribed.sh
 extension.tenant.unsubscribed         =tenant-unsubscribed.sh
\ No newline at end of file


[6/9] stratos git commit: PCA - Moved bash extensions to extensions/bash PCA - Added ExtensionExecutor to run extension bash scripts PCA - Integration test, change extension permissions

Posted by im...@apache.org.
PCA - Moved bash extensions to extensions/bash
PCA - Added ExtensionExecutor to run extension bash scripts
PCA - Integration test, change extension permissions


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

Branch: refs/heads/master
Commit: d4d812e6790023fb100d56dc00470514ec399839
Parents: a78e377
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Tue Feb 24 13:45:19 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Thu Mar 5 12:15:30 2015 +0530

----------------------------------------------------------------------
 .../cartridge.agent/cartridge.agent/config.py   |   3 +
 .../cartridge.agent/constants.py                |  23 +-
 .../extensions/artifacts-copy.sh                |  32 --
 .../extensions/artifacts-updated.sh             |  28 --
 .../extensions/bash/artifacts-copy.sh           |  32 ++
 .../extensions/bash/artifacts-updated.sh        |  28 ++
 .../cartridge.agent/extensions/bash/clean.sh    |  28 ++
 .../extensions/bash/complete-tenant.sh          |  30 ++
 .../extensions/bash/complete-topology.sh        |  34 ++
 .../extensions/bash/domain-mapping-added.sh     |  41 +++
 .../extensions/bash/domain-mapping-removed.sh   |  39 ++
 .../extensions/bash/instance-activated.sh       |  28 ++
 .../extensions/bash/instance-started.sh         |  27 ++
 .../extensions/bash/member-activated.sh         |  43 +++
 .../extensions/bash/member-started.sh           |  43 +++
 .../extensions/bash/member-suspended.sh         |  43 +++
 .../extensions/bash/member-terminated.sh        |  43 +++
 .../extensions/bash/mount-volumes.sh            |  87 +++++
 .../extensions/bash/start-servers.sh            |  39 ++
 .../extensions/bash/tenant-subscribed.sh        |  28 ++
 .../extensions/bash/tenant-unsubscribed.sh      |  28 ++
 .../cartridge.agent/extensions/clean.sh         |  28 --
 .../extensions/complete-tenant.sh               |  30 --
 .../extensions/complete-topology.sh             |  34 --
 .../extensions/domain-mapping-added.sh          |  41 ---
 .../extensions/domain-mapping-removed.sh        |  39 --
 .../extensions/instance-activated.sh            |  28 --
 .../extensions/instance-started.sh              |  27 --
 .../extensions/member-activated.sh              |  43 ---
 .../extensions/member-started.sh                |  43 ---
 .../extensions/member-suspended.sh              |  43 ---
 .../extensions/member-terminated.sh             |  43 ---
 .../cartridge.agent/extensions/mount-volumes.sh |  87 -----
 .../extensions/py/ExtensionExecutor.py          |  37 ++
 .../py/ExtensionExecutor.yapsy-plugin           |   9 +
 .../cartridge.agent/extensions/py/__init__.py   |  18 +
 .../cartridge.agent/extensions/py/util.py       |  34 ++
 .../cartridge.agent/extensions/start-servers.sh |  39 --
 .../extensions/tenant-subscribed.sh             |  28 --
 .../extensions/tenant-unsubscribed.sh           |  28 --
 .../modules/event/eventhandler.py               | 365 ++++++++++++-------
 .../test/PythonCartridgeAgentTest.java          |   8 +
 42 files changed, 993 insertions(+), 786 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/config.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/config.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/config.py
index 5f5f07d..91503af 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/config.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/config.py
@@ -280,6 +280,9 @@ class CartridgeAgentConfiguration:
             plugins_dir = os.path.abspath(os.path.dirname(__file__)).split("modules")[0] + "/plugins"
             self.__properties.set("agent", constants.PLUGINS_DIR, plugins_dir)
 
+            plugins_dir = os.path.abspath(os.path.dirname(__file__)).split("modules")[0] + "/extensions/py"
+            self.__properties.set("agent", constants.EXTENSIONS_DIR, plugins_dir)
+
         def __read_parameter_file(self):
             """
             Reads the payload file of the cartridge and stores the values in a dictionary

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py
index fb3a341..91d1407 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py
@@ -17,6 +17,7 @@
 
 PARAM_FILE_PATH = "param.file.path"
 PLUGINS_DIR = "plugins.dir"
+EXTENSIONS_DIR = "extensions.dir"
 
 MB_IP = "mb.ip"
 MB_PORT = "mb.port"
@@ -109,17 +110,25 @@ APPLICATION_SIGNUP = "application/signup/#"
 # Messaging Model
 TENANT_RANGE_DELIMITER = "-"
 
+# MB events
+ARTIFACT_UPDATED_EVENT = "ArtifactUpdatedEvent"
 INSTANCE_STARTED_EVENT = "InstanceStartedEvent"
 INSTANCE_ACTIVATED_EVENT = "InstanceActivatedEvent"
 INSTANCE_MAINTENANCE_MODE_EVENT = "InstanceMaintenanceModeEvent"
 INSTANCE_READY_TO_SHUTDOWN_EVENT = "InstanceReadyToShutdownEvent"
-
-PUBLISHER_SERVICE_NAME = "publisher"
-APISTORE_SERVICE_NAME = "apistore"
-APIMANAGER_SERVICE_NAME = "apim"
-GATEWAY_SERVICE_NAME = "gatewaymgt"
-GATEWAY_MGT_SERVICE_NAME = "gateway"
-KEY_MANAGER_SERVICE_NAME = "keymanager"
+INSTANCE_CLEANUP_CLUSTER_EVENT = "InstanceCleanupClusterEvent"
+INSTANCE_CLEANUP_MEMBER_EVENT = "InstanceCleanupMemberEvent"
+COMPLETE_TOPOLOGY_EVENT = "CompleteTopologyEvent"
+COMPLETE_TENANT_EVENT = "CompleteTenantEvent"
+DOMAIN_MAPPING_ADDED_EVENT = "DomainMappingAddedEvent"
+DOMAIN_MAPPING_REMOVED_EVENT = "DomainMappingRemovedEvent"
+MEMBER_INITIALIZED_EVENT = "MemberInitializedEvent"
+MEMBER_ACTIVATED_EVENT = "MemberActivatedEvent"
+MEMBER_TERMINATED_EVENT = "MemberTerminatedEvent"
+MEMBER_SUSPENDED_EVENT = "MembeSuspendedEvent"
+MEMBER_STARTED_EVENT = "MemberStartedEvent"
+TENANT_SUBSCRIBED_EVENT = "TenantSubscribedEvent"
+APPLICATION_SIGNUP_REMOVAL_EVENT = "ApplicationSignUpRemovedEvent"
 
 PRIMARY = "PRIMARY"
 MIN_COUNT = "MIN_COUNT"

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/artifacts-copy.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/artifacts-copy.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/artifacts-copy.sh
deleted file mode 100755
index baa0aeb..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/artifacts-copy.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/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
-if [[ ! -d $2 ]]; then
-   mkdir -p $2
-fi
-cp -rf $1* $2
-echo "Artifacts Copied" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/artifacts-updated.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/artifacts-updated.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/artifacts-updated.sh
deleted file mode 100755
index 15d5591..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/artifacts-updated.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/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
-echo `date`": Artifacts Updated Event" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/artifacts-copy.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/artifacts-copy.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/artifacts-copy.sh
new file mode 100755
index 0000000..baa0aeb
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/artifacts-copy.sh
@@ -0,0 +1,32 @@
+#!/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
+if [[ ! -d $2 ]]; then
+   mkdir -p $2
+fi
+cp -rf $1* $2
+echo "Artifacts Copied" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/artifacts-updated.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/artifacts-updated.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/artifacts-updated.sh
new file mode 100755
index 0000000..15d5591
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/artifacts-updated.sh
@@ -0,0 +1,28 @@
+#!/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
+echo `date`": Artifacts Updated Event" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/clean.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/clean.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/clean.sh
new file mode 100755
index 0000000..c62ad35
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/clean.sh
@@ -0,0 +1,28 @@
+#!/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 stratos manager requests
+# to clean up the instance before terminating it.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+echo `date`": Cleaning the cartridge" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/complete-tenant.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/complete-tenant.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/complete-tenant.sh
new file mode 100755
index 0000000..2586474
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/complete-tenant.sh
@@ -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/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/complete-topology.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/complete-topology.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/complete-topology.sh
new file mode 100755
index 0000000..ea2e941
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/complete-topology.sh
@@ -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/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/domain-mapping-added.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/domain-mapping-added.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/domain-mapping-added.sh
new file mode 100755
index 0000000..7f39472
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/domain-mapping-added.sh
@@ -0,0 +1,41 @@
+#!/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 a subscription domain added
+# event is received by the cartridge agent.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+
+echo "Domain mapping added: [tenant-id] $1 [tenant-domain] $2 [domain-name] $3 [application-context] $4" | tee -a $log
+OUTPUT=`date`": Subscription Domain Added Event"
+OUTPUT="$OUTPUT SUBSCRIPTION_APPLICATION_ID: ${SUBSCRIPTION_APPLICATION_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_SERVICE_NAME: ${STRATOS_SUBSCRIPTION_SERVICE_NAME},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_DOMAIN_NAME: ${STRATOS_SUBSCRIPTION_DOMAIN_NAME},"
+OUTPUT="$OUTPUT SUBSCRIPTION_CLUSTER_ID: ${SUBSCRIPTION_CLUSTER_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_ID: ${STRATOS_SUBSCRIPTION_TENANT_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_DOMAIN: $STRATOS_SUBSCRIPTION_TENANT_DOMAIN},"
+OUTPUT="$OUTPUT APPLICATION_PATH: ${APPLICATION_PATH},"
+OUTPUT="$OUTPUT SUBSCRIPTION_CONTEXT_PATH: ${SUBSCRIPTION_CONTEXT_PATH}"
+echo $OUTPUT | tee -a $log
+
+curl -k -v -X POST -H "Content-Type:application/soap+xml;charset=UTF-8;action=urn:addWebAppToHost" -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\"><s:Body><p:addWebAppToHost xmlns:p=\"http://mapper.url.carbon.wso2.org\"><xs:hostName xmlns:xs=\"http://mapper.url.carbon.wso2.org\">$STRATOS_SUBSCRIPTION_DOMAIN_NAME</xs:hostName><xs:uri xmlns:xs=\"http://mapper.url.carbon.wso2.org\">/t/$STRATOS_SUBSCRIPTION_TENANT_DOMAIN/webapps/$SUBSCRIPTION_CONTEXT_PATH/</xs:uri><xs:appType xmlns:xs=\"http://mapper.url.carbon.wso2.org\">webapp</xs:appType></p:addWebAppToHost></s:Body></s:Envelope>" https://localhost:9443/services/UrlMapperAdminService -u admin:admin

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/domain-mapping-removed.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/domain-mapping-removed.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/domain-mapping-removed.sh
new file mode 100755
index 0000000..3911ec6
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/domain-mapping-removed.sh
@@ -0,0 +1,39 @@
+#!/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 a subscription domain removed
+# event is received by the cartridge agent.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+OUTPUT=`date`": Domain Mapping Removed Event"
+OUTPUT="$OUTPUT SUBSCRIPTION_APPLICATION_ID: ${SUBSCRIPTION_APPLICATION_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_SERVICE_NAME: ${STRATOS_SUBSCRIPTION_SERVICE_NAME},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_DOMAIN_NAME: ${STRATOS_SUBSCRIPTION_DOMAIN_NAME},"
+OUTPUT="$OUTPUT SUBSCRIPTION_CLUSTER_ID: ${SUBSCRIPTION_CLUSTER_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_ID: ${STRATOS_SUBSCRIPTION_TENANT_ID},"
+OUTPUT="$OUTPUT APPLICATION_PATH: ${APPLICATION_PATH},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_DOMAIN: $STRATOS_SUBSCRIPTION_TENANT_DOMAIN}"
+echo $OUTPUT | tee -a $log
+
+curl -k -v -X POST -H "Content-Type:application/soap+xml;charset=UTF-8;action=urn:deleteHost" -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\"><s:Body><p:deleteHost xmlns:p=\"http://mapper.url.carbon.wso2.org\"><xs:hostName xmlns:xs=\"http://mapper.url.carbon.wso2.org\">$STRATOS_SUBSCRIPTION_DOMAIN_NAME</xs:hostName></p:deleteHost></s:Body></s:Envelope>" https://localhost:9443/services/UrlMapperAdminService -u admin:admin
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/instance-activated.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/instance-activated.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/instance-activated.sh
new file mode 100755
index 0000000..f5d60e8
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/instance-activated.sh
@@ -0,0 +1,28 @@
+#!/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 instance is
+# activated and ready to serve incoming requests.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+echo `date`": Instance activated" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/instance-started.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/instance-started.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/instance-started.sh
new file mode 100755
index 0000000..7b5aa6a
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/instance-started.sh
@@ -0,0 +1,27 @@
+#!/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 instance is started.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+echo `date`": Instance Started Event: " | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-activated.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-activated.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-activated.sh
new file mode 100755
index 0000000..e59b41e
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-activated.sh
@@ -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 activated
+# event is received.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+OUTPUT=`date`": Member Activated 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 APPLICATION_PATH: ${APPLICATION_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/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-started.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-started.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-started.sh
new file mode 100755
index 0000000..b750fd0
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-started.sh
@@ -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 APPLICATION_PATH: ${APPLICATION_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/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-suspended.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-suspended.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-suspended.sh
new file mode 100755
index 0000000..103e8dd
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-suspended.sh
@@ -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 APPLICATION_PATH: ${APPLICATION_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/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-terminated.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-terminated.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-terminated.sh
new file mode 100755
index 0000000..37bbd84
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-terminated.sh
@@ -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 APPLICATION_PATH: ${APPLICATION_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/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/mount-volumes.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/mount-volumes.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/mount-volumes.sh
new file mode 100755
index 0000000..2e649bd
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/mount-volumes.sh
@@ -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/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/start-servers.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/start-servers.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/start-servers.sh
new file mode 100755
index 0000000..31ce66c
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/start-servers.sh
@@ -0,0 +1,39 @@
+#!/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 start the servers.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+if [[ -z $STRATOS_CLUSTERING ]]; then
+   echo `date`": Starting servers..." | tee -a $log
+else
+   echo `date`": Starting servers in clustering mode..." | tee -a $log
+fi
+
+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
+echo "APPLICATION_PATH: ${APPLICATION_PATH}" | tee -a $log
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/tenant-subscribed.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/tenant-subscribed.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/tenant-subscribed.sh
new file mode 100755
index 0000000..66f004c
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/tenant-subscribed.sh
@@ -0,0 +1,28 @@
+#!/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
+echo `date`": Tenant Subscribed Event" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/tenant-unsubscribed.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/tenant-unsubscribed.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/tenant-unsubscribed.sh
new file mode 100755
index 0000000..651015d
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/tenant-unsubscribed.sh
@@ -0,0 +1,28 @@
+#!/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
+echo `date`": Tenant UnSubscribed Event" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/clean.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/clean.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/clean.sh
deleted file mode 100755
index c62ad35..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/clean.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/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 stratos manager requests
-# to clean up the instance before terminating it.
-# --------------------------------------------------------------
-#
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-echo `date`": Cleaning the cartridge" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/complete-tenant.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/complete-tenant.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/complete-tenant.sh
deleted file mode 100755
index 2586474..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/complete-tenant.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/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/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/complete-topology.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/complete-topology.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/complete-topology.sh
deleted file mode 100755
index ea2e941..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/complete-topology.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/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/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/domain-mapping-added.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/domain-mapping-added.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/domain-mapping-added.sh
deleted file mode 100755
index 7f39472..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/domain-mapping-added.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/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 a subscription domain added
-# event is received by the cartridge agent.
-# --------------------------------------------------------------
-#
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-
-echo "Domain mapping added: [tenant-id] $1 [tenant-domain] $2 [domain-name] $3 [application-context] $4" | tee -a $log
-OUTPUT=`date`": Subscription Domain Added Event"
-OUTPUT="$OUTPUT SUBSCRIPTION_APPLICATION_ID: ${SUBSCRIPTION_APPLICATION_ID},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_SERVICE_NAME: ${STRATOS_SUBSCRIPTION_SERVICE_NAME},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_DOMAIN_NAME: ${STRATOS_SUBSCRIPTION_DOMAIN_NAME},"
-OUTPUT="$OUTPUT SUBSCRIPTION_CLUSTER_ID: ${SUBSCRIPTION_CLUSTER_ID},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_ID: ${STRATOS_SUBSCRIPTION_TENANT_ID},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_DOMAIN: $STRATOS_SUBSCRIPTION_TENANT_DOMAIN},"
-OUTPUT="$OUTPUT APPLICATION_PATH: ${APPLICATION_PATH},"
-OUTPUT="$OUTPUT SUBSCRIPTION_CONTEXT_PATH: ${SUBSCRIPTION_CONTEXT_PATH}"
-echo $OUTPUT | tee -a $log
-
-curl -k -v -X POST -H "Content-Type:application/soap+xml;charset=UTF-8;action=urn:addWebAppToHost" -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\"><s:Body><p:addWebAppToHost xmlns:p=\"http://mapper.url.carbon.wso2.org\"><xs:hostName xmlns:xs=\"http://mapper.url.carbon.wso2.org\">$STRATOS_SUBSCRIPTION_DOMAIN_NAME</xs:hostName><xs:uri xmlns:xs=\"http://mapper.url.carbon.wso2.org\">/t/$STRATOS_SUBSCRIPTION_TENANT_DOMAIN/webapps/$SUBSCRIPTION_CONTEXT_PATH/</xs:uri><xs:appType xmlns:xs=\"http://mapper.url.carbon.wso2.org\">webapp</xs:appType></p:addWebAppToHost></s:Body></s:Envelope>" https://localhost:9443/services/UrlMapperAdminService -u admin:admin

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/domain-mapping-removed.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/domain-mapping-removed.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/domain-mapping-removed.sh
deleted file mode 100755
index 3911ec6..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/domain-mapping-removed.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/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 a subscription domain removed
-# event is received by the cartridge agent.
-# --------------------------------------------------------------
-#
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-OUTPUT=`date`": Domain Mapping Removed Event"
-OUTPUT="$OUTPUT SUBSCRIPTION_APPLICATION_ID: ${SUBSCRIPTION_APPLICATION_ID},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_SERVICE_NAME: ${STRATOS_SUBSCRIPTION_SERVICE_NAME},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_DOMAIN_NAME: ${STRATOS_SUBSCRIPTION_DOMAIN_NAME},"
-OUTPUT="$OUTPUT SUBSCRIPTION_CLUSTER_ID: ${SUBSCRIPTION_CLUSTER_ID},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_ID: ${STRATOS_SUBSCRIPTION_TENANT_ID},"
-OUTPUT="$OUTPUT APPLICATION_PATH: ${APPLICATION_PATH},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_DOMAIN: $STRATOS_SUBSCRIPTION_TENANT_DOMAIN}"
-echo $OUTPUT | tee -a $log
-
-curl -k -v -X POST -H "Content-Type:application/soap+xml;charset=UTF-8;action=urn:deleteHost" -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\"><s:Body><p:deleteHost xmlns:p=\"http://mapper.url.carbon.wso2.org\"><xs:hostName xmlns:xs=\"http://mapper.url.carbon.wso2.org\">$STRATOS_SUBSCRIPTION_DOMAIN_NAME</xs:hostName></p:deleteHost></s:Body></s:Envelope>" https://localhost:9443/services/UrlMapperAdminService -u admin:admin
-

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/instance-activated.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/instance-activated.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/instance-activated.sh
deleted file mode 100755
index f5d60e8..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/instance-activated.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/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 instance is
-# activated and ready to serve incoming requests.
-# --------------------------------------------------------------
-#
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-echo `date`": Instance activated" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/instance-started.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/instance-started.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/instance-started.sh
deleted file mode 100755
index 7b5aa6a..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/instance-started.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/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 instance is started.
-# --------------------------------------------------------------
-#
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-echo `date`": Instance Started Event: " | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/member-activated.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/member-activated.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/member-activated.sh
deleted file mode 100755
index e59b41e..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/member-activated.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/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.
-# --------------------------------------------------------------
-#
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-OUTPUT=`date`": Member Activated 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 APPLICATION_PATH: ${APPLICATION_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/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/member-started.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/member-started.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/member-started.sh
deleted file mode 100755
index b750fd0..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/member-started.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/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 APPLICATION_PATH: ${APPLICATION_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/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/member-suspended.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/member-suspended.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/member-suspended.sh
deleted file mode 100755
index 103e8dd..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/member-suspended.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/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 APPLICATION_PATH: ${APPLICATION_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/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/member-terminated.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/member-terminated.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/member-terminated.sh
deleted file mode 100755
index 37bbd84..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/member-terminated.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/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 APPLICATION_PATH: ${APPLICATION_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/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/mount-volumes.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/mount-volumes.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/mount-volumes.sh
deleted file mode 100755
index 2e649bd..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/mount-volumes.sh
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/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/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/ExtensionExecutor.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/ExtensionExecutor.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/ExtensionExecutor.py
new file mode 100644
index 0000000..18a688c
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/ExtensionExecutor.py
@@ -0,0 +1,37 @@
+# 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.
+
+from plugins.contracts import ICartridgeAgentPlugin
+import util
+
+
+class ExtensionExecutor(ICartridgeAgentPlugin):
+
+    def run_plugin(self, values, log):
+        event_name = values["EVENT"]
+        log.debug("Running extension for %s" % event_name)
+        extension_values = {}
+        for key in values.keys():
+            extension_values["STRATOS_" + key] = values[key]
+            log.debug("%s => %s" % ("STRATOS_" + key, extension_values["STRATOS_" + key]))
+
+        # script_name = "mount-volumes.sh"
+        output, errors = util.execute_bash(event_name)
+        if len(errors) > 0:
+            raise RuntimeError("Extension execution failed for script %s: %s" % (event_name, errors))
+
+        log.info("%s Extension executed. [output]: %s" % (event_name, output))


[3/9] stratos git commit: PCA - removed extension conf and const entries

Posted by im...@apache.org.
PCA - removed extension conf and const entries


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

Branch: refs/heads/master
Commit: 3289538d613da9771fc5c95e1f0f868aa334968b
Parents: 16f9cf7
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Tue Feb 24 15:30:31 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Thu Mar 5 12:15:30 2015 +0530

----------------------------------------------------------------------
 .../cartridge.agent/cartridge.agent/agent.conf  | 17 -----------------
 .../cartridge.agent/constants.py                | 20 --------------------
 2 files changed, 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/3289538d/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/agent.conf
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/agent.conf b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/agent.conf
index 468ab74..dc33a59 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/agent.conf
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/agent.conf
@@ -42,20 +42,3 @@ APPLICATION_PATH                      =APPLICATION-PATH
 METADATA_SERVICE_URL                  =METADATA-SERVICE-URL
 super.tenant.repository.path          =/repository/deployment/server/
 tenant.repository.path                =/repository/tenants/
-extension.instance.started            =instance-started.sh
-extension.start.servers               =start-servers.sh
-extension.instance.activated          =instance-activated.sh
-extension.artifacts.updated           =artifacts-updated.sh
-extension.clean                       =clean.sh
-extension.mount.volumes               =mount_volumes.sh
-extension.member.started              =member-started.sh
-extension.member.activated            =member-activated.sh
-extension.member.suspended            =member-suspended.sh
-extension.member.terminated           =member-terminated.sh
-extension.complete.topology           =complete-topology.sh
-extension.complete.tenant             =complete-tenant.sh
-extension.domain.mapping.added        =domain-mapping-added.sh
-extension.domain.mapping.removed      =domain-mapping-removed.sh
-extension.artifacts.copy              =artifacts-copy.sh
-extension.tenant.subscribed           =tenant-subscribed.sh
-extension.tenant.unsubscribed         =tenant-unsubscribed.sh
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/3289538d/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py
index e6207ad..dfab659 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py
@@ -67,26 +67,6 @@ LB_PRIVATE_IP = "lb.private.ip"
 LB_PUBLIC_IP = "lb.public.ip"
 METADATA_SERVICE_URL = "METADATA_SERVICE_URL"
 
-# stratos.sh extension points shell scripts names keys
-INSTANCE_STARTED_SCRIPT = "extension.instance.started"
-START_SERVERS_SCRIPT = "extension.start.servers"
-INSTANCE_ACTIVATED_SCRIPT = "extension.instance.activated"
-ARTIFACTS_UPDATED_SCRIPT = "extension.artifacts.updated"
-CLEAN_UP_SCRIPT = "extension.clean"
-MOUNT_VOLUMES_SCRIPT = "extension.mount.volumes"
-MEMBER_ACTIVATED_SCRIPT = "extension.member.activated"
-MEMBER_TERMINATED_SCRIPT = "extension.member.terminated"
-MEMBER_SUSPENDED_SCRIPT = "extension.member.suspended"
-MEMBER_STARTED_SCRIPT = "extension.member.started"
-COMPLETE_TOPOLOGY_SCRIPT = "extension.complete.topology"
-COMPLETE_TENANT_SCRIPT = "extension.complete.tenant"
-DOMAIN_MAPPING_ADDED_SCRIPT = "extension.domain.mapping.added"
-DOMAIN_MAPPING_REMOVED_SCRIPT = "extension.domain.mapping.removed"
-ARTIFACTS_COPY_SCRIPT = "extension.artifacts.copy"
-TENANT_SUBSCRIBED_SCRIPT = "extension.tenant.subscribed"
-TENANT_UNSUBSCRIBED_SCRIPT = "extension.tenant.unsubscribed"
-APPLICATION_SIGNUP_REMOVAL_SCRIPT = "extension.application.signup.removal"
-
 SERVICE_GROUP_TOPOLOGY_KEY = "payload_parameter.SERIVCE_GROUP"
 CLUSTERING_TOPOLOGY_KEY = "payload_parameter.CLUSTERING"
 CLUSTERING_PRIMARY_KEY = "PRIMARY"


[9/9] stratos git commit: PCA - ExtensionExecutor plugin improvments.

Posted by im...@apache.org.
PCA - ExtensionExecutor plugin improvments.


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

Branch: refs/heads/master
Commit: 16f9cf7e0b88f25769dfe07b0a31e2f945685e98
Parents: d4d812e
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Tue Feb 24 15:21:56 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Thu Mar 5 12:15:30 2015 +0530

----------------------------------------------------------------------
 .../cartridge.agent/constants.py                |  2 +-
 .../bash/ApplicationSignUpRemovedEvent.sh       | 28 +++++++
 .../extensions/bash/ArtifactsUpdatedEvent.sh    | 28 +++++++
 .../extensions/bash/CompleteTenantEvent.sh      | 30 +++++++
 .../extensions/bash/CompleteTopologyEvent.sh    | 34 ++++++++
 .../extensions/bash/CopyArtifacts.sh            | 32 +++++++
 .../extensions/bash/DomainMappingAddedEvent.sh  | 41 +++++++++
 .../bash/DomainMappingRemovedEvent.sh           | 39 +++++++++
 .../extensions/bash/InstanceActivatedEvent.sh   | 28 +++++++
 .../extensions/bash/InstanceStartedEvent.sh     | 27 ++++++
 .../extensions/bash/MemberActivatedEvent.sh     | 43 ++++++++++
 .../extensions/bash/MemberStartedEvent.sh       | 43 ++++++++++
 .../extensions/bash/MemberSuspendedEvent.sh     | 43 ++++++++++
 .../extensions/bash/MemberTerminatedEvent.sh    | 43 ++++++++++
 .../extensions/bash/StartServers.sh             | 39 +++++++++
 .../extensions/bash/TenantSubscribedEvent.sh    | 28 +++++++
 .../extensions/bash/VolumeMount.sh              | 87 ++++++++++++++++++++
 .../extensions/bash/artifacts-copy.sh           | 32 -------
 .../extensions/bash/artifacts-updated.sh        | 28 -------
 .../extensions/bash/complete-tenant.sh          | 30 -------
 .../extensions/bash/complete-topology.sh        | 34 --------
 .../extensions/bash/domain-mapping-added.sh     | 41 ---------
 .../extensions/bash/domain-mapping-removed.sh   | 39 ---------
 .../extensions/bash/instance-activated.sh       | 28 -------
 .../extensions/bash/instance-started.sh         | 27 ------
 .../extensions/bash/member-activated.sh         | 43 ----------
 .../extensions/bash/member-started.sh           | 43 ----------
 .../extensions/bash/member-suspended.sh         | 43 ----------
 .../extensions/bash/member-terminated.sh        | 43 ----------
 .../extensions/bash/mount-volumes.sh            | 87 --------------------
 .../extensions/bash/start-servers.sh            | 39 ---------
 .../extensions/bash/tenant-subscribed.sh        | 28 -------
 .../extensions/bash/tenant-unsubscribed.sh      | 28 -------
 .../extensions/py/ExtensionExecutor.py          | 25 +++++-
 .../cartridge.agent/extensions/py/util.py       | 34 --------
 .../modules/event/eventhandler.py               |  5 +-
 36 files changed, 640 insertions(+), 652 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py
index 91d1407..e6207ad 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py
@@ -125,7 +125,7 @@ DOMAIN_MAPPING_REMOVED_EVENT = "DomainMappingRemovedEvent"
 MEMBER_INITIALIZED_EVENT = "MemberInitializedEvent"
 MEMBER_ACTIVATED_EVENT = "MemberActivatedEvent"
 MEMBER_TERMINATED_EVENT = "MemberTerminatedEvent"
-MEMBER_SUSPENDED_EVENT = "MembeSuspendedEvent"
+MEMBER_SUSPENDED_EVENT = "MemberSuspendedEvent"
 MEMBER_STARTED_EVENT = "MemberStartedEvent"
 TENANT_SUBSCRIBED_EVENT = "TenantSubscribedEvent"
 APPLICATION_SIGNUP_REMOVAL_EVENT = "ApplicationSignUpRemovedEvent"

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ApplicationSignUpRemovedEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ApplicationSignUpRemovedEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ApplicationSignUpRemovedEvent.sh
new file mode 100755
index 0000000..651015d
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ApplicationSignUpRemovedEvent.sh
@@ -0,0 +1,28 @@
+#!/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
+echo `date`": Tenant UnSubscribed Event" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ArtifactsUpdatedEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ArtifactsUpdatedEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ArtifactsUpdatedEvent.sh
new file mode 100755
index 0000000..15d5591
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ArtifactsUpdatedEvent.sh
@@ -0,0 +1,28 @@
+#!/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
+echo `date`": Artifacts Updated Event" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CompleteTenantEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CompleteTenantEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CompleteTenantEvent.sh
new file mode 100755
index 0000000..2586474
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CompleteTenantEvent.sh
@@ -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/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CompleteTopologyEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CompleteTopologyEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CompleteTopologyEvent.sh
new file mode 100755
index 0000000..ea2e941
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CompleteTopologyEvent.sh
@@ -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/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CopyArtifacts.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CopyArtifacts.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CopyArtifacts.sh
new file mode 100755
index 0000000..baa0aeb
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CopyArtifacts.sh
@@ -0,0 +1,32 @@
+#!/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
+if [[ ! -d $2 ]]; then
+   mkdir -p $2
+fi
+cp -rf $1* $2
+echo "Artifacts Copied" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/DomainMappingAddedEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/DomainMappingAddedEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/DomainMappingAddedEvent.sh
new file mode 100755
index 0000000..7f39472
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/DomainMappingAddedEvent.sh
@@ -0,0 +1,41 @@
+#!/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 a subscription domain added
+# event is received by the cartridge agent.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+
+echo "Domain mapping added: [tenant-id] $1 [tenant-domain] $2 [domain-name] $3 [application-context] $4" | tee -a $log
+OUTPUT=`date`": Subscription Domain Added Event"
+OUTPUT="$OUTPUT SUBSCRIPTION_APPLICATION_ID: ${SUBSCRIPTION_APPLICATION_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_SERVICE_NAME: ${STRATOS_SUBSCRIPTION_SERVICE_NAME},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_DOMAIN_NAME: ${STRATOS_SUBSCRIPTION_DOMAIN_NAME},"
+OUTPUT="$OUTPUT SUBSCRIPTION_CLUSTER_ID: ${SUBSCRIPTION_CLUSTER_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_ID: ${STRATOS_SUBSCRIPTION_TENANT_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_DOMAIN: $STRATOS_SUBSCRIPTION_TENANT_DOMAIN},"
+OUTPUT="$OUTPUT APPLICATION_PATH: ${APPLICATION_PATH},"
+OUTPUT="$OUTPUT SUBSCRIPTION_CONTEXT_PATH: ${SUBSCRIPTION_CONTEXT_PATH}"
+echo $OUTPUT | tee -a $log
+
+curl -k -v -X POST -H "Content-Type:application/soap+xml;charset=UTF-8;action=urn:addWebAppToHost" -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\"><s:Body><p:addWebAppToHost xmlns:p=\"http://mapper.url.carbon.wso2.org\"><xs:hostName xmlns:xs=\"http://mapper.url.carbon.wso2.org\">$STRATOS_SUBSCRIPTION_DOMAIN_NAME</xs:hostName><xs:uri xmlns:xs=\"http://mapper.url.carbon.wso2.org\">/t/$STRATOS_SUBSCRIPTION_TENANT_DOMAIN/webapps/$SUBSCRIPTION_CONTEXT_PATH/</xs:uri><xs:appType xmlns:xs=\"http://mapper.url.carbon.wso2.org\">webapp</xs:appType></p:addWebAppToHost></s:Body></s:Envelope>" https://localhost:9443/services/UrlMapperAdminService -u admin:admin

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/DomainMappingRemovedEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/DomainMappingRemovedEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/DomainMappingRemovedEvent.sh
new file mode 100755
index 0000000..3911ec6
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/DomainMappingRemovedEvent.sh
@@ -0,0 +1,39 @@
+#!/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 a subscription domain removed
+# event is received by the cartridge agent.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+OUTPUT=`date`": Domain Mapping Removed Event"
+OUTPUT="$OUTPUT SUBSCRIPTION_APPLICATION_ID: ${SUBSCRIPTION_APPLICATION_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_SERVICE_NAME: ${STRATOS_SUBSCRIPTION_SERVICE_NAME},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_DOMAIN_NAME: ${STRATOS_SUBSCRIPTION_DOMAIN_NAME},"
+OUTPUT="$OUTPUT SUBSCRIPTION_CLUSTER_ID: ${SUBSCRIPTION_CLUSTER_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_ID: ${STRATOS_SUBSCRIPTION_TENANT_ID},"
+OUTPUT="$OUTPUT APPLICATION_PATH: ${APPLICATION_PATH},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_DOMAIN: $STRATOS_SUBSCRIPTION_TENANT_DOMAIN}"
+echo $OUTPUT | tee -a $log
+
+curl -k -v -X POST -H "Content-Type:application/soap+xml;charset=UTF-8;action=urn:deleteHost" -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\"><s:Body><p:deleteHost xmlns:p=\"http://mapper.url.carbon.wso2.org\"><xs:hostName xmlns:xs=\"http://mapper.url.carbon.wso2.org\">$STRATOS_SUBSCRIPTION_DOMAIN_NAME</xs:hostName></p:deleteHost></s:Body></s:Envelope>" https://localhost:9443/services/UrlMapperAdminService -u admin:admin
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/InstanceActivatedEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/InstanceActivatedEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/InstanceActivatedEvent.sh
new file mode 100755
index 0000000..f5d60e8
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/InstanceActivatedEvent.sh
@@ -0,0 +1,28 @@
+#!/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 instance is
+# activated and ready to serve incoming requests.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+echo `date`": Instance activated" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/InstanceStartedEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/InstanceStartedEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/InstanceStartedEvent.sh
new file mode 100755
index 0000000..7b5aa6a
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/InstanceStartedEvent.sh
@@ -0,0 +1,27 @@
+#!/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 instance is started.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+echo `date`": Instance Started Event: " | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberActivatedEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberActivatedEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberActivatedEvent.sh
new file mode 100755
index 0000000..e59b41e
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberActivatedEvent.sh
@@ -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 activated
+# event is received.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+OUTPUT=`date`": Member Activated 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 APPLICATION_PATH: ${APPLICATION_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/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberStartedEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberStartedEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberStartedEvent.sh
new file mode 100755
index 0000000..b750fd0
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberStartedEvent.sh
@@ -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 APPLICATION_PATH: ${APPLICATION_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/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberSuspendedEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberSuspendedEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberSuspendedEvent.sh
new file mode 100755
index 0000000..103e8dd
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberSuspendedEvent.sh
@@ -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 APPLICATION_PATH: ${APPLICATION_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/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberTerminatedEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberTerminatedEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberTerminatedEvent.sh
new file mode 100755
index 0000000..37bbd84
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberTerminatedEvent.sh
@@ -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 APPLICATION_PATH: ${APPLICATION_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/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/StartServers.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/StartServers.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/StartServers.sh
new file mode 100755
index 0000000..31ce66c
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/StartServers.sh
@@ -0,0 +1,39 @@
+#!/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 start the servers.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+if [[ -z $STRATOS_CLUSTERING ]]; then
+   echo `date`": Starting servers..." | tee -a $log
+else
+   echo `date`": Starting servers in clustering mode..." | tee -a $log
+fi
+
+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
+echo "APPLICATION_PATH: ${APPLICATION_PATH}" | tee -a $log
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/TenantSubscribedEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/TenantSubscribedEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/TenantSubscribedEvent.sh
new file mode 100755
index 0000000..66f004c
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/TenantSubscribedEvent.sh
@@ -0,0 +1,28 @@
+#!/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
+echo `date`": Tenant Subscribed Event" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/VolumeMount.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/VolumeMount.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/VolumeMount.sh
new file mode 100755
index 0000000..2e649bd
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/VolumeMount.sh
@@ -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/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/artifacts-copy.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/artifacts-copy.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/artifacts-copy.sh
deleted file mode 100755
index baa0aeb..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/artifacts-copy.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/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
-if [[ ! -d $2 ]]; then
-   mkdir -p $2
-fi
-cp -rf $1* $2
-echo "Artifacts Copied" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/artifacts-updated.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/artifacts-updated.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/artifacts-updated.sh
deleted file mode 100755
index 15d5591..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/artifacts-updated.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/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
-echo `date`": Artifacts Updated Event" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/complete-tenant.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/complete-tenant.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/complete-tenant.sh
deleted file mode 100755
index 2586474..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/complete-tenant.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/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/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/complete-topology.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/complete-topology.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/complete-topology.sh
deleted file mode 100755
index ea2e941..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/complete-topology.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/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/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/domain-mapping-added.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/domain-mapping-added.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/domain-mapping-added.sh
deleted file mode 100755
index 7f39472..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/domain-mapping-added.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/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 a subscription domain added
-# event is received by the cartridge agent.
-# --------------------------------------------------------------
-#
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-
-echo "Domain mapping added: [tenant-id] $1 [tenant-domain] $2 [domain-name] $3 [application-context] $4" | tee -a $log
-OUTPUT=`date`": Subscription Domain Added Event"
-OUTPUT="$OUTPUT SUBSCRIPTION_APPLICATION_ID: ${SUBSCRIPTION_APPLICATION_ID},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_SERVICE_NAME: ${STRATOS_SUBSCRIPTION_SERVICE_NAME},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_DOMAIN_NAME: ${STRATOS_SUBSCRIPTION_DOMAIN_NAME},"
-OUTPUT="$OUTPUT SUBSCRIPTION_CLUSTER_ID: ${SUBSCRIPTION_CLUSTER_ID},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_ID: ${STRATOS_SUBSCRIPTION_TENANT_ID},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_DOMAIN: $STRATOS_SUBSCRIPTION_TENANT_DOMAIN},"
-OUTPUT="$OUTPUT APPLICATION_PATH: ${APPLICATION_PATH},"
-OUTPUT="$OUTPUT SUBSCRIPTION_CONTEXT_PATH: ${SUBSCRIPTION_CONTEXT_PATH}"
-echo $OUTPUT | tee -a $log
-
-curl -k -v -X POST -H "Content-Type:application/soap+xml;charset=UTF-8;action=urn:addWebAppToHost" -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\"><s:Body><p:addWebAppToHost xmlns:p=\"http://mapper.url.carbon.wso2.org\"><xs:hostName xmlns:xs=\"http://mapper.url.carbon.wso2.org\">$STRATOS_SUBSCRIPTION_DOMAIN_NAME</xs:hostName><xs:uri xmlns:xs=\"http://mapper.url.carbon.wso2.org\">/t/$STRATOS_SUBSCRIPTION_TENANT_DOMAIN/webapps/$SUBSCRIPTION_CONTEXT_PATH/</xs:uri><xs:appType xmlns:xs=\"http://mapper.url.carbon.wso2.org\">webapp</xs:appType></p:addWebAppToHost></s:Body></s:Envelope>" https://localhost:9443/services/UrlMapperAdminService -u admin:admin

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/domain-mapping-removed.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/domain-mapping-removed.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/domain-mapping-removed.sh
deleted file mode 100755
index 3911ec6..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/domain-mapping-removed.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/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 a subscription domain removed
-# event is received by the cartridge agent.
-# --------------------------------------------------------------
-#
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-OUTPUT=`date`": Domain Mapping Removed Event"
-OUTPUT="$OUTPUT SUBSCRIPTION_APPLICATION_ID: ${SUBSCRIPTION_APPLICATION_ID},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_SERVICE_NAME: ${STRATOS_SUBSCRIPTION_SERVICE_NAME},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_DOMAIN_NAME: ${STRATOS_SUBSCRIPTION_DOMAIN_NAME},"
-OUTPUT="$OUTPUT SUBSCRIPTION_CLUSTER_ID: ${SUBSCRIPTION_CLUSTER_ID},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_ID: ${STRATOS_SUBSCRIPTION_TENANT_ID},"
-OUTPUT="$OUTPUT APPLICATION_PATH: ${APPLICATION_PATH},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_DOMAIN: $STRATOS_SUBSCRIPTION_TENANT_DOMAIN}"
-echo $OUTPUT | tee -a $log
-
-curl -k -v -X POST -H "Content-Type:application/soap+xml;charset=UTF-8;action=urn:deleteHost" -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\"><s:Body><p:deleteHost xmlns:p=\"http://mapper.url.carbon.wso2.org\"><xs:hostName xmlns:xs=\"http://mapper.url.carbon.wso2.org\">$STRATOS_SUBSCRIPTION_DOMAIN_NAME</xs:hostName></p:deleteHost></s:Body></s:Envelope>" https://localhost:9443/services/UrlMapperAdminService -u admin:admin
-

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/instance-activated.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/instance-activated.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/instance-activated.sh
deleted file mode 100755
index f5d60e8..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/instance-activated.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/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 instance is
-# activated and ready to serve incoming requests.
-# --------------------------------------------------------------
-#
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-echo `date`": Instance activated" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/instance-started.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/instance-started.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/instance-started.sh
deleted file mode 100755
index 7b5aa6a..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/instance-started.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/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 instance is started.
-# --------------------------------------------------------------
-#
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-echo `date`": Instance Started Event: " | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-activated.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-activated.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-activated.sh
deleted file mode 100755
index e59b41e..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-activated.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/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.
-# --------------------------------------------------------------
-#
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-OUTPUT=`date`": Member Activated 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 APPLICATION_PATH: ${APPLICATION_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/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-started.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-started.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-started.sh
deleted file mode 100755
index b750fd0..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-started.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/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 APPLICATION_PATH: ${APPLICATION_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/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-suspended.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-suspended.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-suspended.sh
deleted file mode 100755
index 103e8dd..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-suspended.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/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 APPLICATION_PATH: ${APPLICATION_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/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-terminated.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-terminated.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-terminated.sh
deleted file mode 100755
index 37bbd84..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/member-terminated.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/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 APPLICATION_PATH: ${APPLICATION_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/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/mount-volumes.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/mount-volumes.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/mount-volumes.sh
deleted file mode 100755
index 2e649bd..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/mount-volumes.sh
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/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/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/start-servers.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/start-servers.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/start-servers.sh
deleted file mode 100755
index 31ce66c..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/start-servers.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/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 start the servers.
-# --------------------------------------------------------------
-#
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-if [[ -z $STRATOS_CLUSTERING ]]; then
-   echo `date`": Starting servers..." | tee -a $log
-else
-   echo `date`": Starting servers in clustering mode..." | tee -a $log
-fi
-
-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
-echo "APPLICATION_PATH: ${APPLICATION_PATH}" | tee -a $log
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/tenant-subscribed.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/tenant-subscribed.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/tenant-subscribed.sh
deleted file mode 100755
index 66f004c..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/tenant-subscribed.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/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
-echo `date`": Tenant Subscribed Event" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/tenant-unsubscribed.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/tenant-unsubscribed.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/tenant-unsubscribed.sh
deleted file mode 100755
index 651015d..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/tenant-unsubscribed.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/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
-echo `date`": Tenant UnSubscribed Event" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/ExtensionExecutor.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/ExtensionExecutor.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/ExtensionExecutor.py
index 18a688c..d423764 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/ExtensionExecutor.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/ExtensionExecutor.py
@@ -16,7 +16,8 @@
 # under the License.
 
 from plugins.contracts import ICartridgeAgentPlugin
-import util
+import os
+import subprocess
 
 
 class ExtensionExecutor(ICartridgeAgentPlugin):
@@ -29,9 +30,27 @@ class ExtensionExecutor(ICartridgeAgentPlugin):
             extension_values["STRATOS_" + key] = values[key]
             log.debug("%s => %s" % ("STRATOS_" + key, extension_values["STRATOS_" + key]))
 
-        # script_name = "mount-volumes.sh"
-        output, errors = util.execute_bash(event_name)
+        try:
+            output, errors = ExtensionExecutor.execute_bash(event_name + ".sh")
+        except OSError:
+            raise RuntimeError("Could not find an extension file for event %s" % event_name)
+
         if len(errors) > 0:
             raise RuntimeError("Extension execution failed for script %s: %s" % (event_name, errors))
 
         log.info("%s Extension executed. [output]: %s" % (event_name, output))
+
+    @staticmethod
+    def execute_bash(bash_file):
+        """ Execute the given bash files in the <PCA_HOME>/extensions/bash folder
+        :param bash_file: name of the bash file to execute
+        :return: tuple of (output, errors)
+        """
+        working_dir = os.path.abspath(os.path.dirname(__file__)).split("modules")[0]
+        command = working_dir[:-2] + "bash/" + bash_file
+        extension_values = os.environ.copy()
+
+        p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=extension_values)
+        output, errors = p.communicate()
+
+        return output, errors
\ No newline at end of file


[7/9] stratos git commit: PCA - ExtensionExecutor improved Dockerfile - PHP and Tomcat dockerfiles updated and server start plugins included

Posted by im...@apache.org.
PCA - ExtensionExecutor improved
Dockerfile - PHP and Tomcat dockerfiles updated and server start plugins included


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

Branch: refs/heads/master
Commit: 11613b29863634d540aac972f0c1ea657507efd1
Parents: 3289538
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Thu Mar 5 01:55:32 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Thu Mar 5 12:15:30 2015 +0530

----------------------------------------------------------------------
 .../extensions/bash/ArtifactUpdatedEvent.sh     |  28 +++++
 .../extensions/bash/ArtifactsUpdatedEvent.sh    |  28 -----
 .../extensions/py/ExtensionExecutor.py          |  10 +-
 .../base-image/Dockerfile                       |   7 +-
 .../base-image/files/populate-user-data.sh      |  27 -----
 .../base-image/files/run                        | 114 ++++++++++---------
 .../packs/extensions/artifacts-copy.sh          |  28 -----
 .../packs/extensions/artifacts-updated.sh       |  28 -----
 .../base-image/packs/extensions/clean.sh        |  28 -----
 .../packs/extensions/complete-tenant.sh         |  28 -----
 .../packs/extensions/complete-topology.sh       |  28 -----
 .../packs/extensions/domain-mapping-added.sh    |  29 -----
 .../packs/extensions/domain-mapping-removed.sh  |  29 -----
 .../packs/extensions/instance-activated.sh      |  28 -----
 .../packs/extensions/instance-started.sh        |  27 -----
 .../packs/extensions/member-activated.sh        |  28 -----
 .../packs/extensions/member-started.sh          |  28 -----
 .../packs/extensions/member-suspended.sh        |  28 -----
 .../packs/extensions/member-terminated.sh       |  28 -----
 .../packs/extensions/mount-volumes.sh           |  87 --------------
 .../packs/extensions/start-servers.sh           |  27 -----
 .../service-images/php/Dockerfile               |   5 +
 .../php/packs/plugins/PhpServerStarterPlugin.py |  36 ++++++
 .../plugins/PhpServerStarterPlugin.yapsy-plugin |   9 ++
 .../service-images/tomcat-saml-sso/Dockerfile   |  28 ++++-
 .../service-images/tomcat/Dockerfile            |  58 +++++++---
 .../service-images/tomcat/files/env             |   5 +
 .../service-images/tomcat/files/run.sh          |   3 -
 .../packs/plugins/TomcatServerStarterPlugin.py  |  38 +++++++
 .../TomcatServerStarterPlugin.yapsy-plugin      |   9 ++
 .../service-images/wso2is-saml-sso/Dockerfile   |  23 +++-
 31 files changed, 289 insertions(+), 618 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ArtifactUpdatedEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ArtifactUpdatedEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ArtifactUpdatedEvent.sh
new file mode 100755
index 0000000..15d5591
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ArtifactUpdatedEvent.sh
@@ -0,0 +1,28 @@
+#!/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
+echo `date`": Artifacts Updated Event" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ArtifactsUpdatedEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ArtifactsUpdatedEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ArtifactsUpdatedEvent.sh
deleted file mode 100755
index 15d5591..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ArtifactsUpdatedEvent.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/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
-echo `date`": Artifacts Updated Event" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/ExtensionExecutor.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/ExtensionExecutor.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/ExtensionExecutor.py
index d423764..fbd315b 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/ExtensionExecutor.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/ExtensionExecutor.py
@@ -18,20 +18,22 @@
 from plugins.contracts import ICartridgeAgentPlugin
 import os
 import subprocess
+from modules.util.log import LogFactory
 
 
 class ExtensionExecutor(ICartridgeAgentPlugin):
 
-    def run_plugin(self, values, log):
+    def run_plugin(self, values):
+        log = LogFactory().get_log(__name__)
         event_name = values["EVENT"]
         log.debug("Running extension for %s" % event_name)
         extension_values = {}
         for key in values.keys():
             extension_values["STRATOS_" + key] = values[key]
-            log.debug("%s => %s" % ("STRATOS_" + key, extension_values["STRATOS_" + key]))
+            # log.debug("%s => %s" % ("STRATOS_" + key, extension_values["STRATOS_" + key]))
 
         try:
-            output, errors = ExtensionExecutor.execute_bash(event_name + ".sh")
+            output, errors = ExtensionExecutor.execute_script(event_name + ".sh")
         except OSError:
             raise RuntimeError("Could not find an extension file for event %s" % event_name)
 
@@ -41,7 +43,7 @@ class ExtensionExecutor(ICartridgeAgentPlugin):
         log.info("%s Extension executed. [output]: %s" % (event_name, output))
 
     @staticmethod
-    def execute_bash(bash_file):
+    def execute_script(bash_file):
         """ Execute the given bash files in the <PCA_HOME>/extensions/bash folder
         :param bash_file: name of the bash file to execute
         :return: tuple of (output, errors)

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/base-image/Dockerfile
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/base-image/Dockerfile b/tools/docker-images/cartridge-docker-images/base-image/Dockerfile
index d8f7c9f..1d1dfb0 100644
--- a/tools/docker-images/cartridge-docker-images/base-image/Dockerfile
+++ b/tools/docker-images/cartridge-docker-images/base-image/Dockerfile
@@ -47,11 +47,14 @@ RUN pip install yapsy
 # Install cartridge agent 
 # -------------------------
 WORKDIR /mnt/
+
 ADD packs/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT.zip /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT.zip
 RUN unzip -q /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT.zip -d /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/
 RUN rm /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT.zip
+
 RUN mkdir -p /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/payload
-RUN chmod +x /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/extensions/*
+
+RUN chmod +x /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/extensions/bash/*
 RUN mkdir -p /var/log/apache-stratos/
 RUN touch /var/log/apache-stratos/cartridge-agent-extensions.log
 
@@ -60,5 +63,3 @@ RUN touch /var/log/apache-stratos/cartridge-agent-extensions.log
 # -----------------------
 ADD files/run /usr/local/bin/run
 RUN chmod +x /usr/local/bin/run
-ADD files/populate-user-data.sh /usr/local/bin/populate-user-data.sh
-RUN chmod +x /usr/local/bin/populate-user-data.sh

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/base-image/files/populate-user-data.sh
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/base-image/files/populate-user-data.sh b/tools/docker-images/cartridge-docker-images/base-image/files/populate-user-data.sh
deleted file mode 100755
index 522b392..0000000
--- a/tools/docker-images/cartridge-docker-images/base-image/files/populate-user-data.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/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.
-#
-# --------------------------------------------------------------
-
-# Persists the payload parameters by storing the environment variables in the launch-params file
-
-#echo "APPLICATION_ID=${APPLICATION_ID},APPLICATION_PATH=${APPLICATION_PATH},SERVICE_NAME=${SERVICE_NAME},HOST_NAME=${HOST_NAME},MULTITENANT=false,TENANT_ID=${TENANT_ID},TENANT_RANGE=*,CARTRIDGE_ALIAS=${CARTRIDGE_ALIAS},CLUSTER_ID=${CLUSTER_ID},CLUSTER_INSTANCE_ID=${CLUSTER_INSTANCE_ID},CARTRIDGE_KEY=${CARTRIDGE_KEY},DEPLOYMENT=${DEPLOYMENT},REPO_URL=${REPO_URL},PORTS=${PORTS},PUPPET_IP=${PUPPET_IP},PUPPET_HOSTNAME=${PUPPET_HOSTNAME},PUPPET_ENV=${PUPPET_ENV},MEMBER_ID=${MEMBER_ID},LB_CLUSTER_ID=${LB_CLUSTER_ID},NETWORK_PARTITION_ID=${NETWORK_PARTITION_ID},PARTITION_ID=${PARTITION_ID},MIN_COUNT=${MIN_COUNT},INTERNAL=${INTERNAL},CLUSTERING_PRIMARY_KEY=${CLUSTERING_PRIMARY_KEY}" >> /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/payload/launch-params
-
-set -o posix ; set | sed -e ':a;N;$!ba;s/\n/,/g' > /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/payload/launch-params
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/base-image/files/run
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/base-image/files/run b/tools/docker-images/cartridge-docker-images/base-image/files/run
index 69f45b6..042856a 100755
--- a/tools/docker-images/cartridge-docker-images/base-image/files/run
+++ b/tools/docker-images/cartridge-docker-images/base-image/files/run
@@ -25,162 +25,168 @@
 
 
 source /root/.bashrc
-/usr/local/bin/populate-user-data.sh
+
+export STRATOS_VERSION="4.1.0-SNAPSHOT"
+export PCA_HOME="/mnt/apache-stratos-python-cartridge-agent-${STRATOS_VERSION}"
+
+set -o posix ; set | sed -e ':a;N;$!ba;s/\n/,/g' > ${PCA_HOME}/payload/launch-params
 
 #mandatory parameters
-sed -i "s/MB-IP/${MB_IP}/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
-sed -i "s/MB-PORT/${MB_PORT}/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+sed -i "s/MB-IP/${MB_IP}/g" ${PCA_HOME}/agent.conf
+sed -i "s/MB-PORT/${MB_PORT}/g" ${PCA_HOME}/agent.conf
 
 
 #parameters that can be empty
 #default values have to be set
 
 if [ -z "${LISTEN_ADDR}" ]; then
-	sed -i "s/LISTEN_ADDR/localhost/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/LISTEN_ADDR/localhost/g" ${PCA_HOME}/agent.conf
 else
-	sed -i "s/LISTEN_ADDR/${LISTEN_ADDR}/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/LISTEN_ADDR/${LISTEN_ADDR}/g" ${PCA_HOME}/agent.conf
 fi
 
 
 # defaults to the message broker IP if not set
 if [ -z "${CEP_IP}" ]; then
-	sed -i "s/CEP-IP/${MB_IP}/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/CEP-IP/${MB_IP}/g" ${PCA_HOME}/agent.conf
 else
-	sed -i "s/CEP-IP/${CEP_IP}/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/CEP-IP/${CEP_IP}/g" ${PCA_HOME}/agent.conf
 fi
 
 
 if [ -z "${CEP_PORT}" ]; then
-	sed -i "s/CEP-PORT/7711/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/CEP-PORT/7711/g" ${PCA_HOME}/agent.conf
 else
-	sed -i "s/CEP-PORT/${CEP_PORT}/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/CEP-PORT/${CEP_PORT}/g" ${PCA_HOME}/agent.conf
 fi
 
 if [ -z "${CEP_USERNAME}" ]; then
-	sed -i "s/CEP-ADMIN-USERNAME/admin/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/CEP-ADMIN-USERNAME/admin/g" ${PCA_HOME}/agent.conf
 else
-	sed -i "s/CEP-ADMIN-USERNAME/${CEP_USERNAME}/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/CEP-ADMIN-USERNAME/${CEP_USERNAME}/g" ${PCA_HOME}/agent.conf
 fi
 
 if [ -z "${CEP_PASSWORD}" ]; then
-	sed -i "s/CEP-ADMIN-PASSWORD/admin/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/CEP-ADMIN-PASSWORD/admin/g" ${PCA_HOME}/agent.conf
 else
-	sed -i "s/CEP-ADMIN-PASSWORD/${CEP_PASSWORD}/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/CEP-ADMIN-PASSWORD/${CEP_PASSWORD}/g" ${PCA_HOME}/agent.conf
 fi
 
 if [ -z "${ENABLE_HEALTH_PUBLISHER}" ]; then
-	sed -i "s/ENABLE_HEALTH_PUBLISHER/true/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/ENABLE_HEALTH_PUBLISHER/true/g" ${PCA_HOME}/agent.conf
 else
-	sed -i "s/ENABLE_HEALTH_PUBLISHER/${ENABLE_HEALTH_PUBLISHER}/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/ENABLE_HEALTH_PUBLISHER/${ENABLE_HEALTH_PUBLISHER}/g" ${PCA_HOME}/agent.conf
 fi
 
 if [ -z "${LB_PRIVATE_IP}" ]; then
-	sed -i "s/LB_PRIVATE_IP/ /g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/LB_PRIVATE_IP/ /g" ${PCA_HOME}/agent.conf
 else
-	sed -i "s/LB_PRIVATE_IP/${LB_PRIVATE_IP}/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/LB_PRIVATE_IP/${LB_PRIVATE_IP}/g" ${PCA_HOME}/agent.conf
 fi
 
 if [ -z "${LB_PUBLIC_IP}" ]; then
-	sed -i "s/LB_PUBLIC_IP/ /g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/LB_PUBLIC_IP/ /g" ${PCA_HOME}/agent.conf
 else
-	sed -i "s/LB_PUBLIC_IP/${LB_PUBLIC_IP}/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/LB_PUBLIC_IP/${LB_PUBLIC_IP}/g" ${PCA_HOME}/agent.conf
 fi
 
 if [ -z "${ENABLE_ARTFCT_UPDATE}" ]; then
-	sed -i "s/ENABLE_ARTFCT_UPDATE/true/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/ENABLE_ARTFCT_UPDATE/true/g" ${PCA_HOME}/agent.conf
 else
-	sed -i "s/ENABLE_ARTFCT_UPDATE/${ENABLE_ARTFCT_UPDATE}/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/ENABLE_ARTFCT_UPDATE/${ENABLE_ARTFCT_UPDATE}/g" ${PCA_HOME}/agent.conf
 fi
 
 if [ -z "${COMMIT_ENABLED}" ]; then
-	sed -i "s/COMMIT_ENABLED/false/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/COMMIT_ENABLED/false/g" ${PCA_HOME}/agent.conf
 else
-	sed -i "s/COMMIT_ENABLED/${COMMIT_ENABLED}/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/COMMIT_ENABLED/${COMMIT_ENABLED}/g" ${PCA_HOME}/agent.conf
 fi
 
 if [ -z "${CHECKOUT_ENABLED}" ]; then
-	sed -i "s/CHECKOUT_ENABLED/true/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/CHECKOUT_ENABLED/true/g" ${PCA_HOME}/agent.conf
 else
-	sed -i "s/CHECKOUT_ENABLED/${CHECKOUT_ENABLED}/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/CHECKOUT_ENABLED/${CHECKOUT_ENABLED}/g" ${PCA_HOME}/agent.conf
 fi
 
 if [ -z "${ARTFCT_UPDATE_INT}" ]; then
-	sed -i "s/ARTFCT_UPDATE_INT/15/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/ARTFCT_UPDATE_INT/15/g" ${PCA_HOME}/agent.conf
 else
-	sed -i "s/ARTFCT_UPDATE_INT/${ARTFCT_UPDATE_INT}/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/ARTFCT_UPDATE_INT/${ARTFCT_UPDATE_INT}/g" ${PCA_HOME}/agent.conf
 fi
 
 if [ -z "${PORT_CHECK_TIMEOUT}" ]; then
-	sed -i "s/PORT_CHECK_TIMEOUT/600000/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/PORT_CHECK_TIMEOUT/600000/g" ${PCA_HOME}/agent.conf
 else
-	sed -i "s/PORT_CHECK_TIMEOUT/${PORT_CHECK_TIMEOUT}/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/PORT_CHECK_TIMEOUT/${PORT_CHECK_TIMEOUT}/g" ${PCA_HOME}/agent.conf
 fi
 
 if [ -z "${ENABLE_DATA_PUBLISHER}" ]; then
-	sed -i "s/ENABLE-DATA-PUBLISHER/false/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/ENABLE-DATA-PUBLISHER/false/g" ${PCA_HOME}/agent.conf
 else
-	sed -i "s/ENABLE-DATA-PUBLISHER/${ENABLE_DATA_PUBLISHER}/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/ENABLE-DATA-PUBLISHER/${ENABLE_DATA_PUBLISHER}/g" ${PCA_HOME}/agent.conf
 fi
 
 # defaults to the message broker IP if not set
 if [ -z "${MONITORING_SERVER_IP}" ]; then
-	sed -i "s/MONITORING-SERVER-IP/${MB_IP}/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/MONITORING-SERVER-IP/${MB_IP}/g" ${PCA_HOME}/agent.conf
 else
-	sed -i "s/MONITORING-SERVER-IP/${MONITORING_SERVER_IP}/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/MONITORING-SERVER-IP/${MONITORING_SERVER_IP}/g" ${PCA_HOME}/agent.conf
 fi
 
 if [ -z "${MONITORING_SERVER_PORT}" ]; then
-	sed -i "s/MONITORING-SERVER-PORT/7611/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/MONITORING-SERVER-PORT/7611/g" ${PCA_HOME}/agent.conf
 else
-	sed -i "s/MONITORING-SERVER-PORT/${MONITORING_SERVER_PORT}/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/MONITORING-SERVER-PORT/${MONITORING_SERVER_PORT}/g" ${PCA_HOME}/agent.conf
 fi
 
 if [ -z "${MONITORING_SERVER_SECURE_PORT}" ]; then
-	sed -i "s/MONITORING-SERVER-SECURE-PORT/7711/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/MONITORING-SERVER-SECURE-PORT/7711/g" ${PCA_HOME}/agent.conf
 else
-	sed -i "s/MONITORING-SERVER-SECURE-PORT/${MONITORING_SERVER_SECURE_PORT}/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/MONITORING-SERVER-SECURE-PORT/${MONITORING_SERVER_SECURE_PORT}/g" ${PCA_HOME}/agent.conf
 fi
 
 if [ -z "${MONITORING_SERVER_ADMIN_USERNAME}" ]; then
-	sed -i "s/MONITORING-SERVER-ADMIN-USERNAME/admin/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/MONITORING-SERVER-ADMIN-USERNAME/admin/g" ${PCA_HOME}/agent.conf
 else
-	sed -i "s/MONITORING-SERVER-ADMIN-USERNAME/${MONITORING_SERVER_ADMIN_USERNAME}/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/MONITORING-SERVER-ADMIN-USERNAME/${MONITORING_SERVER_ADMIN_USERNAME}/g" ${PCA_HOME}/agent.conf
 fi
 
 if [ -z "${MONITORING_SERVER_ADMIN_PASSWORD}" ]; then
-	sed -i "s/MONITORING-SERVER-ADMIN-PASSWORD/admin/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/MONITORING-SERVER-ADMIN-PASSWORD/admin/g" ${PCA_HOME}/agent.conf
 else
-	sed -i "s/MONITORING-SERVER-ADMIN-PASSWORD/${MONITORING_SERVER_ADMIN_PASSWORD}/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/MONITORING-SERVER-ADMIN-PASSWORD/${MONITORING_SERVER_ADMIN_PASSWORD}/g" ${PCA_HOME}/agent.conf
 fi
 
 if [ -z "${LOG_FILE_PATHS}" ]; then
-	sed -i "s/LOG_FILE_PATHS/ /g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/LOG_FILE_PATHS/ /g" ${PCA_HOME}/agent.conf
 else
-	sed -i "s#LOG_FILE_PATHS#${LOG_FILE_PATHS}#g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s#LOG_FILE_PATHS#${LOG_FILE_PATHS}#g" ${PCA_HOME}/agent.conf
 fi
 
 if [ -z "${APPLICATION_PATH}" ]; then
-	sed -i "s/APPLICATION-PATH/ /g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/APPLICATION-PATH/ /g" ${PCA_HOME}/agent.conf
 else
-	sed -i "s#APPLICATION-PATH#${APPLICATION_PATH}#g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s#APPLICATION-PATH#${APPLICATION_PATH}#g" ${PCA_HOME}/agent.conf
 fi
 
 if [ -z "${METADATA_SERVICE_URL}" ]; then
-	sed -i "s/METADATA-SERVICE-URL/ /g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s/METADATA-SERVICE-URL/ /g" ${PCA_HOME}/agent.conf
 else
-	sed -i "s#METADATA-SERVICE-URL#${METADATA_SERVICE_URL}#g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/agent.conf
+	sed -i "s#METADATA-SERVICE-URL#${METADATA_SERVICE_URL}#g" ${PCA_HOME}/agent.conf
 fi
 
 if [ -z "${LOG_LEVEL}" ]; then
-	sed -i "s/LOG_LEVEL/INFO/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/logging.ini
+	sed -i "s/LOG_LEVEL/INFO/g" ${PCA_HOME}/logging.ini
 else
-	sed -i "s/LOG_LEVEL/${LOG_LEVEL}/g" /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/logging.ini
+	sed -i "s/LOG_LEVEL/${LOG_LEVEL}/g" ${PCA_HOME}/logging.ini
 fi
 
-# copy plugins to PCA
-cp -R /mnt/plugins /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT/
+# copy custom plugins to PCA
+cp -R /mnt/plugins ${PCA_HOME}/
+
+# copy custom extensions to PCA
+cp -R /mnt/extensions ${PCA_HOME}/
 
 # Start cartridge agent
-cd /mnt/apache-stratos-python-cartridge-agent-4.1.0-SNAPSHOT
-python agent.py > /tmp/agent.screen.log 2>&1 &
-#/usr/sbin/apache2ctl -D FOREGROUND
+cd ${PCA_HOME}/
+python agent.py > /tmp/agent.screen.log 2>&1 &
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/artifacts-copy.sh
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/artifacts-copy.sh b/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/artifacts-copy.sh
deleted file mode 100644
index f25182f..0000000
--- a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/artifacts-copy.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/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
-echo `date`": Artifacts Copied: " | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/artifacts-updated.sh
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/artifacts-updated.sh b/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/artifacts-updated.sh
deleted file mode 100755
index 15d5591..0000000
--- a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/artifacts-updated.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/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
-echo `date`": Artifacts Updated Event" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/clean.sh
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/clean.sh b/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/clean.sh
deleted file mode 100755
index c62ad35..0000000
--- a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/clean.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/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 stratos manager requests
-# to clean up the instance before terminating it.
-# --------------------------------------------------------------
-#
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-echo `date`": Cleaning the cartridge" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/complete-tenant.sh
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/complete-tenant.sh b/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/complete-tenant.sh
deleted file mode 100644
index 50e4506..0000000
--- a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/complete-tenant.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/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

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/complete-topology.sh
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/complete-topology.sh b/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/complete-topology.sh
deleted file mode 100644
index a3311ad..0000000
--- a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/complete-topology.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/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

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/domain-mapping-added.sh
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/domain-mapping-added.sh b/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/domain-mapping-added.sh
deleted file mode 100644
index 759f6b4..0000000
--- a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/domain-mapping-added.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/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`": Domain Mapping Added Event"
-echo $OUTPUT | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/domain-mapping-removed.sh
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/domain-mapping-removed.sh b/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/domain-mapping-removed.sh
deleted file mode 100644
index 3be259e..0000000
--- a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/domain-mapping-removed.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/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`": Domain Mapping Removed Event"
-echo $OUTPUT | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/instance-activated.sh
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/instance-activated.sh b/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/instance-activated.sh
deleted file mode 100755
index f5d60e8..0000000
--- a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/instance-activated.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/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 instance is
-# activated and ready to serve incoming requests.
-# --------------------------------------------------------------
-#
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-echo `date`": Instance activated" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/instance-started.sh
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/instance-started.sh b/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/instance-started.sh
deleted file mode 100755
index 7b5aa6a..0000000
--- a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/instance-started.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/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 instance is started.
-# --------------------------------------------------------------
-#
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-echo `date`": Instance Started Event: " | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/member-activated.sh
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/member-activated.sh b/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/member-activated.sh
deleted file mode 100644
index f6e8201..0000000
--- a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/member-activated.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/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.
-# --------------------------------------------------------------
-#
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-OUTPUT=`date`": Member Activated Event: "

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/member-started.sh
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/member-started.sh b/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/member-started.sh
deleted file mode 100644
index 0b558b6..0000000
--- a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/member-started.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/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
-echo `date`": Member Started Event: " | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/member-suspended.sh
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/member-suspended.sh b/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/member-suspended.sh
deleted file mode 100644
index acf44b9..0000000
--- a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/member-suspended.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/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
-echo `date`": Member Suspended Event:" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/member-terminated.sh
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/member-terminated.sh b/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/member-terminated.sh
deleted file mode 100644
index 0e69629..0000000
--- a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/member-terminated.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/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: "

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/mount-volumes.sh
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/mount-volumes.sh b/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/mount-volumes.sh
deleted file mode 100755
index 2e649bd..0000000
--- a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/mount-volumes.sh
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/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/11613b29/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/start-servers.sh
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/start-servers.sh b/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/start-servers.sh
deleted file mode 100755
index bac3a57..0000000
--- a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/start-servers.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/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 start the servers.
-# --------------------------------------------------------------
-#
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-echo `date`": Starting servers" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/service-images/php/Dockerfile
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/service-images/php/Dockerfile b/tools/docker-images/cartridge-docker-images/service-images/php/Dockerfile
index 64bcf49..4ac9530 100644
--- a/tools/docker-images/cartridge-docker-images/service-images/php/Dockerfile
+++ b/tools/docker-images/cartridge-docker-images/service-images/php/Dockerfile
@@ -29,6 +29,11 @@ RUN apt-get install -y apache2 php5 zip stress
 RUN rm -f /etc/apache2/sites-enabled/000-default.conf
 ADD files/000-default.conf /etc/apache2/sites-enabled/000-default.conf
 
+#------------------------
+# Copy PHP related PCA plugins
+#-----------------------
+ADD packs/plugins /mnt/plugins
+
 EXPOSE 80
 
 # ----------------

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/service-images/php/packs/plugins/PhpServerStarterPlugin.py
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/service-images/php/packs/plugins/PhpServerStarterPlugin.py b/tools/docker-images/cartridge-docker-images/service-images/php/packs/plugins/PhpServerStarterPlugin.py
new file mode 100644
index 0000000..13d165c
--- /dev/null
+++ b/tools/docker-images/cartridge-docker-images/service-images/php/packs/plugins/PhpServerStarterPlugin.py
@@ -0,0 +1,36 @@
+# 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.
+
+import mdsclient
+from plugins.contracts import ICartridgeAgentPlugin
+import time
+import zipfile
+import subprocess
+from modules.util.log import LogFactory
+import os
+
+
+class PhpServerStarterPlugin(ICartridgeAgentPlugin):
+
+    def run_plugin(self, values):
+        log = LogFactory().get_log(__name__)
+        # php_start_command = "/usr/sbin/apache2ctl -D FOREGROUND"
+        php_start_command = "/etc/init.d/apache2 restart"
+        p = subprocess.Popen(php_start_command, shell=True)
+        output, errors = p.communicate()
+        log.debug("Apache server started: [command] %s, [output] %s" % (php_start_command, output))
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/service-images/php/packs/plugins/PhpServerStarterPlugin.yapsy-plugin
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/service-images/php/packs/plugins/PhpServerStarterPlugin.yapsy-plugin b/tools/docker-images/cartridge-docker-images/service-images/php/packs/plugins/PhpServerStarterPlugin.yapsy-plugin
new file mode 100644
index 0000000..221ffd5
--- /dev/null
+++ b/tools/docker-images/cartridge-docker-images/service-images/php/packs/plugins/PhpServerStarterPlugin.yapsy-plugin
@@ -0,0 +1,9 @@
+[Core]
+Name = PhpServerStarterPlugin to start Apache server with PHP
+Module = PhpServerStarterPlugin
+
+[Documentation]
+Description = ArtifactUpdatedEvent
+Author = Op1
+Version = 0.1
+Website = stratos.apache.org
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/service-images/tomcat-saml-sso/Dockerfile
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/service-images/tomcat-saml-sso/Dockerfile b/tools/docker-images/cartridge-docker-images/service-images/tomcat-saml-sso/Dockerfile
index b5ada30..63ce7d3 100644
--- a/tools/docker-images/cartridge-docker-images/service-images/tomcat-saml-sso/Dockerfile
+++ b/tools/docker-images/cartridge-docker-images/service-images/tomcat-saml-sso/Dockerfile
@@ -1,4 +1,25 @@
-FROM chamilad/base-image:4.1.0-beta
+# --------------------------------------------------------------
+#
+# 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.
+#
+# --------------------------------------------------------------
+
+FROM stratos/base-image:4.1.0-beta
 MAINTAINER dev@stratos.apache.org
 
 ENV JDK_VERSION 1.7.0_60
@@ -8,15 +29,11 @@ ENV TOMCAT_VERSION 7.0.55
 # ----------------------
 # Install prerequisites
 # ----------------------
-# RUN apt-get update && \ apt-get install -yq --no-install-recommends openjdk-7-jre wget ca-certificates && \apt-get clean && \rm -rf /var/lib/apt/lists/*
 WORKDIR /opt
-# RUN wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u67-b01/jdk-7u60-linux-x64.tar.gz
 ADD packs/${JDK_TAR_FILENAME} /mnt/${JDK_TAR_FILENAME}
-# RUN tar zxvf /mnt/${JDK_TAR_FILENAME}
 RUN mv /mnt/${JDK_TAR_FILENAME}/jdk${JDK_VERSION} /opt/jdk${JDK_VERSION}
 ENV JAVA_HOME /opt/jdk${JDK_VERSION}
 
-
 ENV CATALINA_HOME /opt/tomcat
 
 # ----------------------
@@ -30,7 +47,6 @@ RUN mv /opt/apache-tomcat-${TOMCAT_VERSION}.tar.gz/apache-tomcat-${TOMCAT_VERSIO
 # Add shell scripts
 # -----------------------
 ADD files/create-admin-user.sh /opt/create-admin-user.sh
-# ADD files/run.sh /opt/run.sh
 RUN chmod +x /opt/create-admin-user.sh && \
     bash /opt/create-admin-user.sh
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/service-images/tomcat/Dockerfile
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/service-images/tomcat/Dockerfile b/tools/docker-images/cartridge-docker-images/service-images/tomcat/Dockerfile
index 1f8d1b3..7eb916b 100644
--- a/tools/docker-images/cartridge-docker-images/service-images/tomcat/Dockerfile
+++ b/tools/docker-images/cartridge-docker-images/service-images/tomcat/Dockerfile
@@ -1,37 +1,69 @@
+# --------------------------------------------------------------
+#
+# 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.
+#
+# --------------------------------------------------------------
+
 FROM stratos/base-image:4.1.0-beta
 MAINTAINER dev@stratos.apache.org
 
+ENV JDK_VERSION 1.7.0_67
+ENV JDK_TAR_FILENAME jdk-7u67-linux-x64.tar.gz
+ENV TOMCAT_VERSION 7.0.59
+
 # ----------------------
 # Install prerequisites
 # ----------------------
-RUN apt-get update && \
-    apt-get install -yq --no-install-recommends openjdk-7-jre wget ca-certificates && \
-    apt-get clean && \
-    rm -rf /var/lib/apt/lists/*
+WORKDIR /opt
+ADD packs/${JDK_TAR_FILENAME} /mnt/${JDK_TAR_FILENAME}
+RUN mv /mnt/${JDK_TAR_FILENAME}/jdk${JDK_VERSION} /opt/jdk${JDK_VERSION}
+ENV JAVA_HOME /opt/jdk${JDK_VERSION}
 
 ENV CATALINA_HOME /opt/tomcat
 
 # ----------------------
 # Install Tomcat
 # ----------------------
-RUN cd /opt/ && \
-    wget -q https://archive.apache.org/dist/tomcat/tomcat-7/v7.0.55/bin/apache-tomcat-7.0.55.tar.gz && \
-    wget -qO- https://archive.apache.org/dist/tomcat/tomcat-7/v7.0.55/bin/apache-tomcat-7.0.55.tar.gz.md5 | md5sum -c - && \
-    tar zxf apache-tomcat-7.0.55.tar.gz && \
-    rm apache-tomcat-7.0.55.tar.gz && \
-    mv apache-tomcat-7.0.55 tomcat
+ADD packs/apache-tomcat-${TOMCAT_VERSION}.tar.gz /opt/apache-tomcat-${TOMCAT_VERSION}.tar.gz
+RUN mv /opt/apache-tomcat-${TOMCAT_VERSION}.tar.gz/apache-tomcat-${TOMCAT_VERSION} /opt/tomcat && \
+    rm -rf /opt/apache-tomcat-${TOMCAT_VERSION}.tar.gz
 
 # -----------------------
 # Add shell scripts
 # -----------------------
 ADD files/create-admin-user.sh /opt/create-admin-user.sh
-ADD files/run.sh /opt/run.sh
-RUN chmod +x /opt/create-admin-user.sh /opt/run.sh && \
+RUN chmod +x /opt/create-admin-user.sh && \
     bash /opt/create-admin-user.sh
 
+ADD files/env /tmp/env
+RUN chmod +x /tmp/env && \
+    sleep 1 && \
+    /tmp/env ${JAVA_HOME} ${CATALINA_HOME}
+
+#------------------------
+# Copy Tomcat related PCA plugins
+#-----------------------
+ADD packs/plugins /mnt/plugins
+
+
 EXPOSE 8080
 
 # -----------------------
 # Define entry point
 # -----------------------
-ENTRYPOINT /usr/local/bin/run | /opt/run.sh | /usr/sbin/sshd -D
+ENTRYPOINT /usr/local/bin/run | /usr/sbin/sshd -D

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/service-images/tomcat/files/env
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/service-images/tomcat/files/env b/tools/docker-images/cartridge-docker-images/service-images/tomcat/files/env
new file mode 100644
index 0000000..b9deae3
--- /dev/null
+++ b/tools/docker-images/cartridge-docker-images/service-images/tomcat/files/env
@@ -0,0 +1,5 @@
+JAVA_HOME=$1
+CATALINA_HOME=$2
+
+echo "JAVA_HOME=${JAVA_HOME}" >> /etc/environment
+echo "CATALINA_HOME=${CATALINA_HOME}" >> /etc/environment
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/service-images/tomcat/files/run.sh
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/service-images/tomcat/files/run.sh b/tools/docker-images/cartridge-docker-images/service-images/tomcat/files/run.sh
deleted file mode 100644
index 2058dd9..0000000
--- a/tools/docker-images/cartridge-docker-images/service-images/tomcat/files/run.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-exec ${CATALINA_HOME}/bin/catalina.sh run

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/service-images/tomcat/packs/plugins/TomcatServerStarterPlugin.py
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/service-images/tomcat/packs/plugins/TomcatServerStarterPlugin.py b/tools/docker-images/cartridge-docker-images/service-images/tomcat/packs/plugins/TomcatServerStarterPlugin.py
new file mode 100644
index 0000000..6509865
--- /dev/null
+++ b/tools/docker-images/cartridge-docker-images/service-images/tomcat/packs/plugins/TomcatServerStarterPlugin.py
@@ -0,0 +1,38 @@
+# 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.
+
+import mdsclient
+from plugins.contracts import ICartridgeAgentPlugin
+import time
+import zipfile
+import subprocess
+from modules.util.log import LogFactory
+import os
+
+
+class TomcatServerStarterPlugin(ICartridgeAgentPlugin):
+
+    def run_plugin(self, values):
+        log = LogFactory().get_log(__name__)
+        # start tomcat
+        tomcat_start_command = "exec ${CATALINA_HOME}/bin/startup.sh"
+        log.info("Starting Tomcat server: [command] %s" % tomcat_start_command)
+
+        p = subprocess.Popen(tomcat_start_command, shell=True)
+        output, errors = p.communicate()
+        log.debug("Tomcat server started: [command] %s, [output] %s" % (p.args, output))
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/service-images/tomcat/packs/plugins/TomcatServerStarterPlugin.yapsy-plugin
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/service-images/tomcat/packs/plugins/TomcatServerStarterPlugin.yapsy-plugin b/tools/docker-images/cartridge-docker-images/service-images/tomcat/packs/plugins/TomcatServerStarterPlugin.yapsy-plugin
new file mode 100644
index 0000000..87e0de2
--- /dev/null
+++ b/tools/docker-images/cartridge-docker-images/service-images/tomcat/packs/plugins/TomcatServerStarterPlugin.yapsy-plugin
@@ -0,0 +1,9 @@
+[Core]
+Name = TomcatServerStarterPlugin to read SAML SSO related metadata needed to configure SAML SSO for apps and start tomcat
+Module = TomcatServerStarterPlugin
+
+[Documentation]
+Description = ArtifactUpdatedEvent
+Author = Op1
+Version = 0.1
+Website = stratos.apache.org
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/11613b29/tools/docker-images/cartridge-docker-images/service-images/wso2is-saml-sso/Dockerfile
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/service-images/wso2is-saml-sso/Dockerfile b/tools/docker-images/cartridge-docker-images/service-images/wso2is-saml-sso/Dockerfile
index bb612b7..09e1d5a 100644
--- a/tools/docker-images/cartridge-docker-images/service-images/wso2is-saml-sso/Dockerfile
+++ b/tools/docker-images/cartridge-docker-images/service-images/wso2is-saml-sso/Dockerfile
@@ -1,4 +1,25 @@
-FROM chamilad/base-image:4.1.0-beta
+# --------------------------------------------------------------
+#
+# 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.
+#
+# --------------------------------------------------------------
+
+FROM stratos/base-image:4.1.0-beta
 MAINTAINER dev@stratos.apache.org
 
 ENV DEBIAN_FRONTEND noninteractive


[4/9] stratos git commit: This closes #257 on GitHub

Posted by im...@apache.org.
This closes #257 on GitHub


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

Branch: refs/heads/master
Commit: f97407f301d88bf9b300884da0764b4a3871d1b8
Parents: 11613b2
Author: Imesh Gunaratne <im...@apache.org>
Authored: Thu Mar 5 12:15:30 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Thu Mar 5 12:15:30 2015 +0530

----------------------------------------------------------------------

----------------------------------------------------------------------



[5/9] stratos git commit: PCA - Moved bash extensions to extensions/bash PCA - Added ExtensionExecutor to run extension bash scripts PCA - Integration test, change extension permissions

Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/ExtensionExecutor.yapsy-plugin
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/ExtensionExecutor.yapsy-plugin b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/ExtensionExecutor.yapsy-plugin
new file mode 100644
index 0000000..1332437
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/ExtensionExecutor.yapsy-plugin
@@ -0,0 +1,9 @@
+[Core]
+Name = ExtensionExecutor
+Module = ExtensionExecutor
+
+[Documentation]
+Description = ExtensionExecutor
+Author = Op1
+Version = 0.1
+Website = stratos.apache.org
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/__init__.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/__init__.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/__init__.py
new file mode 100644
index 0000000..9dd7d7b
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/__init__.py
@@ -0,0 +1,18 @@
+# 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.
+
+__author__ = 'chamilad'

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/util.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/util.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/util.py
new file mode 100644
index 0000000..7c53db4
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/util.py
@@ -0,0 +1,34 @@
+# 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.
+
+import os
+import subprocess
+
+
+def execute_bash(bash_file):
+    """ Execute the given bash files in the <PCA_HOME>/extensions/bash folder
+    :param bash_file: name of the bash file to execute
+    :return: tuple of (output, errors)
+    """
+    working_dir = os.path.abspath(os.path.dirname(__file__)).split("modules")[0]
+    command = working_dir[:-2] + "bash/" + bash_file
+    extension_values = os.environ.copy()
+
+    p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=extension_values)
+    output, errors = p.communicate()
+
+    return output, errors
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/start-servers.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/start-servers.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/start-servers.sh
deleted file mode 100755
index 31ce66c..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/start-servers.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/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 start the servers.
-# --------------------------------------------------------------
-#
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-if [[ -z $STRATOS_CLUSTERING ]]; then
-   echo `date`": Starting servers..." | tee -a $log
-else
-   echo `date`": Starting servers in clustering mode..." | tee -a $log
-fi
-
-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
-echo "APPLICATION_PATH: ${APPLICATION_PATH}" | tee -a $log
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/tenant-subscribed.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/tenant-subscribed.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/tenant-subscribed.sh
deleted file mode 100755
index 66f004c..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/tenant-subscribed.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/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
-echo `date`": Tenant Subscribed Event" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/tenant-unsubscribed.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/tenant-unsubscribed.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/tenant-unsubscribed.sh
deleted file mode 100755
index 651015d..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/tenant-unsubscribed.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/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
-echo `date`": Tenant UnSubscribed Event" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
index f27fee1..f831a89 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
@@ -48,133 +48,19 @@ class EventHandler:
     def __init__(self):
         self.__log = LogFactory().get_log(__name__)
         self.__config = CartridgeAgentConfiguration()
-        self.__plugin_manager = None
         self.__plugins = {}
         """ :type dict{str: [PluginInfo]} : """
         self.__artifact_mgt_plugins = []
-        self.__plugin_manager, self.__plugins, self.__artifact_mgt_plugins = self.initialize_plugins()
-
-    def initialize_plugins(self):
-        self.__log.info("Collecting and loading plugins")
-
-        try:
-            plugin_manager = PluginManager()
-            # TODO: change plugin descriptor extensions, plugin_manager.setPluginInfoExtension(AGENT_PLUGIN_EXT)
-            plugin_manager.setCategoriesFilter({
-                CARTRIDGE_AGENT_PLUGIN: ICartridgeAgentPlugin,
-                ARTIFACT_MGT_PLUGIN: IArtifactManagementPlugin
-            })
-
-            plugin_manager.setPluginPlaces([self.__config.read_property(constants.PLUGINS_DIR)])
-
-            plugin_manager.collectPlugins()
-
-            # activate cartridge agent plugins
-            plugins = plugin_manager.getPluginsOfCategory(CARTRIDGE_AGENT_PLUGIN)
-            grouped_plugins = {}
-            for plugin_info in plugins:
-                self.__log.debug("Found plugin [%s] at [%s]" % (plugin_info.name, plugin_info.path))
-                plugin_manager.activatePluginByName(plugin_info.name)
-                self.__log.info("Activated plugin [%s]" % plugin_info.name)
-
-                mapped_events = plugin_info.description.split(",")
-                for mapped_event in mapped_events:
-                    if mapped_event.strip() != "":
-                        if grouped_plugins.get(mapped_event) is None:
-                            grouped_plugins[mapped_event] = []
-
-                        grouped_plugins[mapped_event].append(plugin_info)
-
-            # activate artifact management plugins
-            artifact_mgt_plugins = plugin_manager.getPluginsOfCategory(ARTIFACT_MGT_PLUGIN)
-            for plugin_info in artifact_mgt_plugins:
-                self.__log.debug("Found artifact management plugin [%s] at [%s]" % (plugin_info.name, plugin_info.path))
-                plugin_manager.activatePluginByName(plugin_info.name)
-                self.__log.info("Activated artifact management plugin [%s]" % plugin_info.name)
-
-            return plugin_manager, grouped_plugins, artifact_mgt_plugins
-        except ParameterNotFoundException as e:
-            self.__log.exception("Could not load plugins. Plugins directory not set: %s" % e)
-            return None, None, None
-        except Exception as e:
-            self.__log.exception("Error while loading plugin: %s" % e)
-            return None, None, None
-
-    def execute_plugins_for_event(self, event, plugin_values):
-        """ For each plugin registered for the specified event, start a plugin execution thread
-        :param str event: The event name string
-        :param dict plugin_values: the values to be passed to the plugin
-        :return:
-        """
-        try:
-            plugin_values = self.get_values_for_plugins(plugin_values)
-            plugin_values["EVENT"] = event
-            plugins_for_event = self.__plugins.get(event)
-            if plugins_for_event is not None:
-                for plugin_info in plugins_for_event:
-                    self.__log.debug("Executing plugin %s for event %s" % (plugin_info.name, event))
-                    plugin_thread = PluginExecutor(plugin_info, plugin_values)
-                    plugin_thread.start()
-
-                    # block till plugin run completes.
-                    plugin_thread.join()
-            else:
-                self.__log.debug("No plugins registered for event %s" % event)
-        except Exception as e:
-            self.__log.exception("Error while executing plugin for event %s: %s" % (event, e))
+        self.__plugins, self.__artifact_mgt_plugins = self.initialize_plugins()
+        self.__extension_executor = self.initialize_extensions()
 
     def on_instance_started_event(self):
         self.__log.debug("Processing instance started event...")
-        self.execute_plugins_for_event("InstanceStartedEvent", {})
+        self.execute_event_extendables(constants.INSTANCE_STARTED_EVENT, {})
 
     def on_instance_activated_event(self):
         self.__log.debug("Processing instance activated event...")
-        self.execute_plugins_for_event("InstanceActivatedEvent", {})
-
-    def get_repo_path_for_tenant(self, tenant_id, git_local_repo_path, is_multitenant):
-        repo_path = ""
-
-        if is_multitenant:
-            if tenant_id == SUPER_TENANT_ID:
-                # super tenant, /repository/deploy/server/
-                super_tenant_repo_path = self.__config.super_tenant_repository_path
-                # "app_path"
-                repo_path += git_local_repo_path
-
-                if super_tenant_repo_path is not None and super_tenant_repo_path != "":
-                    super_tenant_repo_path = super_tenant_repo_path if super_tenant_repo_path.startswith("/") \
-                        else "/" + super_tenant_repo_path
-                    super_tenant_repo_path = super_tenant_repo_path if super_tenant_repo_path.endswith("/") \
-                        else super_tenant_repo_path + "/"
-                    # "app_path/repository/deploy/server/"
-                    repo_path += super_tenant_repo_path
-                else:
-                    # "app_path/repository/deploy/server/"
-                    repo_path += SUPER_TENANT_REPO_PATH
-
-            else:
-                # normal tenant, /repository/tenants/tenant_id
-                tenant_repo_path = self.__config.tenant_repository_path
-                # "app_path"
-                repo_path += git_local_repo_path
-
-                if tenant_repo_path is not None and tenant_repo_path != "":
-                    tenant_repo_path = tenant_repo_path if tenant_repo_path.startswith("/") else "/" + tenant_repo_path
-                    tenant_repo_path = tenant_repo_path if tenant_repo_path.endswith("/") else tenant_repo_path + "/"
-                    # "app_path/repository/tenants/244653444"
-                    repo_path += tenant_repo_path + tenant_id
-                else:
-                    # "app_path/repository/tenants/244653444"
-                    repo_path += TENANT_REPO_PATH + tenant_id
-
-                # tenant_dir_path = git_local_repo_path + AgentGitHandler.TENANT_REPO_PATH + tenant_id
-                # GitUtils.create_dir(repo_path)
-        else:
-            # not multi tenant, app_path
-            repo_path = git_local_repo_path
-
-        self.__log.debug("Repo path returned : %r" % repo_path)
-        return repo_path
+        self.execute_event_extendables(constants.INSTANCE_ACTIVATED_EVENT, {})
 
     def on_artifact_updated_event(self, artifacts_updated_event):
         self.__log.info("Processing Artifact update event: [tenant] %s [cluster] %s [status] %s" %
@@ -215,7 +101,7 @@ class EventHandler:
                              "ARTIFACT_UPDATED_REPO_USERNAME": artifacts_updated_event.repo_username,
                              "ARTIFACT_UPDATED_STATUS": artifacts_updated_event.status}
 
-            self.execute_plugins_for_event("ArtifactUpdatedEvent", plugin_values)
+            self.execute_event_extendables(constants.ARTIFACT_UPDATED_EVENT, plugin_values)
 
             if subscribe_run:
                 # publish instanceActivated
@@ -252,15 +138,15 @@ class EventHandler:
         plugin_values = {"ARTIFACT_UPDATED_TENANT_ID": str(tenant_id),
                          "ARTIFACT_UPDATED_SCHEDULER": str(True)}
 
-        self.execute_plugins_for_event("ArtifactUpdateSchedulerEvent", plugin_values)
+        self.execute_event_extendables("ArtifactUpdateSchedulerEvent", plugin_values)
 
     def on_instance_cleanup_cluster_event(self):
         self.__log.info("Processing instance cleanup cluster event...")
-        self.cleanup("InstanceCleanupClusterEvent")
+        self.cleanup(constants.INSTANCE_CLEANUP_CLUSTER_EVENT)
 
     def on_instance_cleanup_member_event(self):
         self.__log.info("Processing instance cleanup member event...")
-        self.cleanup("InstanceCleanupMemberEvent")
+        self.cleanup(constants.INSTANCE_CLEANUP_MEMBER_EVENT)
 
     def on_member_activated_event(self, member_activated_event):
         self.__log.info("Processing Member activated event: [service] %r [cluster] %r [member] %r"
@@ -277,7 +163,7 @@ class EventHandler:
             self.__log.error("Member has not initialized, failed to execute member activated event")
             return
 
-        self.execute_plugins_for_event("MemberActivatedEvent", {})
+        self.execute_event_extendables(constants.MEMBER_ACTIVATED_EVENT, {})
 
     def on_complete_topology_event(self, complete_topology_event):
         self.__log.debug("Processing Complete topology event...")
@@ -303,7 +189,7 @@ class EventHandler:
         plugin_values = {"TOPOLOGY_JSON": json.dumps(topology.json_str),
                          "MEMBER_LIST_JSON": json.dumps(cluster.member_list_json)}
 
-        self.execute_plugins_for_event("CompleteTopologyEvent", plugin_values)
+        self.execute_event_extendables(constants.COMPLETE_TOPOLOGY_EVENT, plugin_values)
 
     def on_member_initialized_event(self):
         """
@@ -325,7 +211,7 @@ class EventHandler:
         if member_exists:
             self.__config.initialized = True
 
-        self.execute_plugins_for_event("MemberInitializedEvent", {})
+        self.execute_event_extendables(constants.MEMBER_INITIALIZED_EVENT, {})
 
     def on_complete_tenant_event(self, complete_tenant_event):
         self.__log.debug("Processing Complete tenant event...")
@@ -335,7 +221,7 @@ class EventHandler:
 
         plugin_values = {"TENANT_LIST_JSON": json.dumps(tenant_list_json)}
 
-        self.execute_plugins_for_event("CompleteTenantEvent", plugin_values)
+        self.execute_event_extendables(constants.COMPLETE_TENANT_EVENT, plugin_values)
 
     def on_member_terminated_event(self, member_terminated_event):
         self.__log.info("Processing Member terminated event: [service] %s [cluster] %s [member] %s" %
@@ -352,7 +238,7 @@ class EventHandler:
             self.__log.error("Member has not initialized, failed to execute member terminated event")
             return
 
-        self.execute_plugins_for_event("MemberTerminatedEvent", {})
+        self.execute_event_extendables(constants.MEMBER_TERMINATED_EVENT, {})
 
     def on_member_suspended_event(self, member_suspended_event):
         self.__log.info("Processing Member suspended event: [service] %s [cluster] %s [member] %s" %
@@ -369,7 +255,7 @@ class EventHandler:
             self.__log.error("Member has not initialized, failed to execute member suspended event")
             return
 
-        self.execute_plugins_for_event("MembeSuspendedEvent", {})
+        self.execute_event_extendables(constants.MEMBER_SUSPENDED_EVENT, {})
 
     def on_member_started_event(self, member_started_event):
         self.__log.info("Processing Member started event: [service] %s [cluster] %s [member] %s" %
@@ -386,7 +272,7 @@ class EventHandler:
             self.__log.error("Member has not initialized, failed to execute member started event")
             return
 
-        self.execute_plugins_for_event("MemberStartedEvent", {})
+        self.execute_event_extendables(constants.MEMBER_STARTED_EVENT, {})
 
     def start_server_extension(self):
         self.__log.info("Processing start server extension...")
@@ -401,11 +287,11 @@ class EventHandler:
             self.__log.error("Member has not initialized, failed to execute start server event")
             return
 
-        self.execute_plugins_for_event("StartServers", {})
+        self.execute_event_extendables("StartServers", {})
 
     def volume_mount_extension(self, persistence_mappings_payload):
         self.__log.info("Processing volume mount extension...")
-        self.execute_plugins_for_event("VolumeMount", persistence_mappings_payload)
+        self.execute_event_extendables("VolumeMount", persistence_mappings_payload)
 
     def on_domain_mapping_added_event(self, domain_mapping_added_event):
         tenant_domain = EventHandler.find_tenant_domain(domain_mapping_added_event.tenant_id)
@@ -424,7 +310,7 @@ class EventHandler:
                          "SUBSCRIPTION_CONTEXT_PATH":
                              domain_mapping_added_event.context_path}
 
-        self.execute_plugins_for_event("DomainMappingAddedEvent", plugin_values)
+        self.execute_event_extendables(constants.DOMAIN_MAPPING_ADDED_EVENT, plugin_values)
 
     def on_domain_mapping_removed_event(self, domain_mapping_removed_event):
         tenant_domain = EventHandler.find_tenant_domain(domain_mapping_removed_event.tenant_id)
@@ -440,12 +326,12 @@ class EventHandler:
                          "SUBSCRIPTION_TENANT_ID": int(domain_mapping_removed_event.tenant_id),
                          "SUBSCRIPTION_TENANT_DOMAIN": tenant_domain}
 
-        self.execute_plugins_for_event("DomainMappingRemovedEvent", plugin_values)
+        self.execute_event_extendables(constants.DOMAIN_MAPPING_REMOVED_EVENT, plugin_values)
 
     def on_copy_artifacts_extension(self, src, dest):
         self.__log.info("Processing Copy artifacts extension...")
         plugin_values = {"SOURCE": src, "DEST": dest}
-        self.execute_plugins_for_event("CopyArtifacts", plugin_values)
+        self.execute_event_extendables("CopyArtifacts", plugin_values)
 
     def on_tenant_subscribed_event(self, tenant_subscribed_event):
         self.__log.info(
@@ -453,7 +339,7 @@ class EventHandler:
             " [service] " + tenant_subscribed_event.service_name + " [cluster] " + tenant_subscribed_event.cluster_ids
         )
 
-        self.execute_plugins_for_event("TenantSubscribedEvent", {})
+        self.execute_event_extendables(constants.TENANT_SUBSCRIBED_EVENT, {})
 
     def on_application_signup_removed_event(self, application_signup_removal_event):
         self.__log.info(
@@ -464,19 +350,222 @@ class EventHandler:
         if self.__config.application_id == application_signup_removal_event.applicationId:
             AgentGitHandler.remove_repo(application_signup_removal_event.tenant_id)
 
-        self.execute_plugins_for_event("ApplicationSignUpRemovedEvent", {})
+        self.execute_event_extendables(constants.APPLICATION_SIGNUP_REMOVAL_EVENT, {})
 
     def cleanup(self, event):
         self.__log.info("Executing cleaning up the data in the cartridge instance...")
 
         cartridgeagentpublisher.publish_maintenance_mode_event()
 
-        self.execute_plugins_for_event(event, {})
+        self.execute_event_extendables(event, {})
         self.__log.info("cleaning up finished in the cartridge instance...")
 
         self.__log.info("publishing ready to shutdown event...")
         cartridgeagentpublisher.publish_instance_ready_to_shutdown_event()
 
+    def initialize_plugins(self):
+        """ Find, load, activate and group plugins for Python CA
+        :return: a tuple of (PluginManager, plugins, artifact management plugins)
+        """
+        self.__log.info("Collecting and loading plugins")
+
+        try:
+            # TODO: change plugin descriptor ext, plugin_manager.setPluginInfoExtension(AGENT_PLUGIN_EXT)
+            plugins_dir = self.__config.read_property(constants.PLUGINS_DIR)
+            category_filter = {CARTRIDGE_AGENT_PLUGIN: ICartridgeAgentPlugin, ARTIFACT_MGT_PLUGIN: IArtifactManagementPlugin}
+
+            plugin_manager = EventHandler.create_plugin_manager(category_filter, plugins_dir)
+
+            # activate cartridge agent plugins
+            plugins = plugin_manager.getPluginsOfCategory(CARTRIDGE_AGENT_PLUGIN)
+            grouped_plugins = {}
+            for plugin_info in plugins:
+                self.__log.debug("Found plugin [%s] at [%s]" % (plugin_info.name, plugin_info.path))
+                plugin_manager.activatePluginByName(plugin_info.name)
+                self.__log.info("Activated plugin [%s]" % plugin_info.name)
+
+                mapped_events = plugin_info.description.split(",")
+                for mapped_event in mapped_events:
+                    if mapped_event.strip() != "":
+                        if grouped_plugins.get(mapped_event) is None:
+                            grouped_plugins[mapped_event] = []
+
+                        grouped_plugins[mapped_event].append(plugin_info)
+
+            # activate artifact management plugins
+            artifact_mgt_plugins = plugin_manager.getPluginsOfCategory(ARTIFACT_MGT_PLUGIN)
+            for plugin_info in artifact_mgt_plugins:
+                self.__log.debug("Found artifact management plugin [%s] at [%s]" % (plugin_info.name, plugin_info.path))
+                plugin_manager.activatePluginByName(plugin_info.name)
+                self.__log.info("Activated artifact management plugin [%s]" % plugin_info.name)
+
+            return grouped_plugins, artifact_mgt_plugins
+        except ParameterNotFoundException as e:
+            self.__log.exception("Could not load plugins. Plugins directory not set: %s" % e)
+            return None, None
+        except Exception as e:
+            self.__log.exception("Error while loading plugin: %s" % e)
+            return None, None
+
+    def initialize_extensions(self):
+        """ Find, load and activate extension scripts for Python CA. The extensions are mapped to the event by the
+        name used in the plugin descriptor.
+        :return:a tuple of (PluginManager, extensions)
+        """
+        self.__log.info("Collecting and loading extensions")
+
+        try:
+            extensions_dir = self.__config.read_property(constants.EXTENSIONS_DIR)
+            category_filter = {CARTRIDGE_AGENT_PLUGIN: ICartridgeAgentPlugin}
+
+            extension_manager = EventHandler.create_plugin_manager(category_filter, extensions_dir)
+
+            all_extensions = extension_manager.getPluginsOfCategory(CARTRIDGE_AGENT_PLUGIN)
+            for plugin_info in all_extensions:
+                try:
+                    self.__log.debug("Found extension executor [%s] at [%s]" % (plugin_info.name, plugin_info.path))
+                    extension_manager.activatePluginByName(plugin_info.name)
+                    extension_executor = plugin_info
+                    self.__log.info("Activated extension executor [%s]" % plugin_info.name)
+                    # extension executor found. break loop and return
+                    return extension_executor
+                except Exception as ignored:
+                    pass
+
+            # no extension executor plugin could be loaded or activated
+            raise RuntimeError("Couldn't activated any ExtensionExecutor plugin")
+        except ParameterNotFoundException as e:
+            self.__log.exception("Could not load extensions. Extensions directory not set: %s" % e)
+            return None
+        except Exception as e:
+            self.__log.exception("Error while loading extension: %s" % e)
+            return None
+
+    @staticmethod
+    def create_plugin_manager(category_filter, plugin_place):
+        """ Creates a PluginManager object from the given folder according to the given filter
+        :param category_filter:
+        :param plugin_place:
+        :return:
+        :rtype: PluginManager
+        """
+        plugin_manager = PluginManager()
+        plugin_manager.setCategoriesFilter(category_filter)
+        plugin_manager.setPluginPlaces([plugin_place])
+
+        plugin_manager.collectPlugins()
+
+        return plugin_manager
+
+    def execute_event_extendables(self, event, input_values):
+        """ Execute the extensions and plugins related to the event
+        :param event: The event name string
+        :param input_values: the values to be passed to the plugin
+        :return:
+        """
+        try:
+            input_values = self.add_common_input_values(input_values)
+            input_values["EVENT"] = event
+        except Exception as e:
+            self.__log.error("Error while adding common input values for event extendables: %s" % e)
+
+        # Execute the extension
+        self.execute_extension_for_event(event, input_values)
+        # Execute the plugins
+        self.execute_plugins_for_event(event, input_values)
+
+    def execute_plugins_for_event(self, event, input_values):
+        """ For each plugin registered for the specified event, start a plugin execution thread
+       :param str event: The event name string
+       :param dict input_values: the values to be passed to the plugin
+       :return:
+       """
+        try:
+            plugins_for_event = self.__plugins.get(event)
+            if plugins_for_event is not None:
+                for plugin_info in plugins_for_event:
+                    self.__log.debug("Executing plugin %s for event %s" % (plugin_info.name, event))
+                    plugin_thread = PluginExecutor(plugin_info, input_values)
+                    plugin_thread.start()
+
+                    # block till plugin run completes.
+                    plugin_thread.join()
+            else:
+                self.__log.debug("No plugins registered for event %s" % event)
+        except Exception as e:
+            self.__log.exception("Error while executing plugin for event %s: %s" % (event, e))
+
+    def execute_extension_for_event(self, event, extension_values):
+        """ Execute the extension related to the event
+        :param event: The event name string
+        :param extension_values: the values to be passed to the plugin
+        :return:
+        """
+        try:
+            if self.__extension_executor is not None:
+                self.__log.debug("Executing extension for event [%s]" % event)
+                PluginExecutor(self.__extension_executor, extension_values).start()
+                extension_thread = PluginExecutor(self.__extension_executor, extension_values)
+                extension_thread.start()
+
+                # block till plugin run completes.
+                extension_thread.join()
+            else:
+                self.__log.debug("No extensions registered for event %s" % event)
+        except Exception as e:
+            self.__log.exception("Error while executing extension for event %s: %s" % (event, e))
+
+    def get_repo_path_for_tenant(self, tenant_id, git_local_repo_path, is_multitenant):
+        """ Finds the repository path for tenant to clone from the remote repository
+        :param tenant_id:
+        :param git_local_repo_path:
+        :param is_multitenant:
+        :return:
+        """
+        repo_path = ""
+
+        if is_multitenant:
+            if tenant_id == SUPER_TENANT_ID:
+                # super tenant, /repository/deploy/server/
+                super_tenant_repo_path = self.__config.super_tenant_repository_path
+                # "app_path"
+                repo_path += git_local_repo_path
+
+                if super_tenant_repo_path is not None and super_tenant_repo_path != "":
+                    super_tenant_repo_path = super_tenant_repo_path if super_tenant_repo_path.startswith("/") \
+                        else "/" + super_tenant_repo_path
+                    super_tenant_repo_path = super_tenant_repo_path if super_tenant_repo_path.endswith("/") \
+                        else super_tenant_repo_path + "/"
+                    # "app_path/repository/deploy/server/"
+                    repo_path += super_tenant_repo_path
+                else:
+                    # "app_path/repository/deploy/server/"
+                    repo_path += SUPER_TENANT_REPO_PATH
+
+            else:
+                # normal tenant, /repository/tenants/tenant_id
+                tenant_repo_path = self.__config.tenant_repository_path
+                # "app_path"
+                repo_path += git_local_repo_path
+
+                if tenant_repo_path is not None and tenant_repo_path != "":
+                    tenant_repo_path = tenant_repo_path if tenant_repo_path.startswith("/") else "/" + tenant_repo_path
+                    tenant_repo_path = tenant_repo_path if tenant_repo_path.endswith("/") else tenant_repo_path + "/"
+                    # "app_path/repository/tenants/244653444"
+                    repo_path += tenant_repo_path + tenant_id
+                else:
+                    # "app_path/repository/tenants/244653444"
+                    repo_path += TENANT_REPO_PATH + tenant_id
+
+                    # tenant_dir_path = git_local_repo_path + AgentGitHandler.TENANT_REPO_PATH + tenant_id
+                    # GitUtils.create_dir(repo_path)
+        else:
+            # not multi tenant, app_path
+            repo_path = git_local_repo_path
+
+        self.__log.debug("Repo path returned : %r" % repo_path)
+        return repo_path
+
     def check_member_state_in_topology(self, service_name, cluster_id, member_id):
         topology = TopologyContext.get_topology()
         service = topology.get_service(service_name)
@@ -518,7 +607,7 @@ class EventHandler:
 
         return True
 
-    def get_values_for_plugins(self, plugin_values):
+    def add_common_input_values(self, plugin_values):
         """
         Adds the common parameters to be used by the extension scripts
         :param dict[str, str] plugin_values: Dictionary to be added

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d812e6/components/org.apache.stratos.python.cartridge.agent/src/test/java/org/apache/stratos/python.cartridge.agent/test/PythonCartridgeAgentTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/test/java/org/apache/stratos/python.cartridge.agent/test/PythonCartridgeAgentTest.java b/components/org.apache.stratos.python.cartridge.agent/src/test/java/org/apache/stratos/python.cartridge.agent/test/PythonCartridgeAgentTest.java
index a625bd4..bd016f4 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/test/java/org/apache/stratos/python.cartridge.agent/test/PythonCartridgeAgentTest.java
+++ b/components/org.apache.stratos.python.cartridge.agent/src/test/java/org/apache/stratos/python.cartridge.agent/test/PythonCartridgeAgentTest.java
@@ -402,6 +402,14 @@ public class PythonCartridgeAgentTest {
             String srcPayloadPath = getResourcesFolderPath() + "/payload";
             String destPayloadPath = destAgentPath + "/payload";
             FileUtils.copyDirectory(new File(srcPayloadPath), new File(destPayloadPath));
+
+            log.info("Changing extension scripts permissions");
+            File extensionsPath = new File(destAgentPath + "/extensions/bash");
+            File[] extensions = extensionsPath.listFiles();
+            for (File extension:extensions){
+                extension.setExecutable(true);
+            }
+
             log.info("Python cartridge agent setup completed");
 
             return destAgentPath;


[8/9] stratos git commit: PCA - ExtensionExecutor plugin improvments.

Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/util.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/util.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/util.py
deleted file mode 100644
index 7c53db4..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/util.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# 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.
-
-import os
-import subprocess
-
-
-def execute_bash(bash_file):
-    """ Execute the given bash files in the <PCA_HOME>/extensions/bash folder
-    :param bash_file: name of the bash file to execute
-    :return: tuple of (output, errors)
-    """
-    working_dir = os.path.abspath(os.path.dirname(__file__)).split("modules")[0]
-    command = working_dir[:-2] + "bash/" + bash_file
-    extension_values = os.environ.copy()
-
-    p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=extension_values)
-    output, errors = p.communicate()
-
-    return output, errors
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
index f831a89..5ce9b4a 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
@@ -56,6 +56,7 @@ class EventHandler:
 
     def on_instance_started_event(self):
         self.__log.debug("Processing instance started event...")
+        # TODO: copy artifacts extension
         self.execute_event_extendables(constants.INSTANCE_STARTED_EVENT, {})
 
     def on_instance_activated_event(self):
@@ -357,7 +358,7 @@ class EventHandler:
 
         cartridgeagentpublisher.publish_maintenance_mode_event()
 
-        self.execute_event_extendables(event, {})
+        self.execute_event_extendables("clean", {})
         self.__log.info("cleaning up finished in the cartridge instance...")
 
         self.__log.info("publishing ready to shutdown event...")
@@ -512,6 +513,8 @@ class EventHandler:
                 extension_thread.join()
             else:
                 self.__log.debug("No extensions registered for event %s" % event)
+        except OSError:
+            self.__log.warn("No extension was found for event %s" % event)
         except Exception as e:
             self.__log.exception("Error while executing extension for event %s: %s" % (event, e))
 


[2/9] stratos git commit: PCA - Renamed SubscriptionDomain*Event to DomainMapping*Event, replaced extension scripts

Posted by im...@apache.org.
PCA - Renamed SubscriptionDomain*Event to DomainMapping*Event, replaced extension scripts


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

Branch: refs/heads/master
Commit: da243903254656ad4fd9197e81e9cacfa25e68c3
Parents: ee66a9c
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Mon Feb 23 14:39:09 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Thu Mar 5 12:15:29 2015 +0530

----------------------------------------------------------------------
 .../cartridge.agent/cartridge.agent/agent.py    | 21 +++---
 .../extensions/domain-mapping-added.sh          | 41 +++++++++++
 .../extensions/domain-mapping-removed.sh        | 39 ++++++++++
 .../extensions/subscription-domain-added.sh     | 39 ----------
 .../extensions/subscription-domain-removed.sh   | 37 ----------
 .../modules/event/domain/__init__.py            | 18 +++++
 .../modules/event/domain/mapping/__init__.py    | 18 +++++
 .../modules/event/domain/mapping/events.py      | 77 ++++++++++++++++++++
 .../modules/event/eventhandler.py               | 42 ++++++-----
 .../modules/event/tenant/events.py              | 53 --------------
 .../src/main/extensions/domain-mapping-added.sh | 41 +++++++++++
 .../main/extensions/domain-mapping-removed.sh   | 39 ++++++++++
 .../extensions/subscription-domain-added.sh     | 39 ----------
 .../extensions/subscription-domain-removed.sh   | 37 ----------
 .../packs/extensions/domain-mapping-added.sh    | 29 ++++++++
 .../packs/extensions/domain-mapping-removed.sh  | 29 ++++++++
 .../extensions/subscription-domain-added.sh     | 29 --------
 .../extensions/subscription-domain-removed.sh   | 29 --------
 tools/puppet3/modules/agent/manifests/init.pp   |  4 +-
 .../extensions/domain-mapping-added.sh.erb      | 29 ++++++++
 .../extensions/domain-mapping-removed.sh.erb    | 29 ++++++++
 .../extensions/subscription-domain-added.sh.erb | 29 --------
 .../subscription-domain-removed.sh.erb          | 29 --------
 .../extensions/domain-mapping-added.sh.erb      | 39 ++++++++++
 .../extensions/domain-mapping-removed.sh.erb    | 36 +++++++++
 .../extensions/subscription-domain-added.sh.erb | 35 ---------
 .../subscription-domain-removed.sh.erb          | 34 ---------
 .../modules/python_agent/manifests/init.pp      |  4 +-
 .../extensions/domain-mapping-added.sh.erb      | 39 ++++++++++
 .../extensions/domain-mapping-removed.sh.erb    | 36 +++++++++
 .../extensions/subscription-domain-added.sh.erb | 35 ---------
 .../subscription-domain-removed.sh.erb          | 34 ---------
 32 files changed, 577 insertions(+), 492 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/agent.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/agent.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/agent.py
index 1efb0c6..4268269 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/agent.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/agent.py
@@ -24,6 +24,7 @@ from modules.event.instance.notifier.events import *
 from modules.event.tenant.events import *
 from modules.event.topology.events import *
 from modules.event.application.signup.events import *
+from modules.event.domain.mapping.events import *
 from modules.tenant.tenantcontext import *
 from modules.topology.topologycontext import *
 from modules.datapublisher.logpublisher import *
@@ -161,10 +162,10 @@ class CartridgeAgent(threading.Thread):
 
     def register_tenant_event_listeners(self):
         self.__log.debug("Starting tenant event message receiver thread")
-        self.__tenant_topic_subscriber.register_handler("SubscriptionDomainAddedEvent",
-                                                        self.on_subscription_domain_added)
-        self.__tenant_topic_subscriber.register_handler("SubscriptionDomainsRemovedEvent",
-                                                        self.on_subscription_domain_removed)
+        self.__tenant_topic_subscriber.register_handler("DomainMappingAddedEvent",
+                                                        self.on_domain_mapping_added)
+        self.__tenant_topic_subscriber.register_handler("DomainsMappingRemovedEvent",
+                                                        self.on_domain_mapping_removed)
         self.__tenant_topic_subscriber.register_handler("CompleteTenantEvent", self.on_complete_tenant)
         self.__tenant_topic_subscriber.register_handler("TenantSubscribedEvent", self.on_tenant_subscribed)
 
@@ -260,15 +261,15 @@ class CartridgeAgent(threading.Thread):
         event_obj = MemberStartedEvent.create_from_json(msg.payload)
         self.__event_handler.on_member_started_event(event_obj)
 
-    def on_subscription_domain_added(self, msg):
+    def on_domain_mapping_added(self, msg):
         self.__log.debug("Subscription domain added event received : %r" % msg.payload)
-        event_obj = SubscriptionDomainAddedEvent.create_from_json(msg.payload)
-        self.__event_handler.on_subscription_domain_added_event(event_obj)
+        event_obj = DomainMappingAddedEvent.create_from_json(msg.payload)
+        self.__event_handler.on_domain_mapping_added_event(event_obj)
 
-    def on_subscription_domain_removed(self, msg):
+    def on_domain_mapping_removed(self, msg):
         self.__log.debug("Subscription domain removed event received : %r" % msg.payload)
-        event_obj = SubscriptionDomainRemovedEvent.create_from_json(msg.payload)
-        self.__event_handler.on_subscription_domain_removed_event(event_obj)
+        event_obj = DomainMappingRemovedEvent.create_from_json(msg.payload)
+        self.__event_handler.on_domain_mapping_removed_event(event_obj)
 
     def on_complete_tenant(self, msg):
         if not self.__tenant_context_initialized:

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/domain-mapping-added.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/domain-mapping-added.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/domain-mapping-added.sh
new file mode 100755
index 0000000..7f39472
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/domain-mapping-added.sh
@@ -0,0 +1,41 @@
+#!/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 a subscription domain added
+# event is received by the cartridge agent.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+
+echo "Domain mapping added: [tenant-id] $1 [tenant-domain] $2 [domain-name] $3 [application-context] $4" | tee -a $log
+OUTPUT=`date`": Subscription Domain Added Event"
+OUTPUT="$OUTPUT SUBSCRIPTION_APPLICATION_ID: ${SUBSCRIPTION_APPLICATION_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_SERVICE_NAME: ${STRATOS_SUBSCRIPTION_SERVICE_NAME},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_DOMAIN_NAME: ${STRATOS_SUBSCRIPTION_DOMAIN_NAME},"
+OUTPUT="$OUTPUT SUBSCRIPTION_CLUSTER_ID: ${SUBSCRIPTION_CLUSTER_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_ID: ${STRATOS_SUBSCRIPTION_TENANT_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_DOMAIN: $STRATOS_SUBSCRIPTION_TENANT_DOMAIN},"
+OUTPUT="$OUTPUT APPLICATION_PATH: ${APPLICATION_PATH},"
+OUTPUT="$OUTPUT SUBSCRIPTION_CONTEXT_PATH: ${SUBSCRIPTION_CONTEXT_PATH}"
+echo $OUTPUT | tee -a $log
+
+curl -k -v -X POST -H "Content-Type:application/soap+xml;charset=UTF-8;action=urn:addWebAppToHost" -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\"><s:Body><p:addWebAppToHost xmlns:p=\"http://mapper.url.carbon.wso2.org\"><xs:hostName xmlns:xs=\"http://mapper.url.carbon.wso2.org\">$STRATOS_SUBSCRIPTION_DOMAIN_NAME</xs:hostName><xs:uri xmlns:xs=\"http://mapper.url.carbon.wso2.org\">/t/$STRATOS_SUBSCRIPTION_TENANT_DOMAIN/webapps/$SUBSCRIPTION_CONTEXT_PATH/</xs:uri><xs:appType xmlns:xs=\"http://mapper.url.carbon.wso2.org\">webapp</xs:appType></p:addWebAppToHost></s:Body></s:Envelope>" https://localhost:9443/services/UrlMapperAdminService -u admin:admin

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/domain-mapping-removed.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/domain-mapping-removed.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/domain-mapping-removed.sh
new file mode 100755
index 0000000..3911ec6
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/domain-mapping-removed.sh
@@ -0,0 +1,39 @@
+#!/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 a subscription domain removed
+# event is received by the cartridge agent.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+OUTPUT=`date`": Domain Mapping Removed Event"
+OUTPUT="$OUTPUT SUBSCRIPTION_APPLICATION_ID: ${SUBSCRIPTION_APPLICATION_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_SERVICE_NAME: ${STRATOS_SUBSCRIPTION_SERVICE_NAME},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_DOMAIN_NAME: ${STRATOS_SUBSCRIPTION_DOMAIN_NAME},"
+OUTPUT="$OUTPUT SUBSCRIPTION_CLUSTER_ID: ${SUBSCRIPTION_CLUSTER_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_ID: ${STRATOS_SUBSCRIPTION_TENANT_ID},"
+OUTPUT="$OUTPUT APPLICATION_PATH: ${APPLICATION_PATH},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_DOMAIN: $STRATOS_SUBSCRIPTION_TENANT_DOMAIN}"
+echo $OUTPUT | tee -a $log
+
+curl -k -v -X POST -H "Content-Type:application/soap+xml;charset=UTF-8;action=urn:deleteHost" -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\"><s:Body><p:deleteHost xmlns:p=\"http://mapper.url.carbon.wso2.org\"><xs:hostName xmlns:xs=\"http://mapper.url.carbon.wso2.org\">$STRATOS_SUBSCRIPTION_DOMAIN_NAME</xs:hostName></p:deleteHost></s:Body></s:Envelope>" https://localhost:9443/services/UrlMapperAdminService -u admin:admin
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/subscription-domain-added.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/subscription-domain-added.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/subscription-domain-added.sh
deleted file mode 100755
index 9e488f6..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/subscription-domain-added.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/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 a subscription domain added
-# event is received by the cartridge agent.
-# --------------------------------------------------------------
-#
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-
-echo "Subscription domain added: [tenant-id] $1 [tenant-domain] $2 [domain-name] $3 [application-context] $4" | tee -a $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 APPLICATION_PATH: ${APPLICATION_PATH},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_APPLICATION_CONTEXT: ${STRATOS_SUBSCRIPTION_APPLICATION_CONTEXT}"
-echo $OUTPUT | tee -a $log
-
-curl -k -v -X POST -H "Content-Type:application/soap+xml;charset=UTF-8;action=urn:addWebAppToHost" -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\"><s:Body><p:addWebAppToHost xmlns:p=\"http://mapper.url.carbon.wso2.org\"><xs:hostName xmlns:xs=\"http://mapper.url.carbon.wso2.org\">$STRATOS_SUBSCRIPTION_DOMAIN_NAME</xs:hostName><xs:uri xmlns:xs=\"http://mapper.url.carbon.wso2.org\">/t/$STRATOS_SUBSCRIPTION_TENANT_DOMAIN/webapps/$STRATOS_SUBSCRIPTION_APPLICATION_CONTEXT/</xs:uri><xs:appType xmlns:xs=\"http://mapper.url.carbon.wso2.org\">webapp</xs:appType></p:addWebAppToHost></s:Body></s:Envelope>" https://localhost:9443/services/UrlMapperAdminService -u admin:admin

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/subscription-domain-removed.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/subscription-domain-removed.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/subscription-domain-removed.sh
deleted file mode 100755
index a727953..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/subscription-domain-removed.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/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 a subscription domain removed
-# event is received by the cartridge agent.
-# --------------------------------------------------------------
-#
-
-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 APPLICATION_PATH: ${APPLICATION_PATH},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_DOMAIN: $STRATOS_SUBSCRIPTION_TENANT_DOMAIN}"
-echo $OUTPUT | tee -a $log
-
-curl -k -v -X POST -H "Content-Type:application/soap+xml;charset=UTF-8;action=urn:deleteHost" -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\"><s:Body><p:deleteHost xmlns:p=\"http://mapper.url.carbon.wso2.org\"><xs:hostName xmlns:xs=\"http://mapper.url.carbon.wso2.org\">$STRATOS_SUBSCRIPTION_DOMAIN_NAME</xs:hostName></p:deleteHost></s:Body></s:Envelope>" https://localhost:9443/services/UrlMapperAdminService -u admin:admin
-

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/domain/__init__.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/domain/__init__.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/domain/__init__.py
new file mode 100644
index 0000000..9dd7d7b
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/domain/__init__.py
@@ -0,0 +1,18 @@
+# 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.
+
+__author__ = 'chamilad'

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/domain/mapping/__init__.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/domain/mapping/__init__.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/domain/mapping/__init__.py
new file mode 100644
index 0000000..9dd7d7b
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/domain/mapping/__init__.py
@@ -0,0 +1,18 @@
+# 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.
+
+__author__ = 'chamilad'

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/domain/mapping/events.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/domain/mapping/events.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/domain/mapping/events.py
new file mode 100644
index 0000000..8d7c889
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/domain/mapping/events.py
@@ -0,0 +1,77 @@
+# 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.
+
+import json
+
+
+class DomainMappingAddedEvent:
+
+    def __init__(self):
+        self.application_id = None
+        """ :type : str """
+        self.tenant_id = None
+        """ :type : int  """
+        self.service_name = None
+        """ :type : str  """
+        self.cluster_id = None
+        """ :type : str  """
+        self.domain_name = None
+        """ :type : str  """
+        self.context_path = None
+        """ :type : str  """
+
+    @staticmethod
+    def create_from_json(json_str):
+        json_obj = json.loads(json_str)
+        instance = DomainMappingAddedEvent()
+
+        instance.tenant_id = json_obj["applicationId"] if "applicationId" in json_obj else None
+        instance.tenant_id = json_obj["tenantId"] if "tenantId" in json_obj else None
+        instance.service_name = json_obj["serviceName"] if "serviceName" in json_obj else None
+        instance.cluster_ids = json_obj["clusterId"] if "clusterId" in json_obj else None
+        instance.cluster_ids = json_obj["domainName"] if "domainName" in json_obj else None
+        instance.cluster_ids = json_obj["contextPath"] if "contextPath" in json_obj else None
+
+        return instance
+
+
+class DomainMappingRemovedEvent:
+
+    def __init__(self):
+        self.application_id = None
+        """ :type : str """
+        self.tenant_id = None
+        """ :type : int  """
+        self.service_name = None
+        """ :type : str  """
+        self.cluster_id = None
+        """ :type : str  """
+        self.domain_name = None
+        """ :type : str  """
+
+    @staticmethod
+    def create_from_json(json_str):
+        json_obj = json.loads(json_str)
+        instance = DomainMappingRemovedEvent()
+
+        instance.tenant_id = json_obj["applicationId"] if "applicationId" in json_obj else None
+        instance.tenant_id = json_obj["tenantId"] if "tenantId" in json_obj else None
+        instance.service_name = json_obj["serviceName"] if "serviceName" in json_obj else None
+        instance.cluster_ids = json_obj["clusterId"] if "clusterId" in json_obj else None
+        instance.cluster_ids = json_obj["domainName"] if "domainName" in json_obj else None
+
+        return instance

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
index e414ec7..f27fee1 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
@@ -407,36 +407,40 @@ class EventHandler:
         self.__log.info("Processing volume mount extension...")
         self.execute_plugins_for_event("VolumeMount", persistence_mappings_payload)
 
-    def on_subscription_domain_added_event(self, subscription_domain_added_event):
-        tenant_domain = EventHandler.find_tenant_domain(subscription_domain_added_event.tenant_id)
+    def on_domain_mapping_added_event(self, domain_mapping_added_event):
+        tenant_domain = EventHandler.find_tenant_domain(domain_mapping_added_event.tenant_id)
         self.__log.info(
-            "Processing Subscription domain added event: [tenant-id] " + subscription_domain_added_event.tenant_id +
-            " [tenant-domain] " + tenant_domain + " [domain-name] " + subscription_domain_added_event.domain_name +
-            " [application-context] " + subscription_domain_added_event.application_context
+            "Processing Domain mapping added event: [tenant-id] " + domain_mapping_added_event.tenant_id +
+            " [tenant-domain] " + tenant_domain + " [domain-name] " + domain_mapping_added_event.domain_name +
+            " [application-context] " + domain_mapping_added_event.application_context
         )
 
-        plugin_values = {"SUBSCRIPTION_SERVICE_NAME": subscription_domain_added_event.service_name,
-                         "SUBSCRIPTION_DOMAIN_NAME": subscription_domain_added_event.domain_name,
-                         "SUBSCRIPTION_TENANT_ID": int(subscription_domain_added_event.tenant_id),
+        plugin_values = {"SUBSCRIPTION_APPLICATION_ID": domain_mapping_added_event.application_id,
+                         "SUBSCRIPTION_SERVICE_NAME": domain_mapping_added_event.service_name,
+                         "SUBSCRIPTION_DOMAIN_NAME": domain_mapping_added_event.domain_name,
+                         "SUBSCRIPTION_CLUSTER_ID": domain_mapping_added_event.cluster_id,
+                         "SUBSCRIPTION_TENANT_ID": int(domain_mapping_added_event.tenant_id),
                          "SUBSCRIPTION_TENANT_DOMAIN": tenant_domain,
-                         "SUBSCRIPTION_APPLICATION_CONTEXT":
-                             subscription_domain_added_event.application_context}
+                         "SUBSCRIPTION_CONTEXT_PATH":
+                             domain_mapping_added_event.context_path}
 
-        self.execute_plugins_for_event("SubscriptionDomainAddedEvent", plugin_values)
+        self.execute_plugins_for_event("DomainMappingAddedEvent", plugin_values)
 
-    def on_subscription_domain_removed_event(self, subscription_domain_removed_event):
-        tenant_domain = EventHandler.find_tenant_domain(subscription_domain_removed_event.tenant_id)
+    def on_domain_mapping_removed_event(self, domain_mapping_removed_event):
+        tenant_domain = EventHandler.find_tenant_domain(domain_mapping_removed_event.tenant_id)
         self.__log.info(
-            "Subscription domain removed event received: [tenant-id] " + subscription_domain_removed_event.tenant_id +
-            " [tenant-domain] " + tenant_domain + " [domain-name] " + subscription_domain_removed_event.domain_name
+            "Domain mapping removed event received: [tenant-id] " + domain_mapping_removed_event.tenant_id +
+            " [tenant-domain] " + tenant_domain + " [domain-name] " + domain_mapping_removed_event.domain_name
         )
 
-        plugin_values = {"SUBSCRIPTION_SERVICE_NAME": subscription_domain_removed_event.service_name,
-                         "SUBSCRIPTION_DOMAIN_NAME": subscription_domain_removed_event.domain_name,
-                         "SUBSCRIPTION_TENANT_ID": int(subscription_domain_removed_event.tenant_id),
+        plugin_values = {"SUBSCRIPTION_APPLICATION_ID": domain_mapping_removed_event.application_id,
+                         "SUBSCRIPTION_SERVICE_NAME": domain_mapping_removed_event.service_name,
+                         "SUBSCRIPTION_DOMAIN_NAME": domain_mapping_removed_event.domain_name,
+                         "SUBSCRIPTION_CLUSTER_ID": domain_mapping_removed_event.cluster_id,
+                         "SUBSCRIPTION_TENANT_ID": int(domain_mapping_removed_event.tenant_id),
                          "SUBSCRIPTION_TENANT_DOMAIN": tenant_domain}
 
-        self.execute_plugins_for_event("SubscriptionDomainRemovedEvent", plugin_values)
+        self.execute_plugins_for_event("DomainMappingRemovedEvent", plugin_values)
 
     def on_copy_artifacts_extension(self, src, dest):
         self.__log.info("Processing Copy artifacts extension...")

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/tenant/events.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/tenant/events.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/tenant/events.py
index def2b64..473b35c 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/tenant/events.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/tenant/events.py
@@ -19,59 +19,6 @@ import json
 from ... tenant.tenantcontext import *
 
 
-class SubscriptionDomainAddedEvent():
-
-    def __init__(self):
-        self.tenant_id = None
-        """ :type : int  """
-        self.service_name = None
-        """ :type : str  """
-        self.cluster_ids = None
-        """ :type : list[str]  """
-        self.domain_name = None
-        """ :type : str  """
-        self.application_context = None
-        """ :type : str  """
-
-    @staticmethod
-    def create_from_json(json_str):
-        json_obj = json.loads(json_str)
-        instance = SubscriptionDomainAddedEvent()
-
-        instance.cluster_ids = json_obj["clusterIds"] if "clusterIds" in json_obj else None
-        instance.tenant_id = json_obj["tenantId"] if "tenantId" in json_obj else None
-        instance.service_name = json_obj["serviceName"] if "serviceName" in json_obj else None
-        instance.domain_name = json_obj["domainName"] if "domainName" in json_obj else None
-        instance.application_context = json_obj["applicationContext"] if "applicationContext" in json_obj else None
-
-        return instance
-
-
-class SubscriptionDomainRemovedEvent:
-
-    def __init__(self, tenant_id, service_name, cluster_ids, domain_name):
-        self.tenant_id = tenant_id
-        """ :type : int  """
-        self.service_name = service_name
-        """ :type : str  """
-        self.cluster_ids = cluster_ids
-        """ :type : list[str]  """
-        self.domain_name = domain_name
-        """ :type : str  """
-
-    @staticmethod
-    def create_from_json(json_str):
-        json_obj = json.loads(json_str)
-        instance = SubscriptionDomainRemovedEvent()
-
-        instance.cluster_ids = json_obj["clusterIds"] if "clusterIds" in json_obj else None
-        instance.tenant_id = json_obj["tenantId"] if "tenantId" in json_obj else None
-        instance.service_name = json_obj["serviceName"] if "serviceName" in json_obj else None
-        instance.domain_name = json_obj["domainName"] if "domainName" in json_obj else None
-
-        return instance
-
-
 class CompleteTenantEvent:
 
     def __init__(self):

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/products/cartridge-agent/modules/distribution/src/main/extensions/domain-mapping-added.sh
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/modules/distribution/src/main/extensions/domain-mapping-added.sh b/products/cartridge-agent/modules/distribution/src/main/extensions/domain-mapping-added.sh
new file mode 100755
index 0000000..7f39472
--- /dev/null
+++ b/products/cartridge-agent/modules/distribution/src/main/extensions/domain-mapping-added.sh
@@ -0,0 +1,41 @@
+#!/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 a subscription domain added
+# event is received by the cartridge agent.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+
+echo "Domain mapping added: [tenant-id] $1 [tenant-domain] $2 [domain-name] $3 [application-context] $4" | tee -a $log
+OUTPUT=`date`": Subscription Domain Added Event"
+OUTPUT="$OUTPUT SUBSCRIPTION_APPLICATION_ID: ${SUBSCRIPTION_APPLICATION_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_SERVICE_NAME: ${STRATOS_SUBSCRIPTION_SERVICE_NAME},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_DOMAIN_NAME: ${STRATOS_SUBSCRIPTION_DOMAIN_NAME},"
+OUTPUT="$OUTPUT SUBSCRIPTION_CLUSTER_ID: ${SUBSCRIPTION_CLUSTER_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_ID: ${STRATOS_SUBSCRIPTION_TENANT_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_DOMAIN: $STRATOS_SUBSCRIPTION_TENANT_DOMAIN},"
+OUTPUT="$OUTPUT APPLICATION_PATH: ${APPLICATION_PATH},"
+OUTPUT="$OUTPUT SUBSCRIPTION_CONTEXT_PATH: ${SUBSCRIPTION_CONTEXT_PATH}"
+echo $OUTPUT | tee -a $log
+
+curl -k -v -X POST -H "Content-Type:application/soap+xml;charset=UTF-8;action=urn:addWebAppToHost" -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\"><s:Body><p:addWebAppToHost xmlns:p=\"http://mapper.url.carbon.wso2.org\"><xs:hostName xmlns:xs=\"http://mapper.url.carbon.wso2.org\">$STRATOS_SUBSCRIPTION_DOMAIN_NAME</xs:hostName><xs:uri xmlns:xs=\"http://mapper.url.carbon.wso2.org\">/t/$STRATOS_SUBSCRIPTION_TENANT_DOMAIN/webapps/$SUBSCRIPTION_CONTEXT_PATH/</xs:uri><xs:appType xmlns:xs=\"http://mapper.url.carbon.wso2.org\">webapp</xs:appType></p:addWebAppToHost></s:Body></s:Envelope>" https://localhost:9443/services/UrlMapperAdminService -u admin:admin

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/products/cartridge-agent/modules/distribution/src/main/extensions/domain-mapping-removed.sh
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/modules/distribution/src/main/extensions/domain-mapping-removed.sh b/products/cartridge-agent/modules/distribution/src/main/extensions/domain-mapping-removed.sh
new file mode 100755
index 0000000..3911ec6
--- /dev/null
+++ b/products/cartridge-agent/modules/distribution/src/main/extensions/domain-mapping-removed.sh
@@ -0,0 +1,39 @@
+#!/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 a subscription domain removed
+# event is received by the cartridge agent.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+OUTPUT=`date`": Domain Mapping Removed Event"
+OUTPUT="$OUTPUT SUBSCRIPTION_APPLICATION_ID: ${SUBSCRIPTION_APPLICATION_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_SERVICE_NAME: ${STRATOS_SUBSCRIPTION_SERVICE_NAME},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_DOMAIN_NAME: ${STRATOS_SUBSCRIPTION_DOMAIN_NAME},"
+OUTPUT="$OUTPUT SUBSCRIPTION_CLUSTER_ID: ${SUBSCRIPTION_CLUSTER_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_ID: ${STRATOS_SUBSCRIPTION_TENANT_ID},"
+OUTPUT="$OUTPUT APPLICATION_PATH: ${APPLICATION_PATH},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_DOMAIN: $STRATOS_SUBSCRIPTION_TENANT_DOMAIN}"
+echo $OUTPUT | tee -a $log
+
+curl -k -v -X POST -H "Content-Type:application/soap+xml;charset=UTF-8;action=urn:deleteHost" -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\"><s:Body><p:deleteHost xmlns:p=\"http://mapper.url.carbon.wso2.org\"><xs:hostName xmlns:xs=\"http://mapper.url.carbon.wso2.org\">$STRATOS_SUBSCRIPTION_DOMAIN_NAME</xs:hostName></p:deleteHost></s:Body></s:Envelope>" https://localhost:9443/services/UrlMapperAdminService -u admin:admin
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/products/cartridge-agent/modules/distribution/src/main/extensions/subscription-domain-added.sh
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/modules/distribution/src/main/extensions/subscription-domain-added.sh b/products/cartridge-agent/modules/distribution/src/main/extensions/subscription-domain-added.sh
deleted file mode 100644
index 9deefab..0000000
--- a/products/cartridge-agent/modules/distribution/src/main/extensions/subscription-domain-added.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/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 a subscription domain added
-# event is received by the cartridge agent.
-# --------------------------------------------------------------
-#
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-
-echo "Subscription domain added: [tenant-id] $1 [tenant-domain] $2 [domain-name] $3 [application-context] $4" | tee -a $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
-
-curl -k -v -X POST -H "Content-Type:application/soap+xml;charset=UTF-8;action=urn:addWebAppToHost" -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\"><s:Body><p:addWebAppToHost xmlns:p=\"http://mapper.url.carbon.wso2.org\"><xs:hostName xmlns:xs=\"http://mapper.url.carbon.wso2.org\">$STRATOS_SUBSCRIPTION_DOMAIN_NAME</xs:hostName><xs:uri xmlns:xs=\"http://mapper.url.carbon.wso2.org\">/t/$STRATOS_SUBSCRIPTION_TENANT_DOMAIN/webapps/$STRATOS_SUBSCRIPTION_APPLICATION_CONTEXT/</xs:uri><xs:appType xmlns:xs=\"http://mapper.url.carbon.wso2.org\">webapp</xs:appType></p:addWebAppToHost></s:Body></s:Envelope>" https://localhost:9443/services/UrlMapperAdminService -u admin:admin

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/products/cartridge-agent/modules/distribution/src/main/extensions/subscription-domain-removed.sh
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/modules/distribution/src/main/extensions/subscription-domain-removed.sh b/products/cartridge-agent/modules/distribution/src/main/extensions/subscription-domain-removed.sh
deleted file mode 100644
index f74a725..0000000
--- a/products/cartridge-agent/modules/distribution/src/main/extensions/subscription-domain-removed.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/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 a subscription domain removed
-# event is received by the cartridge agent.
-# --------------------------------------------------------------
-#
-
-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
-
-curl -k -v -X POST -H "Content-Type:application/soap+xml;charset=UTF-8;action=urn:deleteHost" -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\"><s:Body><p:deleteHost xmlns:p=\"http://mapper.url.carbon.wso2.org\"><xs:hostName xmlns:xs=\"http://mapper.url.carbon.wso2.org\">$STRATOS_SUBSCRIPTION_DOMAIN_NAME</xs:hostName></p:deleteHost></s:Body></s:Envelope>" https://localhost:9443/services/UrlMapperAdminService -u admin:admin
-

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/domain-mapping-added.sh
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/domain-mapping-added.sh b/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/domain-mapping-added.sh
new file mode 100644
index 0000000..759f6b4
--- /dev/null
+++ b/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/domain-mapping-added.sh
@@ -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 when subscription domain
+# added event is received.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+OUTPUT=`date`": Domain Mapping Added Event"
+echo $OUTPUT | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/domain-mapping-removed.sh
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/domain-mapping-removed.sh b/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/domain-mapping-removed.sh
new file mode 100644
index 0000000..3be259e
--- /dev/null
+++ b/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/domain-mapping-removed.sh
@@ -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 when subscription domain
+# removed event is received.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+OUTPUT=`date`": Domain Mapping Removed Event"
+echo $OUTPUT | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/subscription-domain-added.sh
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/subscription-domain-added.sh b/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/subscription-domain-added.sh
deleted file mode 100644
index a8b7459..0000000
--- a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/subscription-domain-added.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/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"
-echo $OUTPUT | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/subscription-domain-removed.sh
----------------------------------------------------------------------
diff --git a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/subscription-domain-removed.sh b/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/subscription-domain-removed.sh
deleted file mode 100644
index 3612bb6..0000000
--- a/tools/docker-images/cartridge-docker-images/base-image/packs/extensions/subscription-domain-removed.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/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"
-echo $OUTPUT | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/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 ea67b7c..b6e59f7 100644
--- a/tools/puppet3/modules/agent/manifests/init.pp
+++ b/tools/puppet3/modules/agent/manifests/init.pp
@@ -53,8 +53,8 @@ class agent(
     'extensions/member-suspended.sh',
     'extensions/member-terminated.sh',
     'extensions/mount-volumes.sh',
-    'extensions/subscription-domain-added.sh',
-    'extensions/subscription-domain-removed.sh',
+    'extensions/domain-mapping-added.sh',
+    'extensions/domain-mapping-removed.sh',
     ]
 
   agent::initialize { $deployment_code:

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/tools/puppet3/modules/agent/templates/extensions/domain-mapping-added.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/agent/templates/extensions/domain-mapping-added.sh.erb b/tools/puppet3/modules/agent/templates/extensions/domain-mapping-added.sh.erb
new file mode 100644
index 0000000..759f6b4
--- /dev/null
+++ b/tools/puppet3/modules/agent/templates/extensions/domain-mapping-added.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 when subscription domain
+# added event is received.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+OUTPUT=`date`": Domain Mapping Added Event"
+echo $OUTPUT | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/tools/puppet3/modules/agent/templates/extensions/domain-mapping-removed.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/agent/templates/extensions/domain-mapping-removed.sh.erb b/tools/puppet3/modules/agent/templates/extensions/domain-mapping-removed.sh.erb
new file mode 100644
index 0000000..3be259e
--- /dev/null
+++ b/tools/puppet3/modules/agent/templates/extensions/domain-mapping-removed.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 when subscription domain
+# removed event is received.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+OUTPUT=`date`": Domain Mapping Removed Event"
+echo $OUTPUT | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/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
deleted file mode 100644
index a8b7459..0000000
--- a/tools/puppet3/modules/agent/templates/extensions/subscription-domain-added.sh.erb
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/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"
-echo $OUTPUT | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/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
deleted file mode 100644
index 3612bb6..0000000
--- a/tools/puppet3/modules/agent/templates/extensions/subscription-domain-removed.sh.erb
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/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"
-echo $OUTPUT | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/tools/puppet3/modules/appserver/templates/agent/extensions/domain-mapping-added.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/appserver/templates/agent/extensions/domain-mapping-added.sh.erb b/tools/puppet3/modules/appserver/templates/agent/extensions/domain-mapping-added.sh.erb
new file mode 100755
index 0000000..d2a1de7
--- /dev/null
+++ b/tools/puppet3/modules/appserver/templates/agent/extensions/domain-mapping-added.sh.erb
@@ -0,0 +1,39 @@
+#!/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 a subscription domain added
+# event is received by the cartridge agent.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+
+echo "Domain mapping added: [tenant-id] $1 [tenant-domain] $2 [domain-name] $3 [application-context] $4" | tee -a $log
+OUTPUT=`date`": Subscription Domain Added Event"
+OUTPUT="$OUTPUT SUBSCRIPTION_APPLICATION_ID: ${SUBSCRIPTION_APPLICATION_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_SERVICE_NAME: ${STRATOS_SUBSCRIPTION_SERVICE_NAME},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_DOMAIN_NAME: ${STRATOS_SUBSCRIPTION_DOMAIN_NAME},"
+OUTPUT="$OUTPUT SUBSCRIPTION_CLUSTER_ID: ${SUBSCRIPTION_CLUSTER_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_ID: ${STRATOS_SUBSCRIPTION_TENANT_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_DOMAIN: $STRATOS_SUBSCRIPTION_TENANT_DOMAIN},"
+OUTPUT="$OUTPUT APPLICATION_PATH: ${APPLICATION_PATH},"
+OUTPUT="$OUTPUT SUBSCRIPTION_CONTEXT_PATH: ${SUBSCRIPTION_CONTEXT_PATH}"
+echo $OUTPUT | tee -a $log
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/tools/puppet3/modules/appserver/templates/agent/extensions/domain-mapping-removed.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/appserver/templates/agent/extensions/domain-mapping-removed.sh.erb b/tools/puppet3/modules/appserver/templates/agent/extensions/domain-mapping-removed.sh.erb
new file mode 100755
index 0000000..00a553d
--- /dev/null
+++ b/tools/puppet3/modules/appserver/templates/agent/extensions/domain-mapping-removed.sh.erb
@@ -0,0 +1,36 @@
+#!/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 a subscription domain removed
+# event is received by the cartridge agent.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+OUTPUT=`date`": Domain Mapping Removed Event"
+OUTPUT="$OUTPUT SUBSCRIPTION_APPLICATION_ID: ${SUBSCRIPTION_APPLICATION_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_SERVICE_NAME: ${STRATOS_SUBSCRIPTION_SERVICE_NAME},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_DOMAIN_NAME: ${STRATOS_SUBSCRIPTION_DOMAIN_NAME},"
+OUTPUT="$OUTPUT SUBSCRIPTION_CLUSTER_ID: ${SUBSCRIPTION_CLUSTER_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_ID: ${STRATOS_SUBSCRIPTION_TENANT_ID},"
+OUTPUT="$OUTPUT APPLICATION_PATH: ${APPLICATION_PATH},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_DOMAIN: $STRATOS_SUBSCRIPTION_TENANT_DOMAIN}"
+echo $OUTPUT | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/tools/puppet3/modules/appserver/templates/agent/extensions/subscription-domain-added.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/appserver/templates/agent/extensions/subscription-domain-added.sh.erb b/tools/puppet3/modules/appserver/templates/agent/extensions/subscription-domain-added.sh.erb
deleted file mode 100644
index 9ef88a2..0000000
--- a/tools/puppet3/modules/appserver/templates/agent/extensions/subscription-domain-added.sh.erb
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/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/da243903/tools/puppet3/modules/appserver/templates/agent/extensions/subscription-domain-removed.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/appserver/templates/agent/extensions/subscription-domain-removed.sh.erb b/tools/puppet3/modules/appserver/templates/agent/extensions/subscription-domain-removed.sh.erb
deleted file mode 100644
index ff7b56b..0000000
--- a/tools/puppet3/modules/appserver/templates/agent/extensions/subscription-domain-removed.sh.erb
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/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

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/tools/puppet3/modules/python_agent/manifests/init.pp
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/manifests/init.pp b/tools/puppet3/modules/python_agent/manifests/init.pp
index 0e91ece..08430ac 100644
--- a/tools/puppet3/modules/python_agent/manifests/init.pp
+++ b/tools/puppet3/modules/python_agent/manifests/init.pp
@@ -53,8 +53,8 @@ class python_agent(
     'extensions/member-suspended.sh',
     'extensions/member-terminated.sh',
     'extensions/mount-volumes.sh',
-    'extensions/subscription-domain-added.sh',
-    'extensions/subscription-domain-removed.sh',
+    'extensions/domain-mapping-added.sh',
+    'extensions/domain-mapping-removed.sh',
   ]
 
  python_agent::initialize { $service_code:

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/tools/puppet3/modules/python_agent/templates/extensions/domain-mapping-added.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/templates/extensions/domain-mapping-added.sh.erb b/tools/puppet3/modules/python_agent/templates/extensions/domain-mapping-added.sh.erb
new file mode 100755
index 0000000..d2a1de7
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/templates/extensions/domain-mapping-added.sh.erb
@@ -0,0 +1,39 @@
+#!/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 a subscription domain added
+# event is received by the cartridge agent.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+
+echo "Domain mapping added: [tenant-id] $1 [tenant-domain] $2 [domain-name] $3 [application-context] $4" | tee -a $log
+OUTPUT=`date`": Subscription Domain Added Event"
+OUTPUT="$OUTPUT SUBSCRIPTION_APPLICATION_ID: ${SUBSCRIPTION_APPLICATION_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_SERVICE_NAME: ${STRATOS_SUBSCRIPTION_SERVICE_NAME},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_DOMAIN_NAME: ${STRATOS_SUBSCRIPTION_DOMAIN_NAME},"
+OUTPUT="$OUTPUT SUBSCRIPTION_CLUSTER_ID: ${SUBSCRIPTION_CLUSTER_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_ID: ${STRATOS_SUBSCRIPTION_TENANT_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_DOMAIN: $STRATOS_SUBSCRIPTION_TENANT_DOMAIN},"
+OUTPUT="$OUTPUT APPLICATION_PATH: ${APPLICATION_PATH},"
+OUTPUT="$OUTPUT SUBSCRIPTION_CONTEXT_PATH: ${SUBSCRIPTION_CONTEXT_PATH}"
+echo $OUTPUT | tee -a $log
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/tools/puppet3/modules/python_agent/templates/extensions/domain-mapping-removed.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/templates/extensions/domain-mapping-removed.sh.erb b/tools/puppet3/modules/python_agent/templates/extensions/domain-mapping-removed.sh.erb
new file mode 100755
index 0000000..00a553d
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/templates/extensions/domain-mapping-removed.sh.erb
@@ -0,0 +1,36 @@
+#!/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 a subscription domain removed
+# event is received by the cartridge agent.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+OUTPUT=`date`": Domain Mapping Removed Event"
+OUTPUT="$OUTPUT SUBSCRIPTION_APPLICATION_ID: ${SUBSCRIPTION_APPLICATION_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_SERVICE_NAME: ${STRATOS_SUBSCRIPTION_SERVICE_NAME},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_DOMAIN_NAME: ${STRATOS_SUBSCRIPTION_DOMAIN_NAME},"
+OUTPUT="$OUTPUT SUBSCRIPTION_CLUSTER_ID: ${SUBSCRIPTION_CLUSTER_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_ID: ${STRATOS_SUBSCRIPTION_TENANT_ID},"
+OUTPUT="$OUTPUT APPLICATION_PATH: ${APPLICATION_PATH},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_DOMAIN: $STRATOS_SUBSCRIPTION_TENANT_DOMAIN}"
+echo $OUTPUT | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/da243903/tools/puppet3/modules/python_agent/templates/extensions/subscription-domain-added.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/templates/extensions/subscription-domain-added.sh.erb b/tools/puppet3/modules/python_agent/templates/extensions/subscription-domain-added.sh.erb
deleted file mode 100644
index 9ef88a2..0000000
--- a/tools/puppet3/modules/python_agent/templates/extensions/subscription-domain-added.sh.erb
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/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/da243903/tools/puppet3/modules/python_agent/templates/extensions/subscription-domain-removed.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/templates/extensions/subscription-domain-removed.sh.erb b/tools/puppet3/modules/python_agent/templates/extensions/subscription-domain-removed.sh.erb
deleted file mode 100644
index ff7b56b..0000000
--- a/tools/puppet3/modules/python_agent/templates/extensions/subscription-domain-removed.sh.erb
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/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