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

[2/2] stratos git commit: Puppet - New manifest to copy custom plugins from modules to PCA/plugins Puppet - PHP puppet module contains the httpd restart PCA plugin

Puppet - New manifest to copy custom plugins from modules to PCA/plugins
Puppet - PHP puppet module contains the httpd restart PCA plugin


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

Branch: refs/heads/master
Commit: db0ae09bbb0494d860a682f38a61741b524d89b0
Parents: caa1415
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Fri Mar 6 12:32:08 2015 +0530
Committer: Chamila de Alwis <ch...@apache.org>
Committed: Fri Mar 27 12:05:54 2015 +0530

----------------------------------------------------------------------
 tools/puppet3/manifests/nodes/base.pp           |  1 +
 .../agent/plugins/PhpServerStarterPlugin.py     | 36 ++++++++++++++++++++
 .../plugins/PhpServerStarterPlugin.yapsy-plugin |  9 +++++
 tools/puppet3/modules/php/manifests/init.pp     | 16 +++++----
 .../python_agent/manifests/copy_plugins.pp      | 29 ++++++++++++++++
 .../modules/python_agent/manifests/init.pp      |  9 ++++-
 6 files changed, 92 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/db0ae09b/tools/puppet3/manifests/nodes/base.pp
----------------------------------------------------------------------
diff --git a/tools/puppet3/manifests/nodes/base.pp b/tools/puppet3/manifests/nodes/base.pp
index afd8770..2d37cf7 100755
--- a/tools/puppet3/manifests/nodes/base.pp
+++ b/tools/puppet3/manifests/nodes/base.pp
@@ -40,6 +40,7 @@ node 'base' {
   $bam_secure_port	= '7711'
   $bam_username		= 'admin'
   $bam_password		= 'admin'
+  $metadata_service_url = 'https://127.0.0.1:9443'
 
   require stratos_base 
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/db0ae09b/tools/puppet3/modules/php/files/agent/plugins/PhpServerStarterPlugin.py
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/php/files/agent/plugins/PhpServerStarterPlugin.py b/tools/puppet3/modules/php/files/agent/plugins/PhpServerStarterPlugin.py
new file mode 100644
index 0000000..13d165c
--- /dev/null
+++ b/tools/puppet3/modules/php/files/agent/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/db0ae09b/tools/puppet3/modules/php/files/agent/plugins/PhpServerStarterPlugin.yapsy-plugin
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/php/files/agent/plugins/PhpServerStarterPlugin.yapsy-plugin b/tools/puppet3/modules/php/files/agent/plugins/PhpServerStarterPlugin.yapsy-plugin
new file mode 100644
index 0000000..221ffd5
--- /dev/null
+++ b/tools/puppet3/modules/php/files/agent/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/db0ae09b/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 e088fdd..be9f225 100755
--- a/tools/puppet3/modules/php/manifests/init.pp
+++ b/tools/puppet3/modules/php/manifests/init.pp
@@ -23,8 +23,10 @@
 class php () {
 
   $custom_agent_templates = ['extensions/artifacts-updated.sh']
+  $custom_plugins = ['plugins/PhpServerStarterPlugin.py', 'plugins/PhpServerStarterPlugin.yapsy-plugin']
   class {'python_agent':
     custom_templates => $custom_agent_templates,
+    custom_plugins => $custom_plugins,
     module=>'php'
   }
 
@@ -121,13 +123,13 @@ class php () {
                    Php::Importssl['import ssl']
                  ];
 
-    'apache2 restart':
-      path    => ['/bin', '/usr/bin', '/usr/sbin/'],
-      command => "/etc/init.d/apache2 restart",
-      require => [ Exec["enable ssl module"],
-                   File['/etc/apache2/sites-enabled/default'], 
-                   File['/etc/apache2/sites-enabled/default-ssl']
-                 ];
+#    'apache2 restart':
+#      path    => ['/bin', '/usr/bin', '/usr/sbin/'],
+#      command => "/etc/init.d/apache2 restart",
+#      require => [ Exec["enable ssl module"],
+#                   File['/etc/apache2/sites-enabled/default'],
+#                   File['/etc/apache2/sites-enabled/default-ssl']
+#                 ];
   }
 
   #install stratos_base before java before php before agent

http://git-wip-us.apache.org/repos/asf/stratos/blob/db0ae09b/tools/puppet3/modules/python_agent/manifests/copy_plugins.pp
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/python_agent/manifests/copy_plugins.pp b/tools/puppet3/modules/python_agent/manifests/copy_plugins.pp
new file mode 100755
index 0000000..882741b
--- /dev/null
+++ b/tools/puppet3/modules/python_agent/manifests/copy_plugins.pp
@@ -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.
+
+# Copy the plugins from the modules
+
+define python_agent::copy_plugins ($target,$plugins_dir) {
+  file { "${target}/${name}":
+    ensure  => present,
+    owner   => $agent::owner,
+    group   => $agent::group,
+    mode    => '0755',
+    source => "puppet:///modules/${plugins_dir}/${name}"
+  #content => template("${plugins_dir}/${name}"),
+  }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/db0ae09b/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 36fbc97..603d79b 100644
--- a/tools/puppet3/modules/python_agent/manifests/init.pp
+++ b/tools/puppet3/modules/python_agent/manifests/init.pp
@@ -26,7 +26,8 @@ class python_agent(
   $auto_checkout          = true,
   $module                 = 'undef',
   $custom_templates       = [],
-  $exclude_templates	  = []
+  $exclude_templates	    = [],
+  $custom_plugins         = []
 ){
 
   $service_code    = 'cartridge-agent'
@@ -147,6 +148,12 @@ class python_agent(
     require => File["${agent_home}/agent.conf"],
   }
 
+  python_agent::copy_plugins { $custom_plugins:
+    target => $agent_home,
+    plugins_dir => "${module}/agent",
+    require => File["${agent_home}/logging.ini"]
+  }
+
   python_agent::start { $service_code:
     owner   => $owner,
     target  => $agent_home,