[master] dracut args: "rhgb quiet" should come last.

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

 



The patch introduces a simple mechanism to order the (otherwise unsorted)
dracut arguments.

With a UT.

Resolves: rhbz#740949
---
 pyanaconda/bootloader.py                 |   12 +++++++++++-
 tests/pyanaconda_test/bootloader_test.py |    8 ++++++++
 2 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
index 45950d7..210ea15 100644
--- a/pyanaconda/bootloader.py
+++ b/pyanaconda/bootloader.py
@@ -79,6 +79,11 @@ class BootLoaderError(Exception):
     pass
 
 class Arguments(set):
+    ordering_dict = {
+        "rhgb" : 99,
+        "quiet" : 100
+        }
+
     def _merge_ip(self):
         """
         Find ip= arguments targetting the same interface and merge them.
@@ -111,7 +116,12 @@ class Arguments(set):
 
     def __str__(self):
         self._merge_ip()
-        return " ".join(self)
+        # sort the elements according to their values in ordering_dict. The
+        # higher the number the closer to the final string the argument
+        # gets. The default is 50.
+        lst = sorted(self, key=lambda s: self.ordering_dict.get(s, 50))
+
+        return " ".join(lst)
 
 class BootLoaderImage(object):
     """ Base class for bootloader images. Suitable for non-linux OS images. """
diff --git a/tests/pyanaconda_test/bootloader_test.py b/tests/pyanaconda_test/bootloader_test.py
index 59b6ea2..6aa93bb 100644
--- a/tests/pyanaconda_test/bootloader_test.py
+++ b/tests/pyanaconda_test/bootloader_test.py
@@ -49,3 +49,11 @@ class ArgumentsTest(mock.TestCase):
         self.assertEqual(str(a), "ip=eth0:dhcp")
         a = Arguments(["ip=eth0:dhcp", "ip=eth0:auto6"])
         assert(str(a) in ["ip=eth0:auto6,dhcp", "ip=eth0:dhcp,auto6"])
+
+    def test_sorting(self):
+        from pyanaconda.bootloader import Arguments
+        a = Arguments(["ip=eth0:dhcp", "rhgb", "quiet",
+                       "root=/dev/mapper/destroyers-rubies", "rd.md=0",
+                       "rd.luks=0"])
+        # 'rhgb quiet' should be the final entries:
+        assert(str(a).endswith("rhgb quiet"))
-- 
1.7.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