def _inject_instance_metadata(self, instance, vm_ref):
        """Inject instance metadata into xenstore."""
        @utils.synchronized('xenstore-' + instance['uuid'])
        def store_meta(topdir, data_dict):
            for key, value in data_dict.items():
                key = self._sanitize_xenstore_key(key)
                value = value or ''
                self._add_to_param_xenstore(vm_ref, '%s/%s' % (topdir, key),
                                            jsonutils.dumps(value))

        # Store user metadata
        store_meta('vm-data/user-metadata', utils.instance_meta(instance))
dataset/ETHPy150Open openstack/nova/nova/virt/xenapi/vmops.py/VMOps._inject_instance_metadata/original