- Do not report volume name for FW RAID container device (vpodzime) - Search for just "UUID" in mdadm --examine output (vpodzime) - Use 'mdadm --examine --export' to get MD RAID level (vpodzime)
		
			
				
	
	
		
			113 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			113 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
From 8123db9319a26c59996d4c42e84100ebe5822b82 Mon Sep 17 00:00:00 2001
 | 
						|
From: Vratislav Podzimek <vpodzime@redhat.com>
 | 
						|
Date: Tue, 4 Oct 2016 21:19:22 +0200
 | 
						|
Subject: [PATCH 3/3] Do not report volume name for FW RAID container device
 | 
						|
 | 
						|
This may be confusing for tools/libraries using our API because they need info
 | 
						|
about the immediate descendant device which is the container.
 | 
						|
 | 
						|
Related: rhbz#1379865
 | 
						|
 | 
						|
(cherry-picked from commit ad6eb3d47c57171cea7abbae0f5d0c1f5ee2c357)
 | 
						|
 | 
						|
Signed-off-by: Vratislav Podzimek <vpodzime@redhat.com>
 | 
						|
---
 | 
						|
 src/plugins/mdraid.c              | 13 ++++++++-----
 | 
						|
 tests/md_test.py                  | 12 ++----------
 | 
						|
 tests/mdadm_fw_raid_examine/mdadm | 18 ------------------
 | 
						|
 3 files changed, 10 insertions(+), 33 deletions(-)
 | 
						|
 delete mode 100755 tests/mdadm_fw_raid_examine/mdadm
 | 
						|
 | 
						|
diff --git a/src/plugins/mdraid.c b/src/plugins/mdraid.c
 | 
						|
index 5bfbfb8..9cb0cc7 100644
 | 
						|
--- a/src/plugins/mdraid.c
 | 
						|
+++ b/src/plugins/mdraid.c
 | 
						|
@@ -768,7 +768,7 @@ BDMDExamineData* bd_md_examine (gchar *device, GError **error) {
 | 
						|
     gchar **output_fields = NULL;
 | 
						|
     gchar *orig_data = NULL;
 | 
						|
     guint i = 0;
 | 
						|
-    gboolean found_dev_name = FALSE;
 | 
						|
+    gboolean found_array_line = FALSE;
 | 
						|
 
 | 
						|
     success = bd_utils_exec_and_capture_output (argv, &output, error);
 | 
						|
     if (!success)
 | 
						|
@@ -831,13 +831,16 @@ BDMDExamineData* bd_md_examine (gchar *device, GError **error) {
 | 
						|
 
 | 
						|
     /* try to find the "ARRAY /dev/md/something" pair in the output */
 | 
						|
     output_fields = g_strsplit_set (output, " \n", 0);
 | 
						|
-    for (i=0; !found_dev_name && (i < g_strv_length (output_fields) - 1); i++)
 | 
						|
-        if (g_strcmp0 (output_fields[i], "ARRAY") == 0)
 | 
						|
+    for (i=0; !found_array_line && (i < g_strv_length (output_fields) - 1); i++)
 | 
						|
+        if (g_strcmp0 (output_fields[i], "ARRAY") == 0) {
 | 
						|
+            found_array_line = TRUE;
 | 
						|
             if (g_str_has_prefix (output_fields[i+1], "/dev/md/")) {
 | 
						|
                 ret->device = g_strdup (output_fields[i+1]);
 | 
						|
-                found_dev_name = TRUE;
 | 
						|
+            } else {
 | 
						|
+                ret->device = NULL;
 | 
						|
             }
 | 
						|
-    if (!found_dev_name)
 | 
						|
+        }
 | 
						|
+    if (!found_array_line)
 | 
						|
         ret->device = NULL;
 | 
						|
     g_strfreev (output_fields);
 | 
						|
 
 | 
						|
diff --git a/tests/md_test.py b/tests/md_test.py
 | 
						|
index 2fab378..d7e007a 100644
 | 
						|
--- a/tests/md_test.py
 | 
						|
+++ b/tests/md_test.py
 | 
						|
@@ -395,17 +395,8 @@ class MDTestNameNodeBijection(MDTestCase):
 | 
						|
 
 | 
						|
 class FakeMDADMutilTest(unittest.TestCase):
 | 
						|
     # no setUp nor tearDown needed, we are gonna use fake utils
 | 
						|
-
 | 
						|
-    def test_fw_raid_examine(self):
 | 
						|
-        """Verify that md_examine works as expected on FW RAID data"""
 | 
						|
-
 | 
						|
-        with fake_utils("tests/mdadm_fw_raid_examine"):
 | 
						|
-            ex_data = BlockDev.md_examine("fake_dev")
 | 
						|
-
 | 
						|
-        self.assertEqual(ex_data.device, "/dev/md/Volume0")
 | 
						|
-
 | 
						|
     def test_fw_raid_uppercase_examine(self):
 | 
						|
-        """Verify that md_examine works with output using "RAID" instead of "Raid" """
 | 
						|
+        """Verify that md_examine works with output using "RAID" instead of "Raid" and other quirks """
 | 
						|
 
 | 
						|
         with fake_utils("tests/mdadm_fw_RAID_examine"):
 | 
						|
             ex_data = BlockDev.md_examine("fake_dev")
 | 
						|
@@ -413,6 +404,7 @@ class FakeMDADMutilTest(unittest.TestCase):
 | 
						|
         self.assertEqual(ex_data.level, "container")
 | 
						|
         self.assertEqual(ex_data.num_devices, 1)
 | 
						|
         self.assertEqual(ex_data.uuid, "b42756a2-37e4-3e47-674b-d1dd6e822145")
 | 
						|
+        self.assertEqual(ex_data.device, None)
 | 
						|
 
 | 
						|
     def test_no_metadata_examine(self):
 | 
						|
         """Verify that md_examine works as expected with no metadata spec"""
 | 
						|
diff --git a/tests/mdadm_fw_raid_examine/mdadm b/tests/mdadm_fw_raid_examine/mdadm
 | 
						|
deleted file mode 100755
 | 
						|
index 54ec4ed..0000000
 | 
						|
--- a/tests/mdadm_fw_raid_examine/mdadm
 | 
						|
+++ /dev/null
 | 
						|
@@ -1,18 +0,0 @@
 | 
						|
-#!/bin/bash
 | 
						|
-
 | 
						|
-echo "$@"|grep -- "--brief" &>/dev/null
 | 
						|
-is_brief=$?
 | 
						|
-
 | 
						|
-if [ $is_brief -eq 0 ]; then
 | 
						|
-    cat <<EOF
 | 
						|
-ARRAY metadata=imsm UUID=e0fb362e:9865d1c0:cdb0f5e3:27c9a085
 | 
						|
-ARRAY /dev/md/Volume0 container=e0fb362e:9865d1c0:cdb0f5e3:27c9a085 member=0 UUID=1d1335e9:79d4be6a:e16b7fa7:fe8c41f6
 | 
						|
-EOF
 | 
						|
-else
 | 
						|
-    cat <<EOF
 | 
						|
-MD_METADATA=imsm
 | 
						|
-MD_LEVEL=container
 | 
						|
-MD_UUID=e0fb362e:9865d1c0:cdb0f5e3:27c9a085
 | 
						|
-MD_DEVICES=2
 | 
						|
-EOF
 | 
						|
-fi
 | 
						|
-- 
 | 
						|
2.7.4
 | 
						|
 |