def handle(self, request, data):
        id = self.initial['id']
        old_metadata = self.initial['metadata']

        try:
            new_metadata = json.loads(self.data['metadata'])

            metadata = dict(
                (item['key'], str(item['value']))
                for item in new_metadata
            )
            api.nova.flavor_extra_set(request, id, metadata)

            remove_keys = [key for key in old_metadata if key not in metadata]

            api.nova.flavor_extra_delete(request, id, remove_keys)

            message = _('Metadata successfully updated.')
            messages.success(request, message)
        except Exception:
            exceptions.handle(request,
                              _('Unable to update the flavor metadata.'))
            return False
        return True
dataset/ETHPy150Open CiscoSystems/avos/openstack_dashboard/dashboards/admin/flavors/forms.py/UpdateMetadataForm.handle/original