~rcarrillocruz/nova/lp836978

« back to all changes in this revision

Viewing changes to nova/virt/xenapi/vmops.py

  • Committer: Tarmac
  • Author(s): Josh Kearney
  • Date: 2011-09-13 21:54:40 UTC
  • mfrom: (1561.1.2 inject_hostname)
  • Revision ID: tarmac-20110913215440-8x3z4s3z8tn8asjz
Only allow up to 15 chars for a Windows hostname.

Show diffs side-by-side

added added

removed removed

Lines of Context:
253
253
 
254
254
        self.create_vifs(vm_ref, instance, network_info)
255
255
        self.inject_network_info(instance, network_info, vm_ref)
256
 
        self.inject_hostname(vm_ref, instance['hostname'])
 
256
        self.inject_hostname(instance, vm_ref, instance['hostname'])
257
257
 
258
258
        return vm_ref
259
259
 
1160
1160
        resp = self._make_plugin_call('agent', 'resetnetwork', instance, '',
1161
1161
                                                               args, vm_ref)
1162
1162
 
1163
 
    def inject_hostname(self, vm_ref, hostname):
 
1163
    def inject_hostname(self, instance, vm_ref, hostname):
1164
1164
        """Inject the hostname of the instance into the xenstore."""
 
1165
        if instance.os_type == "windows":
 
1166
            # NOTE(jk0): Windows hostnames can only be <= 15 chars.
 
1167
            hostname = hostname[:15]
 
1168
 
1165
1169
        logging.debug(_("injecting hostname to xs for vm: |%s|"), vm_ref)
1166
1170
        self._session.call_xenapi_request("VM.add_to_xenstore_data",
1167
1171
                (vm_ref, "vm-data/hostname", hostname))