def update(self, req, domain_id, id, body):
        """Add or modify dns entry."""
        context = req.environ['nova.context']
        authorize(context)
        domain = _unquote_domain(domain_id)
        name = id
        try:
            entry = body['dns_entry']
            address = entry['ip']
            dns_type = entry['dns_type']
        except (TypeError, __HOLE__):
            raise webob.exc.HTTPUnprocessableEntity()

        try:
            entries = self.network_api.get_dns_entries_by_name(
                context, name, domain)
            if not entries:
                # create!
                self.network_api.add_dns_entry(context, address, name,
                                               dns_type, domain)
            else:
                # modify!
                self.network_api.modify_dns_entry(context, name, address,
                                                  domain)
        except NotImplementedError:
            msg = _("Unable to create dns entry")
            raise webob.exc.HTTPNotImplemented(explanation=msg)

        return _translate_dns_entry_view({'ip': address,
                                          'name': name,
                                          'type': dns_type,
                                          'domain': domain})
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/api/openstack/compute/legacy_v2/contrib/floating_ip_dns.py/FloatingIPDNSEntryController.update