summaryrefslogtreecommitdiff
path: root/nova/virt/disk/mount/api.py
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2012-11-13 11:15:40 +0000
committerDaniel P. Berrange <berrange@redhat.com>2012-11-21 11:53:07 +0000
commit6aebaca79ad394c99d0b9698834bccfcfa226ab4 (patch)
tree0efaebbf1440666362ed7ef32baf74b76151897e /nova/virt/disk/mount/api.py
parent72918415f2b6a241d6097a563aba55a849936591 (diff)
Remove img_handlers config parameter usage
Now that the only disk code requiring host filesystem mounts is the LXC filesystem setup, the img_handlers config parameter is an solution looking for a purpose. For any disk image format we can categorically say whether it should be mounted using loop or qemu-nbd mount impls. There is no desire to use libguestfs FUSE for mounting LXC disk images, since users of LXC do not want a huge KVM process alongside every container! Move the mount class choice logic into the mount API, by creating new methods nova.virt.disk.mount.API.instance_for_format() nova.virt.disk.mount.API.instance_for_device() and then call these from nova.virt.disk.API code blueprint: virt-disk-api-refactoring Change-Id: I088b5debdf62d4a9a6b4521eee68cd4757f2ff42 Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Notes
Notes (review): Verified+2: Jenkins Approved+1: p-draigbrady <P@draigBrady.com> Code-Review+2: p-draigbrady <P@draigBrady.com> Code-Review+2: Michael Still <michael.still@canonical.com> Code-Review+2: Sean Dague <sdague@linux.vnet.ibm.com> Submitted-by: Jenkins Submitted-at: Wed, 21 Nov 2012 16:30:11 +0000 Reviewed-on: https://review.openstack.org/16178 Project: openstack/nova Branch: refs/heads/master
Diffstat (limited to 'nova/virt/disk/mount/api.py')
-rw-r--r--nova/virt/disk/mount/api.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/nova/virt/disk/mount/api.py b/nova/virt/disk/mount/api.py
index e683658..b63aa33 100644
--- a/nova/virt/disk/mount/api.py
+++ b/nova/virt/disk/mount/api.py
@@ -17,6 +17,7 @@
17 17
18import os 18import os
19 19
20from nova.openstack.common import importutils
20from nova.openstack.common import log as logging 21from nova.openstack.common import log as logging
21from nova import utils 22from nova import utils
22 23
@@ -30,7 +31,29 @@ class Mount(object):
30 to be called in that order. 31 to be called in that order.
31 """ 32 """
32 33
33 mode = device_id_string = None # to be overridden in subclasses 34 mode = None # to be overridden in subclasses
35
36 @staticmethod
37 def instance_for_format(imgfile, mountdir, partition, imgfmt):
38 if imgfmt == "raw":
39 return importutils.import_object(
40 "nova.virt.disk.mount.loop.LoopMount",
41 imgfile, mountdir, partition)
42 else:
43 return importutils.import_object(
44 "nova.virt.disk.mount.nbd.NbdMount",
45 imgfile, mountdir, partition)
46
47 @staticmethod
48 def instance_for_device(imgfile, mountdir, partition, device):
49 if "loop" in device:
50 return importutils.import_object(
51 "nova.virt.disk.mount.loop.LoopMount",
52 imgfile, mountdir, partition, device)
53 else:
54 return importutils.import_object(
55 "nova.virt.disk.mount.nbd.NbdMount",
56 imgfile, mountdir, partition, device)
34 57
35 def __init__(self, image, mount_dir, partition=None, device=None): 58 def __init__(self, image, mount_dir, partition=None, device=None):
36 59