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

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

http://git-wip-us.apache.org/repos/asf/stratos/blob/16f9cf7e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/util.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/util.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/util.py
deleted file mode 100644
index 7c53db4..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/py/util.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-import os
-import subprocess
-
-
-def execute_bash(bash_file):
-    """ Execute the given bash files in the <PCA_HOME>/extensions/bash folder
-    :param bash_file: name of the bash file to execute
-    :return: tuple of (output, errors)
-    """
-    working_dir = os.path.abspath(os.path.dirname(__file__)).split("modules")[0]
-    command = working_dir[:-2] + "bash/" + bash_file
-    extension_values = os.environ.copy()
-
-    p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=extension_values)
-    output, errors = p.communicate()
-
-    return output, errors
\ No newline at end of file

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