diff options
| author | Josh Kearney <josh@jk0.org> | 2011-02-25 14:35:29 -0600 |
|---|---|---|
| committer | Josh Kearney <josh@jk0.org> | 2011-02-25 14:35:29 -0600 |
| commit | 6cfa479a1375fb8274dd9130946eab38e1398538 (patch) | |
| tree | f112386a5c275a739272e9713887b65c3d93d1bc /nova | |
| parent | 2dc9d8bfe4bcd61c4d634767715b2be3a214426e (diff) | |
| download | nova-6cfa479a1375fb8274dd9130946eab38e1398538.tar.gz nova-6cfa479a1375fb8274dd9130946eab38e1398538.tar.xz nova-6cfa479a1375fb8274dd9130946eab38e1398538.zip | |
Set rescue instance VIF device
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/virt/xenapi/vm_utils.py | 4 | ||||
| -rw-r--r-- | nova/virt/xenapi/vmops.py | 21 |
2 files changed, 21 insertions, 4 deletions
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index 206201817..f0b1e993c 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -207,11 +207,11 @@ class VMHelper(HelperBase): raise StorageError(_('Unable to destroy VBD %s') % vbd_ref) @classmethod - def create_vif(cls, session, vm_ref, network_ref, mac_address): + def create_vif(cls, session, vm_ref, network_ref, mac_address, dev="0"): """Create a VIF record. Returns a Deferred that gives the new VIF reference.""" vif_rec = {} - vif_rec['device'] = '0' + vif_rec['device'] = dev vif_rec['network'] = network_ref vif_rec['VM'] = vm_ref vif_rec['MAC'] = mac_address diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 6b531ca2c..c1e9bec62 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -483,6 +483,14 @@ class VMOps(object): task1 = self._session.call_xenapi("Async.VM.hard_shutdown", rescue_vm) self._session.wait_for_task(task1, instance.id) + vdis = VMHelper.lookup_vm_vdis(self._session, rescue_vm) + for vdi in vdis: + try: + task = self._session.call_xenapi('Async.VDI.destroy', vdi) + self._session.wait_for_task(task, instance.id) + except self.XenAPI.Failure: + continue + task2 = self._session.call_xenapi('Async.VM.destroy', rescue_vm) self._session.wait_for_task(task2, instance.id) @@ -574,8 +582,17 @@ class VMOps(object): NetworkHelper.find_network_with_bridge(self._session, bridge) if network_ref: - VMHelper.create_vif(self._session, vm_opaque_ref, - network_ref, instance.mac_address) + try: + device = "1" if instance._rescue else "0" + except AttributeError: + device = "0" + + VMHelper.create_vif( + self._session, + vm_opaque_ref, + network_ref, + instance.mac_address, + device) def reset_network(self, instance): """ |
