[augeas-devel] Transform and "Lenses xx and xx could be used to load this file"

Richard W.M. Jones rjones at redhat.com
Thu Nov 3 14:27:43 UTC 2016


Hi David,

We have a general problem using Augeas in libguestfs and I wonder
if you have any advice.

The problem is that we often -- as with yesterday's patch -- add new
config file paths to lenses.  Or we want to parse config files which
are not necessarily in the exact paths that Augeas is expecting.

Now it's easy enough to parse such files using an arbitrary lens by
calling aug_transform, eg:

  $ ls
  passwd
  $ augtool -r `pwd`
  augtool> transform passwd incl /passwd
  augtool> load
  augtool> ls /files/passwd/
  abrt/                 lightdm/              rjones/
  adm/                  lirc/                 root/
  akmods/               lp/                   rpc/
  # etc

As you can see I applied the 'passwd' lens to the /passwd file
because it's not in the expected location (/etc/passwd).

However if the Augeas lens happens to contain that path already,
things go wrong:

  augtool> transform passwd incl /etc/passwd
  augtool> load
  # /etc/passwd is not parsed by the passwd lens
  augtool> get /augeas/files/etc/passwd/error/message
  /augeas/files/etc/passwd/error/message = Lenses @Passwd and passwd.lns could be used to load this file

This is specifically a problem when libguestfs adds a call to
aug_transform to cater for a file that is not covered by an existing
lens, but then Augeas adds that file, and then we get the error above
until libguestfs removes the call to aug_transform.  We cannot control
when Augeas and libguestfs are released in different Linux distros.

There are workarounds for this involving fishing out the existing
transform and working out if it covers the file or not, but that's
pretty tedious.

It seems to be that Augeas could be cleverer here and could just
ignore the case where two identical transforms apply to the same file
and DWIM.

What do you think?

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top




More information about the augeas-devel mailing list