Giter Site home page Giter Site logo

Comments (6)

olofhagsand avatar olofhagsand commented on August 29, 2024

From a yang perspective, if you have an object A and a leafref to A, then if you remove A, the validation will fail. E.g from test/test_leafref.sh ("template" means leafref"):

   olof@vandal> set sender A              
   olof@vandal> set sender B template A
   olof@vandal> validate 
   olof@vandal> delete sender A
   olof@vandal> validate 
   Nov 23 11:38:37: Validate failed. Edit and try again or discard changes: application operation-failed   Leafref validation failed, no such leaf: A 

CLI supports leafref when doing completion but does not enforce them, you can enter other leafrefs than "A" (ie "C"), but you will fail on validate/commit. Therefore, the CLI support of leafrefs is "soft", it assist but does not enforce. If you wish to have an invalid configuration in the candidate config you can.
However, once you validate/commit, an invalid reference should not be allowed (including you case with "dangling" references). If you see such a case it is an error.

It would in principle be possible to strictly enforce syntactic constraints in candidate, but it would result in a very strict command-line tool. Sometime you may want to add/remove objects so that they are not valid during an intermediate period, such as copy/paste large number of lines. With strict enforcement, every incremental change would have to be valid, so that you may have to perform operations in a very strict order. One example is renaming an object (A->B), both if you rename the object first, as well as renaming the leafrefs would give you an intermediate invalid state.

from clixon.

katdiam avatar katdiam commented on August 29, 2024

Thanks a lot for your response, hope you are having a wonderful thanksgiving holidays!

I tried routing-instance in [email protected], created a routing instance on interface eth0(type if:interface-ref), I am able to delete interface eth0, the validation did not fail. Did I miss something?

[email protected]:
744 container routing {
....
747 list routing-instance {
...
824 container interfaces {

827 list interface {
828 key "name";
829 description
830 "List of network layer interfaces assigned to the routing
831 instance.";
832 leaf name {
833 type if:interface-ref;
834 description
835 "A reference to the name of a configured network layer
836 interface.";
837 }
838 }
839 }

server03> set interfaces interface eth0 type ex:eth
server03> set routing routing-instance rt0 interfaces interface eth0
server03> delete interfaces interface eth0
server03> show configuration
routing {
routing-instance {
name rt0;
type rt:default-routing-instance;
enabled true;
interfaces {
interface {
name eth0;
}
}
}
}

from clixon.

katdiam avatar katdiam commented on August 29, 2024

I did validate after "delete interfaces interface eth0", it did not fail.

server03> set interfaces interface eth0 type ex:eth
server03> set routing routing-instance rt0 interfaces interface eth0
server03> delete interfaces interface eth0
server03> validate
server03>

from clixon.

katdiam avatar katdiam commented on August 29, 2024

For the routing-instance on eth0 example above, should the "delete interfaces interface eth0" failed (since routing instance interface is of type if:interface-ref)? But it did not fail.

from clixon.

olofhagsand avatar olofhagsand commented on August 29, 2024

The validate should fail.
Not the delete interfaces interface eth0. Did it not?

from clixon.

olofhagsand avatar olofhagsand commented on August 29, 2024

Resolved and obsolete question.

from clixon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.