| 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 |
GET_IDRAC_FC_DETAILS_URI = "/redfish/v1/Chassis/System.Embedded.1/Oem/Dell/DellFC" |
| 29 |
GET_IDRAC_FC_CAPABILITY_DETAILS_URI = "/redfish/v1/Chassis/System.Embedded.1/Oem/Dell/DellFCCapabilities" |
| 30 |
GET_IDRAC_FC_PORT_METRICS_DETAILS_URI = "/redfish/v1/Chassis/System.Embedded.1//Oem/Dell/DellFCPortMetrics" |
| 31 |
GET_IDRAC_FC_STATISTICS_DETAILS_URI = "/redfish/v1/Chassis/System.Embedded.1/Oem/Dell/DellFCStatistics" |
| 32 |
NA = "Not Available" |
| 33 |
|
| 34 |
|
| 35 |
class IDRACFCInfo(object): |
| 36 |
def __init__(self, idrac): |
| 37 |
self.idrac = idrac |
| 38 |
|
| 39 |
def get_fc_capability_details(self, id): |
| 40 |
response = self.idrac.invoke_request(method='GET', uri=GET_IDRAC_FC_CAPABILITY_DETAILS_URI) |
| 41 |
if response.status_code == 200: |
| 42 |
for member in response.json_data.get("Members", []): |
| 43 |
if member.get("Id", "") == id: |
| 44 |
feature_licensing_support = member.get("FeatureLicensingSupport", "") |
| 45 |
uefi_support = member.get("uEFISupport", "") |
| 46 |
flex_addressing_support = member.get("FlexAddressingSupport", "") |
| 47 |
on_chip_thermal_sensor = member.get("OnChipThermalSensor", "") |
| 48 |
fc_max_num_exchanges = member.get("FCMaxNumberExchanges", "") |
| 49 |
fc_max_num_outstanding_cmds = member.get("FCMaxNumberOutStandingCommands", "") |
| 50 |
persistence_policy_support = member.get("PersistencePolicySupport", "") |
| 51 |
|
| 52 |
return feature_licensing_support, uefi_support, flex_addressing_support, \ |
| 53 |
on_chip_thermal_sensor, fc_max_num_exchanges, fc_max_num_outstanding_cmds, \ |
| 54 |
persistence_policy_support |
| 55 |
|
| 56 |
return "", "", "", "", "", "", "" |
| 57 |
|
| 58 |
def get_fc_port_metrics_details(self, id): |
| 59 |
response = self.idrac.invoke_request(method='GET', uri=GET_IDRAC_FC_PORT_METRICS_DETAILS_URI) |
| 60 |
if response.status_code == 200: |
| 61 |
for member in response.json_data.get("Members", []): |
| 62 |
if member.get("Id", "") == id: |
| 63 |
os_driver_state = member.get("OSDriverState", "") |
| 64 |
fc_tx_total_frames = member.get("FCTxTotalFrames", "") |
| 65 |
fc_rx_total_frames = member.get("FCRxTotalFrames", "") |
| 66 |
fc_tx_sequences = member.get("FCTxSequences", "") |
| 67 |
fc_rx_sequences = member.get("FCRxSequences", "") |
| 68 |
fc_tx_kb_count = member.get("FCTxKBCount", "") |
| 69 |
fc_rx_kb_count = member.get("FCRxKBCount", "") |
| 70 |
fc_invalid_crcs = member.get("FCInvalidCRCs", "") |
| 71 |
fc_loss_of_signals = member.get("FCLossOfSignals", "") |
| 72 |
fc_link_failures = member.get("FCLinkFailures", "") |
| 73 |
|
| 74 |
oem_data = member.get("Oem", {}) |
| 75 |
if not isinstance(oem_data, dict): |
| 76 |
oem_data = {} |
| 77 |
|
| 78 |
return os_driver_state, fc_tx_total_frames, fc_rx_total_frames, \ |
| 79 |
fc_tx_sequences, fc_rx_sequences, fc_tx_kb_count, fc_rx_kb_count, \ |
| 80 |
fc_invalid_crcs, fc_loss_of_signals, fc_link_failures, oem_data |
| 81 |
|
| 82 |
return "", "", "", "", "", "", "", "", "", "", {} |
| 83 |
|
| 84 |
def get_fc_statistics_details(self, id): |
| 85 |
response = self.idrac.invoke_request(method='GET', uri=GET_IDRAC_FC_STATISTICS_DETAILS_URI) |
| 86 |
if response.status_code == 200: |
| 87 |
for member in response.json_data.get("Members", []): |
| 88 |
if member.get("Id", "") == id: |
| 89 |
port_status = member.get("PortStatus", "") |
| 90 |
return port_status |
| 91 |
return "" |
| 92 |
|
| 93 |
def map_fc_data(self, fc, id): |
| 94 |
"""Maps FC fields from the API response to a structured format.""" |
| 95 |
def sanitize(value): |
| 96 |
return NA if value == "" else value |
| 97 |
|
| 98 |
feature_licensing_support, uefi_support, flex_addressing_support, \ |
| 99 |
on_chip_thermal_sensor, fc_max_num_exchanges, fc_max_num_outstanding_cmds, \ |
| 100 |
persistence_policy_support = self.get_fc_capability_details(id) |
| 101 |
|
| 102 |
os_driver_state, fc_tx_total_frames, fc_rx_total_frames, \ |
| 103 |
fc_tx_sequences, fc_rx_sequences, fc_tx_kb_count, fc_rx_kb_count, \ |
| 104 |
fc_invalid_crcs, fc_loss_of_signals, fc_link_failures, oem_data = self.get_fc_port_metrics_details(id) |
| 105 |
|
| 106 |
port_status = self.get_fc_statistics_details(id) |
| 107 |
|
| 108 |
output = { |
| 109 |
"DeviceName": fc.get("DeviceName", NA), |
| 110 |
"Id": fc.get("Id", NA), |
| 111 |
"Bus": fc.get("Bus", NA), |
| 112 |
"PortDownRetryCount": fc.get("PortDownRetryCount", NA), |
| 113 |
"VendorName": fc.get("VendorName", NA), |
| 114 |
"HardZoneAddress": fc.get("HardZoneAddress", NA), |
| 115 |
"Description": fc.get("Description", NA), |
| 116 |
"PortLoginTimeout": fc.get("PortLoginTimeout", NA), |
| 117 |
"FramePayloadSize": fc.get("FramePayloadSize", NA), |
| 118 |
"LinkDownTimeout": fc.get("LinkDownTimeout", NA), |
| 119 |
"SerialNumber": fc.get("SerialNumber", NA), |
| 120 |
"LoopResetDelay": fc.get("LoopResetDelay", NA), |
| 121 |
"FCoEOSDriverVersion": fc.get("FCoEOSDriverVersion", NA), |
| 122 |
"FCTapeEnable": fc.get("FCTapeEnable", NA), |
| 123 |
"ProductName": fc.get("ProductName", NA), |
| 124 |
"SecondFCTargetLUN": fc.get("SecondFCTargetLUN", NA), |
| 125 |
"Name": fc.get("Name", NA), |
| 126 |
"FabricLoginTimeout": fc.get("FabricLoginTimeout", NA), |
| 127 |
"ChipType": fc.get("ChipType", NA), |
| 128 |
"RDMAOSDriverVersion": fc.get("RDMAOSDriverVersion", NA), |
| 129 |
"HardZoneEnable": fc.get("HardZoneEnable", NA), |
| 130 |
"EFIVersion": fc.get("EFIVersion", NA), |
| 131 |
"DeviceDescription": fc.get("DeviceDescription", NA), |
| 132 |
"FabricLoginRetryCount": fc.get("FabricLoginRetryCount", NA), |
| 133 |
"ISCSIOSDriverVersion": fc.get("ISCSIOSDriverVersion", NA), |
| 134 |
"SecondFCTargetWWPN": fc.get("SecondFCTargetWWPN", NA), |
| 135 |
"Device": fc.get("Device", NA), |
| 136 |
"LANDriverVersion": fc.get("LANDriverVersion", NA), |
| 137 |
"FCOSDriverVersion": fc.get("FCOSDriverVersion", NA), |
| 138 |
"Function": fc.get("Function", NA), |
| 139 |
"FamilyVersion": fc.get("FamilyVersion", NA), |
| 140 |
"PortLoginRetryCount": fc.get("PortLoginRetryCount", NA), |
| 141 |
"PartNumber": fc.get("PartNumber", NA), |
| 142 |
"PortDownTimeout": fc.get("PortDownTimeout", NA), |
| 143 |
"FeatureLicensingSupport": sanitize(feature_licensing_support), |
| 144 |
"UEFISupport": sanitize(uefi_support), |
| 145 |
"FlexAddressingSupport": sanitize(flex_addressing_support), |
| 146 |
"OnChipThermalSensor": sanitize(on_chip_thermal_sensor), |
| 147 |
"FCMaxNumberExchanges": sanitize(fc_max_num_exchanges), |
| 148 |
"FCMaxNumberOutStandingCommands": sanitize(fc_max_num_outstanding_cmds), |
| 149 |
"PersistencePolicySupport": sanitize(persistence_policy_support), |
| 150 |
"FCInvalidCRCs": sanitize(fc_invalid_crcs), |
| 151 |
"FCLinkFailures": sanitize(fc_link_failures), |
| 152 |
"FCLossOfSignals": sanitize(fc_loss_of_signals), |
| 153 |
"FCTxTotalFrames": sanitize(fc_tx_total_frames), |
| 154 |
"FCRxTotalFrames": sanitize(fc_rx_total_frames), |
| 155 |
"FCTxSequences": sanitize(fc_tx_sequences), |
| 156 |
"FCRxSequences": sanitize(fc_rx_sequences), |
| 157 |
"FCTxKBCount": sanitize(fc_tx_kb_count), |
| 158 |
"FCRxKBCount": sanitize(fc_rx_kb_count), |
| 159 |
"OSDriverState": sanitize(os_driver_state), |
| 160 |
"Oem": oem_data if isinstance(oem_data, dict) else {}, |
| 161 |
"PortStatus": sanitize(port_status) |
| 162 |
} |
| 163 |
|
| 164 |
return output |
| 165 |
|
| 166 |
def get_fc_info(self): |
| 167 |
"""Fetches FC data from iDRAC and maps it.""" |
| 168 |
output = [] |
| 169 |
resp = self.idrac.invoke_request(method='GET', uri=GET_IDRAC_FC_DETAILS_URI) |
| 170 |
|
| 171 |
if resp.status_code == 200: |
| 172 |
fc_members = resp.json_data.get("Members", []) |
| 173 |
for fc in fc_members: |
| 174 |
output.append(self.map_fc_data(fc, fc.get("Id"))) |
| 175 |
return output |