class CumulusTorSwitchService implements ISwitchService {

    @Override
    public SwitchHardwareInfo getSwitchHardwareInfo( SwitchNode switchNode )
    {
        SwitchHardwareInfo hwInfo = hwInfoCache.get( switchNode );
        if ( hwInfo != null )
        {
            return hwInfo;
        }
        else
        {
            hwInfo = new SwitchHardwareInfo();
        }

        CumulusTorSwitchSession switchSession = (CumulusTorSwitchSession) getSession( switchNode );
        boolean cacheResult = true;

        try
        {
            SshExecResult result =
                switchSession.executeEnhanced( CumulusConstants.HARDWARE_MODEL_MANUFACTURER_COMMAND );
            result.logIfError( logger );
            if ( result.getExitCode() != 0 )
                cacheResult = false;

            String[] hwResult = result.getStdoutAsString().split( "," );
            if ( hwResult.length >= 2 )
            {
                hwInfo.setManufacturer( hwResult[0].trim() );
                hwInfo.setModel( hwResult[1].trim() );
            }

            String serialCommand =
                CumulusConstants.GET_SERIAL_ID_COMMAND.replaceAll( "\\{password\\}", qr( switchNode.getPassword() ) );
            result = switchSession.executeEnhanced( serialCommand );
            result.logIfError( logger );
            if ( result.getExitCode() != 0 )
                cacheResult = false;

            String serialResult = result.getStdoutAsString().trim();
            hwInfo.setChassisSerialId( serialResult );

            String partNumberCommand =
                CumulusConstants.GET_PART_NUMBER_COMMAND.replaceAll( "\\{password\\}", qr( switchNode.getPassword() ) );
            result = switchSession.executeEnhanced( partNumberCommand );
            result.logIfError( logger );
            if ( result.getExitCode() != 0 )
                cacheResult = false;

            String partNumberResult = result.getStdoutAsString().trim();
            hwInfo.setPartNumber( partNumberResult );

            String manufactureDateCommand =
                CumulusConstants.GET_MANUFACTURE_DATE_COMMAND.replaceAll( "\\{password\\}",
                                                                          qr( switchNode.getPassword() ) );
            result = switchSession.executeEnhanced( manufactureDateCommand );
            result.logIfError( logger );
            if ( result.getExitCode() != 0 )
                cacheResult = false;

            String manufactureDateResult = result.getStdoutAsString().trim();
            hwInfo.setManufactureDate( manufactureDateResult );

            /* Get MAC address of management port */
            SwitchPort mgmtPort = getSwitchPort( switchNode, CumulusConstants.MANAGEMENT_PORT_NAME );
            if ( mgmtPort != null )
            {
                hwInfo.setManagementMacAddress( mgmtPort.getMacAddress() );
            }
            else
            {
                logger.warn( "Couldn't determine management MAC address of management port on switch "
                    + switchNode.getSwitchId() );
                cacheResult = false;
            }
        }
        catch ( Exception e )
        {
            logger.warn( "Exception received while getting hardware model and serial number on switch "
                + switchNode.getSwitchId(), e );
            cacheResult = false;
        }

        if ( cacheResult )
            hwInfoCache.set( switchNode, hwInfo );

        return ( hwInfo );
    }

}