summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_xenapi.py8
-rw-r--r--nova/tests/xenapi/stubs.py8
2 files changed, 9 insertions, 7 deletions
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index 0820137fa..f05ea9e5b 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -355,9 +355,9 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
stubs.stubout_firewall_driver(self.stubs, self.conn)
instance = self._create_instance()
- name = "MySnapshot"
+ image_id = "my_snapshot_id"
self.assertRaises(exception.NovaException, self.conn.snapshot,
- self.context, instance, name)
+ self.context, instance, image_id)
def test_instance_snapshot(self):
stubs.stubout_instance_snapshot(self.stubs)
@@ -367,8 +367,8 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
stubs.stubout_firewall_driver(self.stubs, self.conn)
instance = self._create_instance()
- name = "MySnapshot"
- template_vm_ref = self.conn.snapshot(self.context, instance, name)
+ image_id = "my_snapshot_id"
+ self.conn.snapshot(self.context, instance, image_id)
# Ensure VM was torn down
vm_labels = []
diff --git a/nova/tests/xenapi/stubs.py b/nova/tests/xenapi/stubs.py
index e026f8eb5..83a17af84 100644
--- a/nova/tests/xenapi/stubs.py
+++ b/nova/tests/xenapi/stubs.py
@@ -15,6 +15,7 @@
"""Stubouts, mocks and fixtures for the test suite"""
+import contextlib
import random
import sys
@@ -317,8 +318,9 @@ class FakeSessionForVolumeFailedTests(FakeSessionForVolumeTests):
def stub_out_migration_methods(stubs):
- def fake_create_snapshot(session, instance, vm_ref, label):
- return 'vm_ref', dict(image='foo', snap='bar')
+ @contextlib.contextmanager
+ def fake_snapshot_attached_here(session, instance, vm_ref, label):
+ yield dict(image='foo', snap='bar')
def fake_move_disks(self, instance, disk_info):
vdi_ref = fake.create_vdi(instance['name'], 'fake')
@@ -347,7 +349,7 @@ def stub_out_migration_methods(stubs):
stubs.Set(vmops.VMOps, '_move_disks', fake_move_disks)
stubs.Set(vm_utils, 'scan_default_sr', fake_sr)
stubs.Set(vm_utils, '_scan_sr', fake_sr)
- stubs.Set(vm_utils, 'create_snapshot', fake_create_snapshot)
+ stubs.Set(vm_utils, 'snapshot_attached_here', fake_snapshot_attached_here)
stubs.Set(vm_utils, 'get_vdi_for_vm_safely', fake_get_vdi)
stubs.Set(vm_utils, 'get_sr_path', fake_get_sr_path)
stubs.Set(vm_utils, 'generate_ephemeral', fake_generate_ephemeral)