@requires_rw
    def add_vrf(self, auth, attr):

        self._logger.debug("add_vrf called; attr: %s" % str(attr))

        # sanity check - do we have all attributes?
        req_attr = [ 'rt', 'name' ]
        self._check_attr(attr, req_attr, _vrf_attrs)

        insert, params = self._sql_expand_insert(attr)
        sql = "INSERT INTO ip_net_vrf " + insert

        self._execute(sql, params)
        vrf_id = self._lastrowid()
        vrf = self.list_vrf(auth, { 'id': vrf_id })[0]

        # write to audit table
        audit_params = {
            'vrf_id': vrf['id'],
            'vrf_rt': vrf['rt'],
            'vrf_name': vrf['name'],
            'username': auth.username,
            'authenticated_as': auth.authenticated_as,
            'full_name': auth.full_name,
            'authoritative_source': auth.authoritative_source,
            'description': 'Added VRF %s with attr: %s' % (vrf['rt'], str(vrf))
        }

        sql, params = self._sql_expand_insert(audit_params)
        self._execute('INSERT INTO ip_net_log %s' % sql, params)

        return vrf
Add a new VRF.
dataset/ETHPy150Open SpriteLink/NIPAP/nipap/nipap/backend.py/Nipap.add_vrf