diff options
author | Ales Kozumplik <akozumpl@redhat.com> | 2011-08-12 14:05:51 +0200 |
---|---|---|
committer | Ales Kozumplik <akozumpl@redhat.com> | 2011-08-16 13:04:26 +0200 |
commit | 625aa598345e83658c203c14781102e63c7ef6fa (patch) | |
tree | 61579625fb3799dbed7f5d1b3e8568661aef0434 | |
parent | 4ac57face300a9a965fc1aa1b04e275bd747188f (diff) | |
download | anaconda-625aa598345e83658c203c14781102e63c7ef6fa.tar.gz anaconda-625aa598345e83658c203c14781102e63c7ef6fa.tar.xz anaconda-625aa598345e83658c203c14781102e63c7ef6fa.zip |
Copy /etc/multipath/wwids to the sysimage.
/etc/multipath/wwids is a list of activated multipaths generated by the
multipath tools. If it is missing in the sysimage it will be missing in
the dracut initramfs and that, in rare cases, can cause race between mpath
and lvm during boot.
This is a merge froh rhel6-branch but includes a unit tests of the new
iutil.copy_to_sysimage().
Resolves: rhbz#701371
-rw-r--r-- | pyanaconda/iutil.py | 14 | ||||
-rw-r--r-- | pyanaconda/storage/__init__.py | 1 | ||||
-rw-r--r-- | tests/mock/__init__.py | 1 | ||||
-rw-r--r-- | tests/mock/disk.py | 2 | ||||
-rw-r--r-- | tests/pyanaconda_test/iutil_test.py | 29 |
5 files changed, 46 insertions, 1 deletions
diff --git a/pyanaconda/iutil.py b/pyanaconda/iutil.py index e43af8cc1..96a3fd4ce 100644 --- a/pyanaconda/iutil.py +++ b/pyanaconda/iutil.py @@ -22,6 +22,7 @@ import glob import os, string, stat, sys +import shutil import signal import os.path import errno @@ -927,6 +928,19 @@ def setup_translations(module): add_po_path(module, TRANSLATIONS_UPDATE_DIR) module.textdomain("anaconda") +def copy_to_sysimage(source, root_path): + if not os.access(source, os.R_OK): + log.info("copy_to_sysimage: source '%s' does not exist." % source) + return False + + target = root_path + source + target_dir = os.path.dirname(target) + log.debug("copy_to_sysimage: '%s' -> '%s'." % (source, target)) + if not os.path.isdir(target_dir): + os.makedirs(target_dir) + shutil.copy(source, target) + return True + def get_sysfs_attr(path, attr): if not attr: log.debug("get_sysfs_attr() called with attr=None") diff --git a/pyanaconda/storage/__init__.py b/pyanaconda/storage/__init__.py index c1c1fea49..abfdb5572 100644 --- a/pyanaconda/storage/__init__.py +++ b/pyanaconda/storage/__init__.py @@ -2338,6 +2338,7 @@ class FSSet(object): f.close() else: log.info("not writing out mpath configuration") + iutil.copy_to_sysimage("/etc/multipath/wwids", root_path=instPath) def crypttab(self): # if we are upgrading, do we want to update crypttab? diff --git a/tests/mock/__init__.py b/tests/mock/__init__.py index 900bef386..3fd749a9a 100644 --- a/tests/mock/__init__.py +++ b/tests/mock/__init__.py @@ -91,3 +91,4 @@ class TestCase(unittest.TestCase): os.listdir = disk.os_listdir os.path.exists = disk.os_path_exists os.path.isdir = disk.os_path_isdir + os.access = disk.os_access
\ No newline at end of file diff --git a/tests/mock/disk.py b/tests/mock/disk.py index 3ee98aab2..926fe8fa6 100644 --- a/tests/mock/disk.py +++ b/tests/mock/disk.py @@ -125,4 +125,4 @@ class DiskIO(object): raise OSError("[Errno 2] No such file or directory: '%s'" % (path,)) def os_access(self, path, mode): - return self.path_exists(path) + return self.os_path_exists(path) diff --git a/tests/pyanaconda_test/iutil_test.py b/tests/pyanaconda_test/iutil_test.py new file mode 100644 index 000000000..ba1114ec1 --- /dev/null +++ b/tests/pyanaconda_test/iutil_test.py @@ -0,0 +1,29 @@ +import mock + +class IutilTest(mock.TestCase): + def setUp(self): + self.setupModules( + ['_isys', 'logging', 'pyanaconda.anaconda_log', 'block']) + + import pyanaconda + pyanaconda.anaconda_log = mock.Mock() + + def tearDown(self): + self.tearDownModules() + + def copy_to_sysimage_test(self): + from pyanaconda import iutil + fs = mock.DiskIO() + self.take_over_io(fs, iutil) + self.assertEqual(iutil.copy_to_sysimage("/etc/securetty", "/sysimage"), + False) + + fs["/etc/securetty"] = "tty1" + iutil.os.makedirs = mock.Mock() + iutil.shutil.copy = mock.Mock() + self.assertEqual(iutil.copy_to_sysimage("/etc/securetty", + "/sysimage/subdir"), + True) + iutil.os.makedirs.assert_called_with("/sysimage/subdir/etc") + iutil.shutil.copy.assert_called_with("/etc/securetty", + "/sysimage/subdir/etc/securetty") |