import re


def to_mb(s):
    """Simple function to convert `disk_quota` or `memory` attribute string
    values into MB integer values.
    """
    if s is None:
        return s
    if s.endswith('M'):
        return int(re.sub('M$', '', s))
    elif s.endswith('G'):
        return int(re.sub('G$', '', s)) * 1000
    return 512