<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <br>
    <div class="moz-cite-prefix">On 3/16/2014 5:35 AM, Raphaël Pinson
      wrote:<br>
    </div>
    <blockquote
cite="mid:CACE7ikGs2YohR_mC2j-G2fxo=EEHdxUhOKcRfmUScd1z_+=kPQ@mail.gmail.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      <div dir="ltr">Upon thinking about it some more, this is only
        problematic when removing or inserting before existing blocks.
        <div><br>
        </div>
        <div>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:</div>
        <div><br>
        </div>
        <div>    "subnet 10.152.187.0 netmask 255.255.255.0 {}\n"</div>
        <div><br>
        </div>
        <div>mapped as</div>
        <div><br>
        </div>
        <div>
          <div>    { "1" = "subnet"</div>
          <div>      { "network" = "10.152.187.0" }</div>
          <div>      { "netmask" = "255.255.255.0" }</div>
          <div>    }</div>
        </div>
        <div><br>
        </div>
        <div>etc.</div>
        <div><br>
        </div>
        <div>in order to retain formatting in each block.</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>
          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.</div>
        <div><br>
        </div>
      </div>
    </blockquote>
    <br>
    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.<br>
    <br>
    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.<br>
    <br>
    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. 
    <br>
    <br>
    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.<br>
    <br>
    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.<br>
    <br>
    <br>
    <br>
    <blockquote
cite="mid:CACE7ikGs2YohR_mC2j-G2fxo=EEHdxUhOKcRfmUScd1z_+=kPQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div><br>
        </div>
        <div>Raphaël</div>
        <div><br>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>