On 3/16/2014 5:35 AM, Raphaël Pinson wrote:
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.


Yeah. In the case of DHCPD it seems that the entire lense was written without consideration for deleting data (or at least without the consideration of deleting statement blocks). I would argue that this is a bug because it breaks peoples expectations for lenses. The docs say that existing formatting will be preserved, but if you delete things above a block then the formatting gets shifted and lost. It seems weird that the formatting information isn't saved with the data tree.. normally you would expect that formatting for the block that is being deleted gets taken with it.

The question would be if there are scripts out there that depend on the way things work now that would break if it were changed though.

It looks like the only real fix from within the lense is to do as you say and rewrite it so shared-networks, pools, subnets and groups are all sequences. That breaks everyones existing scripts though.

I'm somewhat surprised this hasn't come up before, but I think I'm using augeas differently than most people. Most of the time people probably want to insert new statements or remove single statements. My goal is to programmatically manage a large DHCP file with hundreds of subnets.

Maybe a compromise would be not to break the existing way, but add a new command that let you mark a part of the tree as unused, then skip over that part when a "save" is called.




Raphaël


_______________________________________________
augeas-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/augeas-devel

Reply via email to