diff --git a/webpack/components/extensions/HostDetails/DetailsTabCards/HwPropertiesCard.js b/webpack/components/extensions/HostDetails/DetailsTabCards/HwPropertiesCard.js index 13149278fc8..5d4b70f3f7a 100644 --- a/webpack/components/extensions/HostDetails/DetailsTabCards/HwPropertiesCard.js +++ b/webpack/components/extensions/HostDetails/DetailsTabCards/HwPropertiesCard.js @@ -1,6 +1,5 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { propsToCamelCase } from 'foremanReact/common/helpers'; import { translate as __ } from 'foremanReact/common/I18n'; import { DescriptionList, @@ -14,8 +13,12 @@ import CardTemplate from 'foremanReact/components/HostDetails/Templates/CardItem import { TranslatedPlural } from '../../../Table/components/TranslatedPlural'; import { hostIsNotRegistered } from '../hostDetailsHelpers'; -const HostDisks = ({ totalDisks }) => { - if (!totalDisks) return null; +const HostDisks = ({ blockDevices }) => { + // blockDevices fact will look like this by default 'sr0,sda' and increment like sdb etc could be vda and go up too + var disks = blockDevices.split(',') + // We are filtering out the CDROM drive that gets added by default a lot of the time + var totalDisks = disks.filter(function(e) { return e !== 'sr0' }).length + if (totalDisks.length === 0) return null; return ( <> {__('Storage')} @@ -27,11 +30,11 @@ const HostDisks = ({ totalDisks }) => { }; HostDisks.propTypes = { - totalDisks: PropTypes.number, + blockDevices: PropTypes.string, }; HostDisks.defaultProps = { - totalDisks: null, + blockDevices: null, }; const HwPropertiesCard = ({ isExpandedGlobal, hostDetails }) => { @@ -41,8 +44,7 @@ const HwPropertiesCard = ({ isExpandedGlobal, hostDetails }) => { const cpuCount = facts?.['cpu::cpu(s)']; const cpuSockets = facts?.['cpu::cpu_socket(s)']; const coreSocket = facts?.['cpu::core(s)_per_socket']; - const reportedFacts = propsToCamelCase(hostDetails?.reported_data || {}); - const totalDisks = reportedFacts?.disksTotal; + const blockDevices = facts?.['blockdevices']; const memory = facts?.['dmi::memory::maximum_capacity']; return ( @@ -74,7 +76,7 @@ const HwPropertiesCard = ({ isExpandedGlobal, hostDetails }) => { {memory} - + @@ -90,9 +92,7 @@ HwPropertiesCard.propTypes = { cpuSockets: PropTypes.number, coreSocket: PropTypes.number, memory: PropTypes.string, - }), - reported_data: PropTypes.shape({ - totalDisks: PropTypes.number, + blockdevices: PropTypes.string, }), }), };