cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1721
Views
5
Helpful
1
Replies

Type leafref doesn't fail in NSO if non leafref value given - is this expected behavior?

Hi, I just became aware that the type leafref doesn't fail if the user enters something other than a leafref. This confused me, because NSO will throw an error if a user attempts to use a value other than one specified by a type enumeration. NSO will also force a user to enter in mandatory values if left blank. I would expect NSO to have more strict behavior for a leafref that does not exist, however NSO allows this with no issue. It is only when a commit is attempted that NSO throws an error.

 

Here is an example of configuration that is allowed to be entered into NSO for a leafref and does not have an issue until a commit is attempted.

 

admin@Mothership-6(config)# services ntp test device-name csr

admin@Mothership-6(config-ntp-test)# top

admin@Mothership-6(config)# services ntp test device-name notrealdevice?
^
% Invalid input detected at '^' marker.

admin@Mothership-6(config)# services ntp test device-name notrealdevice

admin@Mothership-6(config-ntp-test)# top

admin@Mothership-6(config)#

admin@Mothership-6(config)# commit
Aborted: illegal reference 'services ntp test device-name'

 

Below you can see that I get an error immediately if I give a value that is not one of the enumerated values. You can also see that I am able to enter a device that does not exist for the device-name with no issues. NSO then forces the user to enter in the mandatory value called `service` (which is where I aborted the transaction). So my question is why are the leafrefs not strict, and should they be.

 

admin@Mothership-6(config)# services apply-to-devices operation ?
Possible completions:
add
remove
replace

 

admin@Mothership-6(config)# services apply-to-devices operation not_valid_op
----------------------------------------------------------------^
syntax error: "not_valid_op" is an invalid value.

admin@Mothership-6(config)# services apply-to-devices device-name [ csr?
Possible completions:
]
csr
csr-copy

admin@Mothership-6(config)# services apply-to-devices device-name [ not_a_device?
                                                                                                                ^
% Invalid input detected at '^' marker.

admin@Mothership-6(config)# services apply-to-devices device-name [not_a_device ]
Value for 'service' (<string>):
Aborted: user aborted

1 Accepted Solution

Accepted Solutions

vleijon
Cisco Employee
Cisco Employee

The reason is that you might fill in the leaf-ref later in your transaction. In particular you can circular leaf-refs so that there is no way of creating it without postponing validation.

 

There is an annotation tailf:cli-strict-leafref that might give the behaviour that you desire.

View solution in original post

1 Reply 1

vleijon
Cisco Employee
Cisco Employee

The reason is that you might fill in the leaf-ref later in your transaction. In particular you can circular leaf-refs so that there is no way of creating it without postponing validation.

 

There is an annotation tailf:cli-strict-leafref that might give the behaviour that you desire.