Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to merge generated go structs from 2 different yang models #835

Open
dlakshma opened this issue May 16, 2023 · 1 comment
Open

How to merge generated go structs from 2 different yang models #835

dlakshma opened this issue May 16, 2023 · 1 comment

Comments

@dlakshma
Copy link

Hi,

I have 2 different sets of yang files, which are converted into go structs, both having parent node as Device. But when i tried to merge the go structs using ygot.MergeStructs() API, getting error as cannot merge structs that are not of matching types, *openconfig.Device != *openconfig.Device

For Example:

 type Device struct {
   abc *Testabc_abc `path:"abc" module:"test-abc"`
 }

 type Device struct {
   xyz *Testxyz_xyz `path:"xyz" module:"test-xyz"`
 }

want to merge these 2 ygot structs into single tree, where both abc and xyz are under single Device struct

Is there a way or an API, which can be used to merge 2 generated go structs.

TestCode :

func TestMergeGoStruct(t *testing.T) {
        appgs, err := yocapp.LookUpGoStruct("/")
        require.Nil(t, err)
       
        tosgs, err := yoc.LookUpGoStruct("/")
        require.Nil(t, err)
        merged, err := ygot.MergeStructs(tosgs, appgs)
        require.Nil(t, err)
        t.Logf("merged:%+v", merged)
}

Thanks,
Deepak

@wenovus
Copy link
Collaborator

wenovus commented Jun 5, 2023

If you want generated ygot GoStructs to represent two different trees then you would need to generate with both sets of YANG files at the same time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants