From cc4e125491168b7f92edc1153437798e5cf64a78 Mon Sep 17 00:00:00 2001 From: Josh Kearney Date: Thu, 2 Feb 2012 15:19:36 -0600 Subject: Set rescue instance hostnames appropriately. Fixes bug 920605. Change-Id: Iedba7d727fb88d169cc5ca6387ef13345d227c48 --- nova/virt/xenapi/vmops.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 96b2a521b..c7f713ea2 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -251,6 +251,14 @@ class VMOps(object): """Spawn a rescue instance.""" self.spawn(context, instance, image_meta, network_info) + def _generate_hostname(self, instance): + """Generate the instance's hostname.""" + hostname = instance["hostname"] + if getattr(instance, "_rescue", False): + hostname = "RESCUE-%s" % hostname + + return hostname + def _create_vm(self, context, instance, vdis, network_info, image_meta): """Create VM instance.""" instance_name = instance.name @@ -339,7 +347,9 @@ class VMOps(object): self.create_vifs(vm_ref, instance, network_info) self.inject_network_info(instance, network_info, vm_ref) - self.inject_hostname(instance, vm_ref, instance['hostname']) + + hostname = self._generate_hostname(instance) + self.inject_hostname(instance, vm_ref, hostname) return vm_ref -- cgit