def add_asn(self, auth, attr):
        """ Add AS number to NIPAP.

            * `auth` [BaseAuth]
                AAA options.
            * `attr` [asn_attr]
                ASN attributes.

            Returns a dict describing the ASN which was added.

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

        self._logger.debug("add_asn called; attr: %s" % unicode(attr))

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

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

        asn = self.list_asn(auth, { 'asn': attr['asn'] })[0]

        # write to audit table
        audit_params = {
            'username': auth.username,
            'authenticated_as': auth.authenticated_as,
            'full_name': auth.full_name,
            'authoritative_source': auth.authoritative_source,
            'description': 'Added ASN %s with attr: %s' % (attr['asn'], unicode(attr))
        }

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

        return asn
Add AS number to NIPAP.

            * `auth` [BaseAuth]
                AAA options.
            * `attr` [asn_attr]
                ASN attributes.

            Returns a dict describing the ASN which was added.

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