Debian Codegraph @

ansible_collections/dellemc/openmanage/plugins/modules/idrac_lifecycle_controller_status_info.py

raw symbols SCIP
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 #
5 # Dell OpenManage Ansible Modules
6 # Version 9.12.1
7 # Copyright (C) 2018-2025 Dell Inc. or its subsidiaries. All Rights Reserved.
8
9 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
10 #
11
12
13 from __future__ import (absolute_import, division, print_function)
14 __metaclass__ = type
15
16 DOCUMENTATION = """
17 ---
18 module: idrac_lifecycle_controller_status_info
19 short_description: Get the status of the Lifecycle Controller
20 version_added: "2.1.0"
21 description:
22 - This module shows the status of the Lifecycle Controller on a Dell PowerEdge server.
23 extends_documentation_fragment:
24 - dellemc.openmanage.idrac_auth_options
25
26 requirements:
27 - "omsdk >= 1.2.488"
28 - "python >= 3.9.6"
29 author:
30 - "Rajeev Arakkal (@rajeevarakkal)"
31 - "Anooja Vardhineni (@anooja-vardhineni)"
32 - "Kritika Bhateja (@Kritika-Bhateja-03)"
33 notes:
34 - Run this module from a system that has direct access to Dell iDRAC.
35 - This module supports both IPv4 and IPv6 address for I(idrac_ip).
36 - This module supports C(check_mode).
37 """
38
39 EXAMPLES = """
40 ---
41 - name: Show status of the Lifecycle Controller
42 dellemc.openmanage.idrac_lifecycle_controller_status_info:
43 idrac_ip: "192.168.0.1"
44 idrac_user: "user_name"
45 idrac_password: "user_password"
46 ca_path: "/path/to/ca_cert.pem"
47 """
48
49 RETURN = r'''
50 ---
51 msg:
52 description: Overall status of fetching lifecycle controller status.
53 returned: always
54 type: str
55 sample: "Successfully fetched the lifecycle controller status."
56 lc_status_info:
57 description: Displays the status of the Lifecycle Controller on a Dell PowerEdge server.
58 returned: success
59 type: dict
60 sample: {
61 "msg": {
62 "LCReady": true,
63 "LCStatus": "Ready"
64 }
65 }
66 error_info:
67 description: Details of the HTTP Error.
68 returned: on HTTP error
69 type: dict
70 sample: {
71 "error": {
72 "code": "Base.1.0.GeneralError",
73 "message": "A general error has occurred. See ExtendedInfo for more information.",
74 "@Message.ExtendedInfo": [
75 {
76 "MessageId": "GEN1234",
77 "RelatedProperties": [],
78 "Message": "Unable to process the request because an error occurred.",
79 "MessageArgs": [],
80 "Severity": "Critical",
81 "Resolution": "Retry the operation. If the issue persists, contact your system administrator."
82 }
83 ]
84 }
85 }
86 '''
87
88
89 from ansible_collections.dellemc.openmanage.plugins.module_utils.\
90 dellemc_idrac import iDRACConnection, idrac_auth_params
91 from ansible_collections.dellemc.openmanage.plugins.module_utils.\
92 idrac_utils.info.lifecycle_controller_status \
93 import IDRACLifecycleControllerStatusInfo
94 from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_redfish \
95 import iDRACRedfishAPI
96 from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_utils.\
97 info.idrac import IDRACInfo
98 from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError
99 from ansible.module_utils.urls import ConnectionError, SSLValidationError
100 from ansible.module_utils.basic import AnsibleModule
101 import json
102
103
104 def main():
105 specs = {}
106 specs.update(idrac_auth_params)
107 module = AnsibleModule(
108 argument_spec=specs,
109 supports_check_mode=True)
110 try:
111 with iDRACRedfishAPI(module.params) as idrac:
112 server_hw_model = IDRACInfo(idrac).get_idrac_hw_model()
113 if server_hw_model:
114 lifecycle_status_obj = IDRACLifecycleControllerStatusInfo(idrac)
115 lcstatus = lifecycle_status_obj.get_lifecycle_controller_status_info()
116 if lcstatus:
117 lcready = (lcstatus == "Ready")
118 else:
119 with iDRACConnection(module.params) as idrac:
120 lcready = idrac.config_mgr.LCReady
121 lcstatus = idrac.config_mgr.LCStatus
122 except HTTPError as err:
123 module.fail_json(msg=str(err), error_info=json.load(err))
124 except URLError as err:
125 module.exit_json(msg=str(err), unreachable=True)
126 except (RuntimeError, SSLValidationError, ConnectionError, KeyError,
127 ImportError, ValueError, TypeError) as e:
128 module.fail_json(msg=str(e))
129 module.exit_json(msg="Successfully fetched the lifecycle controller status.",
130 lc_status_info={'LCReady': lcready, 'LCStatus': lcstatus})
131
132
133 if __name__ == '__main__':
134 main()