Пример #1
0
def get_subnet_cidr_block(address_prefix, host_count):
    """
    This method exctracts the required host addresses from the address prefix, returns the
    updated host prefix and ip range
    :return:
    """
    try:
        address_prefix = Network(address_prefix)
        cidr_block_size = get_cidr_block_size(host_count)
        split_address = str(address_prefix).split("/")
        if not len(split_address) == 2:
            return

        ip_range = split_address[0] + cidr_block_size
        address_prefix = address_prefix.__add__(int(host_count))

    except ValueError as e:
        current_app.logger.debug(e)
        return

    return ip_range, address_prefix