Red Hat Bugzilla – Bug 1301974
Add support for selection in all commands where --select vg_uuid=<uuid> is suggested if multiple VGs found with the same name
Last modified: 2018-01-01 20:15:54 EST
We need to add support for -S|--select for all commands where possible, mainly the ones which suggest --select use if multiple VGs are found with the same name.
For example, lvcreate is one of them:
[root@rhel6-a ~]# vgs -o+vg_uuid -S vg_name=vg
VG #PV #LV #SN Attr VSize VFree VG UUID
vg 1 1 0 wz--n- 4.00g 3.99g eHZp2F-7Qdk-p6br-Z8cI-iEwi-LWIl-ScaCr4
vg 1 1 0 wz--n- 4.00g 3.99g GhDzAe-LAav-yhCu-WF4e-G1zn-FtrQ-yh15OP
[root@rhel6-a ~]# lvcreate -l1 vg
Multiple VGs found with the same name: skipping vg
Use the VG UUID with --select vg_uuid=<uuid>
[root@rhel6-a ~]# lvcreate -l1 -S vg_uuid=eHZp2F-7Qdk-p6br-Z8cI-iEwi-LWIl-ScaCr4
lvcreate: invalid option -- 'S'
Error during parsing of command line.
However, in such cases, we need to make sure that the --select returns only one item that should be processed (one VG for the lvcreate example above). If the result of selection is a set which contains more items, we need to error out and suggest users to refine their selection so there's only one item coming as a result of the selection.
We should either fix this for 6.8 or we need to remove the "Use the VG UUID with --select vg_uuid=<uuid>" message for commands where --select is not yet supported.
I was aware of the error message being inaccurate in a couple of cases like lvcreate, but I thought it was obscure enough to ignore. To change this we simply need to check what the command is before printing the "use -S" suggestion (by looking at the command name or using a cmd flag to control the printing of this message.)
As for adding -S support to commands like lvcreate (that take a single VG)... as you point out, we need to ensure it selects only one VG. That obviously reduces the usefulness and motivation for it. It also includes some messy work in changing the arg processing to allow a missing VG arg (which can also sometimes be embedded into an LV name arg.)