def calc_template_ranges(network):
    """
    Given a network, return the range information for that network. These
    ranges will be used by the user to decide where to request an IP address.
    This function will not actually find that ip address, it will mearly
    suggest which ranges a user might want to check in.

    This function should contain allocation policy that netops controls.
    """
    # See https://mana.mozilla.org/wiki/display/NOC/Node+deployment for
    # allocation templates

    network.update_network()
    dhcp_scope = network.calc_dhcp_scope_name()
    nbase = network.network.network
    name_fragment = calc_name_fragment(network)

    if network.ip_type == '4':
        # if it's in between a /24 or and /20 use this template
        if network.prefixlen <= 24 and network.prefixlen >= 20:
            template_ranges = [
                {
                    'name': 'template',
                    'rtype': 'special purpose',
                    'start': str(nbase + 1),
                    'end': str(nbase + 15),
                    'dhcp_scope': dhcp_scope,
                    'name_fragment': name_fragment
                },
                {
                    'name': 'template',
                    'rtype': 'multi-host pools',
                    'start': str(nbase + 16),
                    'end': str(nbase + 127),
                    'dhcp_scope': dhcp_scope,
                    'name_fragment': name_fragment
                },
                {
                    'name': 'template',
                    'rtype': '/32 allocations',
                    'start': str(nbase + 128),
                    'end': str(nbase + 207),
                    'dhcp_scope': dhcp_scope,
                    'name_fragment': name_fragment
                },
                {
                    'name': 'template',
                    'rtype': 'load balancers',
                    'start': str(nbase + 208),
                    'end': str(nbase + 223),
                    'dhcp_scope': dhcp_scope,
                    'name_fragment': name_fragment
                },
                {
                    'name': 'template',
                    'rtype': 'dynamic',
                    'start': str(nbase + 224),
                    'end': str(nbase + 247),
                    'dhcp_scope': dhcp_scope,
                    'name_fragment': name_fragment
                },
                {
                    'name': 'template',
                    'rtype': 'reserved',
                    'start': str(nbase + 248),
                    'end': str(nbase + 255),
                    'dhcp_scope': dhcp_scope,
                    'name_fragment': name_fragment
                }
            ]
            if network.prefixlen < 24:
                template_ranges.append({
                    'name': 'template',
                    'rtype': 'general purpose',
                    'start': str(nbase + 256),
                    'end': str(network.network.broadcast - 1),
                    'dhcp_scope': dhcp_scope,
                    'name_fragment': name_fragment
                })
        elif network.prefixlen > 24 and network.prefixlen < 31:
            # for subnets smaller than /24, reserve first /30
            template_ranges = [{
                'name': 'template',
                'rtype': 'reserved',
                'start': str(nbase + 0),
                'end': str(nbase + 3),
                'dhcp_scope': dhcp_scope,
                'name_fragment': name_fragment
            }]

            if network.prefixlen > 30:
                template_ranges.append({
                    'name': 'template',
                    'rtype': 'general purpose',
                    'start': str(nbase + 5),
                    'end': str(network.network.broadcast - 1),
                    'dhcp_scope': dhcp_scope,
                    'name_fragment': name_fragment
                })
        else:
            template_ranges = []
        return template_ranges
    elif network.ip_type == '6' and network.prefixlen == 64:
        # Only do /64s for IPv6
        # reserve the first /112 for human created IPs, the rest is unallocated
        # in the /64

        # /112 is the first :ffff addresses
        return [
            {
                'name': 'template',
                'rtype': 'reserved (netops)',
                'start': str(nbase + 1),
                'end': str(nbase + int('ffff', 16)),
                'dhcp_scope': dhcp_scope,
                'name_fragment': name_fragment
            },
            {
                'name': 'template',
                'rtype': 'general purpose',
                'start': str(nbase + int('10001', 16)),
                'end': str(nbase + int('1ffff', 16)),
                'dhcp_scope': dhcp_scope,
                'name_fragment': name_fragment
            },
            {
                'name': 'template',
                'rtype': 'vips',
                'start': str(nbase + int('20001', 16)),
                'end': str(nbase + int('2ffff', 16)),
                'dhcp_scope': dhcp_scope,
                'name_fragment': name_fragment
            }
        ]
    else:
        return []
dataset/ETHPy150Open mozilla/inventory/core/range/ip_choosing_utils.py/calc_template_ranges/original