/** * Copyright 2017 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. */ import { defineMessages, FormattedDate, FormattedMessage, FormattedTime, injectIntl } from 'react-intl'; import { startCase } from 'lodash'; import React from 'react'; import PropTypes from 'prop-types'; import { Row, Col } from 'react-bootstrap'; const messages = defineMessages({ macAddresses: { id: 'NodeExtendedInfo.macAddresses', defaultMessage: 'Mac Addresses:' }, interfaces: { id: 'nodeExtendedinfo.interfaces', defaultMessage: 'Interfaces:' }, macAddress: { id: 'nodeExtendedinfo.interfaceMacAddress', defaultMessage: 'MAC Address' }, ipAddress: { id: 'nodeExtendedinfo.interfaceIpAddress', defaultMessage: 'IP Address' }, bios: { id: 'nodeExtendedinfo.bios', defaultMessage: 'Bios:' }, rootDisk: { id: 'nodeExtendedinfo.rootDisk', defaultMessage: 'Root Disk:' }, product: { id: 'nodeExtendedinfo.product', defaultMessage: 'Product:' }, productName: { id: 'nodeExtendedinfo.productName', defaultMessage: 'Name' }, productVendor: { id: 'nodeExtendedinfo.productVendor', defaultMessage: 'Vendor' }, productVersion: { id: 'nodeExtendedinfo.productVersion', defaultMessage: 'Version' }, kernel: { id: 'nodeExtendedinfo.kernel', defaultMessage: 'Kernel:' }, uuid: { id: 'nodeExtendedinfo.uuid', defaultMessage: 'UUID:' }, registered: { id: 'nodeExtendedinfo.registered', defaultMessage: 'Registered:' }, architecture: { id: 'nodeExtendedinfo.architecture', defaultMessage: 'Architecture:' }, driver: { id: 'nodeExtendedinfo.driver', defaultMessage: 'Driver:' } }); class NodeExtendedInfo extends React.Component { componentDidMount() { if ( this.props.node.getIn(['introspectionStatus', 'state']) === 'finished' ) { this.props.fetchNodeIntrospectionData(this.props.node.get('uuid')); } } renderInterfaces() { const { intl, node } = this.props; if (node.getIn(['introspectionData', 'interfaces']).isEmpty()) { return (
{node.get('macs').map(mac =>
{mac}
)}
); } else { return (
{node .getIn(['introspectionData', 'interfaces']) .map((ifc, k) => (
{k} -{' '} {ifc.get('mac')} {' '} |{' '} {ifc.get('ip')} {ifc.get('pxe') && '| PXE'}
)) .toList()}
); } } renderBios() { const bios = this.props.node.getIn(['introspectionData', 'bios']); return ( !bios.isEmpty() && (
{bios .map((i, k) => ( {i}{' '} )) .toList()}
) ); } renderRootDisk() { const rootDisk = this.props.node.getIn(['introspectionData', 'rootDisk']); return ( rootDisk && (
{rootDisk}
) ); } renderProduct() { const product = this.props.node.getIn(['introspectionData', 'product']); return ( !product.isEmpty() && (
{product.get('name')} {' '} -{' '} {product.get('vendor')} {' '} |{' '} {product.get('version')}
) ); } renderKernel() { const kernelVersion = this.props.node.getIn([ 'introspectionData', 'kernelVersion' ]); return ( kernelVersion && (
{kernelVersion}
) ); } render() { const { node } = this.props; return (
{node.get('uuid')}
 
{node.getIn(['properties', 'cpu_arch'])}
{this.renderRootDisk()} {this.renderBios()} {this.renderProduct()} {this.renderKernel()}
{node.get('driver')}
{node .get('driver_info') .map((dInfo, key) => (
{startCase(key)}:
{dInfo}
)) .toList()}
{this.renderInterfaces()}
); } } NodeExtendedInfo.propTypes = { fetchNodeIntrospectionData: PropTypes.func.isRequired, intl: PropTypes.object.isRequired, node: PropTypes.object.isRequired }; export default injectIntl(NodeExtendedInfo);