-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathsupport_tunnel_info.py
More file actions
77 lines (61 loc) · 1.82 KB
/
support_tunnel_info.py
File metadata and controls
77 lines (61 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2023, XLAB Steampunk <steampunk@xlab.si>
#
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
__metaclass__ = type
# language=yaml
DOCUMENTATION = r"""
module: support_tunnel_info
author:
- Polona Mihalič (@PolonaM)
short_description: Checks status of the remote support tunnel.
description:
- Checks status of the remote support tunnel on the node.
version_added: 1.2.0
extends_documentation_fragment:
- scale_computing.hypercore.cluster_instance
seealso: []
"""
# language=yaml
EXAMPLES = r"""
- name: Check status of the remote support tunnel
scale_computing.hypercore.support_tunnel_info:
"""
# language=yaml
RETURN = r"""
record:
description:
- Support tunnel status.
returned: success
type: dict
sample:
open: true
code: 4422
"""
from ansible.module_utils.basic import AnsibleModule
from ..module_utils import arguments
from ..module_utils import errors
from ..module_utils.client import Client
from ..module_utils.support_tunnel import SupportTunnel
from ..module_utils.typed_classes import TypedSupportTunnelToAnsible
def run(client: Client) -> TypedSupportTunnelToAnsible:
return SupportTunnel.check_tunnel_status(client).to_ansible()
def main() -> None:
module = AnsibleModule(
supports_check_mode=True,
argument_spec=dict(
arguments.get_spec("cluster_instance"),
),
)
try:
with Client.get_client(module.params["cluster_instance"]) as client:
record = run(client)
module.exit_json(record=record)
except errors.ScaleComputingError as e:
module.fail_json(msg=str(e))
if __name__ == "__main__":
main()