summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authormatt.dietz@rackspace.com <>2011-03-07 17:17:41 +0000
committermatt.dietz@rackspace.com <>2011-03-07 17:17:41 +0000
commita775c4eee279e11268a6cc447aee24c452e4665a (patch)
tree56cefa95312fc27bf19fef780d8d8877a26e1b3e /nova
parent4e98750e0a39b177d6f6523ebf4071f3cebd1a46 (diff)
downloadnova-a775c4eee279e11268a6cc447aee24c452e4665a.tar.gz
nova-a775c4eee279e11268a6cc447aee24c452e4665a.tar.xz
nova-a775c4eee279e11268a6cc447aee24c452e4665a.zip
Merge prop changes and test fixes
Diffstat (limited to 'nova')
-rw-r--r--nova/tests/xenapi/stubs.py26
-rw-r--r--nova/virt/xenapi/vm_utils.py30
-rw-r--r--nova/virt/xenapi/vmops.py4
3 files changed, 27 insertions, 33 deletions
diff --git a/nova/tests/xenapi/stubs.py b/nova/tests/xenapi/stubs.py
index caefcff34..11e89c9b4 100644
--- a/nova/tests/xenapi/stubs.py
+++ b/nova/tests/xenapi/stubs.py
@@ -227,18 +227,8 @@ class FakeSessionForMigrationTests(fake.SessionBase):
def stub_out_migration_methods(stubs):
- class FakeSnapshot(object):
- def __getattr__(self, key):
- return str(key)
-
- def __enter__(self):
- return self
-
- def __exit__(self, type, value, traceback):
- pass
-
def fake_get_snapshot(self, instance):
- return FakeSnapshot()
+ return 'foo', 'bar'
@classmethod
def fake_get_vdi(cls, session, vm_ref):
@@ -251,11 +241,21 @@ def stub_out_migration_methods(stubs):
pass
@classmethod
- def fake_scan_sr(cls, session):
+ def fake_sr(cls, session, *args):
+ pass
+
+ @classmethod
+ def fake_get_sr_path(cls, *args):
+ return "fake"
+
+ def fake_destroy(*args, **kwargs):
pass
- stubs.Set(vm_utils.VMHelper, 'scan_sr', fake_scan_sr)
+ stubs.Set(vmops.VMOps, '_destroy', fake_destroy)
+ stubs.Set(vm_utils.VMHelper, 'scan_default_sr', fake_sr)
+ stubs.Set(vm_utils.VMHelper, 'scan_sr', fake_sr)
stubs.Set(vmops.VMOps, '_get_snapshot', fake_get_snapshot)
stubs.Set(vm_utils.VMHelper, 'get_vdi_for_vm_safely', fake_get_vdi)
stubs.Set(xenapi_conn.XenAPISession, 'wait_for_task', lambda x, y, z: None)
+ stubs.Set(vm_utils.VMHelper, 'get_sr_path', fake_get_sr_path)
stubs.Set(vmops.VMOps, '_shutdown', fake_shutdown)
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index eff207a51..80b7540d4 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -307,10 +307,16 @@ class VMHelper(HelperBase):
return session.call_xenapi('SR.get_by_name_label', sr_label)[0]
@classmethod
- def get_sr_path(cls, session, sr_label='slices'):
- """Finds the SR and then coerces it into a path on the dom0 file
- system"""
- return FLAGS.xenapi_sr_base_path + cls.get_sr(session, sr_label)
+ def get_sr_path(cls, session):
+ """Return the path to our storage repository
+
+ This is used when we're dealing with VHDs directly, either by taking
+ snapshots or by restoring an image in the DISK_VHD format.
+ """
+ sr_ref = safe_find_sr(session)
+ sr_rec = session.get_xenapi().SR.get_record(sr_ref)
+ sr_uuid = sr_rec["uuid"]
+ return os.path.join(FLAGS.xenapi_sr_base_path, sr_uuid)
@classmethod
def upload_image(cls, session, instance_id, vdi_uuids, image_id):
@@ -326,7 +332,7 @@ class VMHelper(HelperBase):
'image_id': image_id,
'glance_host': FLAGS.glance_host,
'glance_port': FLAGS.glance_port,
- 'sr_path': get_sr_path(session)}
+ 'sr_path': cls.get_sr_path(session)}
kwargs = {'params': pickle.dumps(params)}
task = session.async_call_plugin('glance', 'upload_vhd', kwargs)
@@ -369,7 +375,7 @@ class VMHelper(HelperBase):
'glance_host': FLAGS.glance_host,
'glance_port': FLAGS.glance_port,
'uuid_stack': uuid_stack,
- 'sr_path': get_sr_path(session)}
+ 'sr_path': cls.get_sr_path(session)}
kwargs = {'params': pickle.dumps(params)}
task = session.async_call_plugin('glance', 'download_vhd', kwargs)
@@ -775,18 +781,6 @@ def find_sr(session):
return None
-def get_sr_path(session):
- """Return the path to our storage repository
-
- This is used when we're dealing with VHDs directly, either by taking
- snapshots or by restoring an image in the DISK_VHD format.
- """
- sr_ref = safe_find_sr(session)
- sr_rec = session.get_xenapi().SR.get_record(sr_ref)
- sr_uuid = sr_rec["uuid"]
- return os.path.join(FLAGS.xenapi_sr_base_path, sr_uuid)
-
-
def remap_vbd_dev(dev):
"""Return the appropriate location for a plugged-in VBD device
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index 01bfa2dc5..b862c9de9 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -262,7 +262,7 @@ class VMOps(object):
self._session, instance.id, template_vdi_uuids, image_id)
finally:
if template_vm_ref:
- self.virt._destroy(self.instance, template_vm_ref,
+ self._destroy(instance, template_vm_ref,
shutdown=False, destroy_kernel_ramdisk=False)
logging.debug(_("Finished snapshot and upload for VM %s"), instance)
@@ -330,7 +330,7 @@ class VMOps(object):
finally:
if template_vm_ref:
- self.virt._destroy(self.instance, template_vm_ref,
+ self._destroy(instance, template_vm_ref,
shutdown=False, destroy_kernel_ramdisk=False)
# TODO(mdietz): we could also consider renaming these to something