class CumulusTorSwitchService implements ISwitchService {

    @Override
    public SwitchOsInfo getSwitchOsInfo( SwitchNode switchNode )
    {
        SwitchOsInfo osInfo = osInfoCache.get( switchNode );
        if ( osInfo != null )
        {
            return osInfo;
        }
        else
        {
            osInfo = new SwitchOsInfo();
        }

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

        /* Get switch operating system details. */
        try
        {
            SshExecResult result = switchSession.executeEnhanced( CumulusConstants.GET_SWITCH_OS_COMMAND );
            result.logIfError( logger );
            if ( result.getExitCode() != 0 )
                cacheResult = false;

            String osResult = result.getStdoutAsString();
            Properties osProperties = new Properties();
            osProperties.load( new StringReader( osResult ) );

            osInfo.setOsName( osProperties.getProperty( "NAME" ).replaceAll( "^\"|\"$", "" ) );
            osInfo.setOsVersion( osProperties.getProperty( "VERSION_ID" ).replaceAll( "^\"|\"$", "" ) );
        }
        catch ( Exception e )
        {
            logger.warn( "Exception received while gathering OS details.", e );
            cacheResult = false;
        }

        /* Get last boot time */
        try
        {
            SshExecResult result = switchSession.executeEnhanced( CumulusConstants.LAST_BOOT_TIME_COMMAND );
            result.logIfError( logger );
            if ( result.getExitCode() != 0 )
                cacheResult = false;

            String lastBootResult = result.getStdoutAsString();
            String[] lastBootResultArray = lastBootResult.split( "\n" );
            Double secondsSinceEpochString = Double.parseDouble( lastBootResultArray[0] );
            Double secondsSinceBoot = Double.parseDouble( lastBootResultArray[1] );
            long msBootTime = Math.round( ( secondsSinceEpochString - secondsSinceBoot ) * 1000 );

            Date lastBootDate = new Date( msBootTime );
            osInfo.setLastBoot( lastBootDate );
        }
        catch ( Exception e )
        {
            logger.warn( "Exception received while getting last boot time.", e );
            cacheResult = false;
        }

        /* Get firmware name and version */
        try
        {
            String firmwareVersionCommand =
                CumulusConstants.GET_FIRMWARE_VER_COMMAND.replaceAll( "\\{password\\}",
                                                                      qr( switchNode.getPassword() ) );

            SshExecResult result = switchSession.executeEnhanced( firmwareVersionCommand );
            result.logIfError( logger );
            if ( result.getExitCode() != 0 )
                cacheResult = false;

            String firmwareVer = result.getStdoutAsString().trim();
            osInfo.setFirmwareName( CumulusConstants.FIRMWARE_NAME );
            osInfo.setFirmwareVersion( firmwareVer );
        }
        catch ( Exception e )
        {
            logger.warn( "Exception received while gathering firmware details.", e );
            cacheResult = false;
        }

        if ( cacheResult )
            osInfoCache.set( switchNode, osInfo );

        return ( osInfo );
    }

}