> ---> Creating an empty node works fine, though this should actually fail in > my opinion (an empty file is invalid according to the lens). Sorry, I have to correct this. The attached lens definition does allow for an empty file. However, setting lns like this:
let lns = ( empty | comment )* . version . ( empty | comment | rule )* Hence, requiring at least a line with "version" in it, doesn't change the reported behaviour at all for me. Ciao, Xavier. > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of Mol, Xavier (SCC) > Sent: Thursday, December 17, 2015 1:33 PM > To: [email protected] > Subject: [augeas-devel] Why does Augeas fail to create new files? > > Hello Augeas experts, > > attached you can find the source of a custom lens for Augeas and a file with > get and put unit tests; either file is evaluated with augparse > successfully. My question is, why can I not create a new file from scratch > with that lens, while editing existing files works just fine? > > In order to test the steps in between, I used augeas-1.4 and augtool: > > [root ~]# augtool --version > augtool 1.4.0 <http://augeas.net/> > Copyright (C) 2007-2011 David Lutterkort > License LGPLv2+: GNU LGPL version 2.1 or later > <http://www.gnu.org/licenses/lgpl-2.1.html> > This is free software: you are free to change and redistribute it. > There is NO WARRANTY, to the extent permitted by law. > > Written by David Lutterkort > > [root ~]# augtool > augtool> print /augeas/load/StorageAuthzdb/*[label() != "excl"] > /augeas/load/StorageAuthzdb/lens = "@StorageAuthzdb" > /augeas/load/StorageAuthzdb/incl = "/etc/grid-security/storage-authzdb" > > ---> Currently, the node included with that lens doesn't exist. > augtool> ls /files/etc/grid-security/storage-authzdb > augtool> dump-xml /files/etc/grid-security/storage-authzdb > <augeas match="/files/etc/grid-security/storage-authzdb"/> > > ---> Creating an empty node works fine, though this should actually fail in > my opinion (an empty file is invalid according to the lens). > augtool> touch /files/etc/grid-security/storage-authzdb > augtool> save > Saved 1 file(s) > augtool> ls /files/etc/grid-security > storage-authzdb = (none) > augtool> dump-xml /files/etc/grid-security/storage-authzdb > <augeas match="/files/etc/grid-security/storage-authzdb"> > <node label="storage-authzdb" > path="/files/etc/grid-security/storage-authzdb"/> > </augeas> > > ---> Saving the minimal change required for a valid storage-authzdb file > fails. > augtool> set /files/etc/grid-security/storage-authzdb/version "2.1" > augtool> dump-xml /files/etc/grid-security/storage-authzdb > <augeas match="/files/etc/grid-security/storage-authzdb"> > <node label="storage-authzdb" > path="/files/etc/grid-security/storage-authzdb"> > <node label="version"> > <value>2.1</value> > </node> > </node> > </augeas> > augtool> save > error: Failed to execute command > saving failed (run 'errors' for details) > augtool> errors > Error in /etc/grid-security/storage-authzdb:1.0 (parse_skel_failed) > parse can not process entire input > Lens: /usr/share/augeas/lenses/storageauthzdb.aug:34.12-.75: > > > ---> Starting over... > [root ~]# rm /etc/grid-security/storage-authzdb > rm: remove regular empty file `/etc/grid-security/storage-authzdb'? y > [root ~]# augtool > > ---> Create the desired tree > augtool> set /files/etc/grid-security/storage-authzdb/version "2.1" > > ---> Review what the lens would put as a string, which matches what I expect. > augtool> set /in "" > augtool> retrieve StorageAuthzdb.lns /in > /files/etc/grid-security/storage-authzdb /out > augtool> print /out > /out = "version 2.1\n" > > ---> Still saving that output fails > augtool> save > error: Failed to execute command > saving failed (run 'errors' for details) > augtool> errors > Error in /etc/grid-security/storage-authzdb:1.0 (parse_skel_failed) > parse can not process entire input > Lens: /usr/share/augeas/lenses/storageauthzdb.aug:34.12-.75: > > ---> Though when the file exists before augtool is used, everything seems to > work. > [root ~]# echo version 2.1 >/etc/grid-security/storage-authzdb > [root ~]# augtool > augtool> ls /files/etc/grid-security/storage-authzdb > version = 2.1 > augtool> dump-xml /files/etc/grid-security/storage-authzdb > <augeas match="/files/etc/grid-security/storage-authzdb"> > <node label="storage-authzdb" > path="/files/etc/grid-security/storage-authzdb"> > <node label="version"> > <value>2.1</value> > </node> > </node> > </augeas> > augtool> set /files/etc/grid-security/storage-authzdb/version "2.2" > augtool> save > Saved 1 file(s) > [root ~]# cat /etc/grid-security/storage-authzdb > version 2.2 > > > > What am I doing wrong here? > > Thank you for your time, > Xavier. > > > **** > Karlsruher Institute of Technology (KIT) > Steinbuch Centre for Computing (SCC) > > B. Sc. Xavier Mol > GridKa Storage Administrator and Support Manager > > Hermann-von-Helmholtz-Platz 1 > Geb. 449 > 76344 Eggenstein-Leopoldshafen > Phone: +49 721 608 23041 > Email: [email protected] > www.kit.edu > KIT - University of the State of Baden-Württemberg and National Large-scale > Research Center of the Helmholtz Association > "Since 2010, the KIT has been certified as a family-friendly university." > ****
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ augeas-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/augeas-devel
