overridable profiles handled, only one profile is executed for a plugin

This commit is contained in:
Volkan Şahin 2016-07-14 16:26:39 +03:00
parent 58d61accad
commit 80beb37e08

View file

@ -126,6 +126,12 @@ class PluginManager(object):
self.logger.warning('[PluginManager] policy.py not found Plugin Name : ' + str(plugin_name)) self.logger.warning('[PluginManager] policy.py not found Plugin Name : ' + str(plugin_name))
return None return None
def is_profile_overridable(self, profiles, plugin_name):
for profile in profiles:
if profile.plugin.name == plugin_name and profile.overridable.lower() == 'true':
return True
return False
def processPolicy(self, policy): def processPolicy(self, policy):
self.logger.info('[PluginManager] Processing policies...') self.logger.info('[PluginManager] Processing policies...')
@ -135,15 +141,27 @@ class PluginManager(object):
if ahenk_profiles is not None: if ahenk_profiles is not None:
self.logger.info('[PluginManager] Working on Ahenk profiles...') self.logger.info('[PluginManager] Working on Ahenk profiles...')
for profile in ahenk_profiles: for agent_profile in ahenk_profiles:
profile.set_username(None)
self.process_profile(profile) if agent_profile.overridable.lower() != 'true' and self.is_profile_overridable(policy.user_profiles, agent_profile.plugin.name) is True:
temp_list = []
self.logger.debug('[PluginManager] User profile of {0} plugin will not executed because of profile override rules.'.format(agent_profile.plugin.name))
for usr_profile in user_profiles:
if usr_profile.plugin.name != agent_profile.plugin.name:
temp_list.append(usr_profile)
user_profiles = temp_list
else:
self.logger.debug('[PluginManager] Agent profile of {0} plugin will not executed because of profile override rules.'.format(agent_profile.plugin.name))
continue
agent_profile.set_username(None)
self.process_profile(agent_profile)
if user_profiles is not None: if user_profiles is not None:
self.logger.info('[PluginManager] Working on User profiles...') self.logger.info('[PluginManager] Working on User profiles...')
for profile in user_profiles: for user_profile in user_profiles:
profile.set_username(username) user_profile.set_username(username)
self.process_profile(profile) self.process_profile(user_profile)
def process_profile(self, profile): def process_profile(self, profile):