[node-patches] Change in ovirt-node[master]: dracut: Expand and translate devices to compare
fabiand at fedoraproject.org
fabiand at fedoraproject.org
Thu Oct 25 10:30:09 UTC 2012
Fabian Deutsch has uploaded a new change for review.
Change subject: dracut: Expand and translate devices to compare
......................................................................
dracut: Expand and translate devices to compare
The storage_init parameter is a set of devices which pontentially
contain PVs which in turn are members of VGs. Before these VGs are
removed it needs to be determined if all PVs part of the given VGs are
covered by the devices in the storage_init karg.
In order to do this some comparisons are needed, but these comparisons
need to take place after (a) the storage_init values are parsed and (b)
the device names are translated into the device names which are used by
LVM.
Previously the parsing and translation did not happen in some
comparisons which broke the logic.
Two passes are introduced which first parse and afterwards translate the
device names to allow a comparison.
rhbz#869172
Change-Id: I8eb9cff20ef9a0330451c455f35cfbbccdf27a96
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M dracut/ovirt-boot-functions
M dracut/ovirt-cleanup.sh
2 files changed, 47 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/11/8811/1
diff --git a/dracut/ovirt-boot-functions b/dracut/ovirt-boot-functions
index 4835ffb..d59133b 100644
--- a/dracut/ovirt-boot-functions
+++ b/dracut/ovirt-boot-functions
@@ -144,6 +144,16 @@
echo "$disk"
}
+lvm_name_for()
+{
+ # A small hack to get the devname used by lvm for a given device
+ DEVICE="$1"
+ LVM2_VARS=$(lvm pvs --noheadings --nameprefixes --unquoted -o pv_name,vg_name "$DEVICE" 2> /dev/null)
+ if [ -n "$LVM2_VARS" ]; then
+ export $LVM2_VARS
+ echo $LVM2_PV_NAME
+ fi
+}
# execute a function if called as a script, e.g.
# ovirt-boot-functions ovirt_store_config /etc/hosts
diff --git a/dracut/ovirt-cleanup.sh b/dracut/ovirt-cleanup.sh
index 5b84b4d..a0e8206 100755
--- a/dracut/ovirt-cleanup.sh
+++ b/dracut/ovirt-cleanup.sh
@@ -75,31 +75,65 @@
oldIFS=$IFS
IFS=","
+parsed_storage_init=""
+info "Parsing storage_init: $storage_init"
for dev in $storage_init; do
dev="$(echo "$dev" | sed 's/\\\*/\*/g')"
device=$(IFS=$oldIFS parse_disk_id "$dev")
info "After parsing \"$dev\", we got \"$device\""
+ parsed_storage_init="$parsed_storage_init,$device"
+done
+parsed_storage_init=${parsed_storage_init#,}
+
+lvm_storage_init=""
+info "Finding all affected PVs for: $parsed_storage_init"
+for device in $parsed_storage_init; do
+ if [ -z "$device" ]; then
+ continue
+ fi
+ info "Looking for device and partitions on '$device'"
+ IFS=$oldIFS
+ for slave in $(ls $device*); do
+ info " Found '$slave'"
+ lvmslave=$(IFS=$oldIFS lvm_name_for "$slave")
+ if [ -n "$lvmslave" ]; then
+ info " Known by LVM as '$lvmslave'"
+ lvm_storage_init="$lvm_storage_init,$lvmslave"
+ else
+ info " '$slave' is unknown to LVM"
+ fi
+ done
+ IFS=,
+done
+lvm_storage_init=${lvm_storage_init#,}
+
+for device in $lvm_storage_init; do
+ if [ -z "$device" ]; then
+ continue
+ fi
echo "Wiping LVM from device: ${device}"
# Ensure that it's not read-only locking
if [ -f "/etc/lvm/lvm.conf" ]; then
sed -i "s/locking_type =.*/locking_type = 0/" /etc/lvm/lvm.conf
fi
IFS=$oldIFS
- for i in $(lvm pvs --noheadings -o pv_name,vg_name --separator=, $device* 2>/dev/null); do
+ for i in $(lvm pvs --noheadings -o pv_name,vg_name --separator=, $device 2>/dev/null); do
pv="${i%%,*}"
vg="${i##*,}"
if [ -n "$vg" ]; then
+ info "Checking all PVs of VG '$vg'"
for ipv in $(lvm vgs --noheadings -o pv_name $vg 2>/dev/null); do
imach=0
IFS=","
- for idev in $storage_init; do
+ for idev in $lvm_storage_init; do
if [ $idev = $ipv ]; then
imach=1
fi
done
IFS=$oldIFS
if [ $imach -eq 0 ]; then
- info "Not all member PVs of '$vg' are given in the storage_init parameter ,exiting"
+ warn "LV '$lv' is not a member of VG '$vg'"
+ die "Not all member PVs of '$vg' are given in the storage_init parameter, exiting"
return 0
fi
done
--
To view, visit http://gerrit.ovirt.org/8811
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8eb9cff20ef9a0330451c455f35cfbbccdf27a96
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>
More information about the node-patches
mailing list