def majorminor(self): """A string suitable for using as a pseudo-unique ID in kickstart.""" if not self._majorminor: # If this is a device-mapper device, we have to get the DM node and # build the sysfs path from that. try: device = dm_node_from_name(os.path.basename(self.device)) except DMError: device = self.device try: sysfs_path = get_sysfs_path_by_name(device) except RuntimeError: raise StorageError("DeviceFormat.majorminor: " "can not get majorminor for '%s'" % device) dev = udev_get_device(sysfs_path[4:]) self._majorminor = "%03d%03d" %\ (udev_device_get_major(dev), udev_device_get_minor(dev)) return self._majorminor
def notifyKernel(self): log_method_call(self, device=self.device, type=self.type) if not self.device: return if self.device.startswith("/dev/mapper/"): try: name = dm_node_from_name(os.path.basename(self.device)) except DMError: log.warning("failed to get dm node for %s" % self.device) return else: name = self.device path = get_sysfs_path_by_name(name) try: notify_kernel(path, action="change") except (ValueError, IOError) as e: log.warning("failed to notify kernel of change: %s" % e)
def notifyKernel(self): log_method_call(self, device=self.device, type=self.type) if not self.device: return if self.device.startswith("/dev/mapper/"): try: name = dm_node_from_name(os.path.basename(self.device)) except Exception, e: log.warning("failed to get dm node for %s" % self.device) return else: name = self.device path = get_sysfs_path_by_name(name) try: notify_kernel(path, action="change") except Exception, e: log.warning("failed to notify kernel of change: %s" % e) def cacheMajorminor(self): """ Cache the value of self.majorminor. Once a device node of this format's device disappears (for instance after a teardown), it is no longer possible to figure out the value of self.majorminor pseudo-unique string. Call this method before that happens for caching this. """ self._majorminor = None try: