1

I have a Yang model which defines a config=false node which is mandatory too. Should I return that node as an empty XML node in get rpc response, even when my app does not support it?

Ideally my app is supposed to support it, but due to limitations we cannot implement the required support. So what should be the right way to handle such cases? Should we emit/represent it in get rpc response as an empty XML node? I guess if we ignore such nodes, the external controller may fail the get rpc response.

-Ram

Ram
  • 301
  • 2
  • 12

1 Answers1

1

If your server implementation does not support a specific node in the original model, you should create a deviation YANG module, which expresses this limitation. This way clients are informed about it and everyone is happy - you of course advertise your deviation module along with the deviated one.

For example:

module target {
  yang-version 1.1;
  namespace "target:uri";
  prefix "tgt";

  container state {
    config false;
    leaf some-counter {
      type uint64;
      mandatory true;
    }
  }
}

Let's say your device cannot support some-counter leaf above. You then create create a deviation module, which describes how your implementation differs from a compliant implementation.

module target-dev {
  yang-version 1.1;
  namespace "target-dev:uri";
  prefix "tgtd";

  import target {
    prefix tgt;
  }

  deviation "/tgt:state/tgt:some-counter" {
    deviate not-supported;
  }
}

When a get request comes, you return nothing for that leaf, since it does not exist in your implementation's world.

The details of deviation and deviate statements may be found in RFC7950:

You should be very careful when relying on this mechanism! Always create a separate module, which contains only the deviations, possibly deviating a single target module. There is a guidelines document you should read just in case.

Community
  • 1
  • 1
predi
  • 5,528
  • 32
  • 60
  • Thanks @predi, and one follow up question. From the latest findings we realized that we emit the mandatory leaves in some cases and in some cases we don't (in which cases the leaves does not actually contain any values/state). So we cannot really publish a deviation module here. So does our software needs a fix to emit them as empty XML tags in such case, where those leaves does not contain a state? – Ram Jun 21 '19 at 12:46
  • @Ram, if the model specifies a mandatory state node, a compliant server has to supply a valid value for it when a client requests it. The model represents a contract between a server and its clients. Not respecting this contract may be a bad idea. A client may not be happy if it receives an empty tag where a specific value is expected. – predi Jun 21 '19 at 12:57
  • @Ram, in case of config nodes, it is the client's job to supply them at appropriate times and the server's to ensure they exist in the running configuration. – predi Jun 21 '19 at 13:00
  • Thanks @predi. Your responses are always helpful. – Ram Jun 21 '19 at 13:28
  • Hi, @predi I have couple of questions on Yang @ https://stackoverflow.com/questions/56741430/yang-action-vs-rpc-and-anydata-vs-anyxml, https://stackoverflow.com/questions/56714197/pyang-support-for-yang-1-1 can you please help clarify? – Ram Jun 25 '19 at 01:16