Save changes made to object to NIPAP.

            If the object represents a new VRF unknown to NIPAP (attribute `id`
            is `None`) this function maps to the function
            :py:func:`nipap.backend.Nipap.add_vrf` in the backend, used to
            create a new VRF. Otherwise it maps to the function
            :py:func:`nipap.backend.Nipap.edit_vrf` in the backend, used to
            modify the VRF. Please see the documentation for the backend
            functions for information regarding input arguments and return
            values.

def save(self):
        """ Save changes made to object to NIPAP.

            If the object represents a new VRF unknown to NIPAP (attribute `id`
            is `None`) this function maps to the function
            :py:func:`nipap.backend.Nipap.add_vrf` in the backend, used to
            create a new VRF. Otherwise it maps to the function
            :py:func:`nipap.backend.Nipap.edit_vrf` in the backend, used to
            modify the VRF. Please see the documentation for the backend
            functions for information regarding input arguments and return
            values.
        """

        xmlrpc = XMLRPCConnection()
        data = {
            'rt': self.rt,
            'name': self.name,
            'description': self.description,
            'tags': [],
            'avps': self.avps
        }
        for tag_name in self.tags:
            data['tags'].append(tag_name)

        if self.id is None:
            # New object, create
            try:
                vrf = xmlrpc.connection.add_vrf(
                    {
                        'attr': data,
                        'auth': self._auth_opts.options
                    })
            except xmlrpclib.Fault as xml_fault:
                raise _fault_to_exception(xml_fault)

        else:
            # Old object, edit
            try:
                vrfs = xmlrpc.connection.edit_vrf(
                    {
                        'vrf': { 'id': self.id },
                        'attr': data,
                        'auth': self._auth_opts.options
                    })
            except xmlrpclib.Fault as xml_fault:
                raise _fault_to_exception(xml_fault)

            if len(vrfs) != 1:
                raise NipapError('VRF edit returned %d entries, should be 1.' % len(vrfs))
            vrf = vrfs[0]

        # Refresh object data with attributes from add/edit operation
        VRF.from_dict(vrf, self)

        _cache['VRF'][self.id] = self