Debian Codegraph @

ansible_collections/dellemc/enterprise_sonic/plugins/action/interfaces.py

raw symbols SCIP
1 #
2 # (c) 2020 Red Hat Inc.
3 #
4 # (c) 2020 Dell Inc.
5 #
6 # This file is part of Ansible
7 #
8 # Ansible is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # Ansible is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
20 #
21 from __future__ import (absolute_import, division, print_function)
22 __metaclass__ = type
23
24
25 from ansible_collections.ansible.netcommon.plugins.action.network import ActionModule as ActionNetworkModule
26
27 from ansible.utils.display import Display
28
29 display = Display()
30
31 DOCUMENTATION = """
32 short_description: Action plugin module for sonic CLI modules
33 version_added: 1.0.0
34 """
35
36
37 class ActionModule(ActionNetworkModule):
38
39 def run(self, task_vars=None):
40
41 module_name = self._task.action.split('.')[-1]
42 self._config_module = True if module_name == 'sonic_config' else False
43
44 if self._play_context.connection in ('network_cli', 'httpapi'):
45 provider = self._task.args.get('provider', {})
46 if any(provider.values()):
47 display.warning('provider is unnecessary when using network_cli and will be ignored')
48 del self._task.args['provider']
49
50 result = super(ActionModule, self).run(task_vars=task_vars)
51 return result