def decode_to_utf8(text):
    """Paramiko returns bytes object and we need to ensure it is utf-8 before
    parsing
    """
    try:
        return text.decode('utf-8')
    except (AttributeError, UnicodeEncodeError):
        return text
