Previously, the method call was logged into 'tmp/anaconda.log' which made the file harder to do anything useful with. --- iutil.py | 16 ---- storage/devices.py | 157 +++++++++++++++++++++--------------------- storage/devicetree.py | 28 ++++---- storage/formats/__init__.py | 15 ++-- storage/formats/disklabel.py | 20 +++--- storage/formats/dmraid.py | 8 +- storage/formats/fs.py | 8 +-- storage/formats/luks.py | 20 +++--- storage/formats/lvmpv.py | 10 ++-- storage/formats/mdraid.py | 6 +- storage/formats/multipath.py | 8 +- storage/formats/swap.py | 11 ++-- storage/storage_log.py | 20 +++++- 13 files changed, 163 insertions(+), 164 deletions(-) diff --git a/iutil.py b/iutil.py index 82a8f9a..18df7df 100644 --- a/iutil.py +++ b/iutil.py @@ -25,7 +25,6 @@ import os, string, stat, sys import signal import os.path from errno import * -import inspect import warnings import subprocess from flags import flags @@ -808,21 +807,6 @@ def get_sysfs_path_by_name(dev_name, class_name="block"): if os.path.exists(dev_path): return dev_path -def log_method_call(d, *args, **kwargs): - classname = d.__class__.__name__ - methodname = inspect.stack()[1][3] - fmt = "%s.%s:" - fmt_args = [classname, methodname] - for arg in args: - fmt += " %s ;" - fmt_args.append(arg) - - for k, v in kwargs.items(): - fmt += " %s: %s ;" - fmt_args.extend([k, v]) - - log.debug(fmt % tuple(fmt_args)) - def numeric_type(num): """ Verify that a value is given as a numeric data type. diff --git a/storage/devices.py b/storage/devices.py index 63d1cac..19a7afa 100644 --- a/storage/devices.py +++ b/storage/devices.py @@ -108,7 +108,8 @@ import platform import block from errors import * -from iutil import log_method_call, notify_kernel, numeric_type +from iutil import notify_kernel, numeric_type +from .storage_log import logStorageMethodCall from udev import * from formats import get_device_format_class, getFormat, DeviceFormat from isys import compareDrives @@ -273,11 +274,11 @@ class Device(object): return def removeChild(self): - log_method_call(self, name=self.name, kids=self.kids) + logStorageMethodCall(self, name=self.name, kids=self.kids) self.kids -= 1 def addChild(self): - log_method_call(self, name=self.name, kids=self.kids) + logStorageMethodCall(self, name=self.name, kids=self.kids) self.kids += 1 def setup(self, intf=None): @@ -525,7 +526,7 @@ class StorageDevice(Device): def updateSysfsPath(self): """ Update this device's sysfs path. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) sysfsName = self.name.replace("/", "!") path = os.path.join("/sys", self.sysfsBlockDir, sysfsName) self.sysfsPath = os.path.realpath(path)[4:] @@ -543,7 +544,7 @@ class StorageDevice(Device): def notifyKernel(self): """ Send a 'change' uevent to the kernel for this device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: log.debug("not sending change uevent for non-existent device") return @@ -574,7 +575,7 @@ class StorageDevice(Device): def setup(self, intf=None): """ Open, or set up, a device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -584,7 +585,7 @@ class StorageDevice(Device): def teardown(self, recursive=None): """ Close, or tear down, a device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists and not recursive: raise DeviceError("device has not been created", self.name) @@ -662,7 +663,7 @@ class StorageDevice(Device): """ Set the Device's format. """ if not format: format = getFormat(None, device=self.path, exists=self.exists) - log_method_call(self, self.name, type=format.type, + logStorageMethodCall(self, self.name, type=format.type, current=getattr(self._format, "type", None)) if self._format and self._format.status: # FIXME: self.format.status doesn't mean much @@ -679,7 +680,7 @@ class StorageDevice(Device): def create(self, intf=None): """ Create the device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if self.exists: raise DeviceError("device has already been created", self.name) @@ -690,7 +691,7 @@ class StorageDevice(Device): def destroy(self): """ Destroy the device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -776,11 +777,11 @@ class DiskDevice(StorageDevice): pyparted should be able to tell us anything we want to know. size, disklabel type, maybe even partition layout """ - log_method_call(self, self.name, size=self.size, partedDevice=self.partedDevice) + logStorageMethodCall(self, self.name, size=self.size, partedDevice=self.partedDevice) def destroy(self): """ Destroy the device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.mediaPresent: raise DeviceError("cannot destroy disk with no media", self.name) @@ -788,7 +789,7 @@ class DiskDevice(StorageDevice): def setup(self, intf=None): """ Open, or set up, a device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not os.path.exists(self.path): raise DeviceError("device does not exist", self.name) @@ -1025,7 +1026,7 @@ class PartitionDevice(StorageDevice): def _setPartedPartition(self, partition): """ Set this PartitionDevice's parted Partition instance. """ - log_method_call(self, self.name) + logStorageMethodCall(self, self.name) if partition is None: path = None elif isinstance(partition, parted.Partition): @@ -1053,7 +1054,7 @@ class PartitionDevice(StorageDevice): def updateSysfsPath(self): """ Update this device's sysfs path. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.parents: self.sysfsPath = '' @@ -1082,7 +1083,7 @@ class PartitionDevice(StorageDevice): def _setFormat(self, format): """ Set the Device's format. """ - log_method_call(self, self.name) + logStorageMethodCall(self, self.name) StorageDevice._setFormat(self, format) def _setBootable(self, bootable): @@ -1108,7 +1109,7 @@ class PartitionDevice(StorageDevice): bootable = property(_getBootable, _setBootable) def flagAvailable(self, flag): - log_method_call(self, path=self.path, flag=flag, + logStorageMethodCall(self, path=self.path, flag=flag, part=self.partedPartition) if not self.partedPartition: return @@ -1116,7 +1117,7 @@ class PartitionDevice(StorageDevice): return self.partedPartition.isFlagAvailable(flag) def getFlag(self, flag): - log_method_call(self, path=self.path, flag=flag, + logStorageMethodCall(self, path=self.path, flag=flag, part=self.partedPartition) if not self.partedPartition or not self.flagAvailable(flag): return @@ -1124,7 +1125,7 @@ class PartitionDevice(StorageDevice): return self.partedPartition.getFlag(flag) def setFlag(self, flag): - log_method_call(self, path=self.path, flag=flag, + logStorageMethodCall(self, path=self.path, flag=flag, part=self.partedPartition) if not self.partedPartition or not self.flagAvailable(flag): return @@ -1132,7 +1133,7 @@ class PartitionDevice(StorageDevice): self.partedPartition.setFlag(flag) def unsetFlag(self, flag): - log_method_call(self, path=self.path, flag=flag, + logStorageMethodCall(self, path=self.path, flag=flag, part=self.partedPartition) if not self.partedPartition or not self.flagAvailable(flag): return @@ -1144,7 +1145,7 @@ class PartitionDevice(StorageDevice): size, partition type, flags """ - log_method_call(self, self.name, exists=self.exists) + logStorageMethodCall(self, self.name, exists=self.exists) if not self.exists: return @@ -1158,7 +1159,7 @@ class PartitionDevice(StorageDevice): def create(self, intf=None): """ Create the device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if self.exists: raise DeviceError("device already exists", self.name) @@ -1178,7 +1179,7 @@ class PartitionDevice(StorageDevice): self.setup() def _computeResize(self, partition): - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) # compute new size for partition currentGeom = partition.geometry @@ -1196,7 +1197,7 @@ class PartitionDevice(StorageDevice): self.targetSize must be set to the new size. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if self.targetSize != self.currentSize: # partedDisk has been restored to _origPartedDisk, so @@ -1215,7 +1216,7 @@ class PartitionDevice(StorageDevice): def destroy(self): """ Destroy the device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -1247,7 +1248,7 @@ class PartitionDevice(StorageDevice): newsize -- the new size (in MB) """ - log_method_call(self, self.name, + logStorageMethodCall(self, self.name, status=self.status, size=self._size, newsize=newsize) if not self.exists: raise DeviceError("device does not exist", self.name) @@ -1282,7 +1283,7 @@ class PartitionDevice(StorageDevice): Setting up a disk is not trivial. It has the potential to change the underlying object. If necessary we must also change this object. """ - log_method_call(self, self.name, old=self.disk, new=disk) + logStorageMethodCall(self, self.name, old=self.disk, new=disk) if self.disk: self.disk.removeChild() @@ -1363,7 +1364,7 @@ class DMDevice(StorageDevice): def updateSysfsPath(self): """ Update this device's sysfs path. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -1379,7 +1380,7 @@ class DMDevice(StorageDevice): def getDMNode(self): """ Return the dm-X (eg: dm-0) device node for this device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -1387,7 +1388,7 @@ class DMDevice(StorageDevice): def _setName(self, name): """ Set the device's map name. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if self.status: raise DeviceError("cannot rename active device", self.name) @@ -1464,7 +1465,7 @@ class LUKSDevice(DMCryptDevice): def create(self, intf=None): """ Create the device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if self.exists: raise DeviceError("device already exists", self.name) @@ -1479,7 +1480,7 @@ class LUKSDevice(DMCryptDevice): def setup(self, intf=None): """ Open, or set up, a device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -1492,7 +1493,7 @@ class LUKSDevice(DMCryptDevice): def teardown(self, recursive=False): """ Close, or tear down, a device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists and not recursive: raise DeviceError("device has not been created", self.name) @@ -1508,7 +1509,7 @@ class LUKSDevice(DMCryptDevice): self.teardownParents(recursive=recursive) def destroy(self): - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) self.format.teardown() udev_settle(timeout=10) self.teardown() @@ -1619,7 +1620,7 @@ class LVMVolumeGroupDevice(DMDevice): def probe(self): """ Probe for any information about this device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -1636,7 +1637,7 @@ class LVMVolumeGroupDevice(DMDevice): def getDMNode(self): """ Return the dm-X (eg: dm-0) device node for this device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -1670,7 +1671,7 @@ class LVMVolumeGroupDevice(DMDevice): XXX This is for use by device probing routines and is not intended for modification of the VG. """ - log_method_call(self, + logStorageMethodCall(self, self.name, device=device.name, status=self.status) @@ -1698,7 +1699,7 @@ class LVMVolumeGroupDevice(DMDevice): This is for cases like clearing of preexisting partitions. """ - log_method_call(self, + logStorageMethodCall(self, self.name, device=device.name, status=self.status) @@ -1715,7 +1716,7 @@ class LVMVolumeGroupDevice(DMDevice): XXX we don't do anything like "vgchange -ay" because we don't want all of the LVs activated, just the VG itself. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -1729,7 +1730,7 @@ class LVMVolumeGroupDevice(DMDevice): def teardown(self, recursive=None): """ Close, or tear down, a device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists and not recursive: raise DeviceError("device has not been created", self.name) @@ -1741,7 +1742,7 @@ class LVMVolumeGroupDevice(DMDevice): def create(self, intf=None): """ Create the device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if self.exists: raise DeviceError("device already exists", self.name) @@ -1763,7 +1764,7 @@ class LVMVolumeGroupDevice(DMDevice): def destroy(self): """ Destroy the device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -1782,7 +1783,7 @@ class LVMVolumeGroupDevice(DMDevice): def reduce(self, pv_list): """ Remove the listed PVs from the VG. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -2063,7 +2064,7 @@ class LVMLogicalVolumeDevice(DMDevice): def getDMNode(self): """ Return the dm-X (eg: dm-0) device node for this device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -2086,7 +2087,7 @@ class LVMLogicalVolumeDevice(DMDevice): def setup(self, intf=None): """ Open, or set up, a device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -2102,7 +2103,7 @@ class LVMLogicalVolumeDevice(DMDevice): def teardown(self, recursive=None): """ Close, or tear down, a device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists and not recursive: raise DeviceError("device has not been created", self.name) @@ -2124,7 +2125,7 @@ class LVMLogicalVolumeDevice(DMDevice): def create(self, intf=None): """ Create the device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if self.exists: raise DeviceError("device already exists", self.name) @@ -2139,7 +2140,7 @@ class LVMLogicalVolumeDevice(DMDevice): def destroy(self): """ Destroy the device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -2151,7 +2152,7 @@ class LVMLogicalVolumeDevice(DMDevice): def resize(self, intf=None): # XXX resize format probably, right? - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -2367,7 +2368,7 @@ class MDRaidArrayDevice(StorageDevice): I'd like to avoid paying any attention to "Preferred Minor" as it seems problematic. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -2382,7 +2383,7 @@ class MDRaidArrayDevice(StorageDevice): def updateSysfsPath(self): """ Update this device's sysfs path. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -2397,7 +2398,7 @@ class MDRaidArrayDevice(StorageDevice): XXX This is for use when probing devices, not for modification of arrays. """ - log_method_call(self, + logStorageMethodCall(self, self.name, device=device.name, status=self.status) @@ -2437,7 +2438,7 @@ class MDRaidArrayDevice(StorageDevice): XXX This is for use by clearpart, not for reconfiguration. """ - log_method_call(self, + logStorageMethodCall(self, self.name, device=device.name, status=self.status) @@ -2493,7 +2494,7 @@ class MDRaidArrayDevice(StorageDevice): def setup(self, intf=None): """ Open, or set up, a device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -2523,7 +2524,7 @@ class MDRaidArrayDevice(StorageDevice): def teardown(self, recursive=None): """ Close, or tear down, a device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists and not recursive: raise DeviceError("device has not been created", self.name) @@ -2548,7 +2549,7 @@ class MDRaidArrayDevice(StorageDevice): def create(self, intf=None): """ Create the device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if self.exists: raise DeviceError("device already exists", self.name) @@ -2583,7 +2584,7 @@ class MDRaidArrayDevice(StorageDevice): def destroy(self): """ Destroy the device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -2659,7 +2660,7 @@ class DMRaidArrayDevice(DiskDevice): XXX This is for use when probing devices, not for modification of arrays. """ - log_method_call(self, self.name, device=device.name, status=self.status) + logStorageMethodCall(self, self.name, device=device.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -2685,7 +2686,7 @@ class DMRaidArrayDevice(DiskDevice): def updateSysfsPath(self): """ Update this device's sysfs path. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -2698,13 +2699,13 @@ class DMRaidArrayDevice(DiskDevice): def deactivate(self): """ Deactivate the raid set. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) # This call already checks if the set is not active. self._raidSet.deactivate() def activate(self): """ Activate the raid set. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) # This call already checks if the set is active. self._raidSet.activate(mknod=True) udev_settle() @@ -2833,7 +2834,7 @@ class MultipathDevice(DiskDevice): def updateSysfsPath(self): """ Update this device's sysfs path. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -2846,7 +2847,7 @@ class MultipathDevice(DiskDevice): def getDMNode(self): """ Return the dm-X (eg: dm-0) device node for this device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -2879,24 +2880,24 @@ class NoDevice(StorageDevice): def probe(self): """ Probe for any missing information about this device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) def setup(self, intf=None): """ Open, or set up, a device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) def teardown(self, recursive=False): """ Close, or tear down, a device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) def create(self, intf=None): """ Create the device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) self.setupParents() def destroy(self): """ Destroy the device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) class FileDevice(StorageDevice): @@ -2966,7 +2967,7 @@ class FileDevice(StorageDevice): def create(self, intf=None): """ Create the device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if self.exists: raise DeviceError("device already exists", self.name) @@ -2991,7 +2992,7 @@ class FileDevice(StorageDevice): def destroy(self): """ Destroy the device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -3008,7 +3009,7 @@ class DirectoryDevice(FileDevice): def create(self): """ Create the device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if self.exists: raise DeviceError("device already exists", self.name) @@ -3023,7 +3024,7 @@ class DirectoryDevice(FileDevice): def destroy(self): """ Destroy the device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -3097,7 +3098,7 @@ class OpticalDevice(StorageDevice): """ Return a boolean indicating whether or not the device contains media. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -3117,7 +3118,7 @@ class OpticalDevice(StorageDevice): """ Eject the drawer. """ import _isys - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) if not self.exists: raise DeviceError("device has not been created", self.name) @@ -3196,20 +3197,20 @@ class NFSDevice(StorageDevice, NetworkStorageDevice): def setup(self, intf=None): """ Open, or set up, a device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) def teardown(self, recursive=None): """ Close, or tear down, a device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) def create(self, intf=None): """ Create the device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) self.createParents() self.setupParents() def destroy(self): """ Destroy the device. """ - log_method_call(self, self.name, status=self.status) + logStorageMethodCall(self, self.name, status=self.status) diff --git a/storage/devicetree.py b/storage/devicetree.py index 650ef96..453ae8a 100644 --- a/storage/devicetree.py +++ b/storage/devicetree.py @@ -35,7 +35,7 @@ import devicelibs.mdraid import devicelibs.dm import devicelibs.lvm from udev import * -from iutil import log_method_call +from .storage_log import logStorageMethodCall import gettext _ = lambda x: gettext.ldgettext("anaconda", x) @@ -976,7 +976,7 @@ class DeviceTree(object): def addUdevDMDevice(self, info): name = udev_device_get_name(info) - log_method_call(self, name=name) + logStorageMethodCall(self, name=name) uuid = udev_device_get_uuid(info) sysfs_path = udev_device_get_sysfs_path(info) device = None @@ -1050,7 +1050,7 @@ class DeviceTree(object): def addUdevMDDevice(self, info): name = udev_device_get_name(info) - log_method_call(self, name=name) + logStorageMethodCall(self, name=name) uuid = udev_device_get_uuid(info) sysfs_path = udev_device_get_sysfs_path(info) device = None @@ -1108,7 +1108,7 @@ class DeviceTree(object): def addUdevPartitionDevice(self, info, disk=None): name = udev_device_get_name(info) - log_method_call(self, name=name) + logStorageMethodCall(self, name=name) uuid = udev_device_get_uuid(info) sysfs_path = udev_device_get_sysfs_path(info) device = None @@ -1162,7 +1162,7 @@ class DeviceTree(object): def addUdevDiskDevice(self, info): name = udev_device_get_name(info) - log_method_call(self, name=name) + logStorageMethodCall(self, name=name) uuid = udev_device_get_uuid(info) sysfs_path = udev_device_get_sysfs_path(info) serial = udev_device_get_serial(info) @@ -1221,7 +1221,7 @@ class DeviceTree(object): return device def addUdevOpticalDevice(self, info): - log_method_call(self) + logStorageMethodCall(self) # XXX should this be RemovableDevice instead? # # Looks like if it has ID_INSTANCE=0:1 we can ignore it. @@ -1235,7 +1235,7 @@ class DeviceTree(object): def addUdevDevice(self, info): # FIXME: this should be broken up into more discrete chunks name = udev_device_get_name(info) - log_method_call(self, name=name) + logStorageMethodCall(self, name=name) uuid = udev_device_get_uuid(info) sysfs_path = udev_device_get_sysfs_path(info) @@ -1326,7 +1326,7 @@ class DeviceTree(object): self.handleUdevDeviceFormat(info, device) def handleUdevDiskLabelFormat(self, info, device): - log_method_call(self, device=device.name) + logStorageMethodCall(self, device=device.name) if device.format.type == "disklabel": # this device is already set up log.debug("disklabel format on %s already set up" % device.name) @@ -1406,7 +1406,7 @@ class DeviceTree(object): device.format = format def handleUdevLUKSFormat(self, info, device): - log_method_call(self, name=device.name, type=device.format.type) + logStorageMethodCall(self, name=device.name, type=device.format.type) if not device.format.uuid: log.info("luks device %s has no uuid" % device.path) return @@ -1439,7 +1439,7 @@ class DeviceTree(object): % device.format.mapName) def handleUdevLVMPVFormat(self, info, device): - log_method_call(self, name=device.name, type=device.format.type) + logStorageMethodCall(self, name=device.name, type=device.format.type) # lookup/create the VG and LVs try: vg_name = udev_device_get_vg_name(info) @@ -1558,7 +1558,7 @@ class DeviceTree(object): % (lv_device.name, msg)) def handleUdevMDMemberFormat(self, info, device): - log_method_call(self, name=device.name, type=device.format.type) + logStorageMethodCall(self, name=device.name, type=device.format.type) # either look up or create the array device name = udev_device_get_name(info) sysfs_path = udev_device_get_sysfs_path(info) @@ -1617,7 +1617,7 @@ class DeviceTree(object): self._addDevice(md_array) def handleMultipathMemberFormat(self, info, device): - log_method_call(self, name=device.name, type=device.format.type) + logStorageMethodCall(self, name=device.name, type=device.format.type) serial = udev_device_get_serial(info) found = False @@ -1630,7 +1630,7 @@ class DeviceTree(object): self.__multipaths[serial] = mp def handleUdevDMRaidMemberFormat(self, info, device): - log_method_call(self, name=device.name, type=device.format.type) + logStorageMethodCall(self, name=device.name, type=device.format.type) name = udev_device_get_name(info) sysfs_path = udev_device_get_sysfs_path(info) uuid = udev_device_get_uuid(info) @@ -1693,7 +1693,7 @@ class DeviceTree(object): # major=major, minor=minor, uuid=uuid, name=name) def handleUdevDeviceFormat(self, info, device): - log_method_call(self, name=getattr(device, "name", None)) + logStorageMethodCall(self, name=getattr(device, "name", None)) log.debug("%s" % info) name = udev_device_get_name(info) sysfs_path = udev_device_get_sysfs_path(info) diff --git a/storage/formats/__init__.py b/storage/formats/__init__.py index ab33211..ed6d966 100644 --- a/storage/formats/__init__.py +++ b/storage/formats/__init__.py @@ -22,7 +22,8 @@ import os -from iutil import notify_kernel, get_sysfs_path_by_name, log_method_call +from iutil import notify_kernel, get_sysfs_path_by_name +from ..storage_log import logStorageMethodCall from ..errors import * from ..devicelibs.dm import dm_node_from_name @@ -205,11 +206,11 @@ class DeviceFormat(object): return self._type def probe(self): - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) def notifyKernel(self): - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type) if not self.device: return @@ -231,7 +232,7 @@ class DeviceFormat(object): def create(self, *args, **kwargs): - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) # allow late specification of device path device = kwargs.get("device") @@ -242,7 +243,7 @@ class DeviceFormat(object): raise FormatCreateError("invalid device specification", self.device) def destroy(self, *args, **kwargs): - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) # zero out the 1MB at the beginning and end of the device in the # hope that it will wipe any metadata from filesystems that @@ -273,7 +274,7 @@ class DeviceFormat(object): self.exists = False def setup(self, *args, **kwargs): - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) if not self.exists: @@ -291,7 +292,7 @@ class DeviceFormat(object): raise FormatSetupError("invalid device specification") def teardown(self, *args, **kwargs): - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) @property diff --git a/storage/formats/disklabel.py b/storage/formats/disklabel.py index faf04f4..3213c88 100644 --- a/storage/formats/disklabel.py +++ b/storage/formats/disklabel.py @@ -23,7 +23,7 @@ import os import copy -from iutil import log_method_call +from ..storage_log import logStorageMethodCall import parted import _ped import platform @@ -54,7 +54,7 @@ class DiskLabel(DeviceFormat): exists -- indicates whether this is an existing format """ - log_method_call(self, *args, **kwargs) + logStorageMethodCall(self, *args, **kwargs) DeviceFormat.__init__(self, *args, **kwargs) self._size = None @@ -86,12 +86,12 @@ class DiskLabel(DeviceFormat): def resetPartedDisk(self): """ Set this instance's partedDisk to reflect the disk's contents. """ - log_method_call(self, device=self.device) + logStorageMethodCall(self, device=self.device) self._partedDisk = self._origPartedDisk def freshPartedDisk(self): """ Return a new, empty parted.Disk instance for this device. """ - log_method_call(self, device=self.device) + logStorageMethodCall(self, device=self.device) platf = platform.getPlatform(None) labelType = platf.diskLabelType(self.partedDevice.type) return parted.freshDisk(device=self.partedDevice, ty=labelType) @@ -152,7 +152,7 @@ class DiskLabel(DeviceFormat): def setup(self, *args, **kwargs): """ Open, or set up, a device. """ - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) if not self.exists: raise DeviceFormatError("format has not been created") @@ -164,14 +164,14 @@ class DiskLabel(DeviceFormat): def teardown(self, *args, **kwargs): """ Close, or tear down, a device. """ - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) if not self.exists: raise DeviceFormatError("format has not been created") def create(self, *args, **kwargs): """ Create the device. """ - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) if self.exists: raise DeviceFormatError("format already exists") @@ -185,7 +185,7 @@ class DiskLabel(DeviceFormat): def destroy(self, *args, **kwargs): """ Wipe the disklabel from the device. """ - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) if not self.exists: raise DeviceFormatError("format does not exist") @@ -199,7 +199,7 @@ class DiskLabel(DeviceFormat): def commit(self): """ Commit the current partition table to disk and notify the OS. """ - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, numparts=len(self.partitions)) try: self.partedDisk.commit() @@ -210,7 +210,7 @@ class DiskLabel(DeviceFormat): def commitToDisk(self): """ Commit the current partition table to disk. """ - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, numparts=len(self.partitions)) try: self.partedDisk.commitToDevice() diff --git a/storage/formats/dmraid.py b/storage/formats/dmraid.py index 5bdb7f6..496b121 100644 --- a/storage/formats/dmraid.py +++ b/storage/formats/dmraid.py @@ -20,7 +20,7 @@ # Red Hat Author(s): Dave Lehman <dlehman@xxxxxxxxxx> # -from iutil import log_method_call +from ..storage_log import logStorageMethodCall from flags import flags from ..errors import * from . import DeviceFormat, register_device_format @@ -70,7 +70,7 @@ class DMRaidMember(DeviceFormat): On initialization this format is like DeviceFormat """ - log_method_call(self, *args, **kwargs) + logStorageMethodCall(self, *args, **kwargs) DeviceFormat.__init__(self, *args, **kwargs) # Initialize the attribute that will hold the block object. @@ -86,12 +86,12 @@ class DMRaidMember(DeviceFormat): lambda d,r: d._setRaidmem(r)) def create(self, *args, **kwargs): - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) raise DMRaidMemberError("creation of dmraid members is non-sense") def destroy(self, *args, **kwargs): - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) raise DMRaidMemberError("destruction of dmraid members is non-sense") diff --git a/storage/formats/fs.py b/storage/formats/fs.py index 12f624f..e23c753 100644 --- a/storage/formats/fs.py +++ b/storage/formats/fs.py @@ -37,9 +37,7 @@ from . import DeviceFormat, register_device_format import iutil from flags import flags from parted import fileSystemType - -# is this nasty? -log_method_call = iutil.log_method_call +from ..storage_log import logStorageMethodCall import logging log = logging.getLogger("storage") @@ -301,7 +299,7 @@ class FS(DeviceFormat): options -- list of options to pass to mkfs """ - log_method_call(self, type=self.mountType, device=self.device, + logStorageMethodCall(self, type=self.mountType, device=self.device, mountpoint=self.mountpoint) intf = kwargs.get("intf") @@ -711,7 +709,7 @@ class FS(DeviceFormat): @property def supported(self): - log_method_call(self, supported=self._supported) + logStorageMethodCall(self, supported=self._supported) return self._supported and self.utilsAvailable @property diff --git a/storage/formats/luks.py b/storage/formats/luks.py index 668e689..d74522c 100644 --- a/storage/formats/luks.py +++ b/storage/formats/luks.py @@ -29,7 +29,7 @@ try: except ImportError: volume_key = None -from iutil import log_method_call +from ..storage_log import logStorageMethodCall from ..errors import * from ..devicelibs import crypto from . import DeviceFormat, register_device_format @@ -68,7 +68,7 @@ class LUKS(DeviceFormat): escrow_cert -- certificate to use for key escrow add_backup_passphrase -- generate a backup passphrase? """ - log_method_call(self, *args, **kwargs) + logStorageMethodCall(self, *args, **kwargs) DeviceFormat.__init__(self, *args, **kwargs) self.cipher = kwargs.get("cipher") self.key_size = kwargs.get("key_size") @@ -132,7 +132,7 @@ class LUKS(DeviceFormat): def setup(self, *args, **kwargs): """ Open, or set up, the format. """ - log_method_call(self, device=self.device, mapName=self.mapName, + logStorageMethodCall(self, device=self.device, mapName=self.mapName, type=self.type, status=self.status) if not self.configured: raise LUKSError("luks device not configured") @@ -147,7 +147,7 @@ class LUKS(DeviceFormat): def teardown(self, *args, **kwargs): """ Close, or tear down, the format. """ - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) if not self.exists: raise LUKSError("format has not been created") @@ -158,7 +158,7 @@ class LUKS(DeviceFormat): def create(self, *args, **kwargs): """ Create the format. """ - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) if not self.hasKey: raise LUKSError("luks device has no key/passphrase") @@ -177,7 +177,7 @@ class LUKS(DeviceFormat): def destroy(self, *args, **kwargs): """ Create the format. """ - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) self.teardown() DeviceFormat.destroy(self, *args, **kwargs) @@ -193,7 +193,7 @@ class LUKS(DeviceFormat): Add the contents of the specified key file to an available key slot in the LUKS header. """ - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status, file=keyfile) if not self.exists: raise LUKSError("format has not been created") @@ -209,7 +209,7 @@ class LUKS(DeviceFormat): Add the specified passphrase to an available key slot in the LUKS header. """ - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) if not self.exists: raise LUKSError("format has not been created") @@ -225,7 +225,7 @@ class LUKS(DeviceFormat): Remove key contained in the specified key file from the LUKS header. """ - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status, file=keyfile) if not self.exists: raise LUKSError("format has not been created") @@ -238,7 +238,7 @@ class LUKS(DeviceFormat): def removePassphrase(self, passphrase): """ Remove the specified passphrase from the LUKS header. """ - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) if not self.exists: raise LUKSError("format has not been created") diff --git a/storage/formats/lvmpv.py b/storage/formats/lvmpv.py index faec109..f90a8eb 100644 --- a/storage/formats/lvmpv.py +++ b/storage/formats/lvmpv.py @@ -22,7 +22,7 @@ import os -from iutil import log_method_call +from ..storage_log import logStorageMethodCall from parted import PARTITION_LVM from ..errors import * from ..devicelibs import lvm @@ -59,7 +59,7 @@ class LVMPhysicalVolume(DeviceFormat): exists -- indicates whether this is an existing format """ - log_method_call(self, *args, **kwargs) + logStorageMethodCall(self, *args, **kwargs) DeviceFormat.__init__(self, *args, **kwargs) self.vgName = kwargs.get("vgName") self.vgUuid = kwargs.get("vgUuid") @@ -69,7 +69,7 @@ class LVMPhysicalVolume(DeviceFormat): def probe(self): """ Probe for any missing information about this device. """ - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) if not self.exists: raise PhysicalVolumeError("format has not been created") @@ -80,7 +80,7 @@ class LVMPhysicalVolume(DeviceFormat): def create(self, *args, **kwargs): """ Create the format. """ - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) DeviceFormat.create(self, *args, **kwargs) # Consider use of -Z|--zero @@ -96,7 +96,7 @@ class LVMPhysicalVolume(DeviceFormat): def destroy(self, *args, **kwargs): """ Destroy the format. """ - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) if not self.exists: raise PhysicalVolumeError("format has not been created") diff --git a/storage/formats/mdraid.py b/storage/formats/mdraid.py index 3cc9c2b..10e7766 100644 --- a/storage/formats/mdraid.py +++ b/storage/formats/mdraid.py @@ -22,7 +22,7 @@ import os -from iutil import log_method_call +from ..storage_log import logStorageMethodCall from flags import flags from parted import PARTITION_RAID from ..errors import * @@ -58,7 +58,7 @@ class MDRaidMember(DeviceFormat): exists -- indicates whether this is an existing format """ - log_method_call(self, *args, **kwargs) + logStorageMethodCall(self, *args, **kwargs) DeviceFormat.__init__(self, *args, **kwargs) self.mdUuid = kwargs.get("mdUuid") self.raidMinor = None @@ -67,7 +67,7 @@ class MDRaidMember(DeviceFormat): def probe(self): """ Probe for any missing information about this format. """ - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) if not self.exists: raise MDMemberError("format does not exist") diff --git a/storage/formats/multipath.py b/storage/formats/multipath.py index fe2702e..99bd51b 100644 --- a/storage/formats/multipath.py +++ b/storage/formats/multipath.py @@ -24,7 +24,7 @@ # Red Hat Author(s): Peter Jones <pjones@xxxxxxxxxx> # -from iutil import log_method_call +from ..storage_log import logStorageMethodCall from ..errors import * from . import DeviceFormat, register_device_format @@ -60,7 +60,7 @@ class MultipathMember(DeviceFormat): On initialization this format is like DeviceFormat """ - log_method_call(self, *args, **kwargs) + logStorageMethodCall(self, *args, **kwargs) DeviceFormat.__init__(self, *args, **kwargs) # Initialize the attribute that will hold the block object. @@ -76,12 +76,12 @@ class MultipathMember(DeviceFormat): lambda s,m: s._setMember(m)) def create(self, *args, **kwargs): - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) raise MultipathMemberError("creation of multipath members is non-sense") def destroy(self, *args, **kwargs): - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) raise MultipathMemberError("destruction of multipath members is non-sense") diff --git a/storage/formats/swap.py b/storage/formats/swap.py index b1f0d62..305596e 100644 --- a/storage/formats/swap.py +++ b/storage/formats/swap.py @@ -20,11 +20,12 @@ # Red Hat Author(s): Dave Lehman <dlehman@xxxxxxxxxx> # -from iutil import log_method_call, numeric_type +from iutil import numeric_type from parted import PARTITION_SWAP, fileSystemType from ..errors import * from ..devicelibs import swap from . import DeviceFormat, register_device_format +from ..storage_log import logStorageMethodCall import gettext _ = lambda x: gettext.ldgettext("anaconda", x) @@ -56,7 +57,7 @@ class SwapSpace(DeviceFormat): exists -- indicates whether this is an existing format """ - log_method_call(self, *args, **kwargs) + logStorageMethodCall(self, *args, **kwargs) DeviceFormat.__init__(self, *args, **kwargs) self.priority = kwargs.get("priority") @@ -108,7 +109,7 @@ class SwapSpace(DeviceFormat): def setup(self, *args, **kwargs): """ Open, or set up, a device. """ - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) if not self.exists: raise SwapSpaceError("format has not been created") @@ -121,7 +122,7 @@ class SwapSpace(DeviceFormat): def teardown(self, *args, **kwargs): """ Close, or tear down, a device. """ - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) if not self.exists: raise SwapSpaceError("format has not been created") @@ -131,7 +132,7 @@ class SwapSpace(DeviceFormat): def create(self, *args, **kwargs): """ Create the device. """ - log_method_call(self, device=self.device, + logStorageMethodCall(self, device=self.device, type=self.type, status=self.status) force = kwargs.get("force") diff --git a/storage/storage_log.py b/storage/storage_log.py index a771154..2572778 100644 --- a/storage/storage_log.py +++ b/storage/storage_log.py @@ -1,5 +1,22 @@ import logging +import inspect +logger = logging.getLogger("storage") + +def logStorageMethodCall(d, *args, **kwargs): + classname = d.__class__.__name__ + methodname = inspect.stack()[1][3] + fmt = "%s.%s:" + fmt_args = [classname, methodname] + for arg in args: + fmt += " %s ;" + fmt_args.append(arg) + + for k, v in kwargs.items(): + fmt += " %s: %s ;" + fmt_args.extend([k, v]) + + logger.debug(fmt % tuple(fmt_args)) #handler = logging.StreamHandler() file_handler = logging.FileHandler("/tmp/storage.log") @@ -9,9 +26,6 @@ file_handler.setFormatter(formatter) tty3_handler = logging.FileHandler("/dev/tty3") tty3_handler.setFormatter(formatter) -logger = logging.getLogger("storage") logger.addHandler(file_handler) logger.addHandler(tty3_handler) logger.setLevel(logging.DEBUG) - - -- 1.6.2.5 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list