Return a list of pools.

            * `auth` [BaseAuth]
                AAA options.
            * `spec` [pool_spec]
                Specifies what pool(s) to list. Of omitted, all will be listed.

            Returns a list of dicts.

            This is the documentation of the internal backend function. It's
            exposed over XML-RPC, please also see the XML-RPC documentation for
            :py:func:`nipap.xmlrpc.NipapXMLRPC.list_pool` for full
            understanding.

def list_pool(self, auth, spec=None):
        """ Return a list of pools.

            * `auth` [BaseAuth]
                AAA options.
            * `spec` [pool_spec]
                Specifies what pool(s) to list. Of omitted, all will be listed.

            Returns a list of dicts.

            This is the documentation of the internal backend function. It's
            exposed over XML-RPC, please also see the XML-RPC documentation for
            :py:func:`nipap.xmlrpc.NipapXMLRPC.list_pool` for full
            understanding.
        """

        if spec is None:
            spec = {}

        self._logger.debug("list_pool called; spec: %s" % unicode(spec))

        sql = """SELECT DISTINCT (po.id),
                        po.id,
                        po.name,
                        po.description,
                        po.default_type,
                        po.ipv4_default_prefix_length,
                        po.ipv6_default_prefix_length,
                        po.member_prefixes_v4,
                        po.member_prefixes_v6,
                        po.used_prefixes_v4,
                        po.used_prefixes_v6,
                        po.free_prefixes_v4,
                        po.free_prefixes_v6,
                        po.total_prefixes_v4,
                        po.total_prefixes_v6,
                        po.total_addresses_v4,
                        po.total_addresses_v6,
                        po.used_addresses_v4,
                        po.used_addresses_v6,
                        po.free_addresses_v4,
                        po.free_addresses_v6,
                        po.tags,
                        po.avps,
                        vrf.id AS vrf_id,
                        vrf.rt AS vrf_rt,
                        vrf.name AS vrf_name,
                        (SELECT array_agg(prefix::text) FROM (SELECT prefix FROM ip_net_plan WHERE pool_id=po.id ORDER BY prefix) AS a) AS prefixes
                FROM ip_net_pool AS po
                LEFT OUTER JOIN ip_net_plan AS inp ON (inp.pool_id = po.id)
                LEFT OUTER JOIN ip_net_vrf AS vrf ON (vrf.id = inp.vrf_id)"""
        params = list()

        # expand spec
        where, params = self._expand_pool_spec(spec)
        if len(where) > 0:
            sql += " WHERE " + where

        sql += " ORDER BY name"

        self._execute(sql, params)

        res = list()
        for row in self._curs_pg:
            p = dict(row)

            # Make sure that prefixes is a list, even if there are no prefixes
            if p['prefixes'] is None:
                p['prefixes'] = []
            res.append(p)

        return res