[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[booty rhel5-branch 1/2] Do not duplicate getDiskPart() everywhere.
- From: Ales Kozumplik <akozumpl redhat com>
- To: anaconda-devel-list redhat com
- Subject: [booty rhel5-branch 1/2] Do not duplicate getDiskPart() everywhere.
- Date: Wed, 2 Mar 2011 16:51:56 +0100
Related: rhbz#572862
---
bootloaderInfo.py | 35 ++---------------------------------
bootyutil.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
checkbootloader.py | 35 +----------------------------------
3 files changed, 51 insertions(+), 67 deletions(-)
create mode 100644 bootyutil.py
diff --git a/bootloaderInfo.py b/bootloaderInfo.py
index bca1321..245b4f5 100644
--- a/bootloaderInfo.py
+++ b/bootloaderInfo.py
@@ -32,6 +32,8 @@ import rhpl.executil
import booty
import checkbootloader
+from bootyutil import getDiskPart
+
if rhpl.getArch() not in ("s390", "s390x"):
import block
@@ -2041,39 +2043,6 @@ class sparcBootloaderInfo(bootloaderInfo):
###############
# end of boot loader objects... these are just some utility functions used
-# return (disk, partition number) eg ('hda', 1)
-def getDiskPart(dev):
- cut = len(dev)
- if dev[-1] in string.digits:
- if (dev.startswith('rd/') or dev.startswith('ida/') or
- dev.startswith('cciss/') or dev.startswith('sx8/') or
- dev.startswith('mapper/')):
- if dev[-2] == 'p':
- cut = -1
- elif dev[-3] == 'p' and dev[-2] in string.digits:
- cut = -2
- else:
- if dev[-2] in string.digits:
- cut = -2
- else:
- cut = -1
-
- name = dev[:cut]
-
- # hack off the trailing 'p' from /dev/cciss/*, for example
- if name[-1] == 'p':
- for letter in name:
- if letter not in string.letters and letter != "/":
- name = name[:-1]
- break
-
- if cut < 0:
- partNum = int(dev[cut:]) - 1
- else:
- partNum = None
-
- return (name, partNum)
-
# hackery to determine if we should do root=LABEL=/ or whatnot
# as usual, knows too much about anaconda
def getRootDevName(initrd, fsset, rootDev, instRoot):
diff --git a/bootyutil.py b/bootyutil.py
new file mode 100644
index 0000000..cbfab5c
--- /dev/null
+++ b/bootyutil.py
@@ -0,0 +1,48 @@
+#
+# bootyutil.py: functions commonly used by various booty and anaconda modules
+#
+# Copyright 2011 Red Hat, Inc.
+#
+# This software may be freely redistributed under the terms of the GNU
+# library public license.
+#
+# You should have received a copy of the GNU Library Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+#
+
+import string
+
+# return (disk, partition number) eg ('hda', 1)
+def getDiskPart(dev):
+ cut = len(dev)
+ if dev[-1] in string.digits:
+ if (dev.startswith('rd/') or dev.startswith('ida/') or
+ dev.startswith('cciss/') or dev.startswith('sx8/') or
+ dev.startswith('mapper/')):
+ if dev[-2] == 'p':
+ cut = -1
+ elif dev[-3] == 'p' and dev[-2] in string.digits:
+ cut = -2
+ else:
+ if dev[-2] in string.digits:
+ cut = -2
+ else:
+ cut = -1
+
+ name = dev[:cut]
+
+ # hack off the trailing 'p' from /dev/cciss/*, for example
+ if name[-1] == 'p':
+ for letter in name:
+ if letter not in string.letters and letter != "/":
+ name = name[:-1]
+ break
+
+ if cut < 0:
+ partNum = int(dev[cut:]) - 1
+ else:
+ partNum = None
+
+ return (name, partNum)
diff --git a/checkbootloader.py b/checkbootloader.py
index 4b51056..512e880 100644
--- a/checkbootloader.py
+++ b/checkbootloader.py
@@ -23,40 +23,7 @@ liloConfigFile = "/etc/lilo.conf"
yabootConfigFile = "/etc/yaboot.conf"
siloConfigFile = "/etc/silo.conf"
-
-# XXX: this is cut and pasted directly from booty/bootloaderInfo.py
-# should eventually just go from there
-def getDiskPart(dev):
- """Return (disk, partition number) tuple for dev"""
- cut = len(dev)
- if (dev[:3] == "rd/" or dev[:4] == "ida/" or
- dev[:6] == "cciss/"):
- if dev[-2] == 'p':
- cut = -1
- elif dev[-3] == 'p':
- cut = -2
- else:
- if dev[-2] in string.digits:
- cut = -2
- elif dev[-1] in string.digits:
- cut = -1
-
- name = dev[:cut]
-
- # hack off the trailing 'p' from /dev/cciss/*, for example
- if name[-1] == 'p':
- for letter in name:
- if letter not in string.letters and letter != "/":
- name = name[:-1]
- break
-
- if cut < 0:
- partNum = int(dev[cut:]) - 1
- else:
- partNum = None
-
- return (name, partNum)
-
+from bootyutil import getDiskPart
def getRaidDisks(raidDevice, raidLevel=None, stripPart=1):
rc = []
--
1.7.3.3
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]