From 9c63f34ce2e8ec337e6d7194af08f496cea7983b Mon Sep 17 00:00:00 2001
From: David Lehman <dlehman@redhat.com>
Date: Tue, 5 Aug 2014 12:39:56 -0500
Subject: [PATCH 05/14] Stop generating change uevents from blivet.

The various tools making the actual changes should be generating them.
---
 blivet/devices.py          | 17 -----------------
 blivet/formats/__init__.py | 27 ---------------------------
 blivet/formats/fs.py       |  4 ----
 blivet/formats/luks.py     |  2 --
 blivet/formats/lvmpv.py    |  2 --
 blivet/formats/swap.py     |  1 -
 6 files changed, 53 deletions(-)

diff --git a/blivet/devices.py b/blivet/devices.py
index 5f70637..9ef4356 100644
--- a/blivet/devices.py
+++ b/blivet/devices.py
@@ -780,23 +780,6 @@ class StorageDevice(Device):
                 (self.format.type is None or self.format.resizable or
                  not self.format.exists))
 
-    def notifyKernel(self):
-        """ Send a 'change' uevent to the kernel for this device. """
-        log_method_call(self, self.name, status=self.status)
-        if not self.exists:
-            log.debug("not sending change uevent for non-existent device")
-            return
-
-        if not self.status:
-            log.debug("not sending change uevent for inactive device")
-            return
-
-        path = os.path.normpath(self.sysfsPath)
-        try:
-            util.notify_kernel(path, action="change")
-        except (ValueError, IOError) as e:
-            log.warning("failed to notify kernel of change: %s", e)
-
     @property
     def fstabSpec(self):
         spec = self.path
diff --git a/blivet/formats/__init__.py b/blivet/formats/__init__.py
index 70280e8..e95165b 100644
--- a/blivet/formats/__init__.py
+++ b/blivet/formats/__init__.py
@@ -315,33 +315,6 @@ class DeviceFormat(ObjectID):
     def type(self):
         return self._type
 
-    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
-        elif self.device.startswith("/dev/md/"):
-            try:
-                name = md_node_from_name(os.path.basename(self.device))
-            except MDRaidError:
-                log.warning("failed to get md 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 create(self, **kwargs):
         """ Write the formatting to the specified block device.
 
diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py
index 9131a3e..a7428ef 100644
--- a/blivet/formats/fs.py
+++ b/blivet/formats/fs.py
@@ -399,7 +399,6 @@ class FS(DeviceFormat):
             raise FormatCreateError("format failed: %s" % ret, self.device)
 
         self.exists = True
-        self.notifyKernel()
 
         if self.label is not None or not self.relabels():
             try:
@@ -456,7 +455,6 @@ class FS(DeviceFormat):
 
         # XXX must be a smarter way to do this
         self._size = self.targetSize
-        self.notifyKernel()
 
     def _getCheckArgs(self):
         argv = []
@@ -680,8 +678,6 @@ class FS(DeviceFormat):
         if rc:
             raise FSError("label failed")
 
-        self.notifyKernel()
-
     def _getRandomUUID(self):
         uuid = util.capture_output(["uuidgen"]).strip()
         return uuid
diff --git a/blivet/formats/luks.py b/blivet/formats/luks.py
index bcececb..f711bcd 100644
--- a/blivet/formats/luks.py
+++ b/blivet/formats/luks.py
@@ -229,8 +229,6 @@ class LUKS(DeviceFormat):
             if flags.installer_mode:
                 self.mapName = "luks-%s" % self.uuid
 
-            self.notifyKernel()
-
     def destroy(self, **kwargs):
         """ Remove the formatting from the associated block device.
 
diff --git a/blivet/formats/lvmpv.py b/blivet/formats/lvmpv.py
index a9d2801..abc0227 100644
--- a/blivet/formats/lvmpv.py
+++ b/blivet/formats/lvmpv.py
@@ -122,7 +122,6 @@ class LVMPhysicalVolume(DeviceFormat):
             lvm.pvscan(self.device)
 
         self.exists = True
-        self.notifyKernel()
 
     def destroy(self, **kwargs):
         """ Remove the formatting from the associated block device.
@@ -147,7 +146,6 @@ class LVMPhysicalVolume(DeviceFormat):
             lvm.pvscan(self.device)
 
         self.exists = False
-        self.notifyKernel()
 
     @property
     def status(self):
diff --git a/blivet/formats/swap.py b/blivet/formats/swap.py
index ce85a6a..f9acced 100644
--- a/blivet/formats/swap.py
+++ b/blivet/formats/swap.py
@@ -198,7 +198,6 @@ class SwapSpace(DeviceFormat):
             raise
         else:
             self.exists = True
-            self.notifyKernel()
 
 register_device_format(SwapSpace)
 
-- 
1.9.3

