2015-12-18 10:35:44 +01:00
|
|
|
There are the following problems with lvm completions:
|
|
|
|
1)_lvm_physicalvolumes() only gets PVs that belong to a VG. In some
|
|
|
|
cases like pvremove we can use all PVs including those not included
|
|
|
|
in any VGs.
|
|
|
|
solution: Add _lvm_physicalvolumes_all to get all PVs and correct
|
|
|
|
all the commands.
|
2015-09-23 13:59:55 +02:00
|
|
|
|
2015-12-18 10:35:44 +01:00
|
|
|
2)pvcreate should be able to use all block devcices.
|
|
|
|
solution: Add _lvm_filedir() to use _filedir except set $cur to /dev
|
|
|
|
when $cur is empty.
|
|
|
|
|
|
|
|
3)when /etc/lvm/lvm.conf silent is 1 there is no output for vg/lv/pvscan,
|
|
|
|
bash-completion will not work.
|
|
|
|
solution: Check the value of silent option. If it is 1 then temporarily
|
|
|
|
set silent 0 and recover back to 1 after the command executed.
|
|
|
|
|
|
|
|
Signed-off-by: Liuhua Wang <lwang@suse.com>
|
|
|
|
Reviewed-by: Lidong Zhong <lzhong@suse.com>
|
|
|
|
|
|
|
|
|
2016-12-14 12:49:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-12-18 10:35:44 +01:00
|
|
|
diff --git a/completions/lvm b/completions/lvm
|
|
|
|
--- a/completions/lvm
|
|
|
|
+++ b/completions/lvm
|
2016-12-14 12:49:24 +01:00
|
|
|
@@ -6,27 +6,41 @@ _lvm_filedir()
|
|
|
|
_filedir
|
|
|
|
}
|
2015-09-23 13:59:55 +02:00
|
|
|
|
2016-12-14 12:49:24 +01:00
|
|
|
+_lvm_verbose()
|
2015-09-23 13:59:55 +02:00
|
|
|
+{
|
2016-12-14 12:49:24 +01:00
|
|
|
+ local silent=$(sed -n -e "s|^[ \t]*silent[ \t]*=[ \t]*\([01]\)|\1|p" /etc/lvm/lvm.conf)
|
|
|
|
+ test ${silent:-0} -eq 1
|
2015-09-23 13:59:55 +02:00
|
|
|
+}
|
|
|
|
+
|
2015-12-18 10:35:44 +01:00
|
|
|
_lvm_volumegroups()
|
2015-09-23 13:59:55 +02:00
|
|
|
{
|
2016-12-14 12:49:24 +01:00
|
|
|
- COMPREPLY=( $(compgen -W "$( vgscan 2>/dev/null | \
|
|
|
|
+ local verbose
|
|
|
|
+ _lvm_verbose && verbose=-v
|
|
|
|
+ COMPREPLY=( $(compgen -W "$( vgscan $verbose 2>/dev/null | \
|
|
|
|
command sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p' )" -- "$cur" ) )
|
|
|
|
}
|
|
|
|
|
|
|
|
_lvm_physicalvolumes_all()
|
|
|
|
{
|
|
|
|
- COMPREPLY=( $(compgen -W "$( pvscan 2>/dev/null | \
|
|
|
|
+ local verbose
|
|
|
|
+ _lvm_verbose && verbose=-v
|
|
|
|
+ COMPREPLY=( $(compgen -W "$( pvscan $verbose 2>/dev/null | \
|
|
|
|
command sed -n -e 's|^.*PV \([^ ]*\) .*|\1|p' )" -- "$cur" ) )
|
2015-12-18 10:35:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
_lvm_physicalvolumes()
|
|
|
|
{
|
2016-12-14 12:49:24 +01:00
|
|
|
- COMPREPLY=( $(compgen -W "$( pvscan 2>/dev/null | \
|
|
|
|
+ local verbose
|
|
|
|
+ _lvm_verbose && verbose=-v
|
|
|
|
+ COMPREPLY=( $(compgen -W "$( pvscan $verbose 2>/dev/null | \
|
|
|
|
command sed -n -e 's|^.*PV \(.*\) VG.*$|\1|p' )" -- "$cur" ) )
|
2015-12-18 10:35:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
_lvm_logicalvolumes()
|
|
|
|
{
|
2016-12-14 12:49:24 +01:00
|
|
|
- COMPREPLY=( $(compgen -W "$( lvscan 2>/dev/null | \
|
|
|
|
+ local verbose
|
|
|
|
+ _lvm_verbose && verbose=-v
|
|
|
|
+ COMPREPLY=( $(compgen -W "$( lvscan $verbose 2>/dev/null | \
|
|
|
|
command sed -n -e "s|^.*'\(.*\)'.*$|\1|p" )" -- "$cur" ) )
|
2015-12-18 10:35:44 +01:00
|
|
|
if [[ $cur == /dev/mapper/* ]]; then
|
2016-12-14 12:49:24 +01:00
|
|
|
_filedir
|
|
|
|
@@ -394,7 +408,7 @@ _vgreduce()
|
2015-12-18 10:35:44 +01:00
|
|
|
if [[ $args -eq 0 ]]; then
|
|
|
|
_lvm_volumegroups
|
|
|
|
else
|
|
|
|
- _lvm_physicalvolumes
|
|
|
|
+ _lvm_physicalvolumes_all
|
2015-09-23 13:59:55 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
} &&
|
2016-12-14 12:49:24 +01:00
|
|
|
@@ -709,7 +723,7 @@ _lvcreate()
|
2015-12-18 10:35:44 +01:00
|
|
|
if [[ $args -eq 0 ]]; then
|
|
|
|
_lvm_volumegroups
|
|
|
|
else
|
|
|
|
- _lvm_physicalvolumes
|
|
|
|
+ _lvm_physicalvolumes_all
|
2015-09-23 13:59:55 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
} &&
|