[PATCH] Use the pyblock functions when possible.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* storage/devicelibs/dm.py : For each function that is used in the
  storage code, we try to use pyblock first.  We fail to calling
  dmsetup.
* storage/devices.py : Erased the commented line that had the
  pyblock call.  We are doing all the pyblock calls from
  storage/devicelibs/dm.py.
* storage/devicetree.py : likewise.
* storage/formats/dmraid.py : likewise.
---
 storage/devicelibs/dm.py  |    9 +++++++++
 storage/devices.py        |    2 --
 storage/devicetree.py     |    2 --
 storage/formats/dmraid.py |    1 -
 4 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/storage/devicelibs/dm.py b/storage/devicelibs/dm.py
index 74d8228..d3f5b4b 100644
--- a/storage/devicelibs/dm.py
+++ b/storage/devicelibs/dm.py
@@ -22,6 +22,7 @@
 
 import os
 
+import block
 import iutil
 from ..errors import *
 
@@ -32,6 +33,10 @@ import logging
 log = logging.getLogger("storage")
 
 def name_from_dm_node(dm_node):
+    name = block.getNameFromDmNode(dm_node)
+    if name not None:
+        return name
+
     st = os.stat("/dev/%s" % dm_node)
     major = os.major(st.st_rdev)
     minor = os.minor(st.st_rdev)
@@ -44,6 +49,10 @@ def name_from_dm_node(dm_node):
     return name.strip()
 
 def dm_node_from_name(map_name):
+    dm_node = block.getDmNodeFromName(map_name)
+    if dm_node not None:
+        return dm_node
+
     devnum = iutil.execWithCapture("dmsetup",
                                    ["info", "--columns",
                                     "--noheadings",
diff --git a/storage/devices.py b/storage/devices.py
index 8dc20c1..3e2ae10 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -98,7 +98,6 @@ import math
 # device backend modules
 from devicelibs import mdraid
 from devicelibs import lvm
-#import block
 from devicelibs import dm
 import parted
 import _ped
@@ -1230,7 +1229,6 @@ class DMDevice(StorageDevice):
             raise DeviceError("device has not been created")
 
         return dm.dm_node_from_name(self.name)
-        #return block.getDmNodeFromName(self.name)
 
     def _setName(self, name):
         """ Set the device's map name. """
diff --git a/storage/devicetree.py b/storage/devicetree.py
index 2a9d62e..f110b19 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -674,7 +674,6 @@ class DeviceTree(object):
                 for slave_name in slave_names:
                     # if it's a dm-X name, resolve it to a map name first
                     if slave_name.startswith("dm-"):
-                        #slave_name = block.getNameFromDmNode(slave_name)
                         slave_name = dm.name_from_dm_node(slave_name)
                     slave_dev = self.getDeviceByName(slave_name)
                     if slave_dev:
@@ -728,7 +727,6 @@ class DeviceTree(object):
                 for slave_name in slave_names:
                     # if it's a dm-X name, resolve it to a map name
                     if slave_name.startswith("dm-"):
-                        #slave_name = block.getNameFromDmNode(slave_name)
                         slave_name = dm.name_from_dm_node(slave_name)
                     slave_dev = self.getDeviceByName(slave_name)
                     if slave_dev:
diff --git a/storage/formats/dmraid.py b/storage/formats/dmraid.py
index ef80902..f5f2808 100644
--- a/storage/formats/dmraid.py
+++ b/storage/formats/dmraid.py
@@ -23,7 +23,6 @@
 import block
 
 from iutil import log_method_call
-#from dm import dm_node_from_name
 from ..errors import *
 from . import DeviceFormat, register_device_format
 
-- 
1.6.0.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux