[Libguestfs] [libguestfs] RFE: virt-builder ability to print definition for single template (new option or expand --notes) (#20)

Pino Toscano ptoscano at redhat.com
Thu Jan 14 11:36:44 UTC 2016


In data martedì 29 dicembre 2015 17:58:18, Richard W.M. Jones ha scritto:
> On Mon, Dec 28, 2015 at 03:51:51PM -0800, Ryan Sawhill Aroha wrote:
> > The `virt-builder --notes <TEMPLATE>` command is nice, but I really wish it printed the full template definition, eg, something like this:
> > 
> > ```
> > $ virt-builder --notes centos-70
> > 
> > [centos-70]
> > name=CentOS 70
> > osinfo=centos70
> > arch=x86_64
> > file=centos-70xz
> > checksum=cf9ae295f633fbd04e575eeca16f372e933c70c3107c44eb06864760d04354aa94b4f356bfc9a598c138e687304a52e96777e4467e7db1ec0cb5b2d2ec61affc
> > format=raw
> > size=6442450944
> > compressed_size=213203844
> > expand=/dev/sda3
> > notes=CentOS 70
> >  
> > This CentOS image contains only unmodified @Core group packages
> > 
> > It is thus very minimal  The kickstart and install script can be
> > found in the libguestfs source tree:
> > 
> > builder/website/centossh
> > ```
> 
> One problem with this is that the 'index' format isn't the only
> metadata format we now support.  (SimpleStreams is another).
> 
> However there is an intermediate format we use internally, and those
> fields could be printed by --notes or some other mechanism.
> https://github.com/libguestfs/libguestfs/blob/master/builder/index.mli
> 
> This would be suitable for an RFE in Bugzilla.

I'm not sure it makes sense to print the internal representation of the
templates, since that could change anytime (like the format of the
revision field, which changed between 1.30 and 1.32). We have the JSON
output for getting the information about templates, so additions should
be done there.

> > Or maybe it could be like `virt-builder --list-format long --list`
> > (all prettified), but only for a particular template
> >
> > I think normal users need this option to be able to check the
> > `osinfo=` value for use with `virt-install` without having to
> > scroll/grep through all their templates

Theoretically, you can filter the JSON output using jq for the template
you need, and print its osinfo key; for example:
  $ virt-builder --list --list-format \
    | jq -r '.["templates"] | map(select(.["os-version"] == "fedora-23" and .["arch"] == "x86_64")) | .[0] | .["osinfo"]'
will print the osinfo value of the fedora-23/x86_64 template.

> We definitely need a way to get at the osinfo information more easily.

I'm going to send a patch to allow listing just a specified template,
which should make filtering the --list output a bit easier.

-- 
Pino Toscano




More information about the Libguestfs mailing list