7  Example YANG module

7.1  example-fan.yang

 

 

module example-fan {

 

    yang-version 1.1;

    namespace "http://example.com/ns/example-fan";

    prefix fan;

    import yangcli-pro { prefix yp; }

 

    organization  "Example, Inc.";

    contact "Support <support@example.com>.";

 

    description

       "Example show command extension for yangcli-pro";

 

    revision 2018-03-17 {

       description

         "Add example-cmd";

    }

 

    revision 2017-12-04 {

       description

         "Change to YANG 1.1 to allow empty in case";

    }

 

    revision 2014-12-05 {

       description

         "Initial version";

    }

 

    /* add a case to the fan show command, e.g., 'show fan 1'

     * must not clash with other case names in the showtype choice

     */

    augment "/yp:show/yp:input/yp:showtype" {

        case fan {

            leaf fan {

                type union {

                  type empty;

                  type uint32 {

                    range "1 .. max";

                  }

                }

                mandatory true;

                description

                  "The fan number to show or the primary fan if

                   no value is given.";

            }

            leaf diagnostics {

                type empty;

                description

                    "If present, display extra diagnostics info";

            }

        }

        case version {

          leaf version {

            description "Example.com version";

            type empty;

          }

        }

    }

 

    rpc example-cmd {

      description

        "Example external command.

         Input parameters are allowed.

         Output parameters are not allowed.

         YANG constraints are not supported.";

      input {

        leaf parm1 { type string; }

        leaf parm2 { type int32; }

      }

    }

}