def diff_config(jaide, second_host, mode):
    """ Perform a show | compare with some set commands.

    @param jaide: The jaide connection to the device.
    @type jaide: jaide.Jaide object
    @param second_host: The device IP or hostname of the second host to
                      | compare with.
    @type second_host: str
    @param mode: How to compare the configuration, either in 'set' mode or
               | 'stanza' mode.
    @type mode: str

    @returns: The comparison between the two devices.
    @rtype str
    """
    try:
        # create a list of all the lines that differ, and merge it.
        output = '\n'.join([diff for diff in
                            jaide.diff_config(second_host, mode.lower())])
    except errors.SSHError:
        output = color('Unable to connect to port %s on device: %s\n' %
                       (str(jaide.port), second_host), 'red')
    except errors.AuthenticationError:  # NCClient auth failure
        output = color('Authentication failed for device: %s' %
                       second_host, 'red')
    except AuthenticationException:  # Paramiko auth failure
        output = color('Authentication failed for device: %s' %
                       second_host, 'red')
    except SSHException as e:
        output = color('Error connecting to device: %s\nError: %s' %
                       (second_host, str(e)), 'red')
    except socket.timeout:
        output = color('Timeout exceeded connecting to device: %s' %
                       second_host, 'red')
    except socket.gaierror:
        output = color('No route to host, or invalid hostname: %s' %
                       second_host, 'red')
    except socket.error:
        output = color('The device refused the connection on port %s, or '
                       'no route to host.' % jaide.port, 'red')
    if output.strip() == '':
        output = color("There were no config differences between %s and %s\n" %
                       (jaide.host, second_host), 'yel')
    else:
        # color removals red, and additions green
        return color_diffs(output)
    return output
Perform a show | compare with some set commands.

    @param jaide: The jaide connection to the device.
    @type jaide: jaide.Jaide object
    @param second_host: The device IP or hostname of the second host to
                      | compare with.
    @type second_host: str
    @param mode: How to compare the configuration, either in 'set' mode or
               | 'stanza' mode.
    @type mode: str

    @returns: The comparison between the two devices.
    @rtype str