Expand a pool with the ranges set in opts

def grow_pool(arg, opts, shell_opts):
    """ Expand a pool with the ranges set in opts
    """
    if not pool:
        print("No pool with name '%s' found." % arg, file=sys.stderr)
        sys.exit(1)

    if not 'add' in opts:
        print("Please supply a prefix to add to pool '%s'" % pool.name, file=sys.stderr)
        sys.exit(1)

    # Figure out VRF.
    # If pool already has a member prefix, implied_vrf will be set. Look for new
    # prefix to add in the same vrf as implied_vrf.
    # If pool has no members, then use get_vrf() to get vrf to search in for
    # prefix to add.
    if pool.vrf is not None:
        v = pool.vrf
    else:
        v = get_vrf(opts.get('vrf_rt'), abort=True)

    q = { 'prefix': opts['add'] }
    if v.rt != 'all':
        q['vrf_rt'] = v.rt

    res = Prefix.list(q)

    if len(res) == 0:
        print("No prefix found matching %s in %s." % (opts['add'], vrf_format(v)), file=sys.stderr)
        sys.exit(1)
    elif res[0].pool:
        if res[0].pool == pool:
            print("Prefix %s in %s is already assigned to that pool." % (opts['add'], vrf_format(v)), file=sys.stderr)
        else:
            print("Prefix %s in %s is already assigned to a different pool ('%s')." % (opts['add'], vrf_format(v), res[0].pool.name), file=sys.stderr)
        sys.exit(1)

    res[0].pool = pool
    res[0].save()
    print("Prefix %s in %s added to pool '%s'." % (res[0].prefix, vrf_format(v), pool.name))