thanks for all the ideas, I'll think about all of this !
>Since Augeas 0.3.6, you can change the backup type dynamically by
> setting /augeas/save to one of 'newfile', 'backup' or 'overwrite'.
Sure, but in func each new method call of the augeas module (get, set, rm...) instantiate a new Augeas() object.
So I can't keep it from one action to the other.
So I must reset /augeas/save each time
So one solution is to pass the value for /augeas/save as a parameter of the method, with a default value.
But this is tiresome for the end-user if he wants to override the default.
This would be resolved if I used your execute(self, commands) strategy.
Louis
2009/2/24 David Lutterkort <lutter@xxxxxxxxxx>
On Tue, 2009-02-24 at 21:17 +0100, Louis Coilliot wrote:Yeah, passing the root into aug_init is the preferred way to set the
> > Maybe the test scripts could just install some example config
> > files to /tmp and not have to set the an AUGEAS_ROOT at all?
> Well, it does install config files in /tmp.
> For AUGEAS_ROOT, there is a solution:
> I call the class Augeas() in augeas.py, and it is possible to set the
> root there:
> def __init__(self, root=None, loadpath=None, flags=NONE):
> ...
root.
Have you thought about exposing a small language for the Func module
> The problem is that there are more and more options to pass to the
> methods in the func augeas module:
> set(self,entryPath,param='',pvalue='',hierarchy='/files')
rather than mapping Augeas calls 1-1 in the Func module ? (That's what
the Augeas type for puppet does)
Since many config changes require multiple changes to the tree, saving
after each individual change is not always possible (e.g., to add a line
to /etc/hosts, you need to set at least the IP address and the canonical
host name before Augeas will let you save the file, to keep invalid
config files from hitting the disk)
This could be as simple as having a 'execute' or so method on the func
module that takes a list of commands - I don't know what datatypes are
allowed as arguments to func modules, but you could make each command a
list of strings or do something fancier where you have separate classes
to represent each command. I.e., you'd have a method
execute(self, commands)
on your Func module, and would call it like
augeas_func.execute([ ["rm", "/files/etc/hosts/*/alias[. = 'myhost.example.com']"]
["set", "/files/etc/hosts/10000/ipaddr', '192.168.10.1']",
["set", "/files/etc/hosts/10000/canonical", "myhost.example.com"]])
where execute will call aug_save after making the changes. This could be
made a little more friendly if you provide convenience methods that wrap
writing down the individual arrays.
Since Augeas 0.3.6, you can change the backup type dynamically by
> I could also add options like augeasroot and backuptype (newfile/backup/overwrite),
> but then when you want to set only the last option in the list, you need to set
> also all the options before (it's ordered, not labeled)
setting /augeas/save to one of 'newfile', 'backup' or 'overwrite'.
I would phrase that a little differently: it's a tool to make scripting
> Raphael Pinson who showed augeas at the fosdem a few days ago told me
> that augeas was a tool for programmers, not for operators.
config changes easy - so for whoever is writing scripts/programs that do
that.
David
_______________________________________________ Func-list mailing list Func-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/func-list