Range input in CLI accepts invalid values

A leaf is defined as integer with value range as 1 to 10.
When providing the values in ConfD CLI, if it is entered as "… 3,1105 - the command is accepted and no error is thrown. In reality, only 3 is created but no indication that 1105 is not accepted.

There must be more than what you write here, with the simplest possible model it works just fine:

  container root {
    leaf rangetest {
      type uint32 {
        range 1..10;
      }
    }
  }
box$ confd_cli -C -u admin

admin connected from 127.0.0.1 using console on box
box# config
Entering configuration mode terminal
box(config)# root rangetest 3,1231
----------------------------^
syntax error: "3,1231" is not a valid value.
box(config)# root rangetest 3.1231
----------------------------^
syntax error: "3.1231" is not a valid value.
box(config)# root rangetest 12
----------------------------^
syntax error: "12" is out of range.
box(config)# root rangetest 3
box(config)# 

Can you share (part of) your data model and your CLI interaction? Does it work for you with this data model?

New node creation in ConfD does not support range input. So, it will fail even if we send a valid input as range.
The problem is with modifying/deleting existing node.

Sorry, it is pretty much impossible to help you when you do not share any details about your implementation. As I showed, with the simple model the CLI works as expected.

to rephrase, its hard to help if we don’t know what specific command does not work for you as expected… :slight_smile:

YANG range statement is used to limit one exact value of a leaf - it restricts leaf type definition, not a configurable value “range” / two leaves for min/max setting…

Thus it sounds a bit confusing when you mention “node creation does not support range input” -> not sure what you mean by that…

Below is the implementation. And the corresponding results below that.

container root {
list list-under-root {
key “identifier”;

leaf identifier {
  type int8 {
    range "1..10";
  }
}

leaf status {
  type enumeration {
    enum lock {
      value 1;
    }
    enum unlock {
      value 2;
    }
  }
}

}
}

node(config)# root list-under-root 3,5 status unlock
ERROR: no matching instances found
node(config)# root list-under-root 3 status unlock
node(config)#
node(config)# root list-under-root 5 status unlock
node(config)#
node(config)# root list-under-root 3,5 status lock
node(config)#
==> both 3 & 5 are locked
node(config)# root list-under-root 3,1105 status unlock
node(config)#
==> 3 is unlocked but no feedback on 1105

I understand your point now. But look at the range expressions from this point view: a range expression describe configuration changes that should be applied to all list instances whose keys match the range. So your command

node(config)# root list-under-root 3,1105 status unlock

says that the leaf status should be set to unlock for all list-under-root instances that match the expression 3,1105; there is only one such instance, so it is applied to that. There is a reason why it works like that - for example:

node(config)# show full-configuration root
root list-under-root 1
!
root list-under-root 3
!
root list-under-root 4
!
root list-under-root 6
!
root list-under-root 8
!
root list-under-root 9
!
node(config)# root list-under-root 1-10 status unlock
node(config-list-under-root-1-10)# show config
root list-under-root 1
 status unlock
!
root list-under-root 3
 status unlock
!
root list-under-root 4
 status unlock
!
root list-under-root 6
 status unlock
!
root list-under-root 8
 status unlock
!
root list-under-root 9
 status unlock
!
node(config-list-under-root-1-10)# 

My intention is to unlock all existing entries in the range 1-10 and it works fine, even though some entries from this range are missing, namely 2, 5, and 7. It would be inconvenient if ConfD did not allow me to do that; and the behavior in your case follows this pattern.

If you really need different behavior, you can have a look at customizing range expression behavior through callbacks, there are several examples in examples.confd/cli.

I need to create multiple instances by giving range as below

node(config)# root list-under-root 1-5
**Acutal :** 
ERROR: no matching instances found
**Expected:**
node(config-list-under-root-1-5)# show config
root list-under-root 1
!
root list-under-root 2
!
root list-under-root 3
!
root list-under-root 4
!
root list-under-root 5
!

How can I achieve this

Without additional support from your side, range expression can be used only for displaying and modifying list instances. You can use range expression even for list instance creation too, but you need to implement a callback - see the example cli/range_create for details.

Thanks for the reply.
Can you share the specific document or link for cli/range_create with example?

That example is distributed with the full version of ConfD; it is not part of the ConfD Basic version - the reason is that in the Basic version the CLI interface is permitted only for development purposes and customizations like this do not make good sense.