summaryrefslogtreecommitdiff
path: root/nova/virt/disk/mount/api.py
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2012-11-15 12:17:27 +0000
committerDaniel P. Berrange <berrange@redhat.com>2012-11-21 11:53:07 +0000
commit14d97975afd3b0d7a9cd885ae05664d57456f6c4 (patch)
treee00891746bac73ace3159facba0f4fdf06adb895 /nova/virt/disk/mount/api.py
parentd20d9cb66e4aa66e0a815754fb104e4a94b40b0d (diff)
Add debug logging to disk mount modules
To assist in troubleshooting file injection code, add some LOG.debug() statements to the nova/virt/disk/mount/*.py modules blueprint: virt-disk-api-refactoring Change-Id: I75214145ef489a29a58f69abe6195ff01f36153c 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> Verified+1: SmokeStack Code-Review+2: Sean Dague <sdague@linux.vnet.ibm.com> Submitted-by: Jenkins Submitted-at: Wed, 21 Nov 2012 16:40:11 +0000 Reviewed-on: https://review.openstack.org/16180 Project: openstack/nova Branch: refs/heads/master
Diffstat (limited to 'nova/virt/disk/mount/api.py')
-rw-r--r--nova/virt/disk/mount/api.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/nova/virt/disk/mount/api.py b/nova/virt/disk/mount/api.py
index b63aa33..5354c85 100644
--- a/nova/virt/disk/mount/api.py
+++ b/nova/virt/disk/mount/api.py
@@ -35,22 +35,32 @@ class Mount(object):
35 35
36 @staticmethod 36 @staticmethod
37 def instance_for_format(imgfile, mountdir, partition, imgfmt): 37 def instance_for_format(imgfile, mountdir, partition, imgfmt):
38 LOG.debug(_("Instance for format imgfile=%(imgfile)s "
39 "mountdir=%(mountdir)s partition=%(partition)s "
40 "imgfmt=%(imgfmt)s") % locals())
38 if imgfmt == "raw": 41 if imgfmt == "raw":
42 LOG.debug(_("Using LoopMount"))
39 return importutils.import_object( 43 return importutils.import_object(
40 "nova.virt.disk.mount.loop.LoopMount", 44 "nova.virt.disk.mount.loop.LoopMount",
41 imgfile, mountdir, partition) 45 imgfile, mountdir, partition)
42 else: 46 else:
47 LOG.debug(_("Using NbdMount"))
43 return importutils.import_object( 48 return importutils.import_object(
44 "nova.virt.disk.mount.nbd.NbdMount", 49 "nova.virt.disk.mount.nbd.NbdMount",
45 imgfile, mountdir, partition) 50 imgfile, mountdir, partition)
46 51
47 @staticmethod 52 @staticmethod
48 def instance_for_device(imgfile, mountdir, partition, device): 53 def instance_for_device(imgfile, mountdir, partition, device):
54 LOG.debug(_("Instance for device imgfile=%(imgfile)s "
55 "mountdir=%(mountdir)s partition=%(partition)s "
56 "device=%(device)s") % locals())
49 if "loop" in device: 57 if "loop" in device:
58 LOG.debug(_("Using LoopMount"))
50 return importutils.import_object( 59 return importutils.import_object(
51 "nova.virt.disk.mount.loop.LoopMount", 60 "nova.virt.disk.mount.loop.LoopMount",
52 imgfile, mountdir, partition, device) 61 imgfile, mountdir, partition, device)
53 else: 62 else:
63 LOG.debug(_("Using NbdMount"))
54 return importutils.import_object( 64 return importutils.import_object(
55 "nova.virt.disk.mount.nbd.NbdMount", 65 "nova.virt.disk.mount.nbd.NbdMount",
56 imgfile, mountdir, partition, device) 66 imgfile, mountdir, partition, device)
@@ -99,6 +109,7 @@ class Mount(object):
99 def map_dev(self): 109 def map_dev(self):
100 """Map partitions of the device to the file system namespace.""" 110 """Map partitions of the device to the file system namespace."""
101 assert(os.path.exists(self.device)) 111 assert(os.path.exists(self.device))
112 LOG.debug(_("Map dev %s"), self.device)
102 automapped_path = '/dev/%sp%s' % (os.path.basename(self.device), 113 automapped_path = '/dev/%sp%s' % (os.path.basename(self.device),
103 self.partition) 114 self.partition)
104 115
@@ -142,6 +153,7 @@ class Mount(object):
142 """Remove partitions of the device from the file system namespace.""" 153 """Remove partitions of the device from the file system namespace."""
143 if not self.mapped: 154 if not self.mapped:
144 return 155 return
156 LOG.debug(_("Unmap dev %s"), self.device)
145 if self.partition and not self.automapped: 157 if self.partition and not self.automapped:
146 utils.execute('kpartx', '-d', self.device, run_as_root=True) 158 utils.execute('kpartx', '-d', self.device, run_as_root=True)
147 self.mapped = False 159 self.mapped = False
@@ -149,6 +161,8 @@ class Mount(object):
149 161
150 def mnt_dev(self): 162 def mnt_dev(self):
151 """Mount the device into the file system.""" 163 """Mount the device into the file system."""
164 LOG.debug(_("Mount %(dev)s on %(dir)s") %
165 {'dev': self.mapped_device, 'dir': self.mount_dir})
152 _out, err = utils.trycmd('mount', self.mapped_device, self.mount_dir, 166 _out, err = utils.trycmd('mount', self.mapped_device, self.mount_dir,
153 run_as_root=True) 167 run_as_root=True)
154 if err: 168 if err:
@@ -162,6 +176,7 @@ class Mount(object):
162 """Unmount the device from the file system.""" 176 """Unmount the device from the file system."""
163 if not self.mounted: 177 if not self.mounted:
164 return 178 return
179 LOG.debug(_("Umount %s") % self.mapped_device)
165 utils.execute('umount', self.mapped_device, run_as_root=True) 180 utils.execute('umount', self.mapped_device, run_as_root=True)
166 self.mounted = False 181 self.mounted = False
167 182
@@ -172,6 +187,7 @@ class Mount(object):
172 status = self.get_dev() and self.map_dev() and self.mnt_dev() 187 status = self.get_dev() and self.map_dev() and self.mnt_dev()
173 finally: 188 finally:
174 if not status: 189 if not status:
190 LOG.debug(_("Fail to mount, tearing back down"))
175 self.do_umount() 191 self.do_umount()
176 return status 192 return status
177 193