loads action handler for a group of network modules (#21194)

* loads action handler based on module group prefix for network modules
This commit is contained in:
Peter Sprygada 2017-02-09 14:26:09 -05:00 committed by GitHub
parent 0e4f48d684
commit 21157aa1bc

View file

@ -758,9 +758,14 @@ class TaskExecutor:
Returns the correct action plugin to handle the requestion task action
'''
network_group_modules = frozenset(['eos', 'nxos', 'ios', 'iosxr', 'junos', 'vyos'])
module_prefix = self._task.action.split('_')[0]
# let action plugin override module, fallback to 'normal' action plugin otherwise
if self._task.action in self._shared_loader_obj.action_loader:
handler_name = self._task.action
elif all((module_prefix in network_group_modules, module_prefix in self._shared_loader_obj.action_loader)):
handler_name = module_prefix
else:
pc_conn = self._shared_loader_obj.connection_loader.get(self._play_context.connection, class_only=True)
handler_name = getattr(pc_conn, 'action_handler', 'normal')