pyang icon indicating copy to clipboard operation
pyang copied to clipboard

yang 1.1 - submodule augmenting submodule

Open llhotka opened this issue 9 years ago • 6 comments

The following example appeared in #193. IMO it is valid, but pyang cannot find the node /x-b:configs:

$ cat x-base.yang 
module x-base {
  yang-version 1.1;
  namespace "http://example.com/x-base";
  prefix x-b; 
  include x-base2;
  include x-profiles;
}
$ cat x-base2.yang 
submodule x-base2 {
  yang-version 1.1;
  belongs-to x-base {
    prefix x-b;
  }
  container configs {
    container profiles {
    }
  }
}
$ cat x-profiles.yang 
submodule x-profiles {
  yang-version 1.1;
  belongs-to x-base {
    prefix x-b;
  }
  augment "/x-b:configs/x-b:profiles" {
    list profile {
      key name;
      leaf name {
        type string;
      }
    }
  }
}
$ pyang x-base.yang 
x-profiles.yang:6: error: node x-base::configs is not found

llhotka avatar Jan 07 '16 11:01 llhotka

This error depends on the yang version? I only asking because in this example you are using yang-version 1.1 but by reading RFC6020 section-7.15 I think it should also work in yang-version 1.

szabolcsszekely avatar Feb 08 '16 12:02 szabolcsszekely

No, in YANG 1.0 submodule x-profiles needs to include x-base2 in order to see its augment target

/x-b:configs/x-b:profiles

llhotka avatar Feb 10 '16 15:02 llhotka

Yes you are right. In my case I was trying to augment from submodule_a a container defined in a grouping in submodule_b which grouping is then used by the main module. Rereading the augment statement definition in RFC6020 I think this is not allowed, because basically it is an augment from a submodule to its main module.

Modified the example above:

$ cat x-base.yang
module x-base {
    yang-version 1;
    namespace "http://example.com/x-base";
    prefix x-b;
    include x-base2;
    include x-profiles;
    container x-setting {
        uses x-base2-setting;
    }
}
$ cat x-base2.yang 
submodule x-base2 {
    yang-version 1;
    belongs-to x-base {
        prefix x-b;
    }
    grouping x-base2-setting {
        container configs {
            container profiles {
            }
        }
    }
}
$ cat x-profiles.yang 
submodule x-profiles {
    yang-version 1;
    belongs-to x-base {
        prefix x-b;
    }
    include x-base2;
    augment "/x-b:x-setting/x-b:configs/x-b:profiles" {
        list profile {
            key name;
            leaf name {
                type string;
            }
        }
    }
}
$ pyang x-base.yang
x-profiles.yang:7: error: node x-base::x-setting is not found

Could you confirm if my interpretation is correct?

szabolcsszekely avatar Feb 10 '16 16:02 szabolcsszekely

In YANG 1.0, a submodule cannot augment nodes in the main module. In 1.1 this should be OK.

llhotka avatar Feb 15 '16 13:02 llhotka

Thanks for the clarification.

szabolcsszekely avatar Feb 16 '16 07:02 szabolcsszekely

See also #323

mbj4668 avatar Feb 19 '20 09:02 mbj4668