Bug 1140547

Summary: virt-builder option '--format' don't work well
Product: Red Hat Enterprise Linux 7 Reporter: Lingfei Kong <lkong>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 7.1CC: leiwang, mbooth, ptoscano, wshi
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libguestfs-1.27.43-1.1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-03-05 13:44:29 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Lingfei Kong 2014-09-11 08:30:22 UTC
Description of problem:
virt-builder option '--list --format' don't work well. Also i can find the following use with '--format':
# virt-builder fedora-20 --format qcow2

That is to say --format can used for different purpose, i don't know if this is the original design for --format option.


Version-Release number of selected component (if applicable):
libguestfs-1.27.39-1.1.el7


How reproducible:
100%


Steps to Reproduce:
#virt-builder --list --format short
gpg: Signature made Tue 08 Jul 2014 05:11:00 PM CST using RSA key ID E1B768A0
gpg: Good signature from "Richard W.M. Jones <rjones>"
gpg:                 aka "Richard W.M. Jones <rich>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: F777 4FB1 AD07 4A7E 8C87  67EA 9173 8F73 E1B7 68A0
centos-6                 x86_64     CentOS 6.5
centos-7.0               x86_64     CentOS 7.0
cirros-0.3.1             x86_64     CirrOS 0.3.1
debian-6                 x86_64     Debian 6 (Squeeze)
debian-7                 x86_64     Debian 7 (Wheezy)
fedora-18                x86_64     Fedora® 18
fedora-19                x86_64     Fedora® 19
fedora-20                x86_64     Fedora® 20
rhel-7rc                 x86_64     Red Hat Enterprise Linux® 7 Release Candidate
scientificlinux-6        x86_64     Scientific Linux 6.5
ubuntu-10.04             x86_64     Ubuntu 10.04 (Lucid)
ubuntu-12.04             x86_64     Ubuntu 12.04 (Precise)
ubuntu-14.04             x86_64     Ubuntu 14.04 (Trusty)
#virt-builder --list --format long
gpg: Signature made Tue 08 Jul 2014 05:11:00 PM CST using RSA key ID E1B768A0
gpg: Good signature from "Richard W.M. Jones <rjones>"
gpg:                 aka "Richard W.M. Jones <rich>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: F777 4FB1 AD07 4A7E 8C87  67EA 9173 8F73 E1B7 68A0
centos-6                 x86_64     CentOS 6.5
centos-7.0               x86_64     CentOS 7.0
cirros-0.3.1             x86_64     CirrOS 0.3.1
debian-6                 x86_64     Debian 6 (Squeeze)
debian-7                 x86_64     Debian 7 (Wheezy)
fedora-18                x86_64     Fedora® 18
fedora-19                x86_64     Fedora® 19
fedora-20                x86_64     Fedora® 20
rhel-7rc                 x86_64     Red Hat Enterprise Linux® 7 Release Candidate
scientificlinux-6        x86_64     Scientific Linux 6.5
ubuntu-10.04             x86_64     Ubuntu 10.04 (Lucid)
ubuntu-12.04             x86_64     Ubuntu 12.04 (Precise)
ubuntu-14.04             x86_64     Ubuntu 14.04 (Trusty)
#virt-builder --list --format json
gpg: Signature made Tue 08 Jul 2014 05:11:00 PM CST using RSA key ID E1B768A0
gpg: Good signature from "Richard W.M. Jones <rjones>"
gpg:                 aka "Richard W.M. Jones <rich>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: F777 4FB1 AD07 4A7E 8C87  67EA 9173 8F73 E1B7 68A0
centos-6                 x86_64     CentOS 6.5
centos-7.0               x86_64     CentOS 7.0
cirros-0.3.1             x86_64     CirrOS 0.3.1
debian-6                 x86_64     Debian 6 (Squeeze)
debian-7                 x86_64     Debian 7 (Wheezy)
fedora-18                x86_64     Fedora® 18
fedora-19                x86_64     Fedora® 19
fedora-20                x86_64     Fedora® 20
rhel-7rc                 x86_64     Red Hat Enterprise Linux® 7 Release Candidate
scientificlinux-6        x86_64     Scientific Linux 6.5
ubuntu-10.04             x86_64     Ubuntu 10.04 (Lucid)
ubuntu-12.04             x86_64     Ubuntu 12.04 (Precise)
ubuntu-14.04             x86_64     Ubuntu 14.04 (Trusty)

Actual results:
The output format of virt-builder --list --format short, virt-builder --list --format long, virt-builder --list --format json are all short

Expected results:
The output of virt-builder --list --format short, virt-builder --list --format long, virt-builder --list --format json have a correct format

Additional info:

Comment 2 Richard W.M. Jones 2014-09-11 08:42:20 UTC
The option is --list-format (not --list --format).  eg:

$ virt-builder -l --list-format json
{
  "version": 1,
  "sources": [
  {
    "key": "/etc/xdg/virt-builder/repos.d/libguestfs.gpg",
    "uri": "http://libguestfs.org/download/builder/index.asc"
  },
  {
    "uri": "http://file.rdu.redhat.com/~rjones/builder/index.asc"
  }
  ],
[etc]

However I agree that we probably should reject the '--format'
option when the mode is '--list'.

Comment 3 Lingfei Kong 2014-09-11 09:09:32 UTC
(In reply to Richard W.M. Jones from comment #2)
> The option is --list-format (not --list --format).  eg:
> 

Thanks for your quickly response, i checked the man page, found the following lines:
       --list --format format
       --list --long
           List available templates.

           It is possible to choose with --format the output format for the list templates:

           short
               The default format, prints only the template identifier and, next to it, its short
               description.

           long
               Prints a textual list with the details of the available sources, followed by the details of
               the available templates.

           json
               Prints a JSON object with the details of the available sources and the details of the
               available templates.

               The "version" key in the main object represents the "compatibility version", and it is bumped
               every time the resulting JSON output is incompatible with the previous versions (for example
               the structure has changed, or non-optional keys are no more present).


Maybe the man page should change '--list --format format' to '--list --list-format format'

Comment 4 Richard W.M. Jones 2014-09-11 09:15:57 UTC
I've fixed the incorrect documentation in the manual page and added
an extra error message if people use --list + --format:

https://github.com/libguestfs/libguestfs/commit/de3614e0ff67f5a85625946f35af296080cbb6b8

Comment 6 Lingfei Kong 2014-10-22 07:58:51 UTC
Verify with libguestfs-1.28.1-1.2.el7

Steps to verify:
1. #virt-builder --list --list-format json
{
  "version": 1,
  "sources": [
    {
      "uri": "file:///var/run/guestfs-autotest/images/index.asc"
    }
  ],
  "templates": [
    {
      "os-version": "RHEL_7u0_Server",
      "full-name": "RHEL_7u0_Server",
      "arch": "x86_64",
      "size": 8589934592,
      "notes": {
        "C": "RHEL_7u0_Server"
      },
      "hidden": false
    }
  ]
}


2. #virt-builder --list --format short
virt-builder: virt-builder --list: use '--list-format', not '--format'.

3. Check man page of virt-builder, the man page have changed to the right format: 
 -l
       --list
       --list --list-format format
       --list --long
           List available templates.

           It is possible to choose with --list-format the output format for the list templates:

           short
               The default format, prints only the template identifier and, next to it, its short
               description.
           .......

According to step 1, step 2, step 3, this bug is fixed.

Comment 8 errata-xmlrpc 2015-03-05 13:44:29 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-0303.html