Validation of multi-line configuration commands of yet-to-be-commited transaction

Hi all,

I am pretty new to ConfD. Have the following scenario:
Multiple configuration commands will be entered by user through the ConfD cli. Before commiting these commands, I need to do some validation (duplicate value checks across the multi-line configuration command)

  1. The data is not yet commited, so, is there a way to capture this keyed in but yet-to-be-commited data ? If there a way, please provide any references for how to do the same.
    I mean does ConfD provide any in-built support/mechanism to capture this multi-line data so that I can itrerate through the data ?

  2. I have come across the “input” option in YANG. My doubt is that, input will capture single-line configuration commands from cli. But, will it be able to remember multi-line configuration commands as well ? Is there any other of achieving the same other than input option ?

Thanks a lot for your help.

Cheers,
Kanthi Kumar

Hi,

For example:
The configuration command template based on the YANG model:
database group [group-name] region [region-name] region-range [range-name] start [start-IPv6Addr] end [end-Ipv6Addr]

One group can have multiple region(s) and one region could have multiple range(s).
There could be multiple group(s) as well.

Sample configuration command with 3 lines:
database group group-1 region north-1 region-range r-1 start 2009:5000:0000:0100 end 2009:5000:0000:0500
database group group-1 region north-2 region-range r-2 start 2011:6000:0000:0001 end 2011:6000:0000:0500
database group group-1 region north-3 region-range r-3 start 2012:6000:0000:0001 end 2012:6000:0000:0500

Is there a way to capture all the above 3 lines and iterate through them and perform validation checks ?

Would be really helpful, if anyone can comment on my question.

Thanks,
Kanthi

Hello,

i think that you can use the validation callback - invoked after all the changes done by user, and before actual commit. Inside it’s custom implementation, you can use procedure maapi_diff_iterate() to iterate over all the changes, and do whatever checks that are necessary.
You can see a very simple example in examples.confd/validate/c_dependency
More details are described in man pages of procedure and/or user guide.

Hi josephm,

Thanks for the reply.

Am using java for the callbacks. Am not sure how to use the maapi_diff_iterate() using java.
I think we are using ConfD Basic, so don’t have access to the java code samples.

Currently my YANG model looks like this:

Have added a new java class as an action callback one.
The question is: inside the action call back class, will I have access to all the multi-line configuration commands or will it just process one line at a time ?

tailf:action check-ipv6Range {
  tailf:actionpoint check-ipv6Range;
  input {
    list group {
      ...
      list region {
        ...
        list region-range {
          ...
          leaf start {
            type string;
            mandatory true;
          }
          leaf end {
            type string;
            mandatory true;
          }
        }
      }
    }
  }
}

Thanks,
Kanthi

Are you sure you need an action for your use-case? Actions are not the primary tool for configuration changes - they can be used for that, but it looks to me you don’t need the action here. Just remove the action and input nodes and keep the list group there; you need to model how your configuration looks like, the rest is taken care of by confd and its northbound interfaces (be it CLI or NETCONF or others).

As for validation, as Jozef writes, you can declare validation callbacks and implement them (e.g. in Java). But very often you don’t need to write a single line of code to make sure the configuration is correct. Start with data types - I would say plain string is too broad, maybe inet:ipv6-address or at least a string restricted by a pattern would be more appropriate? Definitely go through the ConfD user guide, and in this context, chapters The YANG Data Modelling Language and Semantic validation in particular.

Thanks a lot mvf.
Will try your suggested changes.

I need to make “start” and “end” leaf values unique across the following lists:
“region-range”, “region” and “group”.
I know how to make it unique within the list “region-range”.
This will only ensure that there is only one unique “start”/“end”/combination of “start”/“end”. will ensure uniqueness of just the boundary values, how about the ones in between ?
How to ensure that all the values within that range between “start” and “end” are never repeated ?


list region-range{
min-elements 1;
key “name”;
unique “start end”;
unique “start”;
unique “end”;
leaf name {
type string;
}
leaf start {
type inet:ipv6-address;
mandatory true;
}
leaf end {
type inet:ipv6-address;
mandatory true;
}
}


Am not sure how to make the “start” and “end” leaf values unique across the lists “region” and “group” ?

Any suggestions would be really helpful.

Thanks,
Kanthi

Making those values globally unique is still possible using the must statement. If you also need to have non-overlapping ranges, then it might require a validation point indeed. The chapter Semantic validation describes how to do that and there are examples showing that. (As for java examples - I don’t think you are really using ConfD Basic, that does not come with java enabled; so at least someone in your team should be able to provide the examples to you.)