def _inject_hostname(self, instance, vm_ref, rescue):
        """Inject the hostname of the instance into the xenstore."""
        hostname = instance['hostname']
        if rescue:
            hostname = 'RESCUE-%s' % hostname

        if instance['os_type'] == "windows":
            # NOTE(jk0): Windows host names can only be <= 15 chars.
            hostname = hostname[:15]

        LOG.debug("Injecting hostname (%s) into xenstore", hostname,
                  instance=instance)

        @utils.synchronized('xenstore-' + instance['uuid'])
        def update_hostname():
            self._add_to_param_xenstore(vm_ref, 'vm-data/hostname', hostname)

        update_hostname()
dataset/ETHPy150Open openstack/nova/nova/virt/xenapi/vmops.py/VMOps._inject_hostname/original