virsh: add pool support to vol-key command

Presently the vol-key command only supports being provided with
a volume path.

This patch adds support for providing it with a pool and volume
identifier pair as well.

    virsh # vol-key --pool <pool-name-or-uuid> <vol-name-or-path>
This commit is contained in:
Justin Clift 2010-06-11 21:51:55 +10:00 committed by Eric Blake
parent 08d42b52f1
commit 31495ef6a1
2 changed files with 7 additions and 6 deletions

View File

@ -6098,12 +6098,13 @@ cmdVolPool(vshControl *ctl, const vshCmd *cmd)
* "vol-key" command
*/
static const vshCmdInfo info_vol_key[] = {
{"help", N_("convert a vol UUID to vol key")},
{"help", N_("returns the volume key for a given volume name or path")},
{"desc", ""},
{NULL, NULL}
};
static const vshCmdOptDef opts_vol_key[] = {
{"pool", VSH_OT_STRING, 0, N_("pool name or uuid")},
{"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("vol uuid")},
{NULL, 0, 0, NULL}
};
@ -6116,8 +6117,7 @@ cmdVolKey(vshControl *ctl, const vshCmd *cmd)
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
return FALSE;
if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", "pool", NULL,
VSH_BYUUID)))
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
return FALSE;
vshPrint(ctl, "%s\n", virStorageVolGetKey(vol));

View File

@ -858,10 +858,11 @@ I<vol-name-or-key> is the name or key of the volume to return the path for.
Return the name for a given volume.
I<vol-key-or-path> is the key or path of the volume to return the name for.
=item B<vol-key> I<vol-uuid>
=item B<vol-key> [optional I<--pool> I<pool-or-uuid>] I<vol-name-or-path>
Return the volume key for a given volume UUID.
I<vol-uuid> is the UUID of the volume to return the volume key for.
Return the volume key for a given volume.
I<--pool> I<pool-or-uuid> is the name or UUID of the storage pool the volume is in.
I<vol-name-or-path> is the name or path of the volume to return the volume key for.
=back