Debian Codegraph @

ansible_collections/cisco/meraki/plugins/action/devices_live_tools_throughput_test_info.py

raw
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 # Copyright (c) 2021, Cisco Systems
5 # GNU General Public License v3.0+ (see LICENSE or
6 # https://www.gnu.org/licenses/gpl-3.0.txt)
7
8 from __future__ import (absolute_import, division, print_function)
9 __metaclass__ = type
10 from ansible.plugins.action import ActionBase
11 try:
12 from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
13 AnsibleArgSpecValidator, )
14 except ImportError:
15 ANSIBLE_UTILS_IS_INSTALLED = False
16 else:
17 ANSIBLE_UTILS_IS_INSTALLED = True
18 from ansible.errors import AnsibleActionFail
19 from ansible_collections.cisco.meraki.plugins.plugin_utils.meraki import (
20 MERAKI,
21 meraki_argument_spec,
22 )
23
24 # Get common arguments specification
25 argument_spec = meraki_argument_spec()
26 # Add arguments specific for this module
27 argument_spec.update(dict(
28 ))
29
30 required_if = []
31 required_one_of = []
32 mutually_exclusive = []
33 required_together = []
34
35
36 class ActionModule(ActionBase):
37 def __init__(self, *args, **kwargs):
38 if not ANSIBLE_UTILS_IS_INSTALLED:
39 raise AnsibleActionFail(
40 "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'")
41 super(ActionModule, self).__init__(*args, **kwargs)
42 self._supports_async = False
43 self._supports_check_mode = True
44 self._result = None
45
46 # Checks the supplied parameters against the argument spec for this module
47 def _check_argspec(self):
48 aav = AnsibleArgSpecValidator(
49 data=self._task.args,
50 schema=dict(argument_spec=argument_spec),
51 schema_format="argspec",
52 schema_conditionals=dict(
53 required_if=required_if,
54 required_one_of=required_one_of,
55 mutually_exclusive=mutually_exclusive,
56 required_together=required_together,
57 ),
58 name=self._task.action,
59 )
60 valid, errors, self._task.args = aav.validate()
61 if not valid:
62 raise AnsibleActionFail(errors)
63
64 def run(self, tmp=None, task_vars=None):
65 self._task.diff = False
66 self._result = super(ActionModule, self).run(tmp, task_vars)
67 self._result["changed"] = False
68 self._check_argspec()
69
70 self._result.update(dict(meraki_response={}))
71
72 meraki = MERAKI(params=self._task.args)
73
74 # NOTE: Does not have a get all method or it is in another action
75 response = None
76 meraki.object_modify_result(
77 changed=False,
78 result="Module does not have get all, check arguments of module")
79 self._result.update(dict(meraki_response=response))
80 self._result.update(meraki.exit_json())
81 return self._result