[master] Strip lvm WARNING: lines from output (#1157864)
by Brian C. Lane
LVM has started including a pile of WARNING: lines in its output. These
need to be removed before the return value lvm() is used.
---
blivet/devicelibs/lvm.py | 41 ++++++++++++++++++++++++++---------------
1 file changed, 26 insertions(+), 15 deletions(-)
diff --git a/blivet/devicelibs/lvm.py b/blivet/devicelibs/lvm.py
index 09a4956..c521248 100644
--- a/blivet/devicelibs/lvm.py
+++ b/blivet/devicelibs/lvm.py
@@ -216,13 +216,22 @@ def is_valid_thin_pool_chunk_size(size, discard=False):
else:
return (size % LVM_THINP_MIN_CHUNK_SIZE == 0)
+def strip_lvm_warnings(buf):
+ """ Strip out lines starting with WARNING:
+
+ :param str buf: A string returned from lvm
+ :returns: A list of strings
+ :rtype: list
+ """
+ return [l for l in buf.splitlines() if l and not l.strip().startswith("WARNING:")]
+
def lvm(args, capture=False, ignore_errors=False):
""" Runs lvm with specified arguments.
:param bool capture: if True, return the output of the command.
:param bool ignore_errors: if True, do not raise LVMError on failure
- :returns: the output of the command or None
- :rtype: str or NoneType
+ :returns: list of strings from the output of the command or None
+ :rtype: list or NoneType
:raises: LVMError if command fails
"""
argv = ["lvm"] + args + _getConfigArgs(args)
@@ -230,7 +239,7 @@ def lvm(args, capture=False, ignore_errors=False):
if ret and not ignore_errors:
raise LVMError("running "+ " ".join(argv) + " failed")
if capture:
- return out
+ return strip_lvm_warnings(out)
def pvcreate(device):
# we force dataalignment=1024k since we cannot get lvm to tell us what
@@ -324,9 +333,9 @@ def pvinfo(device=None):
if device:
args.append(device)
- buf = lvm(args, capture=True, ignore_errors=True)
+ lines = lvm(args, capture=True, ignore_errors=True)
pvs = {}
- for line in buf.splitlines():
+ for line in lines:
info = parse_lvm_vars(line)
if len(info.keys()) != 11:
log.warning("ignoring pvs output line: %s", line)
@@ -421,8 +430,12 @@ def vginfo(vg_name):
"-o", "uuid,size,free,extent_size,extent_count,free_count,pv_count",
vg_name]
- buf = lvm(args, capture=True, ignore_errors=True)
- info = parse_lvm_vars(buf)
+ lines = lvm(args, capture=True, ignore_errors=True)
+ try:
+ info = parse_lvm_vars(lines[0])
+ except IndexError:
+ info = {}
+
if len(info.keys()) != 7:
raise LVMError(_("vginfo failed for %s") % vg_name)
@@ -444,9 +457,9 @@ def lvs(vg_name=None):
if vg_name:
args.append(vg_name)
- buf = lvm(args, capture=True, ignore_errors=True)
+ lines = lvm(args, capture=True, ignore_errors=True)
logvols = {}
- for line in buf.splitlines():
+ for line in lines:
info = parse_lvm_vars(line)
if len(info.keys()) != 6:
log.debug("ignoring lvs output line: %s", line)
@@ -461,10 +474,9 @@ def lvorigin(vg_name, lv_name):
args = ["lvs", "--noheadings", "-o", "origin"] + \
["%s/%s" % (vg_name, lv_name)]
- buf = lvm(args, capture=True, ignore_errors=True)
-
+ lines = lvm(args, capture=True, ignore_errors=True)
try:
- origin = buf.splitlines()[0].strip()
+ origin = lines[0].strip()
except IndexError:
origin = ''
@@ -608,10 +620,9 @@ def thinlvpoolname(vg_name, lv_name):
args = ["lvs", "--noheadings", "-o", "pool_lv"] + \
["%s/%s" % (vg_name, lv_name)]
- buf = lvm(args, capture=True, ignore_errors=True)
-
+ lines = lvm(args, capture=True, ignore_errors=True)
try:
- pool = buf.splitlines()[0].strip()
+ pool = lines[0].strip()
except IndexError:
pool = ''
--
1.9.3
9 years, 3 months
[anaconda][master][PATCH] Replace urlgrabber usage by python-requests
by Martin Kolman
Replace the Python 2-only urlgrabber with the Python 3 compatible (and much nicer ;-) )
python-requests library.
The requests API maps quite nicely to the stuff we did with urlgrabber and should
have the same end result & behavior as before.
The only potential mismatch I've found I found is in SSL certificate verification,
the urlgrabber API has two options - ssl_verify_host and ssl_verify_peer, while
request just have a single verify option. We used to set both options always to True
or to False with urlgrabber, so unless requests are skipping some verification urlgrabber
did, so this should be probably fine.
Certificate validation itself seem to work fine as far as I can tell - connections to
server with valid certificates work fine and servers with self-signed certificates raise
an exception.
Martin Kolman (1):
Replace python-urlgrabber with python-requests (#1141242)
anaconda.spec.in | 5 ++-
pyanaconda/kickstart.py | 13 +++++---
pyanaconda/packaging/__init__.py | 36 ++++++++++-----------
pyanaconda/packaging/livepayload.py | 64 ++++++++++++++++++++-----------------
4 files changed, 63 insertions(+), 55 deletions(-)
--
2.1.0
9 years, 3 months
[PATCH 1/2] Revert "Restrict payload kernel versions to kernels in the payload (#1074358)"
by David Shea
This reverts commit 850063aa6a19f87a6ffd6009e00f15c3418d1111.
This idea turned out to have some issues, such as not handling
kernel-core or kernel-debug packages.
---
pyanaconda/bootloader.py | 7 +-----
pyanaconda/packaging/__init__.py | 44 +++++++++++++++++++++++++++++--------
pyanaconda/packaging/dnfpayload.py | 7 ------
pyanaconda/packaging/livepayload.py | 34 ----------------------------
pyanaconda/packaging/tarpayload.py | 8 +++----
pyanaconda/packaging/yumpayload.py | 8 -------
6 files changed, 39 insertions(+), 69 deletions(-)
diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
index b017265..ac9ac5c 100644
--- a/pyanaconda/bootloader.py
+++ b/pyanaconda/bootloader.py
@@ -27,7 +27,6 @@ import re
import struct
import blivet
from parted import PARTITION_BIOS_GRUB
-from glob import glob
from pyanaconda import iutil
from blivet.devicelibs import raid
@@ -2388,11 +2387,7 @@ def writeBootLoader(storage, payload, instClass, ksdata):
return
# get a list of installed kernel packages
- # add whatever rescue kernels we can find to the end
- kernel_versions = list(payload.kernelVersionList)
- kernel_versions += glob(iutil.getSysroot() + "/boot/vmlinuz-*-rescue-*")
- kernel_versions += glob(iutil.getSysroot() + "/boot/efi/EFI/%s/vmlinuz-*-rescue-*" % instClass.efi_dir)
-
+ kernel_versions = payload.kernelVersionList + payload.rescueKernelList
if not kernel_versions:
log.warning("no kernel was installed -- boot loader config unchanged")
return
diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py
index 2438b6f..64985ac 100644
--- a/pyanaconda/packaging/__init__.py
+++ b/pyanaconda/packaging/__init__.py
@@ -72,15 +72,8 @@ from pyanaconda.product import productName, productVersion
import urlgrabber
urlgrabber.grabber.default_grabber.opts.user_agent = "%s (anaconda)/%s" %(productName, productVersion)
-from distutils.version import LooseVersion
-
REPO_NOT_SET = False
-def versionCmp(v1, v2):
- """ Compare two version number strings. """
-
- return LooseVersion(v1).__cmp__(LooseVersion(v2))
-
###
### ERROR HANDLING
###
@@ -135,6 +128,8 @@ class Payload(object):
self.data = data
self.storage = None
self.instclass = None
+ self._kernelVersionList = []
+ self._rescueVersionList = []
self.txID = None
def setup(self, storage, instClass):
@@ -307,6 +302,29 @@ class Payload(object):
self.data.packages.excludedGroupList.append(grp)
###
+ ### METHODS FOR WORKING WITH PACKAGES
+ ###
+ def _updateKernelVersionList(self):
+ try:
+ import yum
+ except ImportError:
+ cmpfunc = cmp
+ else:
+ cmpfunc = yum.rpmUtils.miscutils.compareVerOnly
+
+ files = glob(iutil.getSysroot() + "/boot/vmlinuz-*")
+ files.extend(glob(iutil.getSysroot() + "/boot/efi/EFI/%s/vmlinuz-*" % self.instclass.efi_dir))
+
+ versions = sorted((f.split("/")[-1][8:] for f in files if os.path.isfile(f)), cmp=cmpfunc)
+ log.debug("kernel versions: %s", versions)
+
+ # Store regular and rescue kernels separately
+ self._kernelVersionList = (
+ [v for v in versions if "-rescue-" not in v],
+ [v for v in versions if "-rescue-" in v]
+ )
+
+ ###
### METHODS FOR QUERYING STATE
###
@property
@@ -316,8 +334,16 @@ class Payload(object):
@property
def kernelVersionList(self):
- """ An iterable of the kernel versions installed by the payload. """
- raise NotImplementedError()
+ if not self._kernelVersionList:
+ self._updateKernelVersionList()
+
+ return self._kernelVersionList[0]
+
+ @property
+ def rescueKernelList(self):
+ # do re-scan if looking for rescue kernel
+ self._updateKernelVersionList()
+ return self._kernelVersionList[1]
##
## METHODS FOR TREE VERIFICATION
diff --git a/pyanaconda/packaging/dnfpayload.py b/pyanaconda/packaging/dnfpayload.py
index 6cea430..0fd3ac3 100644
--- a/pyanaconda/packaging/dnfpayload.py
+++ b/pyanaconda/packaging/dnfpayload.py
@@ -820,10 +820,3 @@ class DNFPayload(packaging.PackagePayload):
log.error(e)
super(DNFPayload, self).postInstall()
-
- @property
- def kernelVersionList(self):
- return ('%s-%s.%s' % (p.version, p.release, p.arch) for p in
- sorted(self._base.sack.query().filter(name='kernel'),
- cmp=dnf.rpm.miscutils.compareEVR,
- key=lambda p: (p.epoch, p.version, p.release)))
diff --git a/pyanaconda/packaging/livepayload.py b/pyanaconda/packaging/livepayload.py
index 615bb61..17c1bac 100644
--- a/pyanaconda/packaging/livepayload.py
+++ b/pyanaconda/packaging/livepayload.py
@@ -56,7 +56,6 @@ from blivet.size import Size
import blivet.util
from pyanaconda.threads import threadMgr, AnacondaThread
from pyanaconda.i18n import _
-from pyanaconda.packaging import versionCmp
class LiveImagePayload(ImagePayload):
""" A LivePayload copies the source image onto the target system. """
@@ -68,8 +67,6 @@ class LiveImagePayload(ImagePayload):
self.pct_lock = None
self.source_size = 1
- self._kernelVersionList = []
-
def setup(self, storage, instClass):
super(LiveImagePayload, self).setup(storage, instClass)
@@ -83,9 +80,6 @@ class LiveImagePayload(ImagePayload):
if rc != 0:
raise PayloadInstallError("Failed to mount the install tree")
- # Grab the kernel version list now so it's available after umount
- self._updateKernelVersionList()
-
source = iutil.eintr_retry_call(os.statvfs, INSTALL_TREE)
self.source_size = source.f_frsize * (source.f_blocks - source.f_bfree)
@@ -186,17 +180,6 @@ class LiveImagePayload(ImagePayload):
def spaceRequired(self):
return Size(iutil.getDirSize("/")*1024)
- def _updateKernelVersionList(self):
- files = glob.glob(INSTALL_TREE + "/boot/vmlinuz-*")
- files.extend(glob.glob(INSTALL_TREE + "/boot/efi/EFI/%s/vmlinuz-*" % self.instclass.efi_dir))
-
- self._kernelVersionList = sorted((f.split("/")[-1][8:] for f in files
- if os.path.isfile(f) and "-rescue-" not in f), cmp=versionCmp)
-
- @property
- def kernelVersionList(self):
- return self._kernelVersionList
-
class URLGrabberProgress(object):
""" Provide methods for urlgrabber progress."""
def start(self, filename, url, basename, size, text):
@@ -405,7 +388,6 @@ class LiveImageKSPayload(LiveImagePayload):
# Nothing more to mount
if not os.path.exists(INSTALL_TREE+"/LiveOS"):
- self._updateKernelVersionList()
return
# Mount the first .img in the directory on INSTALL_TREE
@@ -433,8 +415,6 @@ class LiveImageKSPayload(LiveImagePayload):
if errorHandler.cb(exn) == ERROR_RAISE:
raise exn
- self._updateKernelVersionList()
-
source = iutil.eintr_retry_call(os.statvfs, INSTALL_TREE)
self.source_size = source.f_frsize * (source.f_blocks - source.f_bfree)
@@ -513,17 +493,3 @@ class LiveImageKSPayload(LiveImagePayload):
return Size(self._min_size)
else:
return Size(1024*1024*1024)
-
- @property
- def kernelVersionList(self):
- # If it doesn't look like a tarfile use the super's kernelVersionList
- if not self.is_tarfile:
- return super(LiveImageKSPayload, self).kernelVersionList
-
- import tarfile
- with tarfile.open(self.image_path) as archive:
- names = archive.getnames()
-
- # Strip out vmlinuz- from the names
- return sorted((n.split("/")[-1][8:] for n in names if "boot/vmlinuz-" in n),
- cmp=versionCmp)
diff --git a/pyanaconda/packaging/tarpayload.py b/pyanaconda/packaging/tarpayload.py
index 805515d..b6328e0 100644
--- a/pyanaconda/packaging/tarpayload.py
+++ b/pyanaconda/packaging/tarpayload.py
@@ -36,7 +36,7 @@ except ImportError:
log.error("import of tarfile failed")
tarfile = None
-from pyanaconda.packaging import ArchivePayload, PayloadError, versionCmp
+from pyanaconda.packaging import ArchivePayload, PayloadError
from pyanaconda import iutil
# TarPayload is not yet fully implemented
@@ -73,10 +73,8 @@ class TarPayload(ArchivePayload):
@property
def kernelVersionList(self):
names = self.archive.getnames()
-
- # Strip out vmlinuz- from the names
- return sorted((n.split("/")[-1][8:] for n in names if "boot/vmlinuz-" in n),
- cmp=versionCmp)
+ kernels = [n for n in names if "boot/vmlinuz-" in n]
+ return kernels
def install(self):
try:
diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py
index 73caa49..742edad 100644
--- a/pyanaconda/packaging/yumpayload.py
+++ b/pyanaconda/packaging/yumpayload.py
@@ -988,14 +988,6 @@ reposdir=%s
else:
return environment.groups
- @property
- def kernelVersionList(self):
- with _yum_lock:
- return ("%s-%s.%s" % (p.version, p.release, p.arch) for p in
- sorted(self._yum.pkgSack.searchNames(['kernel']),
- cmp=yum.rpmUtils.miscutils.compareEVR,
- key=lambda p: (p.epoch, p.version, p.release)))
-
###
### METHODS FOR WORKING WITH GROUPS
###
--
2.1.0
9 years, 3 months
[rhel6-branch] Add new freebl libraries (#1182595)
by Brian C. Lane
Resolves: rhbz#1182595
---
scripts/upd-instroot | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/scripts/upd-instroot b/scripts/upd-instroot
index 68d7088..464ee33 100755
--- a/scripts/upd-instroot
+++ b/scripts/upd-instroot
@@ -294,6 +294,8 @@ $LIBDIR/dbus-1
$LIBDIR/libaio.so*
$LIBDIR/libfreebl3.so
$LIBDIR/libfreebl3.chk
+$LIBDIR/libfreeblpriv3.chk
+$LIBDIR/libfreeblpriv3.so
$LIBDIR/libmultipath.so*
$LIBDIR/libnss_dns*
$LIBDIR/libnss_files*
@@ -520,6 +522,8 @@ usr/$LIBDIR/libiscsi.so*
usr/$LIBDIR/libbsd.so*
usr/$LIBDIR/libfreebl3.so
usr/$LIBDIR/libfreebl3.chk
+usr/$LIBDIR/libfreeblpriv3.chk
+usr/$LIBDIR/libfreeblpriv3.so
usr/$LIBDIR/libmetacity-private.so*
usr/$LIBDIR/libsgutils2.so*
usr/$LIBDIR/libsoftokn3.so
--
1.9.3
9 years, 3 months
[master] Remove the unused indexed_dict module
by Vratislav Podzimek
Signed-off-by: Vratislav Podzimek <vpodzime(a)redhat.com>
---
old_tests/pyanaconda_test/indexed_dict_test.py | 49 --------------------------
pyanaconda/indexed_dict.py | 46 ------------------------
2 files changed, 95 deletions(-)
delete mode 100644 old_tests/pyanaconda_test/indexed_dict_test.py
delete mode 100644 pyanaconda/indexed_dict.py
diff --git a/old_tests/pyanaconda_test/indexed_dict_test.py b/old_tests/pyanaconda_test/indexed_dict_test.py
deleted file mode 100644
index 14185b6..0000000
--- a/old_tests/pyanaconda_test/indexed_dict_test.py
+++ /dev/null
@@ -1,49 +0,0 @@
-import mock
-
-class IndexedDictTest(mock.TestCase):
- def setUp(self):
- self.setupModules(['_isys'])
-
- def tearDown(self):
- self.tearDownModules()
-
- def instantiation_test(self):
- from pyanaconda.indexed_dict import IndexedDict
- d = IndexedDict()
- self.assertIsInstance(d, IndexedDict)
-
- def append_test(self):
- from pyanaconda.indexed_dict import IndexedDict
- d = IndexedDict()
- stored_data = [1, 2, 3]
- d["some_step"] = stored_data
- self.assertIs(d["some_step"], stored_data)
-
- def cant_append_test(self):
- from pyanaconda.indexed_dict import IndexedDict
- def assign_int(indexed_dict):
- indexed_dict[3] = [1, 2, 3]
- d = IndexedDict()
- self.assertRaises(TypeError, d.__setitem__, 3, [1, 2, 3])
-
- def referencing_test(self):
- from pyanaconda.indexed_dict import IndexedDict
- d = IndexedDict()
- d["first"] = 10
- d["second"] = 20
- d["third"] = 30
- self.assertEqual(d[0], 10)
- self.assertEqual(d[1], 20)
- self.assertEqual(d[2], 30)
- self.assertRaises(IndexError, d.__getitem__, 3)
-
- def index_test(self):
- from pyanaconda.indexed_dict import IndexedDict
- d = IndexedDict()
- d["first"] = 10
- d["second"] = 20
- d["third"] = 30
-
- self.assertEqual(d.index("first"), 0)
- self.assertEqual(d.index("second"), 1)
- self.assertEqual(d.index("third"), 2)
diff --git a/pyanaconda/indexed_dict.py b/pyanaconda/indexed_dict.py
deleted file mode 100644
index eb5050c..0000000
--- a/pyanaconda/indexed_dict.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# indexed_dict.py
-# Implements IndexedDictionary class.
-#
-# Copyright (C) 2009 Red Hat, Inc.
-#
-# This copyrighted material is made available to anyone wishing to use,
-# modify, copy, or redistribute it subject to the terms and conditions of
-# the GNU General Public License v.2, or (at your option) any later version.
-# This program is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY expressed or implied, including the implied warranties of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-# Public License for more details. You should have received a copy of the
-# GNU General Public License along with this program; if not, write to the
-# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
-# source code or documentation are not subject to the GNU General Public
-# License and may only be used or replicated with the express permission of
-# Red Hat, Inc.
-#
-
-class IndexedDict(dict):
- """ Indexed dictionary that remembers order of the inserted elements.
-
- Values can be inserted with string keys only, but referenced by both
- string keys or index.
-
- There's a unit test for the class, please maintain it along.
- """
- def __init__(self):
- super(IndexedDict, self).__init__()
- self._indexes = []
-
- def __getitem__(self, key):
- if type(key) is int:
- key = self._indexes[key]
- return super(IndexedDict, self).__getitem__(key)
-
- def __setitem__(self, key, value):
- if type(key) is int:
- raise TypeError("IndexedDict only accepts strings as new keys")
- assert(len(self) == len(self._indexes))
- self._indexes.append(key)
- return super(IndexedDict, self).__setitem__(key, value)
-
- def index(self, string_key):
- return self._indexes.index(string_key)
--
2.1.0
9 years, 3 months
[master] Fix issues with early exceptions in threads
by Vratislav Podzimek
Properly handling early exceptions from non-main threads is quite a pain. These
three patches make it a bit more straightforward and, what's even better,
working.
Vratislav Podzimek (3):
Move HW errors processing to the code that runs in the main thread
Add a method for waiting for error handling to finish
Use threadMgr to wait for exception handling to finish
pyanaconda/exception.py | 149 +++++++++++++++++++++---------------------
pyanaconda/threads.py | 11 ++++
pyanaconda/ui/gui/__init__.py | 6 +-
3 files changed, 89 insertions(+), 77 deletions(-)
--
2.1.0
9 years, 3 months
[PATCH] Restrict payload kernel versions to kernels in the payload (#1074358)
by David Shea
Remove the generic implementation of kernelVersionList from Payload.
Instead, have each payload return an iterable of the kernels that were
actually in the payload. Add a method to the packaging module to handle
version comparisons in the non-package payload types.
Remove rescueKernelList, since the bootloader was the only thing to use
this, so the bootloader can look for resuce kernels on its own.
---
pyanaconda/bootloader.py | 7 +++++-
pyanaconda/packaging/__init__.py | 44 ++++++++-----------------------------
pyanaconda/packaging/dnfpayload.py | 7 ++++++
pyanaconda/packaging/livepayload.py | 36 ++++++++++++++++++++++++++++++
pyanaconda/packaging/tarpayload.py | 8 +++++--
pyanaconda/packaging/yumpayload.py | 8 +++++++
6 files changed, 72 insertions(+), 38 deletions(-)
diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
index ac9ac5c..b017265 100644
--- a/pyanaconda/bootloader.py
+++ b/pyanaconda/bootloader.py
@@ -27,6 +27,7 @@ import re
import struct
import blivet
from parted import PARTITION_BIOS_GRUB
+from glob import glob
from pyanaconda import iutil
from blivet.devicelibs import raid
@@ -2387,7 +2388,11 @@ def writeBootLoader(storage, payload, instClass, ksdata):
return
# get a list of installed kernel packages
- kernel_versions = payload.kernelVersionList + payload.rescueKernelList
+ # add whatever rescue kernels we can find to the end
+ kernel_versions = list(payload.kernelVersionList)
+ kernel_versions += glob(iutil.getSysroot() + "/boot/vmlinuz-*-rescue-*")
+ kernel_versions += glob(iutil.getSysroot() + "/boot/efi/EFI/%s/vmlinuz-*-rescue-*" % instClass.efi_dir)
+
if not kernel_versions:
log.warning("no kernel was installed -- boot loader config unchanged")
return
diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py
index 64985ac..42fe959 100644
--- a/pyanaconda/packaging/__init__.py
+++ b/pyanaconda/packaging/__init__.py
@@ -72,8 +72,15 @@ from pyanaconda.product import productName, productVersion
import urlgrabber
urlgrabber.grabber.default_grabber.opts.user_agent = "%s (anaconda)/%s" %(productName, productVersion)
+from distutils.version import LooseVersion
+
REPO_NOT_SET = False
+def versionCmp(v1, v2):
+ """ Compare two version number strings. """
+
+ return LooseVersion(v1).__cmp__(LooseVersion(v2))
+
###
### ERROR HANDLING
###
@@ -128,8 +135,6 @@ class Payload(object):
self.data = data
self.storage = None
self.instclass = None
- self._kernelVersionList = []
- self._rescueVersionList = []
self.txID = None
def setup(self, storage, instClass):
@@ -302,29 +307,6 @@ class Payload(object):
self.data.packages.excludedGroupList.append(grp)
###
- ### METHODS FOR WORKING WITH PACKAGES
- ###
- def _updateKernelVersionList(self):
- try:
- import yum
- except ImportError:
- cmpfunc = cmp
- else:
- cmpfunc = yum.rpmUtils.miscutils.compareVerOnly
-
- files = glob(iutil.getSysroot() + "/boot/vmlinuz-*")
- files.extend(glob(iutil.getSysroot() + "/boot/efi/EFI/%s/vmlinuz-*" % self.instclass.efi_dir))
-
- versions = sorted((f.split("/")[-1][8:] for f in files if os.path.isfile(f)), cmp=cmpfunc)
- log.debug("kernel versions: %s", versions)
-
- # Store regular and rescue kernels separately
- self._kernelVersionList = (
- [v for v in versions if "-rescue-" not in v],
- [v for v in versions if "-rescue-" in v]
- )
-
- ###
### METHODS FOR QUERYING STATE
###
@property
@@ -334,16 +316,8 @@ class Payload(object):
@property
def kernelVersionList(self):
- if not self._kernelVersionList:
- self._updateKernelVersionList()
-
- return self._kernelVersionList[0]
-
- @property
- def rescueKernelList(self):
- # do re-scan if looking for rescue kernel
- self._updateKernelVersionList()
- return self._kernelVersionList[1]
+ """ An iterator of the kernel versions installed by the payload. """
+ raise NotImplementedError()
##
## METHODS FOR TREE VERIFICATION
diff --git a/pyanaconda/packaging/dnfpayload.py b/pyanaconda/packaging/dnfpayload.py
index d0eb90e..d3c481b 100644
--- a/pyanaconda/packaging/dnfpayload.py
+++ b/pyanaconda/packaging/dnfpayload.py
@@ -818,3 +818,10 @@ class DNFPayload(packaging.PackagePayload):
log.error(e)
super(DNFPayload, self).postInstall()
+
+ @property
+ def kernelVersionList(self):
+ return ('%s-%s.%s' % (p.version, p.release, p.arch) for p in
+ sorted(self._base.sack.query().filter(name='kernel'),
+ cmp=dnf.rpm.miscutils.compareEVR,
+ key=lambda p: (p.epoch, p.version, p.release)))
diff --git a/pyanaconda/packaging/livepayload.py b/pyanaconda/packaging/livepayload.py
index 17c1bac..1dac9c7 100644
--- a/pyanaconda/packaging/livepayload.py
+++ b/pyanaconda/packaging/livepayload.py
@@ -56,6 +56,7 @@ from blivet.size import Size
import blivet.util
from pyanaconda.threads import threadMgr, AnacondaThread
from pyanaconda.i18n import _
+from pyanaconda.packaging import versionCmp
class LiveImagePayload(ImagePayload):
""" A LivePayload copies the source image onto the target system. """
@@ -67,6 +68,8 @@ class LiveImagePayload(ImagePayload):
self.pct_lock = None
self.source_size = 1
+ self._kernelVersionList = []
+
def setup(self, storage, instClass):
super(LiveImagePayload, self).setup(storage, instClass)
@@ -80,6 +83,9 @@ class LiveImagePayload(ImagePayload):
if rc != 0:
raise PayloadInstallError("Failed to mount the install tree")
+ # Grab the kernel version list now so it's available after umount
+ self._updateKernelVersionList()
+
source = iutil.eintr_retry_call(os.statvfs, INSTALL_TREE)
self.source_size = source.f_frsize * (source.f_blocks - source.f_bfree)
@@ -180,6 +186,17 @@ class LiveImagePayload(ImagePayload):
def spaceRequired(self):
return Size(iutil.getDirSize("/")*1024)
+ def _updateKernelVersionList(self):
+ files = glob.glob(INSTALL_TREE + "/boot/vmlinuz-*")
+ files.extend(glob.glob(INSTALL_TREE + "/boot/efi/EFI/%s/vmlinuz-*" % self.instclass.efi_dir))
+
+ self._kernelVersionList = sorted([f.split("/")[-1][8:] for f in files
+ if os.path.isfile(f) and "-rescue-" not in f], cmp=versionCmp)
+
+ @property
+ def kernelVersionList(self):
+ return self._kernelVersionList
+
class URLGrabberProgress(object):
""" Provide methods for urlgrabber progress."""
def start(self, filename, url, basename, size, text):
@@ -388,6 +405,7 @@ class LiveImageKSPayload(LiveImagePayload):
# Nothing more to mount
if not os.path.exists(INSTALL_TREE+"/LiveOS"):
+ self._updateKernelVersionList()
return
# Mount the first .img in the directory on INSTALL_TREE
@@ -415,6 +433,8 @@ class LiveImageKSPayload(LiveImagePayload):
if errorHandler.cb(exn) == ERROR_RAISE:
raise exn
+ self._updateKernelVersionList()
+
source = iutil.eintr_retry_call(os.statvfs, INSTALL_TREE)
self.source_size = source.f_frsize * (source.f_blocks - source.f_bfree)
@@ -493,3 +513,19 @@ class LiveImageKSPayload(LiveImagePayload):
return Size(self._min_size)
else:
return Size(1024*1024*1024)
+
+ @property
+ def kernelVersionList(self):
+ # If it doesn't look like a tarfile use the super's kernelVersionList
+ if not self.is_tarfile:
+ return super(LiveImageKSPayload, self).kernelVersionList
+
+ import tarfile
+ with tarfile.open(self.image_path) as archive:
+ names = archive.getnames()
+
+ # Strip out vmlinuz- from the names
+ kernels = [n.split("/")[-1][8:] for n in names if "boot/vmlinuz-" in n]
+ kernels.sort(cmp=versionCmp)
+
+ return kernels
diff --git a/pyanaconda/packaging/tarpayload.py b/pyanaconda/packaging/tarpayload.py
index b6328e0..3082530 100644
--- a/pyanaconda/packaging/tarpayload.py
+++ b/pyanaconda/packaging/tarpayload.py
@@ -36,7 +36,7 @@ except ImportError:
log.error("import of tarfile failed")
tarfile = None
-from pyanaconda.packaging import ArchivePayload, PayloadError
+from pyanaconda.packaging import ArchivePayload, PayloadError, versionCmp
from pyanaconda import iutil
# TarPayload is not yet fully implemented
@@ -73,7 +73,11 @@ class TarPayload(ArchivePayload):
@property
def kernelVersionList(self):
names = self.archive.getnames()
- kernels = [n for n in names if "boot/vmlinuz-" in n]
+
+ # Strip out vmlinuz- from the names
+ kernels = [n.split("/")[-1][8:] for n in names if "boot/vmlinuz-" in n]
+ kernels.sort(cmp=versionCmp)
+
return kernels
def install(self):
diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py
index 742edad..73caa49 100644
--- a/pyanaconda/packaging/yumpayload.py
+++ b/pyanaconda/packaging/yumpayload.py
@@ -988,6 +988,14 @@ reposdir=%s
else:
return environment.groups
+ @property
+ def kernelVersionList(self):
+ with _yum_lock:
+ return ("%s-%s.%s" % (p.version, p.release, p.arch) for p in
+ sorted(self._yum.pkgSack.searchNames(['kernel']),
+ cmp=yum.rpmUtils.miscutils.compareEVR,
+ key=lambda p: (p.epoch, p.version, p.release)))
+
###
### METHODS FOR WORKING WITH GROUPS
###
--
2.1.0
9 years, 3 months
[PATCH] Fix install issue when many LUNs and LUN paths present.
by Robert Marshall
If installing a system with over 250 LUN paths the blivet subsystem
would crash with an error. Partnered with David Lehman and he was
able to provide a solution.
Resolves rhbz#1181336
---
blivet/udev.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/blivet/udev.py b/blivet/udev.py
index 65652bd..c23ce7e 100644
--- a/blivet/udev.py
+++ b/blivet/udev.py
@@ -577,7 +577,7 @@ def device_is_biosraid_member(info):
return False
def device_get_dm_partition_disk(info):
- return re.sub(r'p?\d*$', '', device_get_name(info))
+ return os.path.basename(os.path.dirname(device_get_sysfs_path(info)))
def device_is_dm_partition(info):
return (device_is_dm(info) and
--
2.1.0
9 years, 3 months
[PATCH atomic-rhel-7.1] rescue: find root partition of ostree (atomic) installations (#1152041)
by Radek Vykydal
This patch is targeted for RHEL Atomic Host 7.1 which is using 7.0 anaconda
plus patches in atomic-rhel-7.1 dist-git branch. So the patch should go to
rhel7-branch in 7.2 dev.
---
pyanaconda/rescue.py | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/pyanaconda/rescue.py b/pyanaconda/rescue.py
index e0c4e13..fbf3f06 100644
--- a/pyanaconda/rescue.py
+++ b/pyanaconda/rescue.py
@@ -264,6 +264,42 @@ def _unlock_devices(intf, storage):
device.format.passphrase = None
try_passphrase = None
+def findExistingOstreePartitions(devicetree):
+ import blivet
+ if not os.path.exists(blivet.getTargetPhysicalRoot()):
+ util.makedirs(blivet.getTargetPhysicalRoot())
+
+ roots = []
+ for device in devicetree.leaves:
+ if not device.format.linuxNative or not device.format.mountable or \
+ not device.controllable:
+ continue
+
+ try:
+ device.setup()
+ except Exception: # pylint: disable=broad-except
+ log.warning("setup of %s failed", [device.name])
+ continue
+
+ options = device.format.options + ",ro"
+ try:
+ device.format.mount(options=options, mountpoint=iutil.getSysroot())
+ except Exception: # pylint: disable=broad-except
+ log.warning("mount of %s as %s failed", device.name, device.format.type)
+ device.teardown()
+ continue
+
+ if not os.access(iutil.getSysroot() + "/ostree", os.R_OK):
+ device.teardown(recursive=True)
+ continue
+
+ name = _("Ostree on %s") % device.name
+ roots.append(blivet.Root(mounts=None, swaps=None, name=device.name))
+
+ return roots
+
+
+
def doRescue(intf, rescue_mount, ksdata):
import blivet
@@ -323,6 +359,7 @@ def doRescue(intf, rescue_mount, ksdata):
blivet.storageInitialize(sto, ksdata, [])
_unlock_devices(intf, sto)
roots = blivet.findExistingInstallations(sto.devicetree)
+ roots.extend(findExistingOstreePartitions(sto.devicetree))
if not roots:
root = None
--
1.9.3
9 years, 3 months