From dbfe50429202e51bea8268f646a7f72bc5433bde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20=C5=9Eahin?= Date: Mon, 25 Jul 2016 12:21:23 +0300 Subject: [PATCH] timer bug fixing and other minor fixing like log, redundant parameters ... --- opt/ahenk/ahenkd.py | 1 + opt/ahenk/base/execution/ExecutionManager.py | 4 +--- opt/ahenk/base/plugin/Plugin.py | 2 +- opt/ahenk/base/plugin/plugin_manager.py | 8 ++------ 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/opt/ahenk/ahenkd.py b/opt/ahenk/ahenkd.py index 07cc230..44b825f 100755 --- a/opt/ahenk/ahenkd.py +++ b/opt/ahenk/ahenkd.py @@ -332,6 +332,7 @@ class AhenkDeamon(BaseDaemon): kward = {} kward['timeout_args'] = username kward['checker_args'] = username + SetupTimer.start(Timer(timeout=System.Ahenk.get_policy_timeout(), timeout_function=execute_manager.execute_default_policy, checker_func=execute_manager.is_policy_executed, kwargs=kward)) self.logger.info('[AhenkDeamon] Requesting updated policies from Lider. If Ahenk could not reach updated policies in {0} sec, booked policies will be executed'.format(System.Ahenk.get_policy_timeout())) diff --git a/opt/ahenk/base/execution/ExecutionManager.py b/opt/ahenk/base/execution/ExecutionManager.py index a9d9a81..2add485 100644 --- a/opt/ahenk/base/execution/ExecutionManager.py +++ b/opt/ahenk/base/execution/ExecutionManager.py @@ -117,10 +117,8 @@ class ExecutionManager(object): self.policy_executed[username] = False def execute_default_policy(self, username): - print('username' + username) self.logger.debug('[ExecutionManager] Executing active policies for {} user...'.format(username)) - p=self.get_active_policies(username) - self.task_manager.addPolicy(p) + self.task_manager.addPolicy(self.get_active_policies(username)) def execute_policy(self, arg): self.logger.debug('[ExecutionManager] Updating policies...') diff --git a/opt/ahenk/base/plugin/Plugin.py b/opt/ahenk/base/plugin/Plugin.py index 51fa6b3..0787e51 100644 --- a/opt/ahenk/base/plugin/Plugin.py +++ b/opt/ahenk/base/plugin/Plugin.py @@ -171,7 +171,7 @@ class Plugin(threading.Thread): self.context.empty_data() except Exception as e: - self.logger.error("[Plugin] Plugin running exception about {0}. Exception Message: {1} ".format(obj_name, str(e))) + self.logger.error("[Plugin] Plugin running exception. Exception Message: {0} ".format(str(e))) def get_execution_id(self, profile_id): try: diff --git a/opt/ahenk/base/plugin/plugin_manager.py b/opt/ahenk/base/plugin/plugin_manager.py index 12a6d6c..55b0afc 100644 --- a/opt/ahenk/base/plugin/plugin_manager.py +++ b/opt/ahenk/base/plugin/plugin_manager.py @@ -4,7 +4,7 @@ # Author: Volkan Şahin import imp import os - +import threading from base.Scope import Scope from base.model.PluginBean import PluginBean from base.model.modes.init_mode import InitMode @@ -201,10 +201,6 @@ class PluginManager(object): def process_profile(self, profile): - ## - scope = Scope().getInstance() - self.messenger = scope.getMessenger() - ## try: plugin = profile.get_plugin() plugin_name = plugin.get_name() @@ -215,7 +211,7 @@ class PluginManager(object): self.logger.warning('[PluginManager] {} plugin not found. Profile was delayed. Ahenk will request plugin from Lider if distribution available'.format(plugin_name)) self.delayed_profiles[plugin_name] = profile msg = self.message_manager.missing_plugin_message(PluginBean(name=plugin_name, version=plugin_ver)) - self.messenger.send_direct_message(msg) + self.scope.getMessenger().send_direct_message(msg) except Exception as e: self.logger.error('[PluginManager] Exception occurred while processing profile. Error Message: {}'.format(str(e)))