def get_subnet(context, id, fields=None):
LOG.info("<STR_LIT>" %<EOL>(id, context.tenant_id, fields))<EOL>subnet = db_api.subnet_find(context=context, limit=None,<EOL>page_reverse=False, sorts=['<STR_LIT:id>'],<EOL>marker_obj=None, fields=None, id=id,<EOL>join_dns=True, join_routes=True,<EOL>scope=db_api.ONE)<EOL>if not subnet:<EOL><INDENT>raise n_exc.SubnetNotFound(subnet_id=id)<EOL><DEDENT>cache = subnet.get("<STR_LIT>")<EOL>if not cache:<EOL><INDENT>new_cache = subnet.allocation_pools<EOL>db_api.subnet_update_set_alloc_pool_cache(context, subnet, new_cache)<EOL><DEDENT>return v._make_subnet_dict(subnet)<EOL>
Retrieve a subnet.

    : param context: neutron api request context
    : param id: UUID representing the subnet to fetch.
    : param fields: a list of strings that are valid keys in a
        subnet dictionary as listed in the RESOURCE_ATTRIBUTE_MAP
        object in neutron/api/v2/attributes.py. Only these fields
        will be returned.