From 15d5cb5679d69bb016edd8659362bb4c23b3573d Mon Sep 17 00:00:00 2001 From: Vratislav Podzimek Date: Tue, 4 Oct 2016 21:12:06 +0200 Subject: [PATCH 2/3] Search for just "UUID" in mdadm --examine output IMSM raid arrays don't have the "Array UUID" key reported, it's just "UUID". And as a bonus, the volume UUID is reported as well as the container's UUID (we care about), both using just "UUID". Related: rhbz#1379865 (cherry-picked from commit 0fb4e778b8a30200ed6e4272e9427d109f993eb2) Signed-off-by: Vratislav Podzimek --- src/plugins/mdraid.c | 7 ++++++- tests/md_test.py | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plugins/mdraid.c b/src/plugins/mdraid.c index 7e6b2da..5bfbfb8 100644 --- a/src/plugins/mdraid.c +++ b/src/plugins/mdraid.c @@ -164,7 +164,9 @@ static GHashTable* parse_mdadm_vars (gchar *str, gchar *item_sep, gchar *key_val key_val = g_strsplit (*item_p, key_val_sep, 2); if (g_strv_length (key_val) == 2) { /* we only want to process valid lines (with the separator) */ - g_hash_table_insert (table, g_strstrip (key_val[0]), g_strstrip (key_val[1])); + /* only use the first value for the given key */ + if (!g_hash_table_contains (table, g_strstrip (key_val[0]))) + g_hash_table_insert (table, g_strstrip (key_val[0]), g_strstrip (key_val[1])); (*num_items)++; } else /* invalid line, just free key_val */ @@ -211,6 +213,9 @@ static BDMDExamineData* get_examine_data_from_table (GHashTable *table, gboolean data->size = 0; data->uuid = g_strdup ((gchar*) g_hash_table_lookup (table, "Array UUID")); + if (!data->uuid) + /* also try just "UUID" which may be reported e.g for IMSM FW RAID */ + data->uuid = g_strdup ((gchar*) g_hash_table_lookup (table, "UUID")); value = (gchar*) g_hash_table_lookup (table, "Update Time"); if (value) { diff --git a/tests/md_test.py b/tests/md_test.py index 4b4d898..2fab378 100644 --- a/tests/md_test.py +++ b/tests/md_test.py @@ -412,6 +412,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") def test_no_metadata_examine(self): """Verify that md_examine works as expected with no metadata spec""" -- 2.7.4