Debian Codegraph @

ansible_collections/dellemc/openmanage/plugins/module_utils/idrac_utils/info/controller_enclosure.py

raw symbols SCIP
1 # -*- coding: utf-8 -*-
2
3 # Dell OpenManage Ansible Modules
4 # Version 9.12.0
5 # Copyright (C) 2025 Dell Inc. or its subsidiaries. All Rights Reserved.
6
7 # Redistribution and use in source and binary forms, with or without modification,
8 # are permitted provided that the following conditions are met:
9
10 # * Redistributions of source code must retain the above copyright notice,
11 # this list of conditions and the following disclaimer.
12
13 # * Redistributions in binary form must reproduce the above copyright notice,
14 # this list of conditions and the following disclaimer in the documentation
15 # and/or other materials provided with the distribution.
16
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
25 # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #
27
28
29 GET_IDRAC_CHASSIS_URI = "/redfish/v1/Chassis"
30 NA = "Not Available"
31
32
33 class IDRACEnclosureInfo(object):
34 def __init__(self, idrac):
35 self.idrac = idrac
36
37 def get_enclosure_data(self, resp):
38 dellchasis = resp.get("Oem", {}).get("Dell", {}).get("DellChassisEnclosure", {})
39 output = {
40 "AssetTag": NA if (asset := resp.get("AssetTag")) == "" else asset,
41 "Connector": str(dellchasis.get("Connector")),
42 "DeviceDescription": resp.get("Description"),
43 "EMMCount": str(dellchasis.get("Links", {}).get("[email protected]", 0)),
44 "FQDD": resp.get("Id", NA),
45 "FanCount": NA,
46 "Key": resp.get("Id", NA),
47 "PSUCount": NA,
48 "PrimaryStatus": resp.get("Status", {}).get("Health", NA),
49 "ProductName": resp.get("Name", NA),
50 "ServiceTag": NA if (svctag := dellchasis.get("ServiceTag")) is None else svctag,
51 "SlotCount": str(dellchasis.get("SlotCount", NA)),
52 "State": NA,
53 "Version": dellchasis.get("Version", NA),
54 "WiredOrder": str(dellchasis.get("WiredOrder", NA))
55 }
56 return output
57
58 def get_enclosure_system_info(self):
59 output = []
60 resp = self.idrac.invoke_request(method='GET', uri=GET_IDRAC_CHASSIS_URI)
61 for each_member in resp.json_data.get("Members", []):
62 if 'Enclosure' in each_member['@odata.id']:
63 enc_resp = self.idrac.invoke_request(method='GET', uri=each_member['@odata.id'])
64 output.append(self.get_enclosure_data(enc_resp.json_data))
65 return output
66
67 def get_controller_enclosure_sensor_info(self, enclosure_system_info):
68 output = [{"FQDD": each.get("FQDD"), "Key": each.get("Key")} for each in enclosure_system_info]
69 return output