def change_instance_metadata(self, instance, diff):
        """Apply changes to instance metadata to xenstore."""
        try:
            vm_ref = self._get_vm_opaque_ref(instance)
        except exception.NotFound:
            # NOTE(johngarbutt) race conditions mean we can still get here
            # during operations where the VM is not present, like resize.
            # Skip the update when not possible, as the updated metadata will
            # get added when the VM is being booted up at the end of the
            # resize or rebuild.
            LOG.warning(_LW("Unable to update metadata, VM not found."),
                        instance=instance, exc_info=True)
            return

        def process_change(location, change):
            if change[0] == '-':
                self._remove_from_param_xenstore(vm_ref, location)
                try:
                    self._delete_from_xenstore(instance, location,
                                               vm_ref=vm_ref)
                except exception.InstanceNotFound:
                    # If the VM is not running then no need to update
                    # the live xenstore - the param xenstore will be
                    # used next time the VM is booted
                    pass
            elif change[0] == '+':
                self._add_to_param_xenstore(vm_ref, location,
                                            jsonutils.dumps(change[1]))
                try:
                    self._write_to_xenstore(instance, location, change[1],
                                            vm_ref=vm_ref)
                except exception.InstanceNotFound:
                    # If the VM is not running then no need to update
                    # the live xenstore
                    pass

        @utils.synchronized('xenstore-' + instance['uuid'])
        def update_meta():
            for key, change in diff.items():
                key = self._sanitize_xenstore_key(key)
                location = key % 'vm-data/user-metadata/%s'
                process_change(location, change)
        update_meta()
dataset/ETHPy150Open openstack/nova/nova/virt/xenapi/vmops.py/VMOps.change_instance_metadata/swapped operands of `%`