Subject: [netmod] YANG 1.1 Action and RPC

From: Chin Chen <[email-masked]>
Date: Mon, 6 Feb 2017 03:14:30 +0000

Hi, Martin and all,
       I am working on YANG modeling and have a question on action and RPC. The difference between action and RPC in RFC7950 is stated as below,

“The difference between an action and an rpc is that an action is tied
to a node in the datastore, whereas an rpc is not. When an action is
invoked, the node in the datastore is specified along with the name
of the action and the input parameters.”

On statement “The difference between an action and an rpc is that an action is tied to a node in the datastore, whereas an rpc is not.”, can I understand that action could be planted in the model hierarchy but the action name and input parameter will not exist in datastore? On the other hand, RPC will be separated from nodes in the datastore and normally a “top node” in the model, right?

Furthermore, on statement “When an action is invoked, the node in the datastore is specified along with the name of the action and the input parameters.”, does it mean the node in the datastore could be used as additional input parameter when call an action?

Per my understanding, can we change the action example in 7.15.3 to an RPC as below?

Action
========================
list server {
  key name;
  leaf name {
    type string;
  }
  action reset {
    input {
      leaf reset-at {
        type yang:date-and-time;
        mandatory true;
      }
    }
    output {
      leaf reset-finished-at {
        type yang:date-and-time;
        mandatory true;
      }
    }
  }
}

RPC
========================
rpc server-farm-reset{
  input {
    leaf server-name {
      type string;
      mandatory true;
    }
    leaf reset-at {
      type yang:date-and-time;
      mandatory true;
    }
  }
  output {
    leaf reset-finished-at {
      type yang:date-and-time;
      mandatory true;
    }
  }
}

Hope your reply!  Thanks!

BR
///Chin