'Inject the hostname of the instance into the xenstore.'

def _inject_hostname(self, instance, vm_ref, rescue):

    hostname = instance['hostname']
    if rescue:
        hostname = ('RESCUE-%s' % hostname)
    if (instance['os_type'] == 'windows'):
        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()
