Execution manager policy type name fixed

This commit is contained in:
İsmail Başaran 2016-03-29 11:09:22 +03:00
parent fedc9cbd2c
commit eba656d8ae

View file

@ -33,25 +33,24 @@ class ExecutionManager(object):
self.event_manager.register_event('REQUEST_FILE', self.request_file) self.event_manager.register_event('REQUEST_FILE', self.request_file)
self.event_manager.register_event('MOVE_FILE', self.move_file) self.event_manager.register_event('MOVE_FILE', self.move_file)
self.event_manager.register_event('EXECUTE_TASK', self.execute_task) self.event_manager.register_event('EXECUTE_TASK', self.execute_task)
self.event_manager.register_event('POLICY', self.update_policies) self.event_manager.register_event('EXECUTE_POLICY', self.update_policies)
def update_policies(self, arg): def update_policies(self, arg):
self.logger.debug('[ExecutionManager] Updating policies...') self.logger.debug('[ExecutionManager] Updating policies...')
policy = Policy(json.loads(arg)) policy = Policy(json.loads(arg))
print(policy)
# TODO get username # TODO get username
"""
username = 'volkan' username = 'volkan'
ahenk_policy_ver = self.db_service.select_one_result('policy', 'version', 'type = \'A\'') ahenk_policy_ver = self.db_service.select_one_result('policy', 'version', 'type = \'A\'')
user_policy_version = self.db_service.select_one_result('policy', 'version', 'type = \'U\' and name = \'' + username + '\'') user_policy_version = self.db_service.select_one_result('policy', 'version', 'type = \'U\' and name = \'' + username + '\'')
installed_plugins = self.get_installed_plugins() installed_plugins = self.get_installed_plugins()
missing_plugins = [] missing_plugins = []
if policy.ahenk_policy_version != ahenk_policy_ver: if policy.ahenk_policy_version != ahenk_policy_ver:
ahenk_policy_id = self.db_service.select_one_result('policy', 'id', 'type = \'A\'') ahenk_policy_id = self.db_service.select_one_result('policy', 'id', 'type = \'A\'')
self.db_service.delete('profile', 'id=' + str(ahenk_policy_id)) self.db_service.delete('profile', 'id=' + str(ahenk_policy_id))
self.db_service.update('policy', ['version'], [str(policy.ahenk_policy_version)], 'type=\'A\'') self.db_service.update('policy', ['version'], [str(policy.ahenk_policy_version)], 'type=\'A\'')
for profile in policy.ahenk_profiles: for profile in policy.ahenk_profiles:
profile_columns = ['id', 'create_date', 'modify_date', 'label', 'description', 'overridable', 'active', 'deleted', 'profile_data', 'plugin'] profile_columns = ['id', 'create_date', 'modify_date', 'label', 'description', 'overridable', 'active', 'deleted', 'profile_data', 'plugin']
args = [str(ahenk_policy_id), str(profile.create_date), str(profile.modify_date), str(profile.label), args = [str(ahenk_policy_id), str(profile.create_date), str(profile.modify_date), str(profile.label),
@ -79,6 +78,11 @@ class ExecutionManager(object):
# TODO check plugins # TODO check plugins
print("but first need these plugins:" + str(missing_plugins)) print("but first need these plugins:" + str(missing_plugins))
"""
print("Executing policy")
self.task_manager.addPolicy(policy)
def get_installed_plugins(self): def get_installed_plugins(self):
plugins = self.db_service.select('plugin', ['name', 'version']) plugins = self.db_service.select('plugin', ['name', 'version'])