Fixes reboot (and rescue) to work even if libvirt doesn't know about the instance and the network doesn't exist.
This commit is contained in:
@@ -205,8 +205,8 @@ class ComputeManager(manager.Manager):
|
||||
def reboot_instance(self, context, instance_id):
|
||||
"""Reboot an instance on this server."""
|
||||
context = context.elevated()
|
||||
instance_ref = self.db.instance_get(context, instance_id)
|
||||
self._update_state(context, instance_id)
|
||||
instance_ref = self.db.instance_get(context, instance_id)
|
||||
|
||||
if instance_ref['state'] != power_state.RUNNING:
|
||||
logging.warn(_('trying to reboot a non-running '
|
||||
@@ -220,6 +220,7 @@ class ComputeManager(manager.Manager):
|
||||
instance_id,
|
||||
power_state.NOSTATE,
|
||||
'rebooting')
|
||||
self.network_manager.setup_compute_network(context, instance_id)
|
||||
self.driver.reboot(instance_ref)
|
||||
self._update_state(context, instance_id)
|
||||
|
||||
@@ -235,6 +236,7 @@ class ComputeManager(manager.Manager):
|
||||
instance_id,
|
||||
power_state.NOSTATE,
|
||||
'rescuing')
|
||||
self.network_manager.setup_compute_network(context, instance_id)
|
||||
self.driver.rescue(instance_ref)
|
||||
self._update_state(context, instance_id)
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
<domain type='%(type)s'>
|
||||
<name>%(name)s</name>
|
||||
<os>
|
||||
<type>hvm</type>
|
||||
<kernel>%(basepath)s/rescue-kernel</kernel>
|
||||
<initrd>%(basepath)s/rescue-ramdisk</initrd>
|
||||
<cmdline>root=/dev/vda1 console=ttyS0</cmdline>
|
||||
</os>
|
||||
<features>
|
||||
<acpi/>
|
||||
</features>
|
||||
<memory>%(memory_kb)s</memory>
|
||||
<vcpu>%(vcpus)s</vcpu>
|
||||
<devices>
|
||||
<disk type='file'>
|
||||
<source file='%(basepath)s/rescue-disk'/>
|
||||
<target dev='vda' bus='virtio'/>
|
||||
</disk>
|
||||
<disk type='file'>
|
||||
<source file='%(basepath)s/disk'/>
|
||||
<target dev='vdb' bus='virtio'/>
|
||||
</disk>
|
||||
<interface type='bridge'>
|
||||
<source bridge='%(bridge_name)s'/>
|
||||
<mac address='%(mac_address)s'/>
|
||||
<!-- <model type='virtio'/> CANT RUN virtio network right now -->
|
||||
<filterref filter="nova-instance-%(name)s">
|
||||
<parameter name="IP" value="%(ip_address)s" />
|
||||
<parameter name="DHCPSERVER" value="%(dhcp_server)s" />
|
||||
%(extra_params)s
|
||||
</filterref>
|
||||
</interface>
|
||||
<serial type="file">
|
||||
<source path='%(basepath)s/console.log'/>
|
||||
<target port='1'/>
|
||||
</serial>
|
||||
</devices>
|
||||
</domain>
|
||||
@@ -1,31 +0,0 @@
|
||||
<domain type='%(type)s'>
|
||||
<name>%(name)s</name>
|
||||
<memory>%(memory_kb)s</memory>
|
||||
<os>
|
||||
<type>%(type)s</type>
|
||||
<kernel>/usr/bin/linux</kernel>
|
||||
<root>/dev/ubda1</root>
|
||||
</os>
|
||||
<devices>
|
||||
<disk type='file'>
|
||||
<source file='%(basepath)s/rescue-disk'/>
|
||||
<target dev='ubd0' bus='uml'/>
|
||||
</disk>
|
||||
<disk type='file'>
|
||||
<source file='%(basepath)s/disk'/>
|
||||
<target dev='ubd1' bus='uml'/>
|
||||
</disk>
|
||||
<interface type='bridge'>
|
||||
<source bridge='%(bridge_name)s'/>
|
||||
<mac address='%(mac_address)s'/>
|
||||
<filterref filter="nova-instance-%(name)s">
|
||||
<parameter name="IP" value="%(ip_address)s" />
|
||||
<parameter name="DHCPSERVER" value="%(dhcp_server)s" />
|
||||
%(extra_params)s
|
||||
</filterref>
|
||||
</interface>
|
||||
<console type="file">
|
||||
<source path='%(basepath)s/console.log'/>
|
||||
</console>
|
||||
</devices>
|
||||
</domain>
|
||||
@@ -192,7 +192,8 @@ class LibvirtConnection(object):
|
||||
# everything has been vetted a bit
|
||||
def _wait_for_timer():
|
||||
timer_done.wait()
|
||||
self._cleanup(instance)
|
||||
if cleanup:
|
||||
self._cleanup(instance)
|
||||
done.send()
|
||||
|
||||
greenthread.spawn(_wait_for_timer)
|
||||
|
||||
Reference in New Issue
Block a user