Remove a VRF.

            * `auth` [BaseAuth]
                AAA options.
            * `spec` [vrf_spec]
                A VRF specification.

            Remove VRF matching the `spec` argument.

            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.remove_vrf` for full
            understanding.

def remove_vrf(self, auth, spec):
        """ Remove a VRF.

            * `auth` [BaseAuth]
                AAA options.
            * `spec` [vrf_spec]
                A VRF specification.

            Remove VRF matching the `spec` argument.

            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.remove_vrf` for full
            understanding.
        """

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

        # get list of VRFs to remove before removing them
        vrfs = self.list_vrf(auth, spec)

        # remove prefixes in VRFs
        for vrf in vrfs:
            v4spec = {
                'prefix': '0.0.0.0/0',
                'vrf_id': vrf['id']
            }
            v6spec = {
                'prefix': '::/0',
                'vrf_id': vrf['id']
            }
            self.remove_prefix(auth, spec = v4spec, recursive = True)
            self.remove_prefix(auth, spec = v6spec, recursive = True)

        where, params = self._expand_vrf_spec(spec)
        sql = "DELETE FROM ip_net_vrf WHERE %s" % where
        self._execute(sql, params)

        # write to audit table
        for v in vrfs:
            audit_params = {
                'vrf_id': v['id'],
                'vrf_rt': v['rt'],
                'vrf_name': v['name'],
                'username': auth.username,
                'authenticated_as': auth.authenticated_as,
                'full_name': auth.full_name,
                'authoritative_source': auth.authoritative_source,
                'description': 'Removed vrf %s' % v['rt']
            }
            sql, params = self._sql_expand_insert(audit_params)
            self._execute('INSERT INTO ip_net_log %s' % sql, params)