You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2014/11/05 10:12:32 UTC
[2/3] git commit: Adding initial python agent puppet module &
changing agent references
Adding initial python agent puppet module & changing agent references
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/4280eec2
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/4280eec2
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/4280eec2
Branch: refs/heads/docker-grouping-merge
Commit: 4280eec28e94e31249d5e51163730f33261b9f82
Parents: 9af8798
Author: lasinducharith <la...@gmail.com>
Authored: Wed Nov 5 14:39:42 2014 +0530
Committer: lasinducharith <la...@gmail.com>
Committed: Wed Nov 5 14:39:42 2014 +0530
----------------------------------------------------------------------
tools/puppet3/manifests/nodes/default.pp | 4 +-
tools/puppet3/modules/haproxy/manifests/init.pp | 4 +-
tools/puppet3/modules/jboss/manifests/init.pp | 4 +-
tools/puppet3/modules/lb/manifests/init.pp | 4 +-
tools/puppet3/modules/mysql/manifests/init.pp | 4 +-
tools/puppet3/modules/nodejs/manifests/init.pp | 4 +-
tools/puppet3/modules/php/manifests/init.pp | 4 +-
.../modules/python_agent/files/README.txt | 12 +
.../python_agent/lib/facter/stratos_facts.rb | 29 ++
.../modules/python_agent/manifests/init.pp | 97 ++++++
.../python_agent/manifests/initialize.pp | 101 ++++++
.../python_agent/manifests/push_templates.pp | 28 ++
.../modules/python_agent/manifests/start.pp | 27 ++
.../python_agent/templates/agent.conf.erb | 46 +++
.../templates/extensions/addons/_jboss-as.erb | 18 ++
.../templates/extensions/addons/_mysql.erb | 32 ++
.../templates/extensions/addons/_nodejs.erb | 21 ++
.../templates/extensions/addons/_php.erb | 18 ++
.../templates/extensions/addons/_ruby.erb | 34 ++
.../templates/extensions/artifacts-copy.sh.erb | 29 ++
.../extensions/artifacts-updated.sh.erb | 34 ++
.../templates/extensions/clean.sh.erb | 28 ++
.../templates/extensions/complete-tenant.sh.erb | 30 ++
.../extensions/complete-topology.sh.erb | 34 ++
.../extensions/instance-activated.sh.erb | 28 ++
.../extensions/instance-started.sh.erb | 27 ++
.../extensions/member-activated.sh.erb | 303 ++++++++++++++++++
.../templates/extensions/member-started.sh.erb | 43 +++
.../extensions/member-suspended.sh.erb | 43 +++
.../extensions/member-terminated.sh.erb | 43 +++
.../templates/extensions/mount-volumes.sh.erb | 87 ++++++
.../templates/extensions/start-servers.sh.erb | 308 +++++++++++++++++++
.../extensions/subscription-domain-added.sh.erb | 35 +++
.../subscription-domain-removed.sh.erb | 34 ++
.../python_agent/templates/logging.ini.erb | 34 ++
tools/puppet3/modules/ruby/manifests/init.pp | 4 +-
tools/puppet3/modules/tomcat/manifests/init.pp | 4 +-
.../puppet3/modules/wordpress/manifests/init.pp | 4 +-
38 files changed, 1623 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/manifests/nodes/default.pp
----------------------------------------------------------------------
diff --git a/tools/puppet3/manifests/nodes/default.pp b/tools/puppet3/manifests/nodes/default.pp
index 4f420b2..dbed562 100755
--- a/tools/puppet3/manifests/nodes/default.pp
+++ b/tools/puppet3/manifests/nodes/default.pp
@@ -19,7 +19,7 @@
node /default/ inherits base {
require java
- class {'agent':}
+ class {'python_agent':}
- Class['stratos_base'] -> Class['java'] ~> Class['agent']
+ Class['stratos_base'] -> Class['python_agent']
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/haproxy/manifests/init.pp
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/haproxy/manifests/init.pp b/tools/puppet3/modules/haproxy/manifests/init.pp
index 774d939..e1ab5e3 100755
--- a/tools/puppet3/modules/haproxy/manifests/init.pp
+++ b/tools/puppet3/modules/haproxy/manifests/init.pp
@@ -39,7 +39,7 @@ class haproxy(
tag($service_code)
require java
- class {'agent':}
+ class {'python_agent':}
$service_templates = [
'bin/haproxy-extension.sh',
@@ -75,5 +75,5 @@ class haproxy(
}
# install stratos_base before java before haproxy before agent
- Class['stratos_base'] -> Class['java'] -> Class['agent'] -> Class['haproxy']
+ Class['stratos_base'] -> Class['java'] -> Class['python_agent'] -> Class['haproxy']
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/jboss/manifests/init.pp
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/jboss/manifests/init.pp b/tools/puppet3/modules/jboss/manifests/init.pp
index 5ec75d4..1e21fb2 100644
--- a/tools/puppet3/modules/jboss/manifests/init.pp
+++ b/tools/puppet3/modules/jboss/manifests/init.pp
@@ -36,7 +36,7 @@ class jboss (
require java
$custom_agent_templates = ['extensions/artifacts-updated.sh']
- class {'agent':
+ class {'python_agent':
custom_templates => $custom_agent_templates,
module=>'jboss'
}
@@ -55,5 +55,5 @@ class jboss (
}
#install stratos_base before java before jboss before agent
- Class['stratos_base'] -> Class['java'] -> Class['agent'] -> Class['jboss']
+ Class['stratos_base'] -> Class['java'] -> Class['python_agent'] -> Class['jboss']
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/lb/manifests/init.pp
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/lb/manifests/init.pp b/tools/puppet3/modules/lb/manifests/init.pp
index 1025c3f..1436677 100755
--- a/tools/puppet3/modules/lb/manifests/init.pp
+++ b/tools/puppet3/modules/lb/manifests/init.pp
@@ -45,7 +45,7 @@ class lb (
$carbon_home = "${target}/apache-stratos-${service_code}-${carbon_version}"
require java
- class {'agent':}
+ class {'python_agent':}
$service_templates = [
'conf/axis2/axis2.xml',
@@ -110,5 +110,5 @@ class lb (
}
# install stratos_base before java before lb before agent
- Class['stratos_base'] -> Class['java'] -> Class['agent'] -> Class['lb']
+ Class['stratos_base'] -> Class['java'] -> Class['python_agent'] -> Class['lb']
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/mysql/manifests/init.pp
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/mysql/manifests/init.pp b/tools/puppet3/modules/mysql/manifests/init.pp
index 175ba92..d423bcd 100644
--- a/tools/puppet3/modules/mysql/manifests/init.pp
+++ b/tools/puppet3/modules/mysql/manifests/init.pp
@@ -20,7 +20,7 @@ class mysql{
require java
$custom_agent_templates = ['extensions/instance-started.sh']
- class {'agent':
+ class {'python_agent':
custom_templates => $custom_agent_templates,
module=>'mysql'
}
@@ -105,5 +105,5 @@ class mysql{
}
# install stratos_base before java before mysql before agent
- Class['stratos_base'] -> Class['java'] -> Class['agent'] -> Class['mysql']
+ Class['stratos_base'] -> Class['python_agent'] -> Class['mysql']
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/nodejs/manifests/init.pp
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/nodejs/manifests/init.pp b/tools/puppet3/modules/nodejs/manifests/init.pp
index e31dbd8..e1920fd 100644
--- a/tools/puppet3/modules/nodejs/manifests/init.pp
+++ b/tools/puppet3/modules/nodejs/manifests/init.pp
@@ -20,7 +20,7 @@ class nodejs {
require java
$custom_agent_templates = ['extensions/start-servers.sh']
- class {'agent':
+ class {'python_agent':
custom_templates => $custom_agent_templates,
module=>'nodejs'
}
@@ -75,6 +75,6 @@ class nodejs {
}
# install stratos_base before java before nodejs before agent
- Class['stratos_base'] -> Class['java'] -> Class['agent'] -> Class['nodejs']
+ Class['stratos_base'] -> Class['python_agent'] -> Class['nodejs']
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/php/manifests/init.pp
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/php/manifests/init.pp b/tools/puppet3/modules/php/manifests/init.pp
index 2078388..9800933 100755
--- a/tools/puppet3/modules/php/manifests/init.pp
+++ b/tools/puppet3/modules/php/manifests/init.pp
@@ -25,7 +25,7 @@ class php () {
require java
$custom_agent_templates = ['extensions/artifacts-updated.sh']
- class {'agent':
+ class {'python_agent':
custom_templates => $custom_agent_templates,
module=>'php'
}
@@ -141,5 +141,5 @@ class php () {
}
#install stratos_base before java before php before agent
- Class['stratos_base'] -> Class['java'] -> Class['agent'] -> Class['php']
+ Class['stratos_base'] -> Class['python_agent'] -> Class['php']
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/python_agent/files/README.txt
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/files/README.txt b/tools/puppet3/modules/python_agent/files/README.txt
new file mode 100644
index 0000000..6fef5cb
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/files/README.txt
@@ -0,0 +1,12 @@
+This folder should have following:
+
+1. apache-stratos-cartridge-agent-${version}.zip file
+
+2. Folder having a name as $mb_type which is defined in the nodes.pp file.
+
+eg:
+if $mb_type = activemq, folder structure of this folder would be:
+>$ls
+>activemq apache-stratos-cartridge-agent-4.0.0.zip
+
+3. Under $mb_type folder, please add all the client jars, that should be copied to the agent's lib directory.
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/python_agent/lib/facter/stratos_facts.rb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/lib/facter/stratos_facts.rb b/tools/puppet3/modules/python_agent/lib/facter/stratos_facts.rb
new file mode 100644
index 0000000..3cab535
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/lib/facter/stratos_facts.rb
@@ -0,0 +1,29 @@
+# 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.
+
+if FileTest.exists?("/tmp/payload/launch-params")
+
+ configs = File.read("/tmp/payload/launch-params").split(",").map(&:strip)
+
+ configs.each { |x| key_value_pair = x.split("=").map(&:strip)
+ Facter.add("stratos_" + key_value_pair[0].to_s){
+ setcode {
+ key_value_pair[1].to_s
+ }
+ }
+ }
+end
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/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
new file mode 100644
index 0000000..4e170b6
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/manifests/init.pp
@@ -0,0 +1,97 @@
+# 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.
+
+class python_agent(
+ $version = '1.0.0',
+ $owner = 'root',
+ $group = 'root',
+ $target = "/mnt",
+ $type = 'default',
+ $enable_artifact_update = true,
+ $auto_commit = false,
+ $auto_checkout = true,
+){
+
+ $deployment_code = 'cartridge-agent'
+ #$carbon_version = $version
+ $service_code = 'cartridge-agent'
+ #$carbon_home = "${target}/apache-stratos-${service_code}-${carbon_version}"
+ $agent_home= "${target}/${service_code}"
+
+ tag($service_code)
+
+ $service_templates = [
+ 'extensions/clean.sh',
+ 'extensions/instance-activated.sh',
+ 'extensions/instance-started.sh',
+ 'extensions/start-servers.sh',
+ 'extensions/artifacts-copy.sh',
+ 'extensions/artifacts-updated.sh',
+ 'extensions/complete-tenant.sh',
+ 'extensions/complete-topology.sh',
+ 'extensions/member-activated.sh',
+ 'extensions/member-suspended.sh',
+ 'extensions/member-terminated.sh',
+ 'extensions/mount-volumes.sh',
+ 'extensions/subscription-domain-added.sh',
+ 'extensions/subscription-domain-removed.sh',
+ ]
+
+ python_agent::initialize { $deployment_code:
+ repo => $package_repo,
+ version => $version,
+ service => $service_code,
+ local_dir => $local_package_dir,
+ target => $target,
+ owner => $owner,
+ }
+
+ exec { 'copy launch-params to python agent-payload':
+ path => '/bin/',
+ command => "mkdir -p ${target}/${service_code}/payload; cp /tmp/payload/launch-params ${target}/${service_code}/payload/launch-params",
+ require => Py_Agent::Initialize[$deployment_code],
+ }
+
+ exec { 'make extension folder':
+ path => '/bin/',
+ command => "mkdir -p ${target}/${service_code}/extensions",
+ require => Exec["copy launch-params to python agent-payload"],
+ }
+
+ python_agent::push_templates { $service_templates:
+ target => $agent_home,
+ require => Exec["make extension folder"],
+ }
+
+ file { "${target}/${service_code}/agent.conf":
+ ensure => file,
+ content => template("python_agent/agent.conf.erb"),
+ require => Py_Agent::Push_Templates[$service_templates],
+ }
+
+ file { "${target}/${service_code}/logging.ini":
+ ensure => file,
+ content => template("python_agent/logging.ini.erb"),
+ require => File["${target}/${service_code}/agent.conf"],
+ }
+
+ python_agent::start { $deployment_code:
+ owner => $owner,
+ target => "${target}/${service_code}",
+ require => File["${target}/${service_code}/logging.ini"],
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/python_agent/manifests/initialize.pp
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/manifests/initialize.pp b/tools/puppet3/modules/python_agent/manifests/initialize.pp
new file mode 100755
index 0000000..a2f2f27
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/manifests/initialize.pp
@@ -0,0 +1,101 @@
+# 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.
+
+# Initializing the deployment
+
+define python_agent::initialize ($repo, $version, $service, $local_dir, $target, $owner,) {
+
+ exec { "updates":
+ path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+ command => "apt-get update",
+ }
+
+ $packages = ['python-dev', 'python-pip', 'gcc']
+
+ package { $packages:
+ ensure => installed,
+ provider => 'apt',
+ require => Exec["updates"],
+ }
+
+ exec {
+ "pip installs-paho":
+ path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+ command => "pip install paho-mqtt",
+ require => Package[$packages];
+
+ "pip installs-GitPython==0.3.1-beta2":
+ path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+ command => "pip install GitPython==0.3.1-beta2",
+ require => Exec["pip installs-paho"];
+
+ "pip installs-psutil":
+ path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+ command => "pip install psutil",
+ require => Exec["pip installs-GitPython==0.3.1-beta2"];
+
+ "pip installs-gittle":
+ path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+ command => "pip install gittle",
+ require => Exec["pip installs-psutil"];
+ }
+
+ exec { 'cleanup-python-agent':
+ path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+ command => "rm -rf /${local_dir};rm -rf ${target}/${service};",
+ require => Exec["pip installs-gittle"];
+ }
+
+ exec {
+ "creating_target_for_python_${name}":
+ path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+ command => "mkdir -p ${target}",
+ require => Exec["cleanup-python-agent"];
+
+ "creating_local_package_repo_for_python_${name}":
+ path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/java/bin/',
+ unless => "test -d ${local_dir}",
+ command => "mkdir -p ${local_dir}",
+ require => Exec["creating_target_for_python_${name}"];
+ }
+
+ file {
+ "/${local_dir}/${service}.zip":
+ ensure => present,
+ source => ["puppet:///modules/python_agent/${service}.zip"],
+ require => Exec["creating_local_package_repo_for_python_${name}"],
+ }
+
+ exec {
+ "extracting_${service}.zip_for_${name}":
+ path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+ cwd => $target,
+ #/mnt/cartridge-agent/agent.py
+ unless => "test -d ${target}/${service}/agent.conf",
+ command => "unzip -o ${local_dir}/${service}.zip",
+ logoutput => 'on_failure',
+ require => File["/${local_dir}/${service}.zip"];
+
+ "setting_permission_for_python_${name}":
+ path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+ cwd => $target,
+ command => "chown -R ${owner}:${owner} ${target}/${service} ;
+ chmod -R 755 ${target}/${service}",
+ logoutput => 'on_failure',
+ require => Exec["extracting_${service}.zip_for_${name}"];
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/python_agent/manifests/push_templates.pp
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/manifests/push_templates.pp b/tools/puppet3/modules/python_agent/manifests/push_templates.pp
new file mode 100755
index 0000000..94545ad
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/manifests/push_templates.pp
@@ -0,0 +1,28 @@
+# 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.
+
+# Apply the templates
+
+define python_agent::push_templates ($target) {
+ file { "${target}/${name}":
+ ensure => present,
+ owner => $agent::owner,
+ group => $agent::group,
+ mode => '0755',
+ content => template("python_agent/${name}.erb"),
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/python_agent/manifests/start.pp
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/manifests/start.pp b/tools/puppet3/modules/python_agent/manifests/start.pp
new file mode 100755
index 0000000..61c3f97
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/manifests/start.pp
@@ -0,0 +1,27 @@
+# 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.
+
+# Starts the service once the deployment is successful.
+
+define python_agent::start ($target, $owner) {
+ exec { "starting_${name}":
+ user => $owner,
+ path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:',
+ cwd => "${target}/",
+ command => "python agent.py &",
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/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
new file mode 100644
index 0000000..ee35d7c
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/templates/agent.conf.erb
@@ -0,0 +1,46 @@
+[agent]
+mb.ip =MB-IP
+mb.port =MB-PORT
+listen.address =localhost
+thrift.receiver.ip =<%= @cep_ip %>
+thrift.receiver.port =<%= @cep_port %>
+agent.root =<%= @target %>/<%= @service_code %>
+param.file.path =<%= @target %>/<%= @service_code %>/payload/launch-params
+extensions.dir =<%= @target %>/<%= @service_code %>/extensions
+cep.stats.publisher.enabled =true
+lb.private.ip =
+lb.public.ip =
+javax.net.ssl.trustStore =CERT-TRUSTSTORE
+javax.net.ssl.trustStorePassword =<%= @truststore_password %>
+enable.artifact.update =true
+auto.commit =false
+auto.checkout =true
+artifact.update.interval =15
+port.check.timeout =600
+enable.data.publisher =<%= @enable_log_publisher %>
+monitoring.server.ip =<%= @bam_ip %>
+monitoring.server.port =<%= @bam_port %>
+monitoring.server.secure.port =<%= @bam_secure_port %>
+monitoring.server.admin.username =<%= @bam_username %>
+monitoring.server.admin.password =<%= @bam_password %>
+log.file.paths =LOG_FILE_PATHS
+APP_PATH =APP_PATH
+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.subscription.domain.added =subscription-domain-added.sh
+extension.subscription.domain.removed =subscription-domain-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/4280eec2/tools/puppet3/modules/python_agent/templates/extensions/addons/_jboss-as.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/templates/extensions/addons/_jboss-as.erb b/tools/puppet3/modules/python_agent/templates/extensions/addons/_jboss-as.erb
new file mode 100755
index 0000000..b6e23be
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/templates/extensions/addons/_jboss-as.erb
@@ -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.
+
+chown -R <%= @jboss_user %>:<%= @jboss_group %> <%= @docroot %>
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/python_agent/templates/extensions/addons/_mysql.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/templates/extensions/addons/_mysql.erb b/tools/puppet3/modules/python_agent/templates/extensions/addons/_mysql.erb
new file mode 100644
index 0000000..88f8891
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/templates/extensions/addons/_mysql.erb
@@ -0,0 +1,32 @@
+# 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.
+
+export PATH='/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin'
+
+PASSWD=`facter -p stratos_mysql_password`
+
+/etc/init.d/mysql start
+
+# Set mysql password
+mysqladmin -uroot password "$PASSWD"
+
+# Remove other users
+mysql -uroot -p"$PASSWD" -Bse "DELETE from mysql.user WHERE password=''"
+
+# Set root user with remote access
+mysql -uroot -p"$PASSWD" -Bse "CREATE USER 'root'@'%' IDENTIFIED BY '${PASSWD}'"
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/python_agent/templates/extensions/addons/_nodejs.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/templates/extensions/addons/_nodejs.erb b/tools/puppet3/modules/python_agent/templates/extensions/addons/_nodejs.erb
new file mode 100755
index 0000000..463eb53
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/templates/extensions/addons/_nodejs.erb
@@ -0,0 +1,21 @@
+# 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.
+
+export PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin"
+NODEJS_HOME=<%= @stratos_app_path %>
+npm install express
+node web.js > /dev/null 2&1 &
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/python_agent/templates/extensions/addons/_php.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/templates/extensions/addons/_php.erb b/tools/puppet3/modules/python_agent/templates/extensions/addons/_php.erb
new file mode 100755
index 0000000..adb8059
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/templates/extensions/addons/_php.erb
@@ -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.
+
+chown -R www-data:www-data /var/www
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/python_agent/templates/extensions/addons/_ruby.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/templates/extensions/addons/_ruby.erb b/tools/puppet3/modules/python_agent/templates/extensions/addons/_ruby.erb
new file mode 100644
index 0000000..9117dde
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/templates/extensions/addons/_ruby.erb
@@ -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.
+
+export PATH="/usr/local/rvm/gems/ruby-2.1.0/bin:/usr/local/rvm/gems/ruby-2.1.0@global/bin:/usr/local/rvm/rubies/ruby-2.1.0/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/rvm/bin:/root/bin"
+
+export HOME="/root/"
+source ~/.bashrc
+source /etc/profile.d/rvm.sh
+rvm use 2.1.0
+
+RUBY_HOME=<%= @stratos_app_path %>
+GIT_REPO=<%= @stratos_git_repo %>
+
+mkdir -p $RUBY_HOME
+
+git clone $GIT_REPO $RUBY_HOME
+cd $RUBY_HOME
+bundle install
+#rails server > /dev/null 2>&1 &
+rails server > /tmp/ruby.log 2>&1 &
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/python_agent/templates/extensions/artifacts-copy.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/templates/extensions/artifacts-copy.sh.erb b/tools/puppet3/modules/python_agent/templates/extensions/artifacts-copy.sh.erb
new file mode 100644
index 0000000..5cad830
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/templates/extensions/artifacts-copy.sh.erb
@@ -0,0 +1,29 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# --------------------------------------------------------------
+# This extension script will be executed once the update artifacts
+# event is received and they are copied to the given path.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+cp -rf $1* $2
+echo "Artifacts Copied" | tee -a $log
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/python_agent/templates/extensions/artifacts-updated.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/templates/extensions/artifacts-updated.sh.erb b/tools/puppet3/modules/python_agent/templates/extensions/artifacts-updated.sh.erb
new file mode 100755
index 0000000..35a5ca9
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/templates/extensions/artifacts-updated.sh.erb
@@ -0,0 +1,34 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# --------------------------------------------------------------
+# This extension script will be executed 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
+
+<%- if @type == 'php' -%>
+<%= scope.function_template(['python_agent/extensions/addons/_php.erb']) -%>
+<%- elsif @type == 'jboss-as' -%>
+<%= scope.function_template(['python_agent/extensions/addons/_jboss-as.erb']) -%>
+<%- end -%>
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/python_agent/templates/extensions/clean.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/templates/extensions/clean.sh.erb b/tools/puppet3/modules/python_agent/templates/extensions/clean.sh.erb
new file mode 100755
index 0000000..c62ad35
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/templates/extensions/clean.sh.erb
@@ -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/4280eec2/tools/puppet3/modules/python_agent/templates/extensions/complete-tenant.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/templates/extensions/complete-tenant.sh.erb b/tools/puppet3/modules/python_agent/templates/extensions/complete-tenant.sh.erb
new file mode 100644
index 0000000..2586474
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/templates/extensions/complete-tenant.sh.erb
@@ -0,0 +1,30 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# --------------------------------------------------------------
+# This extension script will be executed when complete tenant
+# event is received.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+echo `date`": Complete Tenant Event: " | tee -a $log
+echo "Member List: ${STRATOS_MEMBER_LIST_JSON}" | tee -a $log
+echo "Tenant List: ${STRATOS_TENANT_LIST_JSON}" | tee -a $log
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/python_agent/templates/extensions/complete-topology.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/templates/extensions/complete-topology.sh.erb b/tools/puppet3/modules/python_agent/templates/extensions/complete-topology.sh.erb
new file mode 100644
index 0000000..ea2e941
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/templates/extensions/complete-topology.sh.erb
@@ -0,0 +1,34 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# --------------------------------------------------------------
+# This extension script will be executed when complete topology
+# event is received.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+echo `date`": Complete Topology Event: " | tee -a $log
+echo "LB IP: ${STRATOS_LB_IP}" | tee -a $log
+echo "LB PUBLIC IP: $STRATOS_LB_PUBLIC_IP}" | tee -a $log
+echo "STRATOS_PARAM_FILE_PATH: ${STRATOS_PARAM_FILE_PATH}"
+echo "Member List: ${STRATOS_MEMBER_LIST_JSON}" | tee -a $log
+echo "Complete Topology: ${STRATOS_TOPOLOGY_JSON}" | tee -a $log
+echo "Members in LB: ${STRATOS_MEMBERS_IN_LB_JSON}" | tee -a $log
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/python_agent/templates/extensions/instance-activated.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/templates/extensions/instance-activated.sh.erb b/tools/puppet3/modules/python_agent/templates/extensions/instance-activated.sh.erb
new file mode 100755
index 0000000..f5d60e8
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/templates/extensions/instance-activated.sh.erb
@@ -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/4280eec2/tools/puppet3/modules/python_agent/templates/extensions/instance-started.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/templates/extensions/instance-started.sh.erb b/tools/puppet3/modules/python_agent/templates/extensions/instance-started.sh.erb
new file mode 100755
index 0000000..7b5aa6a
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/templates/extensions/instance-started.sh.erb
@@ -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/4280eec2/tools/puppet3/modules/python_agent/templates/extensions/member-activated.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/templates/extensions/member-activated.sh.erb b/tools/puppet3/modules/python_agent/templates/extensions/member-activated.sh.erb
new file mode 100644
index 0000000..f01d028
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/templates/extensions/member-activated.sh.erb
@@ -0,0 +1,303 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# --------------------------------------------------------------
+# This extension script will be executed when member activated
+# event is received.
+# --------------------------------------------------------------
+#
+
+# Execute error_handler function on script error
+trap 'error_handler ${LINENO} $?' ERR
+
+log=/var/log/apache-stratos/cartridge-agent-extensions-member.activated.log
+VERBOSE=1
+DATE=`which date` || print_error "date command not found"
+ECHO=`which echo` || print_error "echo command not found"
+GREP=`which grep` || print_error "grep command not found"
+PS=`which ps` || print_error "ps command not found"
+SED=`which sed` || print_error "sed command not found"
+
+function printParameters(){
+ ${ECHO} -e "LB IP: ${STRATOS_LB_IP}" | tee -a $log
+ ${ECHO} -e "LB PUBLIC IP: ${STRATOS_LB_PUBLIC_IP}" | tee -a $log
+ ${ECHO} -e "STRATOS_PARAM_FILE_PATH: ${STRATOS_PARAM_FILE_PATH}"
+ ${ECHO} -e "Member List: ${STRATOS_MEMBER_LIST_JSON}" | tee -a $log
+ ${ECHO} -e "Complete Topology: ${STRATOS_TOPOLOGY_JSON}" | tee -a $log
+ ${ECHO} -e "Members in LB: ${STRATOS_MEMBERS_IN_LB_JSON}" | tee -a $log
+ ${ECHO} -e "APP_PATH: ${STRATOS_APP_PATH}" | tee -a $log
+}
+
+function error_handler(){
+ MYSELF="$0" # equals to script name
+ LASTLINE="$1" # argument 1: last line of error occurence
+ LASTERR="$2" # argument 2: error code of last command
+ echo "ERROR in ${MYSELF}: line ${LASTLINE}: exit status of last command: ${LASTERR}"
+ exit 1
+}
+
+function print_message(){
+ if [ ${VERBOSE} -eq 1 ]; then
+ ${ECHO} -e "[INFO] " $1 | tee -a $log
+ fi
+}
+
+function print_error(){
+ ${ECHO} -e "[Error] " $1 | tee -a $log
+ exit 1
+}
+
+function verify_file_exists(){
+ if [[ ! -f $1 ]] ; then
+ print_error "File not found: $1"
+ fi
+}
+
+function update_hosts_file(){
+ instance_hostname="<%= @stratos_instance_data_host_name %>"
+ (${GREP} -q "${instance_hostname}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP} ${instance_hostname} # Stratos LB instance private IP" >> /etc/hosts \
+ && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP} ${instance_hostname}")) \
+ || print_error "Failed to update '/etc/hosts' file. "
+
+ map_to_lb="<%= @stratos_instance_data_map_to_lb %>"
+ arr=$(${ECHO} ${map_to_lb} | tr "," "\n")
+
+ for map_hostname in $arr
+ do
+ (${GREP} -q "${map_hostname}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP} ${map_hostname} # Stratos LB instance private IP" >> /etc/hosts \
+ && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP} ${map_hostname}")) \
+ || print_error "Failed to update '/etc/hosts' file. "
+ done
+
+ <%- if @stratos_instance_data_worker_host_name -%>
+ worker_hostname="<%= @stratos_instance_data_worker_host_name %>"
+ (${GREP} -q " ${worker_hostname}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP} ${worker_hostname} # Stratos LB worker private IP" >> /etc/hosts \
+ && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP} ${worker_hostname}")) \
+ || print_error "Failed to update '/etc/hosts' file. "
+ <%- end -%>
+
+ if [[ "${STRATOS_SERVICE_NAME}" = "apistore" || "${STRATOS_SERVICE_NAME}" = "publisher" ]] ; then
+ gateway_host_name="<%= @stratos_instance_data_gateway_host_name %>"
+ gateway_mgt_host_name="<%= @stratos_instance_data_gateway_mgt_host_name %>"
+ keymanager_host_name="<%= @stratos_instance_data_keymanager_host_name %>"
+
+ (${GREP} -q "${gateway_host_name}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP} ${gateway_host_name} # Stratos LB instance private IP" >> /etc/hosts \
+ && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP} ${gateway_host_name}")) \
+ || print_error "Failed to update '/etc/hosts' file. "
+
+ (${GREP} -q "${gateway_mgt_host_name}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP} ${gateway_mgt_host_name} # Stratos LB instance private IP" >> /etc/hosts \
+ && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP} ${gateway_mgt_host_name}")) \
+ || print_error "Failed to update '/etc/hosts' file. "
+
+
+ (${GREP} -q "${keymanager_host_name}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP} ${keymanager_host_name} # Stratos LB instance private IP" >> /etc/hosts \
+ && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP} ${keymanager_host_name}")) \
+ || print_error "Failed to update '/etc/hosts' file. "
+
+ elif [[ "${STRATOS_SERVICE_NAME}" = "gateway" || "${STRATOS_SERVICE_NAME}" = "gatewaymgt" ]] ; then
+ keymanager_hostname="<%= @stratos_instance_data_keymanager_host_name %>"
+
+ (${GREP} -q "${keymanager_hostname}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP} ${keymanager_hostname} # Stratos LB instance private IP" >> /etc/hosts \
+ && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP} ${keymanager_hostname}")) \
+ || print_error "Failed to update '/etc/hosts' file. "
+
+ fi
+}
+
+function backup_file(){
+ if [[ -f "$1.orig" ]];
+ then
+ print_message "Restoring from the Original template file $1"
+ cp -f "$1.orig" "$1"
+ else
+ print_message "Creating a backup of the file $1"
+ cp -f "$1" "$1.orig"
+ fi
+}
+
+function configure_manager_worker_wka_members(){
+
+ print_message "function configure_manager_worker_wka_members ..... "
+
+ # generic worker manager seperation :D
+ if [[ -z ${STRATOS_WK_MANAGER_MEMBER_COUNT} || ${STRATOS_WK_MANAGER_MEMBER_COUNT} -eq 0 ]] ; then
+ print_message "manager WKA member count is zero or unavailable"
+ else
+ print_message "Configuring manager..."
+ print_message "configure_manager_worker_wka_members STRATOS_WK_MANAGER_MEMBER_COUNT ${STRATOS_WK_MANAGER_MEMBER_COUNT} ..... "
+ for i in `seq 0 $(( ${STRATOS_WK_MANAGER_MEMBER_COUNT} - 1 ))`
+ do
+ member_ip_name="STRATOS_WK_MANAGER_MEMBER_${i}_IP"
+ member_ip=${member_ip_name}
+ if [[ -z ${member_ip} ]] ; then
+ print_error "WKA is null for STRATOS_WK_MANAGER_MEMBER_${i}_IP"
+ fi
+ print_message "$i => ${member_ip}"
+ WKA_XML=$"${WKA_XML}<member><hostName>${!member_ip}</hostName><port>4000</port></member>\n"
+ done
+ fi
+
+ if [[ -z ${STRATOS_WK_WORKER_MEMBER_COUNT} || ${STRATOS_WK_WORKER_MEMBER_COUNT} -eq 0 ]] ; then
+ print_message "worker WKA member count is zero or unavailable"
+ else
+ print_message "Configuring worker..."
+ print_message "STRATOS_WK_WORKER_MEMBER_COUNT ${STRATOS_WK_WORKER_MEMBER_COUNT} ..... "
+ for i in `seq 0 $(( ${STRATOS_WK_WORKER_MEMBER_COUNT} - 1 ))`
+ do
+ member_ip_name="STRATOS_WK_WORKER_MEMBER_${i}_IP"
+ member_ip=${member_ip_name}
+ if [[ -z ${member_ip} ]] ; then
+ print_error "WKA is null for STRATOS_WK_WORKER_MEMBER_${i}_IP"
+ fi
+ print_message "$i => ${member_ip}"
+ WKA_XML=$"${WKA_XML}<member><hostName>${!member_ip}</hostName><port>4000</port></member>\n"
+ done
+ fi
+
+ print_message "${STRATOS_SERVICE_NAME} WKA_XML => ${WKA_XML}"
+ verify_file_exists ${AXIS2_XML_FILE}
+ ${SED} -i "s%${WKA_LINE}%${WKA_XML}%g" ${AXIS2_XML_FILE} && print_message "gateway WKA configuration successful" || print_error "Failed to configure well known members"
+
+}
+
+
+function configure_wk_members(){
+
+ print_message "Performing clustering configuration for ${STRATOS_SERVICE_NAME}..."
+
+ WKA_XML=""
+ KEYMGR_XML=""
+ WKA_LINE="@WELL_KNOWN_MEMBERS"
+ KEYMGR_LINE="@KEYMANAGER_SERVER_URL"
+
+ AXIS2_XML_FILE=${STRATOS_APP_PATH}/repository/conf/axis2/axis2.xml
+ backup_file ${AXIS2_XML_FILE}
+
+
+ if [[ (! -z $STRATOS_SERVICE_GROUP) && "${STRATOS_SERVICE_GROUP}" = "apim" ]] ; then
+ print_message " STRATOS_SERVICE_GROUP_APIM ${STRATOS_SERVICE_GROUP} ..... "
+ API_MANAGER_XML_FILE=${STRATOS_APP_PATH}/repository/conf/api-manager.xml
+ backup_file ${API_MANAGER_XML_FILE}
+
+ if [[ "${STRATOS_SERVICE_NAME}" = "apistore" || "${STRATOS_SERVICE_NAME}" = "publisher" ]] ; then
+
+ print_message "Configuring axis2.xml for ${STRATOS_SERVICE_NAME}..."
+ WKA_XML=$"${WKA_XML}<member><hostName>${STRATOS_WK_APISTORE_MEMBER_IP}</hostName><port>4000</port></member>\n"
+ WKA_XML=$"${WKA_XML}<member><hostName>${STRATOS_WK_PUBLISHER_MEMBER_IP}</hostName><port>4000</port></member>\n"
+ print_message "${STRATOS_SERVICE_NAME} WKA_XML => ${WKA_XML}"
+ verify_file_exists ${AXIS2_XML_FILE}
+ ${SED} -i "s%${WKA_LINE}%${WKA_XML}%g" ${AXIS2_XML_FILE} && print_message "${STRATOS_SERVICE_NAME} WKA configuration successful" || print_error "Failed to configure well known members"
+
+ elif [[ "${STRATOS_SERVICE_NAME}" = "keymanager" ]] ; then
+
+ print_message "In keymanager...nothing to do"
+
+ elif [[ "${STRATOS_SERVICE_NAME}" = "gateway" || "${STRATOS_SERVICE_NAME}" = "gatewaymgt" ]] ; then
+
+ if [[ "${DEPLOYMENT}" = "manager" || "${DEPLOYMENT}" = "worker" ]] ; then
+
+ configure_manager_worker_wka_members
+ fi
+
+ fi
+ elif [[ "${DEPLOYMENT}" = "manager" || "${DEPLOYMENT}" = "worker" ]] ; then
+ print_message " Worker / Manager ..... ${DEPLOYMENT} "
+ configure_manager_worker_wka_members
+ else
+ print_message "Configuring ${STRATOS_SERVICE_NAME}..."
+ print_message "STRATOS_WK_MEMBER_COUNT ....... ${STRATOS_WK_MEMBER_COUNT} "
+ for i in `seq 0 $(( ${STRATOS_WK_MEMBER_COUNT} - 1 ))`
+ do
+ member_ip="STRATOS_WK_MEMBER_${i}_IP"
+ print_message " memberip ${member_ip} ....... "
+ if [[ -z ${!member_ip} ]] ; then
+ print_error "WKA is null for STRATOS_WK_MEMBER_${i}_IP"
+ fi
+ print_message "$i => ${!member_ip}"
+ WKA_XML=$"${WKA_XML}<member><hostName>${!member_ip}</hostName><port>4000</port></member>\n"
+ done
+
+ print_message "${STRATOS_SERVICE_NAME} WKA_XML => ${WKA_XML}"
+ verify_file_exists ${AXIS2_XML_FILE}
+ ${SED} -i "s%${WKA_LINE}%${WKA_XML}%g" ${AXIS2_XML_FILE} && print_message "${STRATOS_SERVICE_NAME} WKA configuration successful" || print_error "Failed to configure well known members"
+ fi
+}
+
+function updateWKMembers() {
+ print_message "Update WKA Members...... "
+ # Check if APP_PATH exists
+ print_message "Stratos App path $STRATOS_APP_PATH ...... "
+ if [[ ! -d $STRATOS_APP_PATH ]] ; then
+ print_error "APP_PATH is not found at: ${STRATOS_APP_PATH}"
+ fi
+
+ # Set JAVA_HOME if it is not already set
+ if [[ -z $JAVA_HOME ]] ; then
+ print_message "Setting JAVA_HOME to /opt/java"
+ export JAVA_HOME=/opt/java
+ fi
+
+ print_message "Stopping wso2server.sh ...... "
+ # Kill Product server
+ $STRATOS_APP_PATH/bin/wso2server.sh stop > /dev/null 2>&1 &
+ sleep 10
+
+ # Check if clustering is enabled for this product
+ if [[ -z $STRATOS_CLUSTERING ]] ; then
+ ${ECHO} -e `date`": starting servers in stand-alone mode..." | tee -a $log
+ if [[ ${VERBOSE} -eq 1 ]]; then
+ printParameters
+ fi
+
+ else
+ ${ECHO} -e `date`": starting servers in clustering mode..." | tee -a $log
+ if [[ ${VERBOSE} -eq 1 ]] ; then
+ printParameters
+ fi
+ # Do the WKA configuration to support clustering
+ configure_wk_members
+ fi
+
+ #Backup hosts file
+ backup_file /etc/hosts
+ # Update the /etc/hosts file with LB instance IP
+ update_hosts_file
+
+ # Run start server command
+ verify_file_exists $STRATOS_APP_PATH/bin/wso2server.sh
+ $STRATOS_APP_PATH/bin/wso2server.sh $* > /dev/null 2>&1 &
+ print_message "Executed run command: $STRATOS_APP_PATH/bin/wso2server.sh $*"
+ print_message "WK Members successfully updated."
+}
+
+# -----------------------
+# Execution starts here
+# -----------------------
+
+ print_message " Executing member activated extension "
+ print_message " Stratos UpdateWK_IP [$STRATOS_UPDATE_WK_IP] "
+# Check if WK Update flag is set
+if [[ $STRATOS_UPDATE_WK_IP = "true" ]]; then
+ print_message " Conditions successful for [$STRATOS_UPDATE_WK_IP] . Executing updateWKMembers "
+ updateWKMembers
+fi
+
+${ECHO} -e `date`": member activated extension successfully completed."
+# END
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/python_agent/templates/extensions/member-started.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/templates/extensions/member-started.sh.erb b/tools/puppet3/modules/python_agent/templates/extensions/member-started.sh.erb
new file mode 100644
index 0000000..29f45c3
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/templates/extensions/member-started.sh.erb
@@ -0,0 +1,43 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# --------------------------------------------------------------
+# This extension script will be executed when member suspended
+# event is received.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+OUTPUT=`date`": Member Started Event: "
+OUTPUT="$OUTPUT MEMBER_ID: ${STRATOS_MEMBER_ID}, "
+OUTPUT="$OUTPUT MEMBER_IP: ${STRATOS_MEMBER_IP}, "
+OUTPUT="$OUTPUT CLUSTER_ID: ${STRATOS_CLUSTER_ID}, "
+OUTPUT="$OUTPUT LB_CLUSTER_ID: ${STRATOS_LB_CLUSTER_ID}, "
+OUTPUT="$OUTPUT NETWORK_PARTITION_ID: ${STRATOS_NETWORK_PARTITION_ID}, "
+OUTPUT="$OUTPUT SERVICE_NAME: ${STRATOS_SERVICE_NAME}, "
+OUTPUT="$OUTPUT PORTS: ${STRATOS_PORTS},"
+OUTPUT="$OUTPUT STRATOS_LB_IP: ${STRATOS_LB_IP},"
+OUTPUT="$OUTPUT STRATOS_LB_PUBLIC_IP: ${STRATOS_LB_PUBLIC_IP},"
+OUTPUT="$OUTPUT APP_PATH: ${APP_PATH},"
+OUTPUT="$OUTPUT STRATOS_PARAM_FILE_PATH: ${STRATOS_PARAM_FILE_PATH}"
+echo $OUTPUT | tee -a $log
+echo "Member List: ${STRATOS_MEMBER_LIST_JSON}" | tee -a $log
+echo "Topology: ${STRATOS_TOPOLOGY_JSON}" | tee -a $log
+echo "---------------" | tee -a $log
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/python_agent/templates/extensions/member-suspended.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/templates/extensions/member-suspended.sh.erb b/tools/puppet3/modules/python_agent/templates/extensions/member-suspended.sh.erb
new file mode 100644
index 0000000..866aa0d
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/templates/extensions/member-suspended.sh.erb
@@ -0,0 +1,43 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# --------------------------------------------------------------
+# This extension script will be executed when member suspended
+# event is received.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+OUTPUT=`date`": Member Suspended Event: "
+OUTPUT="$OUTPUT MEMBER_ID: ${STRATOS_MEMBER_ID}, "
+OUTPUT="$OUTPUT MEMBER_IP: ${STRATOS_MEMBER_IP}, "
+OUTPUT="$OUTPUT CLUSTER_ID: ${STRATOS_CLUSTER_ID}, "
+OUTPUT="$OUTPUT LB_CLUSTER_ID: ${STRATOS_LB_CLUSTER_ID}, "
+OUTPUT="$OUTPUT NETWORK_PARTITION_ID: ${STRATOS_NETWORK_PARTITION_ID}, "
+OUTPUT="$OUTPUT SERVICE_NAME: ${STRATOS_SERVICE_NAME}, "
+OUTPUT="$OUTPUT PORTS: ${STRATOS_PORTS},"
+OUTPUT="$OUTPUT STRATOS_LB_IP: ${STRATOS_LB_IP},"
+OUTPUT="$OUTPUT STRATOS_LB_PUBLIC_IP: ${STRATOS_LB_PUBLIC_IP},"
+OUTPUT="$OUTPUT APP_PATH: ${APP_PATH},"
+OUTPUT="$OUTPUT STRATOS_PARAM_FILE_PATH: ${STRATOS_PARAM_FILE_PATH}"
+echo $OUTPUT | tee -a $log
+echo "Member List: ${STRATOS_MEMBER_LIST_JSON}" | tee -a $log
+echo "Topology: ${STRATOS_TOPOLOGY_JSON}" | tee -a $log
+echo "---------------" | tee -a $log
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/python_agent/templates/extensions/member-terminated.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/templates/extensions/member-terminated.sh.erb b/tools/puppet3/modules/python_agent/templates/extensions/member-terminated.sh.erb
new file mode 100644
index 0000000..89cedf6
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/templates/extensions/member-terminated.sh.erb
@@ -0,0 +1,43 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# --------------------------------------------------------------
+# This extension script will be executed when member terminated
+# event is received.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+OUTPUT=`date`": Member Terminated Event: "
+OUTPUT="$OUTPUT MEMBER_ID: ${STRATOS_MEMBER_ID}, "
+OUTPUT="$OUTPUT MEMBER_IP: ${STRATOS_MEMBER_IP}, "
+OUTPUT="$OUTPUT CLUSTER_ID: ${STRATOS_CLUSTER_ID}, "
+OUTPUT="$OUTPUT LB_CLUSTER_ID: ${STRATOS_LB_CLUSTER_ID}, "
+OUTPUT="$OUTPUT NETWORK_PARTITION_ID: ${STRATOS_NETWORK_PARTITION_ID}, "
+OUTPUT="$OUTPUT SERVICE_NAME: ${STRATOS_SERVICE_NAME}, "
+OUTPUT="$OUTPUT PORTS: ${STRATOS_PORTS},"
+OUTPUT="$OUTPUT STRATOS_LB_IP: ${STRATOS_LB_IP},"
+OUTPUT="$OUTPUT STRATOS_LB_PUBLIC_IP: ${STRATOS_LB_PUBLIC_IP},"
+OUTPUT="$OUTPUT APP_PATH: ${APP_PATH},"
+OUTPUT="$OUTPUT STRATOS_PARAM_FILE_PATH: ${STRATOS_PARAM_FILE_PATH}"
+echo $OUTPUT | tee -a $log
+echo "Member List: ${STRATOS_MEMBER_LIST_JSON}" | tee -a $log
+echo "Topology: ${STRATOS_TOPOLOGY_JSON}" | tee -a $log
+echo "---------------" | tee -a $log
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/python_agent/templates/extensions/mount-volumes.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/templates/extensions/mount-volumes.sh.erb b/tools/puppet3/modules/python_agent/templates/extensions/mount-volumes.sh.erb
new file mode 100755
index 0000000..2e649bd
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/templates/extensions/mount-volumes.sh.erb
@@ -0,0 +1,87 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# --------------------------------------------------------------
+# This extension script will be executed to mount volumes
+# to the instance.
+# --------------------------------------------------------------
+#
+
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+echo -e "Starting mounting volumes" 2>&1 | tee -a $log
+
+# $1 is passed from Cartridge Agent code.
+echo -e "launh param file location $1" | tee -a $log
+#source /opt/apache-stratos-cartridge-agent/launch.params
+PERSISTENCE_MAPPING=$1
+echo -e "Persistance mappings : $PERSISTENCE_MAPPING" 2>&1 | tee -a $log
+
+mount_volume(){
+
+ device=$1;
+ mount_point=$2;
+ echo "device $device"
+ echo "point $mount_point"
+ # check if the volume has a file system
+ output=`sudo file -s $device`;
+ echo $output | tee -a $log
+
+ # this is the pattern of the output of file -s if the volume does not have a file system
+ # refer to http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html
+ pattern="$device: data"
+
+ if [[ $output == $pattern ]]
+ then
+ echo -e "Volume is not formatted. So formating the device $device \n" | tee -a $log
+ sudo mkfs -t ext4 $device
+ fi
+
+ echo "Mounting the device $device to the mount point $mount_point \n" | tee -a $log
+ device_mounted=$(mount | grep "$device")
+
+ if [ ! -d "$mount_point" ]
+ then
+ echo "creating the mount point directory $mount_point since it does not exist." | tee -a $log
+ sudo mkdir $mount_point
+ fi
+
+ #mounting the device if it is not already mounted
+ if [ ! "$device_mounted" = "" ]
+ then
+ echo -e "Device $device is already mounted." | tee -a $log
+ else
+ sudo mount $device $mount_point
+ fi
+
+}
+
+IFS='|' read -ra ADDR <<< "${PERSISTENCE_MAPPING}"
+echo "${ADDR[@]}" | tee -a $log
+
+for i in "${!ADDR[@]}"; do
+ # expected PERSISTANCE_MAPPING format is device1|mountPoint1|device2|mountpoint2...
+ # so that even indexes are devices and odd indexes are mount points..
+ if (( $i % 2 == 0 ))
+ then
+ mount_volume ${ADDR[$i]} ${ADDR[$i + 1]}
+ fi
+done
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/tools/puppet3/modules/python_agent/templates/extensions/start-servers.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/templates/extensions/start-servers.sh.erb b/tools/puppet3/modules/python_agent/templates/extensions/start-servers.sh.erb
new file mode 100755
index 0000000..6e34902
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/templates/extensions/start-servers.sh.erb
@@ -0,0 +1,308 @@
+#!/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.
+# --------------------------------------------------------------
+#
+
+# Execute error_handler function on script error
+trap 'error_handler ${LINENO} $?' ERR
+
+log=/var/log/apache-stratos/cartridge-agent-extensions-start.servers.log
+VERBOSE=1
+DATE=`which date` || print_error "date command not found"
+ECHO=`which echo` || print_error "echo command not found"
+GREP=`which grep` || print_error "grep command not found"
+PS=`which ps` || print_error "ps command not found"
+SED=`which sed` || print_error "sed command not found"
+
+function printParameters(){
+ ${ECHO} -e "LB IP: ${STRATOS_LB_IP}" | tee -a $log
+ ${ECHO} -e "LB PUBLIC IP: ${STRATOS_LB_PUBLIC_IP}" | tee -a $log
+ ${ECHO} -e "STRATOS_PARAM_FILE_PATH: ${STRATOS_PARAM_FILE_PATH}"
+ ${ECHO} -e "Member List: ${STRATOS_MEMBER_LIST_JSON}" | tee -a $log
+ ${ECHO} -e "Complete Topology: ${STRATOS_TOPOLOGY_JSON}" | tee -a $log
+ ${ECHO} -e "Members in LB: ${STRATOS_MEMBERS_IN_LB_JSON}" | tee -a $log
+ ${ECHO} -e "APP_PATH: ${STRATOS_APP_PATH}" | tee -a $log
+}
+
+function error_handler(){
+ MYSELF="$0" # equals to script name
+ LASTLINE="$1" # argument 1: last line of error occurence
+ LASTERR="$2" # argument 2: error code of last command
+ echo "ERROR in ${MYSELF}: line ${LASTLINE}: exit status of last command: ${LASTERR}"
+ exit 1
+}
+
+function print_message(){
+ if [ ${VERBOSE} -eq 1 ]; then
+ ${ECHO} -e "[INFO] " $1 | tee -a $log
+ fi
+}
+
+function print_error(){
+ ${ECHO} -e "[Error] " $1 | tee -a $log
+ exit 1
+}
+
+function verify_file_exists(){
+ if [[ ! -f $1 ]] ; then
+ print_error "File not found: $1"
+ fi
+}
+
+function update_hosts_file(){
+ instance_hostname="<%= @stratos_instance_data_host_name %>"
+ (${GREP} -q "${instance_hostname}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP} ${instance_hostname} # Stratos LB instance private IP" >> /etc/hosts \
+ && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP} ${instance_hostname}")) \
+ || print_error "Failed to update '/etc/hosts' file. "
+
+ map_to_lb="<%= @stratos_instance_data_map_to_lb %>"
+ arr=$(${ECHO} ${map_to_lb} | tr "," "\n")
+
+ for map_hostname in $arr
+ do
+ (${GREP} -q "${map_hostname}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP} ${map_hostname} # Stratos LB instance private IP" >> /etc/hosts \
+ && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP} ${map_hostname}")) \
+ || print_error "Failed to update '/etc/hosts' file. "
+ done
+
+ map_to_ip="<%= @stratos_instance_data_map_to_ip %>"
+ arr=$(${ECHO} ${map_to_ip} | tr "," "\n")
+
+ for mapping in $arr
+ do
+
+ arrr=$(${ECHO} ${mapping} | tr "#" "\n")
+ map_hostname=${arrr[1]}
+ ip_to_map=${arrr[0]}
+
+ (${GREP} -q "${map_hostname}" /etc/hosts || (${ECHO} "${ip_to_map} ${map_hostname} # Additional Mappings" >> /etc/hosts \
+ && print_message "Updated /etc/hosts file with: ${ip_to_map} ${map_hostname}")) \
+ || print_error "Failed to update '/etc/hosts' file. "
+ done
+
+
+ <%- if @stratos_instance_data_worker_host_name -%>
+ worker_hostname="<%= @stratos_instance_data_worker_host_name %>"
+ (${GREP} -q " ${worker_hostname}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP} ${worker_hostname} # Stratos LB worker private IP" >> /etc/hosts \
+ && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP} ${worker_hostname}")) \
+ || print_error "Failed to update '/etc/hosts' file. "
+ <%- end -%>
+
+ if [[ "${STRATOS_SERVICE_NAME}" = "apistore" || "${STRATOS_SERVICE_NAME}" = "publisher" ]] ; then
+ gateway_host_name="<%= @stratos_instance_data_gateway_host_name %>"
+ gateway_mgt_host_name="<%= @stratos_instance_data_gateway_mgt_host_name %>"
+ keymanager_host_name="<%= @stratos_instance_data_keymanager_host_name %>"
+
+ (${GREP} -q "${gateway_host_name}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP} ${gateway_host_name} # Stratos LB instance private IP" >> /etc/hosts \
+ && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP} ${gateway_host_name}")) \
+ || print_error "Failed to update '/etc/hosts' file. "
+
+ (${GREP} -q "${gateway_mgt_host_name}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP} ${gateway_mgt_host_name} # Stratos LB instance private IP" >> /etc/hosts \
+ && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP} ${gateway_mgt_host_name}")) \
+ || print_error "Failed to update '/etc/hosts' file. "
+
+
+ (${GREP} -q "${keymanager_host_name}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP} ${keymanager_host_name} # Stratos LB instance private IP" >> /etc/hosts \
+ && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP} ${keymanager_host_name}")) \
+ || print_error "Failed to update '/etc/hosts' file. "
+
+ elif [[ "${STRATOS_SERVICE_NAME}" = "gateway" || "${STRATOS_SERVICE_NAME}" = "gatewaymgt" ]] ; then
+ keymanager_hostname="<%= @stratos_instance_data_keymanager_host_name %>"
+
+ (${GREP} -q "${keymanager_hostname}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP} ${keymanager_hostname} # Stratos LB instance private IP" >> /etc/hosts \
+ && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP} ${keymanager_hostname}")) \
+ || print_error "Failed to update '/etc/hosts' file. "
+
+ elif [[ "${STRATOS_SERVICE_NAME}" = "keymanager" ]] ; then
+ gateway_host_name="<%= @stratos_instance_data_gateway_host_name %>"
+
+ (${GREP} -q "${gateway_host_name}" /etc/hosts || (${ECHO} "${STRATOS_LB_IP} ${gateway_host_name} # Stratos LB instance private IP" >> /etc/hosts \
+ && print_message "Updated /etc/hosts file with: ${STRATOS_LB_IP} ${gateway_host_name}")) \
+ || print_error "Failed to update '/etc/hosts' file. "
+
+
+ fi
+}
+
+function backup_file(){
+ if [[ -f "$1.orig" ]];
+ then
+ print_message "Restoring from the Original template file $1"
+ cp -f "$1.orig" "$1"
+ else
+ print_message "Creating a backup of the file $1"
+ cp -f "$1" "$1.orig"
+ fi
+}
+
+function configure_manager_worker_wka_members(){
+
+ # generic worker manager seperation :D
+ if [[ -z ${STRATOS_WK_MANAGER_MEMBER_COUNT} || ${STRATOS_WK_MANAGER_MEMBER_COUNT} -eq 0 ]] ; then
+ print_message "manager WKA member count is zero or unavailable"
+ else
+ print_message "Configuring manager..."
+ for i in `seq 0 $(( ${STRATOS_WK_MANAGER_MEMBER_COUNT} - 1 ))`
+ do
+ member_ip_name="STRATOS_WK_MANAGER_MEMBER_${i}_IP"
+ member_ip=${member_ip_name}
+ if [[ -z ${member_ip} ]] ; then
+ print_error "WKA is null for STRATOS_WK_MANAGER_MEMBER_${i}_IP"
+ fi
+ print_message "$i => ${member_ip}"
+ WKA_XML=$"${WKA_XML}<member><hostName>${!member_ip}</hostName><port>4000</port></member>\n"
+ done
+ fi
+
+ if [[ -z ${STRATOS_WK_WORKER_MEMBER_COUNT} || ${STRATOS_WK_WORKER_MEMBER_COUNT} -eq 0 ]] ; then
+ print_message "worker WKA member count is zero or unavailable"
+ else
+ print_message "Configuring worker..."
+ for i in `seq 0 $(( ${STRATOS_WK_WORKER_MEMBER_COUNT} - 1 ))`
+ do
+ member_ip_name="STRATOS_WK_WORKER_MEMBER_${i}_IP"
+ member_ip=${member_ip_name}
+ if [[ -z ${member_ip} ]] ; then
+ print_error "WKA is null for STRATOS_WK_WORKER_MEMBER_${i}_IP"
+ fi
+ print_message "$i => ${member_ip}"
+ WKA_XML=$"${WKA_XML}<member><hostName>${!member_ip}</hostName><port>4000</port></member>\n"
+ done
+ fi
+
+ print_message "${STRATOS_SERVICE_NAME} WKA_XML => ${WKA_XML}"
+ verify_file_exists ${AXIS2_XML_FILE}
+ ${SED} -i "s%${WKA_LINE}%${WKA_XML}%g" ${AXIS2_XML_FILE} && print_message "gateway WKA configuration successful" || print_error "Failed to configure well known members"
+
+}
+
+
+function configure_wk_members(){
+
+ print_message "Performing clustering configuration for ${STRATOS_SERVICE_NAME}..."
+
+ WKA_XML=""
+ KEYMGR_XML=""
+ WKA_LINE="@WELL_KNOWN_MEMBERS"
+ KEYMGR_LINE="@KEYMANAGER_SERVER_URL"
+
+ AXIS2_XML_FILE=${STRATOS_APP_PATH}/repository/conf/axis2/axis2.xml
+ backup_file ${AXIS2_XML_FILE}
+
+
+ if [[ (! -z $STRATOS_SERVICE_GROUP) && "${STRATOS_SERVICE_GROUP}" = "apim" ]] ; then
+ API_MANAGER_XML_FILE=${STRATOS_APP_PATH}/repository/conf/api-manager.xml
+ backup_file ${API_MANAGER_XML_FILE}
+
+ if [[ "${STRATOS_SERVICE_NAME}" = "apistore" || "${STRATOS_SERVICE_NAME}" = "publisher" ]] ; then
+
+ print_message "Configuring axis2.xml for ${STRATOS_SERVICE_NAME}..."
+ WKA_XML=$"${WKA_XML}<member><hostName>${STRATOS_WK_APISTORE_MEMBER_IP}</hostName><port>4000</port></member>\n"
+ WKA_XML=$"${WKA_XML}<member><hostName>${STRATOS_WK_PUBLISHER_MEMBER_IP}</hostName><port>4000</port></member>\n"
+ print_message "${STRATOS_SERVICE_NAME} WKA_XML => ${WKA_XML}"
+ verify_file_exists ${AXIS2_XML_FILE}
+ ${SED} -i "s%${WKA_LINE}%${WKA_XML}%g" ${AXIS2_XML_FILE} && print_message "${STRATOS_SERVICE_NAME} WKA configuration successful" || print_error "Failed to configure well known members"
+
+ elif [[ "${STRATOS_SERVICE_NAME}" = "keymanager" ]] ; then
+
+ print_message "In keymanager...nothing to do"
+
+ elif [[ "${STRATOS_SERVICE_NAME}" = "gateway" || "${STRATOS_SERVICE_NAME}" = "gatewaymgt" ]] ; then
+
+ if [[ "${DEPLOYMENT}" = "manager" || "${DEPLOYMENT}" = "worker" ]] ; then
+
+ configure_manager_worker_wka_members
+ fi
+
+ fi
+ elif [[ "${DEPLOYMENT}" = "manager" || "${DEPLOYMENT}" = "worker" ]] ; then
+
+ configure_manager_worker_wka_members
+ else
+ print_message "Configuring ${STRATOS_SERVICE_NAME}..."
+ for i in `seq 0 $(( ${STRATOS_WK_MEMBER_COUNT} - 1 ))`
+ do
+ member_ip="STRATOS_WK_MEMBER_${i}_IP"
+ if [[ -z ${!member_ip} ]] ; then
+ print_error "WKA is null for STRATOS_WK_MEMBER_${i}_IP"
+ fi
+ print_message "$i => ${!member_ip}"
+ WKA_XML=$"${WKA_XML}<member><hostName>${!member_ip}</hostName><port>4000</port></member>\n"
+ done
+
+ print_message "${STRATOS_SERVICE_NAME} WKA_XML => ${WKA_XML}"
+ verify_file_exists ${AXIS2_XML_FILE}
+ ${SED} -i "s%${WKA_LINE}%${WKA_XML}%g" ${AXIS2_XML_FILE} && print_message "${STRATOS_SERVICE_NAME} WKA configuration successful" || print_error "Failed to configure well known members"
+ fi
+}
+
+# Check if APP_PATH exists
+if [[ ! -d $STRATOS_APP_PATH ]] ; then
+ print_error "APP_PATH is not found at: ${STRATOS_APP_PATH}"
+fi
+
+# Check if product server is already running
+if [[ -f $STRATOS_APP_PATH/wso2carbon.pid ]] ; then
+ PID=`cat $STRATOS_APP_PATH/wso2carbon.pid`
+ if ${PS} -p $PID > /dev/null ; then
+ ${ECHO} -e `date`": process is already running...skipping start servers"
+ exit 0
+ fi
+fi
+
+# Set JAVA_HOME if it is not already set
+if [[ -z $JAVA_HOME ]] ; then
+ print_message "Setting JAVA_HOME to /opt/java"
+ export JAVA_HOME=/opt/java
+fi
+
+# Check if clustering is enabled for this product
+if [[ -z $STRATOS_CLUSTERING ]] ; then
+ ${ECHO} -e `date`": starting servers in stand-alone mode..." | tee -a $log
+ if [[ ${VERBOSE} -eq 1 ]]; then
+ printParameters
+ fi
+
+else
+ ${ECHO} -e `date`": starting servers in clustering mode..." | tee -a $log
+ if [[ ${VERBOSE} -eq 1 ]] ; then
+ printParameters
+ fi
+ # Do the WKA configuration to support clustering
+ configure_wk_members
+fi
+
+<%- if @using_dns == true -%>
+ #Update the DNS mapping
+<%- else -%>
+ # Update the /etc/hosts file with LB instance IP
+ update_hosts_file
+<%- end -%>
+
+
+# Run start server command
+verify_file_exists $STRATOS_APP_PATH/bin/wso2server.sh
+$STRATOS_APP_PATH/bin/wso2server.sh $* > /dev/null 2>&1 &
+print_message "Executed run command: $STRATOS_APP_PATH/bin/wso2server.sh $*"
+${ECHO} -e `date`": start servers extension successfully completed."
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/4280eec2/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
new file mode 100644
index 0000000..9ef88a2
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/templates/extensions/subscription-domain-added.sh.erb
@@ -0,0 +1,35 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# --------------------------------------------------------------
+# This extension script will be executed when subscription domain
+# added event is received.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+OUTPUT=`date`": Subscription Domain Added Event"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_SERVICE_NAME: ${STRATOS_SUBSCRIPTION_SERVICE_NAME},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_DOMAIN_NAME: ${STRATOS_SUBSCRIPTION_DOMAIN_NAME},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_ID: ${STRATOS_SUBSCRIPTION_TENANT_ID},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_DOMAIN: $STRATOS_SUBSCRIPTION_TENANT_DOMAIN},"
+OUTPUT="$OUTPUT APP_PATH: ${APP_PATH},"
+OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_APPLICATION_CONTEXT: ${STRATOS_SUBSCRIPTION_APPLICATION_CONTEXT}"
+echo $OUTPUT | tee -a $log