import string
import random


def generate_random_record_locator(prefix=''):
    """
    The following function generates an RLOC in one of two ways:
    Legacy (prefix not specified): 6 random character RLOC
    Prefix != None: RLOC with the prefix and random characters making up the balance to 8 char
    """
    if prefix == '':
        size = 6
    else:
        size = 8 - len(prefix)

    chars = string.ascii_uppercase + string.digits
    return str.upper(prefix) + (''.join(random.choice(chars) for _ in range(size)))