[augeas-devel] strange results using rm with the dhcpd lense

Raphaël Pinson raphael.pinson at camptocamp.com
Sun Mar 16 09:35:46 UTC 2014


Upon thinking about it some more, this is only problematic when removing or
inserting before existing blocks.

That said, it would be great to write lenses that avoid this kind of
situation. The obvious way to do that would be to use seq on blocks (using
them on subnets wouldn't solve the problem for hosts, etc.), so you'd have:

    "subnet 10.152.187.0 netmask 255.255.255.0 {}\n"

mapped as

    { "1" = "subnet"
      { "network" = "10.152.187.0" }
      { "netmask" = "255.255.255.0" }
    }

etc.

in order to retain formatting in each block.


Obviously, this is an incompatible change, which would have to be made in
every lens that was written this way, so we need to ponder whether it is an
acceptable change.


Raphaël




On Sun, Mar 16, 2014 at 9:15 AM, Raphaël Pinson <
raphael.pinson at camptocamp.com> wrote:

> Hi Robert,
>
>
> You might want to read this email to understand why seq was create, and
> why you're seeing these side-effects when removing your node:
>
> http://www.redhat.com/archives/augeas-devel/2011-February/msg00053.html
>
>
> Cheers,
>
> Raphaël
>
>
>
> On Sun, Mar 16, 2014 at 8:35 AM, Robert Drake <rdrake at direcpath.com>wrote:
>
>> I'm having a problem with the dhcpd lense rewriting subnets when I delete
>> one.  From what I can tell through experimenting, it seems that augeas is
>> not so much deleting the previous subnet but instead it's taking the values
>> of the next subnet and writing it into this one.
>>
>> Here is the example content:
>>
>>     # this comment is before the first subnet
>>     subnet 192.168.1.0 netmask 255.255.255.0
>>     {
>>         option routers 192.168.1.1;
>>         pool { range 192.168.1.2 192.168.1.254; }
>>     }
>>     # comment goes here
>>     subnet 192.168.2.0 netmask 255.255.255.0
>>     {
>>         ddns-updates true;
>>         next-server 192.168.15.2;
>>         filename "pxelinux.0";
>>         ddns-domainname "staging.direcpath.net";
>>         option routers 192.168.2.1;
>>         pool
>>         {
>>
>>             range 192.168.2.2 192.168.2.254;
>>         }
>>
>>     }
>>
>> If I run "rm /files/test.conf/subnet[1]"
>>
>> I get this as the output:
>>
>>     # this comment is before the first subnet
>>     # comment goes here
>>     subnet 192.168.2.0 netmask 255.255.255.0
>>     {
>> ddns-updates true;
>> next-server 192.168.15.2;
>> filename "pxelinux.0";
>> ddns-domainname staging.direcpath.net;
>>         option routers 192.168.2.1;
>>         pool { range 192.168.2.2 192.168.2.254; }
>>     }
>>
>> You can see the first subnet's definition seems to have been rewritten,
>> with the 4 extra lines inserted where appropriate.  This would be fine
>> except it's removing the formatting information when it does it and thus
>> removing the double quotes from ddns-domainname which causes validation
>> errors.
>>
>> I can fix it by rewriting the lens to require double quotes for
>> ddns-domainname (which is how they seem to have fixed it for the filename
>> statement) but I'm wondering if the lens' statement syntax is messed up in
>> general.  From what I understand, it's supposed to keep the quotes on
>> existing data and put them back when things change right?
>>
>> _______________________________________________
>> augeas-devel mailing list
>> augeas-devel at redhat.com
>> https://www.redhat.com/mailman/listinfo/augeas-devel
>>
>
>
>
> --
> Raphaël Pinson
> Infrastructure Developer & Trainer
> +33 479 26 57 93
> +33 781 90 00 79
>
> Camptocamp France
> Savoie Technolac
> BP 352
> 48, avenue du Lac du Bourget
> 73372 Le Bourget du Lac, Cedex
> www.camptocamp.com
>



-- 
Raphaël Pinson
Infrastructure Developer & Trainer
+33 479 26 57 93
+33 781 90 00 79

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/20140316/ebc09e9c/attachment.htm>


More information about the augeas-devel mailing list