summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Kearney <josh@jk0.org>2012-02-02 15:19:36 -0600
committerJosh Kearney <josh@jk0.org>2012-02-02 16:22:04 -0600
commitcc4e125491168b7f92edc1153437798e5cf64a78 (patch)
treecc805c7bb44d2fd5e270745aaa9e17954130c8fa
parent723cbc762a5e1d8d53e7e30223ee701dd65bd61c (diff)
downloadnova-cc4e125491168b7f92edc1153437798e5cf64a78.tar.gz
nova-cc4e125491168b7f92edc1153437798e5cf64a78.tar.xz
nova-cc4e125491168b7f92edc1153437798e5cf64a78.zip
Set rescue instance hostnames appropriately.
Fixes bug 920605. Change-Id: Iedba7d727fb88d169cc5ca6387ef13345d227c48
-rw-r--r--nova/virt/xenapi/vmops.py12
1 files changed, 11 insertions, 1 deletions
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