summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Kearney <josh@jk0.org>2011-09-13 21:54:40 +0000
committerTarmac <>2011-09-13 21:54:40 +0000
commita565f3abd7fb7c5b10ea6942823aadd68fffada1 (patch)
treeac7b285650455b6ad5394b8dad7559831494bc6a
parent462635a8aa6301b79023e8232b20a0f753c0d24a (diff)
parent98e2fd764b33fa5a3af6ca982a171717a12ee206 (diff)
downloadnova-a565f3abd7fb7c5b10ea6942823aadd68fffada1.tar.gz
nova-a565f3abd7fb7c5b10ea6942823aadd68fffada1.tar.xz
nova-a565f3abd7fb7c5b10ea6942823aadd68fffada1.zip
Only allow up to 15 chars for a Windows hostname.
-rw-r--r--nova/tests/test_xenapi.py3
-rw-r--r--nova/virt/xenapi/vmops.py8
2 files changed, 8 insertions, 3 deletions
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index 4a83d139e..47c6a3c95 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -364,7 +364,7 @@ class XenAPIVMTestCase(test.TestCase):
def _test_spawn(self, image_ref, kernel_id, ramdisk_id,
instance_type_id="3", os_type="linux",
- architecture="x86-64", instance_id=1,
+ hostname="test", architecture="x86-64", instance_id=1,
check_injection=False,
create_record=True, empty_dns=False):
stubs.stubout_loopingcall_start(self.stubs)
@@ -377,6 +377,7 @@ class XenAPIVMTestCase(test.TestCase):
'ramdisk_id': ramdisk_id,
'instance_type_id': instance_type_id,
'os_type': os_type,
+ 'hostname': hostname,
'architecture': architecture}
instance = db.instance_create(self.context, values)
else:
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index 15b942a82..6b56d668e 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -253,7 +253,7 @@ class VMOps(object):
self.create_vifs(vm_ref, instance, network_info)
self.inject_network_info(instance, network_info, vm_ref)
- self.inject_hostname(vm_ref, instance['hostname'])
+ self.inject_hostname(instance, vm_ref, instance['hostname'])
return vm_ref
@@ -1160,8 +1160,12 @@ class VMOps(object):
resp = self._make_plugin_call('agent', 'resetnetwork', instance, '',
args, vm_ref)
- def inject_hostname(self, vm_ref, hostname):
+ def inject_hostname(self, instance, vm_ref, hostname):
"""Inject the hostname of the instance into the xenstore."""
+ if instance.os_type == "windows":
+ # NOTE(jk0): Windows hostnames can only be <= 15 chars.
+ hostname = hostname[:15]
+
logging.debug(_("injecting hostname to xs for vm: |%s|"), vm_ref)
self._session.call_xenapi_request("VM.add_to_xenstore_data",
(vm_ref, "vm-data/hostname", hostname))