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