[augeas-devel] OS variations of lenses (was: Lens compatibility (ticket #295))

Raphaël Pinson raphael.pinson at camptocamp.com
Thu Aug 30 08:22:22 UTC 2012


Hello,

On Wed, Aug 29, 2012 at 10:36 PM, Dominic Cleal <dcleal at redhat.com> wrote:

> On 14/08/12 19:11, David Lutterkort wrote:
> > One idea would be to maintain specific variations of lenses using a
> > conditional:
> >
> >         let lns = match shellvars_variant with
> >            "split_exports" -> lens_with_export_splitting
> >          | _               -> old_lens
>
> Taking this in a new direction, an issue I've seen a bit recently is the
> need for different operating systems to need different lenses or changes
> to filters.
>
> One problem that Steven Wills just pointed out was the lens for
> /etc/sysctl.conf, which on FreeBSD follows a slightly different format
> to the same file on Linux (no spaces around equals signs on BSD).  There
> were a few others we hit during #255 but would mostly be solved with
> more flexible filters.
>
> Would it be sensible to use the same construct with some sort of basic
> OS detection (uname for starters) to make Augeas lenses more portable?
>


I would like to avoid OS detection. I think the default behaviour should be
identical on all OSes. Think for example of installation systems (FAI,
kickstart, etc.) that might use Augeas with a fake root to setup chrooted
environments (and that it's already complex enough to maintain one version
of each lens).

The idea of adapting the way lenses behave per OSes (or per other factors)
is interesting though. I think having some kind of runtime options might be
useful. For example, we could have /augeas/load/Sysctl/options/OS set to
the operating system you wish to use. This value could then be used in the
module, for example by getting it with Sys.getopt("OS", "RedHat") to
specify a default value. Adding conditionals like David suggested would
allow for interesting applications of this.

Obviously, such runtime options might not be used just anywhere in the
module code, since it might change the way the lens could typecheck. Maybe
Sys.getopt could contain a validation regexp, too, such as Sys.getopt("OS",
"RedHat", /(RedHat|Debian|Ubuntu|FreeBSD|Solaris)/). This way, the
typechecker would use this regexp to typecheck the lens, and the regexp
would prevent bad values at runtime by checking set values against this
regexp.


-- 
Raphaël Pinson
Administrateur Systèmes & Réseaux
Camptocamp France
Savoie Technolac
BP 352
48, avenue du Lac du Bourget
73372 Le Bourget du Lac, Cedex
www.camptocamp.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20120830/b7d03014/attachment.htm>


More information about the augeas-devel mailing list