ConfD User Community

Augment two nodes with the same identifer to a choice is available?


#1

Let say a year ago I handled a “shorthand case” issue and summarized a knowledge that under a choice node, an identifier can’t appear more than once unless it is “naming protected” ( i.e. wrapped by container/list or comes from different namespace ).

So with the two modules below I was hoping that one of that two augment statements from “aug.yang” should fail on the compilation.
But I found them passed both “confdc” compilation and “pyang” tree conversion, yet only one augment branch occur on the ConfD CLI.
I think it is a semantic error. Can someone share your comments on this? And correct me if I was wrong with something.

bak.yang

module bak {
  namespace "http://tail-f.com/ns/example/bak";
  prefix bak;
  container test{
      list server {
      key name;
      leaf name {type string;}
      leaf ip {type int32;}
      choice children-type {
          case queues {
            leaf queue {type string;}
          }
          case scheduler-nodes {
            list scheduler-node {
              key name;
              leaf name {type string;}
              leaf port {type int32;}
            }
          }
      }
    }
  }
}

aug.yang

module aug {
  namespace "http://tail-f.com/ns/example/aug";
  prefix aug;
  import bak {prefix bak;}
  grouping queue-monitoring {
    container queue-monitoring {
      leaf enable-statistics {type string;}
      leaf enable-performance {type boolean;}
    }
  }
  augment "/bak:test/bak:server/bak:children-type/bak:queues" {
    uses queue-monitoring;
  }
  augment "/bak:test/bak:server/bak:children-type/bak:scheduler-nodes" {
    uses queue-monitoring;
  }
}

#2

I made another test with editing “aug.yang” as below, which make this error more obvious

module aug {
  namespace "http://tail-f.com/ns/example/aug";
  prefix aug;
  import bak {prefix bak;}
  grouping queue-monitoring {
    container queue-monitoring {
      leaf enable-statistics {type string;}
      leaf enable-performance {type boolean;}
    }
  }
  augment "/bak:test/bak:server/bak:children-type/bak:queues" {
    container abc {
      leaf foo {type string;}
    }
    //uses queue-monitoring;
  }
  augment "/bak:test/bak:server/bak:children-type/bak:scheduler-nodes" {
    leaf abc {type string;}
    //uses queue-monitoring;
  }
}

And with this YANG loaded to ConfD (ver 6.5.3), I configured some data and showed them. Here are the output.

admin connected from 192.168.56.1 using ssh on ubuntu
admin@ubuntu> con
Entering configuration mode private
[ok][2018-10-24 23:48:38]

[edit]
admin@ubuntu% set 
Possible completions:
  aaa     - AAA management
  alias   - Create command alias.
  nacm    - Access control
  servers - 
  session - Global default CLI session parameters
  test    - 
  user    - User specific command aliases and default CLI session parameters
  webui   - Web UI specific configuration
admin@ubuntu% set test server 
Possible completions:
  <name:string>
admin@ubuntu% set test server alex 
Possible completions:
  aug:abc  ip  queue  scheduler-node
admin@ubuntu% set test server alex ip 
Possible completions:
  <int>
admin@ubuntu% set test server alex ip 123 
Possible completions:
  aug:abc  queue  scheduler-node
admin@ubuntu% set test server alex ip 123 queue 
Possible completions:
  <string>
admin@ubuntu% set test server alex ip 123 aug:abc foo 
Possible completions:
  <string>
admin@ubuntu% set test server alex ip 123 aug:abc foo helloworld 
[ok][2018-10-24 23:49:41]

[edit]
admin@ubuntu% commit
Commit complete.
[ok][2018-10-24 23:49:44]

[edit]
admin@ubuntu% show test server 
server alex {
    ip 123;
    aug:abc {
        foo helloworld;
    }
    aug:abc {
        foo helloworld;
    }
}
[ok][2018-10-24 23:49:50]

[edit]
admin@ubuntu%

#3

You’re right, augmenting two different cases of a choice with same-named toplevel nodes in the augments is not valid (per e.g. https://tools.ietf.org/html/rfc6020#section-7.9.2 3rd paragraph), and should ideally be rejected by the compiler.