openconfig / ygot

A YANG-centric Go toolkit - Go/Protobuf Code Generation; Validation; Marshaling/Unmarshaling
Apache License 2.0
286 stars 107 forks source link

Does ygot support RPC/action/notification in YANG? #389

Closed fxie00 closed 4 years ago

fxie00 commented 4 years ago

Problem statement

Does protogenerator.go in ygot support RPC/action/notification in YANG?

I have a sample yang file as follows:

/ examples.yang / module examples { namespace "urn:examples"; prefix e;

container cont {
    leaf item1 {
        type string;
    }
}

container stats {
    config false;
    leaf counter {
        type uint64;
    }

    leaf counter2 {
        type uint64;
    }
}

rpc oper { input { leaf arg { type string; } }

    output {
        leaf ret {
            type int64;
        }
    }
}

notification notif {
    leaf val {
        type decimal64 {
            fraction-digits 2;
        }
    }
}

}

I used protogenerator.go to compile this file. It was found that:

  1. when "notification notif {...}" is included, a compile error is seen "[protogenerator.go:130] unknown type of entry Directory in findMappableEntities for /examples"

  2. when "notification notif {...}" is removed, the error is gone. However, there is no protobuf code is generated for "rpc oper{...}".

robshakir commented 4 years ago

Hi!

Thanks for the question.

Today, we don't support YANG notification, action, or rpc statements for code generation. I'm happy to review changes that implement this -- but would also encourage some discussion as to how best to create useful protobuf/Go/$otherLanguage constructs for these types before we dive into implementations.

Cheers, r.

fxie00 commented 4 years ago

Thanks a lot for the quick response! This issue can be closed.

Feng