Operational data tree structure

How can we get tree structure of all the operational data(only config false) nodes defined in YANG model?

depends on what you mean, get via some northbound interface (NETCONF/cli/restconf/…), or when using confd-lib code? (maapi_ vs cdb_, etc.)

Here it’s sample yang file

module _sample {
  yang-version 1.1;
  namespace "urn:altiostar:_sample";
  prefix samplealtiostar;

  leaf userLabel {
    description
      "A user-friendly name of this object.";
    type string;
  }
  leaf userFalse {
    description
      "Operational data";
    type string;
    config false;
  }
}

Defined 2 leaves, one is config true another is config false(operational).

Using pyang tool, able to display this YANG data in tree structure as follows
pyang -f tree sample.yang

module: _sample
  +--rw userLabel?   string
  +--ro userFalse?   string

But we need only operational data to be displayed here like as follows

module: _sample
  +--ro userFalse?   string

Can we get only operational data display?

Not really, I’m afraid. You might have some luck with a “script” like this:

pred='[not(.//yin:config[@value="false"])]'
pyang -f yin your-root-module.yang \
 | xmlstarlet ed -N yin=urn:ietf:params:xml:ns:yang:yin:1 \
    -d "//yin:container${pred}" \
    -d "//yin:leaf${pred}" \
    -d "//yin:list${pred}" \
    -d "//yin:leaf-list${pred}" \
 | pyang -f tree

Note it ignores choice or case statements - it’s up to you how they should be handled. But more importantly, it completely ignores augment or grouping/uses, and I’m afraid those cannot be processed with such script, if your data model uses those, I think you can either do some text-processing of the -f tree output, or write a modification of the tree pyang plugin.