[augeas-devel] using defnode to add new nodes

Kjetil Torgrim Homme kjetilho at linpro.no
Mon Jun 15 10:50:41 UTC 2009


I was trying to use defnode as a simple way to declare state
idempotently, and defnode seems to be the ticket.  let's say I wanted
to add a new entry in /etc/services

  defnode svc '/files/etc/services/service-name[. = "foo" and protocol = "tcp"]' foo
  set $svc/port 4711
  set $svc/protocol tcp

this works fine for known services, but when adding a new entry, it
fails.  Augeas creates the new node and initialises it to the value
"foo", but the $svc can't be used.

  augtool> print /files/etc/services/service-name[last()]
  /files/etc/services/service-name[10313] = "foo"

  # notice port and protocol are missing from the print-out, although
  # they were set without complaint above.

  augtool> set $svc "bar"
  Failed

I tried to look at it in GDB without reaching enlightenment :-) $svc
is added to the symbol table, but I think the problem is that the new
node isn't added to the nodeset it refers to.  just rerunning the
defnode won't help, since the new node doesn't actually match...

-- 
Kjetil T. Homme
Redpill Linpro AS - Changing the game




More information about the augeas-devel mailing list