Debian Codegraph @

ansible_collections/dellemc/openmanage/plugins/module_utils/idrac_utils/info/fan.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 GET_IDRAC_FAN_DETAILS_URI_10 = "/redfish/v1/Chassis/System.Embedded.1/ThermalSubsystem/Fans?$expand=*($levels=1)"
29 NA = "Not Available"
30
31
32 class IDRACFanInfo(object):
33 def __init__(self, idrac):
34 self.idrac = idrac
35
36 def map_fan_data(self, fan):
37 health = fan.get("Status", {}).get("Health", NA)
38 fan_pwm = fan.get("Oem", {}).get("Dell", {}).get("FanPWM", 0)
39 current_reading = (
40 fan["SpeedPercent"][0].get("SpeedRPM", NA)
41 if isinstance(fan.get("SpeedPercent"), list)
42 else fan.get("SpeedPercent", {}).get("SpeedRPM", NA)
43 )
44 output = {
45 "ActiveCooling": fan.get("HotPluggable", NA),
46 "CurrentReading": current_reading,
47 "DeviceDescription": fan.get("Name", NA),
48 "FQDD": fan.get("Id", NA),
49 "Key": fan.get("Id", NA),
50 "Location": fan.get("Location", NA),
51 "PWM": fan_pwm,
52 "PrimaryStatus": "Healthy" if health == "OK" else health,
53 "State": fan.get("State", NA),
54 "VariableSpeed": "true" if fan_pwm > 0 else "false"
55 }
56 return output
57
58 def get_fan_info(self):
59 """Fetches fan data from iDRAC and maps it."""
60 output = []
61 resp = self.idrac.invoke_request(method='GET', uri=GET_IDRAC_FAN_DETAILS_URI_10)
62
63 if resp.status_code == 200:
64 fan_members = resp.json_data.get("Members", [])
65 for fan in fan_members:
66 output.append(self.map_fan_data(fan))
67 return output