Debian Codegraph @

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

raw symbols SCIP
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 # (c) 2022 Manisha Singhal (ATIX AG)
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: snapshot_info
25 version_added: 3.8.0
26 short_description: Fetch information about Foreman Snapshots
27 description:
28 - Fetch information about Foreman Snapshots
29 author:
30 - "Manisha Singhal (@Manisha15) ATIX AG"
31 options:
32 host:
33 description:
34 - Name of related Host
35 required: true
36 type: str
37 extends_documentation_fragment:
38 - theforeman.foreman.foreman
39 - theforeman.foreman.foreman.infomodule
40 '''
41
42 EXAMPLES = '''
43 - name: "Show all snapshots for a host"
44 theforeman.foreman.snapshot_info:
45 username: "admin"
46 password: "changeme"
47 server_url: "https://foreman.example.com"
48 host: "server.example.com"
49
50 - name: "Show a snapshot"
51 theforeman.foreman.snapshot_info:
52 username: "admin"
53 password: "changeme"
54 server_url: "https://foreman.example.com"
55 host: "server.example.com"
56 search: "name=ansible"
57 '''
58
59 RETURN = '''
60 snapshots:
61 description: List of all snapshots and their details for a host
62 returned: success and I(search) was passed
63 type: list
64 elements: dict
65 snapshot:
66 description: Details about the first found snapshot with searched name
67 returned: success and I(name) was passed
68 type: list
69 elements: dict
70 '''
71
72 from ansible_collections.theforeman.foreman.plugins.module_utils.foreman_helper import (
73 ForemanInfoAnsibleModule,
74 )
75
76
77 class ForemanSnapshotInfo(ForemanInfoAnsibleModule):
78 pass
79
80
81 def main():
82 module = ForemanSnapshotInfo(
83 foreman_spec=dict(
84 host=dict(type='entity', required=True),
85 ),
86 entity_opts={'scope': ['host', 'snapshot']},
87 required_plugins=[('snapshot_management', ['*'])],
88 )
89
90 with module.api_connection():
91 module.run()
92
93
94 if __name__ == '__main__':
95 main()