Check that the resolv.conf is present and populated

def _check_resolv(mpt):
    '''
    Check that the resolv.conf is present and populated
    '''
    resolv = os.path.join(mpt, 'etc/resolv.conf')
    replace = False
    if os.path.islink(resolv):
        resolv = os.path.realpath(resolv)
        if not os.path.isdir(os.path.dirname(resolv)):
            os.makedirs(os.path.dirname(resolv))
    if not os.path.isfile(resolv):
        replace = True
    if not replace:
        with salt.utils.files.fopen(resolv, 'rb') as fp_:
            conts = salt.utils.stringutils.to_unicode(fp_.read())
            if 'nameserver' not in conts:
                replace = True
            if 'nameserver 127.0.0.1' in conts:
                replace = True
    if replace:
        shutil.copy('/etc/resolv.conf', resolv)