Debian Codegraph @

ansible_collections/theforeman/foreman/plugins/modules/status_info.py

raw symbols SCIP
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 # (c) 2020 Evgeni Golov
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 from __future__ import absolute_import, division, print_function
19 __metaclass__ = type
20
21
22 DOCUMENTATION = '''
23 ---
24 module: status_info
25 version_added: 1.3.0
26 short_description: Get status info
27 description:
28 - Get status information from the server
29 author:
30 - "Evgeni Golov (@evgeni)"
31 extends_documentation_fragment:
32 - theforeman.foreman.foreman
33 '''
34
35 EXAMPLES = '''
36 - name: status
37 theforeman.foreman.status_info:
38 server_url: "https://foreman.example.com"
39 username: "admin"
40 password: "changeme"
41 '''
42
43 RETURN = '''
44 status:
45 description: Basic status of the server.
46 returned: always
47 type: dict
48 ping:
49 description: Detailed service status.
50 returned: if supported by server
51 type: dict
52 '''
53
54 from ansible_collections.theforeman.foreman.plugins.module_utils.foreman_helper import ForemanAnsibleModule
55
56
57 def main():
58 module = ForemanAnsibleModule()
59
60 with module.api_connection():
61 status = module.status()
62
63 if 'ping' in module.foremanapi.resources:
64 if 'ping' in module.foremanapi.resource('ping').actions:
65 ping_action = 'ping'
66 else:
67 ping_action = 'index'
68 ping = module.foremanapi.resource('ping').call(ping_action)
69 else:
70 ping = None
71
72 module.exit_json(status=status, ping=ping)
73
74
75 if __name__ == '__main__':
76 main()